From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754723AbcEYOad (ORCPT ); Wed, 25 May 2016 10:30:33 -0400 Received: from mga09.intel.com ([134.134.136.24]:22578 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751124AbcEYOab convert rfc822-to-8bit (ORCPT ); Wed, 25 May 2016 10:30:31 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,364,1459839600"; d="scan'208";a="988515240" From: "Li, Liang Z" To: "Michael S. Tsirkin" CC: "linux-kernel@vger.kernel.org" , "qemu-devel@nongnu.org" , "virtualization@lists.linux-foundation.org" , "akpm@linux-foundation.org" , "pbonzini@redhat.com" , "dgilbert@redhat.com" , "amit.shah@redhat.com" , "kvm@vger.kernel.org" Subject: RE: [PATCH RFC kernel] balloon: speed up inflating/deflating process Thread-Topic: [PATCH RFC kernel] balloon: speed up inflating/deflating process Thread-Index: AQHRsn8KiIQymtzct0+t5K4Bv9fZh5/BM1gAgAaKRTD//5+jgIAB+Prg//+Fk4CAAIiU8P//g2AAABDf2cD//4kiAP//OgkQ Date: Wed, 25 May 2016 14:29:35 +0000 Message-ID: References: <1463738386-30868-1-git-send-email-liang.z.li@intel.com> <20160520120038.GA28757@redhat.com> <20160524130041-mutt-send-email-mst@redhat.com> <20160525115419-mutt-send-email-mst@redhat.com> <20160525123546-mutt-send-email-mst@redhat.com> <20160525131716-mutt-send-email-mst@redhat.com> In-Reply-To: <20160525131716-mutt-send-email-mst@redhat.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZDQ3MWU5ODctMTIyOS00YWMyLTg4ODctNGY1ZDRhNDdhMTlkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IkxBZGpMOU1qNnV0RXlwVlV2Y2hBcmVzc3VxU2IxT1Jxdm5zTnhqVlVuVjA9In0= 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 > > > Interesting. How about instead of tell host, we do multiple scans, > > > each time ignoring pages out of range? > > > > > > for (pfn = min pfn; pfn < max pfn; pfn += 1G) { > > > foreach page > > > if page pfn < pfn || page pfn >= pfn + 1G > > > continue > > > set bit > > > tell host > > > } > > > > > > > That means we have to allocate/free all the requested pages first, and then > tell the host. > > It works fine for inflating, but for deflating, because the page has > > been deleted from the vb-> vb_dev_info->pages, so, we have to use a > > struct to save the dequeued pages before calling > > release_pages_balloon(), > > struct list_head? I think you can just replace set_page_pfns with > list_add(&page->lru, &page_list); > > That's is fine, I will retry and get back to you. Thanks! Liang > > > I think a page bitmap is the best struct to save these pages, because it > consumes less memory. > > And that bitmap should be large enough to save pfn 0 to max_pfn. > > > > If the above is true, then we are back to the square one. we really need a > large page bitmap. Right? > > > > Liang > > These look like implementation issues to me. > > I think the below might be helpful (completely untested), your work can go > on top. > > ---> > > virtio-balloon: rework deflate to add page to a tmp list > > Will allow faster notifications using a bitmap down the road. > > Signed-off-by: Michael S. Tsirkin > > --- > > diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c > index 476c0e3..44050a3 100644 > --- a/drivers/virtio/virtio_balloon.c > +++ b/drivers/virtio/virtio_balloon.c > @@ -195,8 +195,9 @@ static void release_pages_balloon(struct > virtio_balloon *vb) static unsigned leak_balloon(struct virtio_balloon *vb, > size_t num) { > unsigned num_freed_pages; > - struct page *page; > + struct page *page, *next; > struct balloon_dev_info *vb_dev_info = &vb->vb_dev_info; > + LIST_HEAD(pages); /* Pages dequeued for handing to > Host */ > > /* We can only do one array worth at a time. */ > num = min(num, ARRAY_SIZE(vb->pfns)); > @@ -207,10 +208,13 @@ static unsigned leak_balloon(struct virtio_balloon > *vb, size_t num) > page = balloon_page_dequeue(vb_dev_info); > if (!page) > break; > - set_page_pfns(vb, vb->pfns + vb->num_pfns, page); > + list_add(&page->lru, &pages); > vb->num_pages -= VIRTIO_BALLOON_PAGES_PER_PAGE; > } > > + list_for_each_entry_safe(page, next, &pages, lru) > + set_page_pfns(vb, vb->pfns + vb->num_pfns, page); > + > num_freed_pages = vb->num_pfns; > /* > * Note that if > -- > MST