Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp988923pxu; Wed, 2 Dec 2020 08:18:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJyDqqGPav9tOXlhwlI8t+ZNec0CeFbUt6TYaGK8edMW2iAjD4TgXdaBiOjAOl2ASJQUppGa X-Received: by 2002:a17:906:1294:: with SMTP id k20mr508885ejb.404.1606925930299; Wed, 02 Dec 2020 08:18:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606925930; cv=none; d=google.com; s=arc-20160816; b=d2k4VsMc9vDvIQi2rfHpdc2/AaKFWyf9h/NcSputj5VWuiX1hoXmC70jw2Zd1YvwGz J7tUcglx+dNNPBnOWhrrE7jdA5yUIPMSrM5bGeObyu27+4nl43RatXgPseO4E1br7MOJ fHwuJ6stE26G5m9stTj7rPHfWy2GyEiX7Czn7Ryu0L3N/mp7aZLKPiBuF6NsR6VtwgYY XwitWDpQtb3iJhj13j3rnASxV1ajrl9mBUIdSJTrH+FUzv0X8qEkLqeteIZTRJbRcdhc QjRVw6KgerM2eKrTsmNivOEWHqi+DYNxgoN4RsovoSkbffir0C6qYRbYu61NyKOB0zHE h6tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rZG0IaP7lxvBzgG5lqt7RoK3LK3aNw0DkDp+YEz1Y/0=; b=GthKJN8hcziNm5FJQI7M/7iaNvwwl4H+YYXEudKAc5vyNS0Wuj+44SI3hIcckEA0WG z4rNFk6HlUz+/zu8ke7dWgNWIfjg5+8OJsYOSTFA0ZDJtv5Q5ly06/S/VUYl9j9EUbHO /hV2a7UJTMJ9KU4gNidPcaa41jSIFGN+U+JXWMQa1h/O4mf5Y2YocD1j5wLpInM3YwoY nt/cuujOe+NaVmRrvifCaDC3FpXRWyahXYKOoRhM9nGBMsIj8dR6fRtSWkjI1RBrnFLK VATjKg+dnU0N4Xk53obqXnlszvvRZnA9X1TRC5bi4svFcLXQ7gNrUwGTvwJkHz8SLj9v D5EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Uuy3Fk6a; 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 w14si227932ejz.314.2020.12.02.08.18.26; Wed, 02 Dec 2020 08:18:50 -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=Uuy3Fk6a; 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 S1730672AbgLBQOa (ORCPT + 99 others); Wed, 2 Dec 2020 11:14:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35502 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730667AbgLBQO3 (ORCPT ); Wed, 2 Dec 2020 11:14:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606925583; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rZG0IaP7lxvBzgG5lqt7RoK3LK3aNw0DkDp+YEz1Y/0=; b=Uuy3Fk6aDzo25b1OqMBO/IVAmx32pb+7J0kf6q84obR1gV4qfks5CIHYqbOtgV5+u27Glw CfMg2Sac29BM4znDG8MCgLjW1Rt4zZf0R6sy3EwqG14Xa41LBlKcAYryVRU7wuD7kyNrXg v40o5JHT96ZRLU6bhhp/rpRJUd7GuJY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-105-eGdF3qlHNkCsp6VIUssoiQ-1; Wed, 02 Dec 2020 11:13:01 -0500 X-MC-Unique: eGdF3qlHNkCsp6VIUssoiQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E9A0A1006C9E; Wed, 2 Dec 2020 16:12:59 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.192.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id BED0F5C1BD; Wed, 2 Dec 2020 16:12:57 +0000 (UTC) From: Vitaly Kuznetsov To: linux-hyperv@vger.kernel.org Cc: Wei Liu , Stephen Hemminger , Haiyang Zhang , Michael Kelley , Dexuan Cui , David Hildenbrand , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 2/2] hv_balloon: do adjust_managed_page_count() when ballooning/un-ballooning Date: Wed, 2 Dec 2020 17:12:45 +0100 Message-Id: <20201202161245.2406143-3-vkuznets@redhat.com> In-Reply-To: <20201202161245.2406143-1-vkuznets@redhat.com> References: <20201202161245.2406143-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 = -- 2.26.2