Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp677480pxu; Thu, 3 Dec 2020 09:53:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJxrJAs037v2omiSXfYtcuRh4WOzAORBg7mJeUrrz8dXe8vRlCtUlj04XA5m7Yvoq3qo0KGC X-Received: by 2002:a05:6402:1714:: with SMTP id y20mr2299087edu.2.1607018034699; Thu, 03 Dec 2020 09:53:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607018034; cv=none; d=google.com; s=arc-20160816; b=Nn9IK4pWPsGbziz5/qixoRGC+eJxKnLeFuFcLKXEO6phUuE+uKV/ZD2bD876uXVBDQ bGUN+sQaVQihZemoiCeAI87icDdOb/dFIiChAJmnM7LO6rmfAYAxVAO3xG10ONpQ8tJG 8Guv7oyzEdTve5SFsDVKz/JtghvBZeUPQhcQ6ivaEQ1GS2G8PVOIoM7B5zsv2kB42oS7 pYdIz8Zlz16i3IgANCsLdw6dPBjgydUGWS4jGUcWTVk3i92a2M0M3pCOmG44T/Y6uc9d 6DSawTQJXEzMVqVDLImjkrB5WenTwW2qXcIwjPo2PHjFsFCDFWR3Aj4eMoZ1EZQgRGHm NEFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=YZXe59hLHI7lUJaoCikBZP/PP9yfQkA8Mgqf1mIV4UE=; b=aWHDgvvdgDTno03N75eq+5VNGJ/LxER0/F6YyqMU5pNy9j6jb8yM5WqlzqXwZHRLE3 vj8QCfUrgUqLSgGmao/hRom7sASURYQvlHvmyAGiCcipxArlYI6TOZwNgtac19dMQepl arG/8Jblo8PBYPOot7nE1Tkz4ATIuuNsvFCGi0O1QfzGS/w7ae46EUw0B81kcM+m0hrX oh+gbb9BNvhh+aSdqEqcPYICoFclKrpkeZisFZVdWfqE4YRDGXSUjESn/sV0ZHjSs/U4 S1Wb/dxmchBbI0Y738MO3/pqLJE8S/mfeEc3QCsd9xLp8K25zPpxC1+YQIjycU0Shn4R nKcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hJgHLfqL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id um9si1514877ejb.521.2020.12.03.09.53.31; Thu, 03 Dec 2020 09:53:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hJgHLfqL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726567AbgLCRug (ORCPT + 99 others); Thu, 3 Dec 2020 12:50:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:46447 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726763AbgLCRuf (ORCPT ); Thu, 3 Dec 2020 12:50:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607017748; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YZXe59hLHI7lUJaoCikBZP/PP9yfQkA8Mgqf1mIV4UE=; b=hJgHLfqL2JnQqGx1b98qQ++aW9/t53FJEkQoAwKf85SntGaM5+0VVm81TdUUjZnzPN6ebU 0OaFWt+mKAa3gOq4qE7V+pG2lMqEJt37ZxDjeQOlo89/eHME350hEOhW4/0eg0uJpt2LNl Rgm2WIByRWxwpfmg/9uufPwSzVXDri4= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-595-L7Nz-I27NGG36EYsQCmsew-1; Thu, 03 Dec 2020 12:49:07 -0500 X-MC-Unique: L7Nz-I27NGG36EYsQCmsew-1 Received: by mail-ej1-f70.google.com with SMTP id n17so1061712eja.23 for ; Thu, 03 Dec 2020 09:49:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=YZXe59hLHI7lUJaoCikBZP/PP9yfQkA8Mgqf1mIV4UE=; b=uQMxfFwBucaQAdKy63CzTxxU5TTawg8Q8T0ZwBBVAAyrlCpj2ORiPH4azyM5cOGnGi r/U8OwXXcHkhxfTygGsSt1gb6HXUn8uXn2Rk6hvBagcRjRaWYpX5WgCdY2Q00zCAGzSO ALoFKoNeZcDtHu3dNRrZfZq8BdXKFcvSwdVNqRhDIIZRK2gaiJ0U/KwS05btr/NR9Od1 R1ZTwSPpWnfF1ZUFO4d/U9EPR118Mpheyzg3pRCFXwr4RGz4e2uqunLs+SB5XZgPKbk+ d4/q8G7YYkhlQVUXv102UevtD+xwSLma/Q8e5Q+n/nnQqXGy3nx7k9RghdPQvKuhHnbu wMRQ== X-Gm-Message-State: AOAM532CESArxJ/CzZ9hoxhwcnnwupUKAOLfDSxwPbCZwpLfS7MFcieT vg1taovkOSO0IiBzdW3oqgEY/ToLeS1B3ad6l+DNL6wuNL+assLYNqf+w+XVeuur2+Q7b/fOL6M V0t0ICOFNZGtrclDyKkeExBYJ X-Received: by 2002:a17:906:edca:: with SMTP id sb10mr3612231ejb.284.1607017745575; Thu, 03 Dec 2020 09:49:05 -0800 (PST) X-Received: by 2002:a17:906:edca:: with SMTP id sb10mr3612222ejb.284.1607017745440; Thu, 03 Dec 2020 09:49:05 -0800 (PST) Received: from vitty.brq.redhat.com (g-server-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id x20sm1308351ejv.66.2020.12.03.09.49.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 09:49:04 -0800 (PST) From: Vitaly Kuznetsov To: David Hildenbrand , linux-hyperv@vger.kernel.org Cc: Wei Liu , Stephen Hemminger , Haiyang Zhang , Michael Kelley , Dexuan Cui , 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 In-Reply-To: <9202aafa-f30e-4d96-72a9-3ccd083cc58c@redhat.com> References: <20201202161245.2406143-1-vkuznets@redhat.com> <20201202161245.2406143-3-vkuznets@redhat.com> <9202aafa-f30e-4d96-72a9-3ccd083cc58c@redhat.com> Date: Thu, 03 Dec 2020 18:49:04 +0100 Message-ID: <871rg6ok4v.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org David Hildenbrand 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 >> Signed-off-by: Vitaly Kuznetsov >> --- >> 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 Thanks! -- Vitaly