From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752614AbcG2AiY (ORCPT ); Thu, 28 Jul 2016 20:38:24 -0400 Received: from mga03.intel.com ([134.134.136.65]:52014 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752311AbcG2AiW convert rfc822-to-8bit (ORCPT ); Thu, 28 Jul 2016 20:38:22 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,436,1464678000"; d="scan'208";a="147252905" From: "Li, Liang Z" To: "Michael S. Tsirkin" CC: "linux-kernel@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , "linux-mm@kvack.org" , "virtio-dev@lists.oasis-open.org" , "kvm@vger.kernel.org" , "qemu-devel@nongnu.org" , "dgilbert@redhat.com" , "quintela@redhat.com" , Andrew Morton , "Vlastimil Babka" , Mel Gorman , "Paolo Bonzini" , Cornelia Huck , Amit Shah Subject: RE: [PATCH v2 repost 4/7] virtio-balloon: speed up inflate/deflate process Thread-Topic: [PATCH v2 repost 4/7] virtio-balloon: speed up inflate/deflate process Thread-Index: AQHR56aT5WMR4KLffEuOEzyB2S9p86AsSHmAgADRwqCAAMwngIAAqwzA Date: Fri, 29 Jul 2016 00:38:18 +0000 Message-ID: References: <1469582616-5729-1-git-send-email-liang.z.li@intel.com> <1469582616-5729-5-git-send-email-liang.z.li@intel.com> <20160728002243-mutt-send-email-mst@kernel.org> <20160729011553-mutt-send-email-mst@kernel.org> In-Reply-To: <20160729011553-mutt-send-email-mst@kernel.org> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYjJiZmQ3NDgtMDk2MS00OGQ0LTg0ZDMtODEyMjVmYmE5MTgxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6InJYTVNZWFlYeG1lcll4aVJRUmg2NHlZRjhHWHlJMUhWXC9ZNWhMbmRFNEw4PSJ9 x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Thu, Jul 28, 2016 at 03:06:37AM +0000, Li, Liang Z wrote: > > > > + * VIRTIO_BALLOON_PFNS_LIMIT is used to limit the size of page > > > > +bitmap > > > > + * to prevent a very large page bitmap, there are two reasons for this: > > > > + * 1) to save memory. > > > > + * 2) allocate a large bitmap may fail. > > > > + * > > > > + * The actual limit of pfn is determined by: > > > > + * pfn_limit = min(max_pfn, VIRTIO_BALLOON_PFNS_LIMIT); > > > > + * > > > > + * If system has more pages than VIRTIO_BALLOON_PFNS_LIMIT, we > > > > +will scan > > > > + * the page list and send the PFNs with several times. To reduce > > > > +the > > > > + * overhead of scanning the page list. VIRTIO_BALLOON_PFNS_LIMIT > > > > +should > > > > + * be set with a value which can cover most cases. > > > > > > So what if it covers 1/32 of the memory? We'll do 32 exits and not > > > 1, still not a big deal for a big guest. > > > > > > > The issue here is the overhead is too high for scanning the page list for 32 > times. > > Limit the page bitmap size to a fixed value is better for a big guest? > > > > I'd say avoid scanning free lists completely. Scan pages themselves and check > the refcount to see whether they are free. > This way each page needs to be tested once. > > And skip the whole optimization if less than e.g. 10% is free. That's better than rescanning the free list. Will change in next version. Thanks! Liang