All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: KY Srinivasan <kys@microsoft.com>
Cc: "devel\@linuxdriverproject.org" <devel@linuxdriverproject.org>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	"linux-kernel\@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Dexuan Cui <decui@microsoft.com>
Subject: Re: [PATCH 1/2] Drivers: hv: hv_balloon: report offline pages as being used
Date: Wed, 25 Feb 2015 17:55:48 +0100	[thread overview]
Message-ID: <87a902j5gr.fsf@vitty.brq.redhat.com> (raw)
In-Reply-To: <BY2PR0301MB07117B61ECC152DED6E094B0A0170@BY2PR0301MB0711.namprd03.prod.outlook.com> (KY Srinivasan's message of "Wed, 25 Feb 2015 14:32:09 +0000")

KY Srinivasan <kys@microsoft.com> writes:

>> -----Original Message-----
>> From: Vitaly Kuznetsov [mailto:vkuznets@redhat.com]
>> Sent: Thursday, February 19, 2015 8:27 AM
>> To: KY Srinivasan; devel@linuxdriverproject.org
>> Cc: Haiyang Zhang; linux-kernel@vger.kernel.org; Dexuan Cui
>> Subject: [PATCH 1/2] Drivers: hv: hv_balloon: report offline pages as being
>> used
>> 
>> When hot-added memory pages are not brought online or when some
>> memory blocks
>> are sent offline the subsequent ballooning process kills the guest with OOM
>> killer. This happens as we don't report these pages as neither used nor free
>> and apparently host algorythm considers them as being unused. Keep track
>> of
>> all online/offline operations and report all currently offline pages as being
>> used so host won't try to balloon them out.
>> 
>> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>> ---
>>  drivers/hv/hv_balloon.c | 33 ++++++++++++++++++++++++---------
>>  1 file changed, 24 insertions(+), 9 deletions(-)
>> 
>> diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
>> index a095b70..e4b4454 100644
>> --- a/drivers/hv/hv_balloon.c
>> +++ b/drivers/hv/hv_balloon.c
>> @@ -503,6 +503,8 @@ struct hv_dynmem_device {
>>  	 * Number of pages we have currently ballooned out.
>>  	 */
>>  	unsigned int num_pages_ballooned;
>> +	unsigned int num_pages_onlined;
>> +	unsigned int num_pages_added;
>> 
>>  	/*
>>  	 * State to manage the ballooning (up) operation.
>> @@ -556,12 +558,15 @@ static void post_status(struct hv_dynmem_device
>> *dm);
>>  static int hv_memory_notifier(struct notifier_block *nb, unsigned long val,
>>  			      void *v)
>>  {
>> +	struct memory_notify *mem = (struct memory_notify *)v;
>> +
>>  	switch (val) {
>>  	case MEM_GOING_ONLINE:
>>  		mutex_lock(&dm_device.ha_region_mutex);
>>  		break;
>> 
>>  	case MEM_ONLINE:
>> +		dm_device.num_pages_onlined += mem->nr_pages;
>>  	case MEM_CANCEL_ONLINE:
>
> Why are we not adjusting num_pages_onlined when we cancel the online
> Operation.

Because we didn't increase the number yet.

To my understanding, events come in the following order:
1) MEM_GOING_ONLINE - we just take the lock
2) MEM_ONLINE - and we increase nr_pages and drop the lock
   or
   MEM_CANCEL_ONLINE - we just drop the lock (mem never was online so
                                              nr_pages wasn't increased)
3) MEM_GOING_OFFLINE - we do nothing
4) MEM_OFFLINE - and we decrease nr_pages
   or 
   MEM_CANCEL_OFFLINE - we do nothing (mem is still online, no need to
                                       adjust nr_pages)

>
> K. Y

-- 
  Vitaly

  reply	other threads:[~2015-02-25 16:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-19 16:27 [PATCH 0/2] Drivers: hv: hv_balloon: avoid OOM killer on the ballooning path Vitaly Kuznetsov
2015-02-19 16:27 ` [PATCH 1/2] Drivers: hv: hv_balloon: report offline pages as being used Vitaly Kuznetsov
2015-02-25 14:32   ` KY Srinivasan
2015-02-25 16:55     ` Vitaly Kuznetsov [this message]
2015-02-25 22:29       ` KY Srinivasan
2015-02-19 16:27 ` [PATCH 2/2] Drivers: hv: hv_balloon: refuse to balloon below the floor Vitaly Kuznetsov

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=87a902j5gr.fsf@vitty.brq.redhat.com \
    --to=vkuznets@redhat.com \
    --cc=decui@microsoft.com \
    --cc=devel@linuxdriverproject.org \
    --cc=haiyangz@microsoft.com \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.