Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp846401imm; Fri, 15 Jun 2018 07:12:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK+LQDce/8RtpydZQ5M8zxSLrybcLpyCSLZREuJHgfxQe5fGPAWsyycWzDjK7XZNZ0dY4db X-Received: by 2002:a65:4348:: with SMTP id k8-v6mr1781390pgq.341.1529071942616; Fri, 15 Jun 2018 07:12:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529071942; cv=none; d=google.com; s=arc-20160816; b=Uil39e46FWE9aOeF4mXkoP46Q1JQ7HyChypts+1stTXGHlPsVDMT8EpT7r8r1TMyC7 JcTG1NjUop5G1FzduWa2RixN1R3inoxQEp+5MnKKONjQobbz+3t/q/v8I7bGereIgCh8 BN/cYVYrKlUycPsvbvzA3thkzlVSbmLrqpyXUcXrd4gdGaR5Byzw7VFQiX0cu6BubcFm uistDQJaxogiVOwXM8p3FwAnPLsPXRv5GrOHO2p5cLGiEEYy5w+5nXPzx/tyCcYq8KBk Te3VT5FpbyD0IzLGv5oHZf5df+4Vbq46CNzZtq1ugyJ02KwRviJk2D15luVGBlulspjo BVFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:arc-authentication-results; bh=dSYGykv6tgBg1ad0O7Cf98XOCoR/UOsxlQ5S7vXC5S8=; b=Q21wamFFykE2JcYjYvmULjQM/cSTdA8NjIh2mIC9ca2zlrWzYsHDyZCgKh8jPQ2cP6 pT4MGwpBA1q1ocrsAFWQ/0g2ZThr1Gs/xBmTzVMhMj2orikX/lLNKN5ljZeROP8kD5B+ Du6FxS6tn+WcgUmGbCy3NgDtG7+FZLomqpWsWqXjYa0od0mm47E7h83n8Vieop5KKj01 r7V/rDoq39KmGOP0GX3BIxQW3WAVfad5Cj7/InkRQpNnLES66Vvn0YQ+36AMTMvqJ8SF q7VaKy6ZO8A9PMiOLkzQrSkOV+1uBM58rVLHzKY1a6VZ19vp3jEA+MxvW4Pxm0KLXaba nX2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f13-v6si6526568pgq.138.2018.06.15.07.12.07; Fri, 15 Jun 2018 07:12:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936325AbeFOOL3 convert rfc822-to-8bit (ORCPT + 99 others); Fri, 15 Jun 2018 10:11:29 -0400 Received: from mga06.intel.com ([134.134.136.31]:51487 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932360AbeFOOL1 (ORCPT ); Fri, 15 Jun 2018 10:11:27 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jun 2018 07:11:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,227,1526367600"; d="scan'208";a="237753276" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga006.fm.intel.com with ESMTP; 15 Jun 2018 07:11:26 -0700 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 15 Jun 2018 07:11:26 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 15 Jun 2018 07:11:25 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.223]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.116]) with mapi id 14.03.0319.002; Fri, 15 Jun 2018 22:11:24 +0800 From: "Wang, Wei W" To: "Michael S. Tsirkin" CC: "virtio-dev@lists.oasis-open.org" , "linux-kernel@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , "kvm@vger.kernel.org" , "linux-mm@kvack.org" , "mhocko@kernel.org" , "akpm@linux-foundation.org" , "torvalds@linux-foundation.org" , "pbonzini@redhat.com" , "liliang.opensource@gmail.com" , "yang.zhang.wz@gmail.com" , "quan.xu0@gmail.com" , "nilal@redhat.com" , "riel@redhat.com" , "peterx@redhat.com" Subject: RE: [PATCH v33 2/4] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT Thread-Topic: [PATCH v33 2/4] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT Thread-Index: AQHUBGb1uIuE7GdLXUGMzLE4+zixk6RgrO+AgACbr0A= Date: Fri, 15 Jun 2018 14:11:23 +0000 Message-ID: <286AC319A985734F985F78AFA26841F7396A3D04@shsmsx102.ccr.corp.intel.com> References: <1529037793-35521-1-git-send-email-wei.w.wang@intel.com> <1529037793-35521-3-git-send-email-wei.w.wang@intel.com> <20180615144000-mutt-send-email-mst@kernel.org> In-Reply-To: <20180615144000-mutt-send-email-mst@kernel.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZWZjN2JlMTQtYWZlYy00MTZjLWJiNDItZjc4YzliZTA5MjY5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoieURsMUJOZElOamhUdGh5MWgzMEI3M0VZb3o3U09FUmQxNU1tZGJFaFFHQzNIeUY4XC9cL3plb0NjOGhcL254dmkycyJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Friday, June 15, 2018 7:42 PM, Michael S. Tsirkin wrote: > On Fri, Jun 15, 2018 at 12:43:11PM +0800, Wei Wang wrote: > > Negotiation of the VIRTIO_BALLOON_F_FREE_PAGE_HINT feature indicates > > the support of reporting hints of guest free pages to host via virtio-balloon. > > > > Host requests the guest to report free page hints by sending a command > > to the guest via setting the > VIRTIO_BALLOON_HOST_CMD_FREE_PAGE_HINT > > bit of the host_cmd config register. > > > > As the first step here, virtio-balloon only reports free page hints > > from the max order (10) free page list to host. This has generated > > similar good results as reporting all free page hints during our tests. > > > > TODO: > > - support reporting free page hints from smaller order free page lists > > when there is a need/request from users. > > > > Signed-off-by: Wei Wang > > Signed-off-by: Liang Li > > Cc: Michael S. Tsirkin > > Cc: Michal Hocko > > Cc: Andrew Morton > > --- > > drivers/virtio/virtio_balloon.c | 187 +++++++++++++++++++++++++++++-- > ----- > > include/uapi/linux/virtio_balloon.h | 13 +++ > > 2 files changed, 163 insertions(+), 37 deletions(-) > > > > diff --git a/drivers/virtio/virtio_balloon.c > > b/drivers/virtio/virtio_balloon.c index 6b237e3..582a03b 100644 > > --- a/drivers/virtio/virtio_balloon.c > > +++ b/drivers/virtio/virtio_balloon.c > > @@ -43,6 +43,9 @@ > > #define OOM_VBALLOON_DEFAULT_PAGES 256 #define > > VIRTBALLOON_OOM_NOTIFY_PRIORITY 80 > > > > +/* The size of memory in bytes allocated for reporting free page > > +hints */ #define FREE_PAGE_HINT_MEM_SIZE (PAGE_SIZE * 16) > > + > > static int oom_pages = OOM_VBALLOON_DEFAULT_PAGES; > > module_param(oom_pages, int, S_IRUSR | S_IWUSR); > > MODULE_PARM_DESC(oom_pages, "pages to free on OOM"); > > Doesn't this limit memory size of the guest we can report? > Apparently to several gigabytes ... > OTOH huge guests with lots of free memory is exactly where we would gain > the most ... Yes, the 16-page array can report up to 32GB (each page can hold 512 addresses of 4MB free page blocks, i.e. 2GB free memory per page) free memory to host. It is not flexible. How about allocating the buffer according to the guest memory size (proportional)? That is, /* Calculates the maximum number of 4MB (equals to 1024 pages) free pages blocks that the system can have */ 4m_page_blocks = totalram_pages / 1024; /* Allocating one page can hold 512 free page blocks, so calculates the number of pages that can hold those 4MB blocks. And this allocation should not exceed 1024 pages */ pages_to_allocate = min(4m_page_blocks / 512, 1024); For a 2TB guests, which has 2^19 page blocks (4MB each), we will allocate 1024 pages as the buffer. When the guest has large memory, it should be easier to succeed in allocation of large buffer. If that allocation fails, that implies that nothing would be got from the 4MB free page list. I think the proportional allocation is simpler compared to other approaches like - scattered buffer, which will complicate the get_from_free_page_list implementation; - one buffer to call get_from_free_page_list multiple times, which needs get_from_free_page_list to maintain states.. also too complicated. Best, Wei