Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1634125rwb; Wed, 5 Oct 2022 02:28:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6SpEZnzh8I5BA3b3Vb6ROMy1bEtljahJ4yYC6gKOwqzNjE7Wh8dameBAHUCt991QAUmEis X-Received: by 2002:a17:907:7b94:b0:731:1b11:c241 with SMTP id ne20-20020a1709077b9400b007311b11c241mr23637009ejc.676.1664962098885; Wed, 05 Oct 2022 02:28:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664962098; cv=none; d=google.com; s=arc-20160816; b=cugXSihz25BnM9TaVDmhBK2ZH5V6k4RUmvKJ1TajQyARqedP5PN7zjUSUJv8+c32YE 5Qcsnzb5c7So6X7cQ5qbDyBkifux3Jn/I711/xSwHw4O84BtLSw64OTA6+bZfP17mKrE K85PVqvZHg1JGCkpOjmTXpAkHWc4HDH0iEO4tAg89b1QF1ylkUKigqjTEVU2Vq/37r0I vuM4RFBPSwVATUJ+wgk1FnQaMLmhUMpSCA/37skHzCvnYdQTLcbaY9qzsUAqsA3RtCEB svoMS0c5r0bj2JQPGoDoRusNY5B+TX6x0Dszie8GzVZSKuY6zgsPR3BTOZc/KTreaVfS 6/PQ== 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=ik/QLsQ36pM7xkyc+CcdduWc6PtaBwWcms+UNTEDpUw=; b=wNyLGnGtWHGZh9/S/LD5ddDGAhAtR5EE3FfDQyqjwuDsRFi1Ax1E7AJhRQNzHWSKCU ZZuparyBCASIyoLWUT8gmCc4588Vge57d2tlVDw78OdyabOAINTcfPpX9ORhimNBy/AA SJ8/mTTKcmTM4qfHECAbJ2QJMECPvHCSygox1IylajBJFbJzybKnVQAG8Zo71pqXwyYW cJ7Xd9R5XjPq/w2L/PzKWYsL8MzQKfG85tkdHkBqCrnHDWEKiT7Q0d4O0GHBcUFnc7gG 5ZRRn69Iilnh8gzHUHgggPi3LvNr5djoQGC7mg5wEBn/kXatmSTeEIrD8ZsWmON+SrON SApw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w8-20020aa7da48000000b0044ebf99d6f9si12534349eds.263.2022.10.05.02.27.46; Wed, 05 Oct 2022 02:28:18 -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 S230071AbiJEJDc (ORCPT + 99 others); Wed, 5 Oct 2022 05:03:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229806AbiJEJD2 (ORCPT ); Wed, 5 Oct 2022 05:03:28 -0400 Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B243A5D132; Wed, 5 Oct 2022 02:03:27 -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 1og0GS-007ckN-ED; Wed, 05 Oct 2022 11:02:53 +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: [PATCH v4 7/7] drivers: hyperv: balloon - report inflated memory Date: Wed, 5 Oct 2022 12:01:57 +0300 Message-Id: <20221005090158.2801592-8-alexander.atanasov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221005090158.2801592-1-alexander.atanasov@virtuozzo.com> References: <20221005090158.2801592-1-alexander.atanasov@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Propagate inflated memory changes to mm. Signed-off-by: Alexander Atanasov --- drivers/hv/hv_balloon.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index fdf6decacf06..b4c828c462a4 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,13 @@ 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 +1376,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 +1396,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; -- 2.31.1