Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp934016rwi; Wed, 19 Oct 2022 04:57:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7xu9HXH3m7N7XHHMSOtqJQ4XvaYuZKo2wk7/zuzUK1SnsPVGtU0062aBlZfxpl9r92XOdd X-Received: by 2002:a17:906:8446:b0:78d:9f1a:9afc with SMTP id e6-20020a170906844600b0078d9f1a9afcmr6443824ejy.637.1666180674847; Wed, 19 Oct 2022 04:57:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666180674; cv=none; d=google.com; s=arc-20160816; b=K4jp85Ab2IJ0S3XrYVAyb2m44+Ekp444VTsEtIF/GcpjOQa4Yab7+1+riD3FEVDRh8 ieVBF930JJ4vOxdQPzTinEuOTR88vWgKjHBqXwBSa/96suzmeCcb+/ZIwLKc63lu+Maq QrpVQZNdMyONnVeJPRXJGTBWrf7RFUQRkq9/0eqJW937MucHUnvqXXwTS+j3fIVF4JPI 8deo97uYlZlZ1T2xQZG0Ik3S0XAOf74qVeJnyQka2y1eFLsIEBaGBP1xqb8Ek93H1Xk2 DvWbs22s5+EAQrRaTcL91fuZm6VeGY/FZG2xj+gRt1b9qTK2CvvwGLhY/i11q3WS+rjV C88g== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ho34-20020a1709070ea200b0078db3ce1e59si16814579ejc.38.2022.10.19.04.57.28; Wed, 19 Oct 2022 04:57:54 -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 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 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) { -- 2.31.1