From patchwork Wed Oct 19 09:56:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Atanasov X-Patchwork-Id: 5240 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp273160wrs; Wed, 19 Oct 2022 04:41:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Pzr+cAKprmWxBVtXRO3hnoT16Hwr7JmNhGLckwMN66+XbXxxAZpsdeK7mSkaxdN1VznE7 X-Received: by 2002:a17:902:ed82:b0:178:5653:ecfb with SMTP id e2-20020a170902ed8200b001785653ecfbmr8190446plj.58.1666179689480; Wed, 19 Oct 2022 04:41:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666179689; cv=none; d=google.com; s=arc-20160816; b=Te9YtBMB8EpUo+n9WdNK2fJwFIa/m+AsT4y1hRE86ebxFWOsDRO5dV/hXrGuljTWXW UysGgdv2rwWcZ8Y70ptU3mNvEqouE+YXUwBvesnLPjl0bL3kyvZLhCZhj5KAwK1U7DaJ iZe0ibIOXkN6fsY5QAUcIQgUvzWPBpEbbOoEiI6N1JjkUr7/XNGW3lrVmyTz4n18UUBe 01mSzwNtlNXdcLAv7+zYSpsDO7PXX2tsWHwetVvk4s9gNnIEQo4rFbXR84+LV4j+vhVe IWwLbVeoYZpMOExq5Si6Jvp8JHsmfhLnwihD915r4AtemZFXIfCaAoTRurXWvUGscfvj U90A== 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; bh=671V1lffgi4VLoXvZlNBB4JMadlneTt/JPeRz1fJQeM=; b=Wt+VWm87ObdSQZhYj9P4vz44Ozu84AVKocPDO2gTVWsF95p0D+DQO0E156sTxOqfL0 aBxn6GSGTvdsNvCyrNGEIVuLADuRFvm34S5EsvCmblaZP+U6Jl1xzupgXmD/maTGLcav ojHjjILfcRrnS/Hd0HeZTU6lvsAAhOnkTs6Sp3wyC8K+8z4jr7QeiDVMYvzCJx88Pnzb XB3AJlOJwu0q5Jo8Ec66CoLRwt+oi3D+AzbxmEI8bO4N/OJ6+xBDlf7Kjl7fqnyHOZdu x8N2lwsfKl9NYZRVAjELIMbKgdMx6++vvlXqtqk3a94OTSd++01a2pw4VnZ2hRCOWsmr I68w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r73-20020a632b4c000000b0045f0795c39esi18521756pgr.578.2022.10.19.04.41.15; Wed, 19 Oct 2022 04:41:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229525AbiJSLaN (ORCPT + 99 others); Wed, 19 Oct 2022 07:30:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230384AbiJSL3n (ORCPT ); Wed, 19 Oct 2022 07:29:43 -0400 Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC789170DDC; Wed, 19 Oct 2022 04:03:45 -0700 (PDT) Received: from dev011.ch-qa.sw.ru ([172.29.1.16]) by relay.virtuozzo.com with esmtp (Exim 4.95) (envelope-from ) id 1ol5lg-00B8K8-NM; Wed, 19 Oct 2022 11:56:35 +0200 From: Alexander Atanasov To: "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui Cc: kernel@openvz.org, Alexander Atanasov , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v5 7/8] drivers: hyperv: balloon - report inflated memory Date: Wed, 19 Oct 2022 12:56:19 +0300 Message-Id: <20221019095620.124909-8-alexander.atanasov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221019095620.124909-1-alexander.atanasov@virtuozzo.com> References: <20221019095620.124909-1-alexander.atanasov@virtuozzo.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747116033685084629?= X-GMAIL-MSGID: =?utf-8?q?1747116033685084629?= Update the inflated memory in the mm core on change. Signed-off-by: Alexander Atanasov --- drivers/hv/hv_balloon.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index fdf6decacf06..280622ee0e9b 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -1280,6 +1281,14 @@ static unsigned int alloc_balloon_pages(struct hv_dynmem_device *dm, return i * alloc_unit; } +static void report_ballooned_pages(struct hv_dynmem_device *dm) +{ + u32 actual = dm->num_pages_ballooned; + long inflated_kb = actual << (HV_HYP_PAGE_SHIFT - 10); + + balloon_set_inflated_total(inflated_kb); +} + static void balloon_up(struct work_struct *dummy) { unsigned int num_pages = dm_device.balloon_wrk.num_pages; @@ -1368,6 +1377,7 @@ static void balloon_up(struct work_struct *dummy) } } + report_ballooned_pages(&dm_device); } static void balloon_down(struct hv_dynmem_device *dm, @@ -1387,6 +1397,8 @@ static void balloon_down(struct hv_dynmem_device *dm, pr_debug("Freed %u ballooned pages.\n", prev_pages_ballooned - dm->num_pages_ballooned); + report_ballooned_pages(dm); + if (req->more_pages == 1) return;