From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752861AbbBYQz7 (ORCPT ); Wed, 25 Feb 2015 11:55:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53029 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752401AbbBYQz6 (ORCPT ); Wed, 25 Feb 2015 11:55:58 -0500 From: Vitaly Kuznetsov To: KY Srinivasan Cc: "devel\@linuxdriverproject.org" , Haiyang Zhang , "linux-kernel\@vger.kernel.org" , Dexuan Cui Subject: Re: [PATCH 1/2] Drivers: hv: hv_balloon: report offline pages as being used References: <1424363230-3758-1-git-send-email-vkuznets@redhat.com> <1424363230-3758-2-git-send-email-vkuznets@redhat.com> Date: Wed, 25 Feb 2015 17:55:48 +0100 In-Reply-To: (KY Srinivasan's message of "Wed, 25 Feb 2015 14:32:09 +0000") Message-ID: <87a902j5gr.fsf@vitty.brq.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org KY Srinivasan 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 >> --- >> 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