From patchwork Wed Oct 19 09:56:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Atanasov X-Patchwork-Id: 5253 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp273751wrs; Wed, 19 Oct 2022 04:42:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5A/61vg7HH6Xg80YIsdEf+/gEdW5u0zcKKVYGFm1Ccn+wuiK+f2HgQXr51WkDJnXmyoDAI X-Received: by 2002:a17:90b:17cf:b0:20d:72eb:fd0c with SMTP id me15-20020a17090b17cf00b0020d72ebfd0cmr9184828pjb.217.1666179768294; Wed, 19 Oct 2022 04:42:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666179768; cv=none; d=google.com; s=arc-20160816; b=gV4L8aLkw3t1UWUN1dxnGnEgwjPdwAxD6UGVlz6wLemHNtcxPalkQypD6hWUhT93Pg 7U8GJTjCizkFM70vWZ611r0CXq5t8YupT85t/l/XRUMInN2zL+2RqMsb7thSCFMOstzm eT9QtfG4ZdeXAiXbRUG23Rtck6R9eFze/Q9Jt7Yq4vIBe3dabnvKOMWOLgHEm+okOuzv aag1T8mjHPlhB6qlpVPo6F4+Wx4eYIHcpcmdt7CnsKGg2k2V6dz50jPN6lTdGr+1dqpR xNv5a9nBm16L/4pnP2SgG5cLiWqSKU9R193UTMsDIDM4JBDsdH3F8G3KfcmEn5XwWuRx QuUg== 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=eH/0PNfBQFD/UE1s0SF9vXZ+c1loynZS8MwxGGWgzQQ=; b=NjTeHwImAbz/9LRqB82rmeGe5HRqbPBY5kFFSAXMeBeuZfFGFAL6uSEhLmVU//iqZM pJrASY5NUhKPKuzYDRRy6/RnNfBPY0F55/892Lpt1Sqjmx6rHcqaWraEkkRIUYBFjdoL SBXINjzxelJ81Dnx4P1RY6HvPws6ZCSAkanzNQU++OABuVLJmTxweu7Bt5rVaUfRocsp s6sGkTTwhltArh6kChQDOTZz3LpPsFBDxtIzgGfJClFhHLO2fbH5ByaT9Z8YELdqw9BB Y7ukQIbak2IinAgmiAAj7h/oh3kt0xGvdvNNAHawALEWI1c0UCd/nNulX9ctpFKPUe7v Y5Xg== 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 kk9-20020a17090b4a0900b001fd7d02c976si27694676pjb.87.2022.10.19.04.42.35; Wed, 19 Oct 2022 04:42:48 -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 S232110AbiJSLak (ORCPT + 99 others); Wed, 19 Oct 2022 07:30:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232086AbiJSLaL (ORCPT ); Wed, 19 Oct 2022 07:30:11 -0400 Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4A3365FD for ; Wed, 19 Oct 2022 04:04:22 -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 1ol5la-00B8K8-3t; Wed, 19 Oct 2022 11:56:28 +0200 From: Alexander Atanasov To: "Michael S. Tsirkin" , David Hildenbrand , Andrew Morton Cc: kernel@openvz.org, Alexander Atanasov , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v5 2/8] mm: Enable balloon drivers to report inflated memory Date: Wed, 19 Oct 2022 12:56:14 +0300 Message-Id: <20221019095620.124909-3-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?1747116116532504252?= X-GMAIL-MSGID: =?utf-8?q?1747116116532504252?= Add counters to be updated by the balloon drivers. Signed-off-by: Alexander Atanasov --- include/linux/balloon.h | 6 ++++++ mm/balloon.c | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/linux/balloon.h b/include/linux/balloon.h index 46ac8f61f607..dd8fb8ac5737 100644 --- a/include/linux/balloon.h +++ b/include/linux/balloon.h @@ -57,6 +57,12 @@ struct balloon_dev_info { struct page *page, enum migrate_mode mode); }; +extern atomic_long_t mem_balloon_inflated_total_kb; +extern atomic_long_t mem_balloon_inflated_free_kb; + +void balloon_set_inflated_total(long inflated_kb); +void balloon_set_inflated_free(long inflated_kb); + struct page *balloon_page_alloc(void); void balloon_page_enqueue(struct balloon_dev_info *b_dev_info, struct page *page); diff --git a/mm/balloon.c b/mm/balloon.c index 22b3e876bc78..59f606bf4390 100644 --- a/mm/balloon.c +++ b/mm/balloon.c @@ -9,6 +9,21 @@ #include #include +atomic_long_t mem_balloon_inflated_total_kb = ATOMIC_LONG_INIT(0); +atomic_long_t mem_balloon_inflated_free_kb = ATOMIC_LONG_INIT(0); + +void balloon_set_inflated_total(long inflated_kb) +{ + atomic_long_set(&mem_balloon_inflated_total_kb, inflated_kb); +} +EXPORT_SYMBOL(balloon_set_inflated_total); + +void balloon_set_inflated_free(long inflated_kb) +{ + atomic_long_set(&mem_balloon_inflated_free_kb, inflated_kb); +} +EXPORT_SYMBOL(balloon_set_inflated_free); + static void balloon_page_enqueue_one(struct balloon_dev_info *b_dev_info, struct page *page) {