From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: David Hildenbrand <david@redhat.com>, linux-hyperv@vger.kernel.org
Cc: Wei Liu <wei.liu@kernel.org>,
Stephen Hemminger <sthemmin@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Michael Kelley <mikelley@microsoft.com>,
Dexuan Cui <decui@microsoft.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH 2/2] hv_balloon: do adjust_managed_page_count() when ballooning/un-ballooning
Date: Thu, 03 Dec 2020 18:49:04 +0100 [thread overview]
Message-ID: <871rg6ok4v.fsf@vitty.brq.redhat.com> (raw)
In-Reply-To: <9202aafa-f30e-4d96-72a9-3ccd083cc58c@redhat.com>
David Hildenbrand <david@redhat.com> writes:
> On 02.12.20 17:12, Vitaly Kuznetsov wrote:
>> Unlike virtio_balloon/virtio_mem/xen balloon drivers, Hyper-V balloon driver
>> does not adjust managed pages count when ballooning/un-ballooning and this leads
>> to incorrect stats being reported, e.g. unexpected 'free' output.
>>
>> Note, the calculation in post_status() seems to remain correct: ballooned out
>> pages are never 'available' and we manually add dm->num_pages_ballooned to
>> 'commited'.
>>
>> Suggested-by: David Hildenbrand <david@redhat.com>
>> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>> ---
>> drivers/hv/hv_balloon.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
>> index da3b6bd2367c..8c471823a5af 100644
>> --- a/drivers/hv/hv_balloon.c
>> +++ b/drivers/hv/hv_balloon.c
>> @@ -1198,6 +1198,7 @@ static void free_balloon_pages(struct hv_dynmem_device *dm,
>> __ClearPageOffline(pg);
>> __free_page(pg);
>> dm->num_pages_ballooned--;
>> + adjust_managed_page_count(pg, 1);
>> }
>> }
>>
>> @@ -1238,8 +1239,10 @@ static unsigned int alloc_balloon_pages(struct hv_dynmem_device *dm,
>> split_page(pg, get_order(alloc_unit << PAGE_SHIFT));
>>
>> /* mark all pages offline */
>> - for (j = 0; j < alloc_unit; j++)
>> + for (j = 0; j < alloc_unit; j++) {
>> __SetPageOffline(pg + j);
>> + adjust_managed_page_count(pg + j, -1);
>> + }
>>
>> bl_resp->range_count++;
>> bl_resp->range_array[i].finfo.start_page =
>>
>
> I assume this has been properly tested such that it does not change the
> system behavior regarding when/how HyperV decides to add/remove memory.
>
I'm always reluctant to confirm 'proper testing' as no matter how small
and 'obvious' the change is, regressions keep happening :-) But yes,
this was tested on a Hyper-V host and 'stress' and I observed 'free'
when the balloon was both inflated and deflated, values looked sane.
> LGTM
>
> Reviewed-by: David Hildenbrand <david@redhat.com>
Thanks!
--
Vitaly
next prev parent reply other threads:[~2020-12-03 17:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-02 16:12 [PATCH 0/2] hv_balloon: hide ballooned out memory in stats Vitaly Kuznetsov
2020-12-02 16:12 ` [PATCH 1/2] hv_balloon: simplify math in alloc_balloon_pages() Vitaly Kuznetsov
2020-12-03 16:15 ` David Hildenbrand
2020-12-02 16:12 ` [PATCH 2/2] hv_balloon: do adjust_managed_page_count() when ballooning/un-ballooning Vitaly Kuznetsov
2020-12-03 16:13 ` David Hildenbrand
2020-12-03 17:49 ` Vitaly Kuznetsov [this message]
2020-12-03 17:49 ` David Hildenbrand
2020-12-09 13:17 ` [PATCH 0/2] hv_balloon: hide ballooned out memory in stats Wei Liu
2020-12-13 15:07 ` Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871rg6ok4v.fsf@vitty.brq.redhat.com \
--to=vkuznets@redhat.com \
--cc=david@redhat.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mikelley@microsoft.com \
--cc=sthemmin@microsoft.com \
--cc=wei.liu@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).