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) { From patchwork Wed Oct 19 09:56:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Atanasov X-Patchwork-Id: 5338 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp287918wrs; Wed, 19 Oct 2022 05:12:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5x5DuuM+mG/0BmsWNFdVOyllfEF/Lo2UZphK4krUgGfcbxCkrPWwOeHValTGf3Sg6anjSw X-Received: by 2002:a05:6402:2319:b0:45c:4231:de18 with SMTP id l25-20020a056402231900b0045c4231de18mr7279312eda.383.1666181546976; Wed, 19 Oct 2022 05:12:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666181546; cv=none; d=google.com; s=arc-20160816; b=aa81etuy8euITkmsOyOGMV3DHIf1CqbaqtD3T//9AqCRxHnEcMKXQ56uQUnvLWHGz1 VxOgL/6WUcdqqD82r2Y6twl4CkKUwdBSwnh/P5rp8p7w3qhoM/UKBfsc5WCvskWzvege 7HAeBwII1WHv0wvOa7QCdxxJAWOgvxDuuWeChTYVpbQOdpYjzJGWUzHM58SGYx5XjtYl /IS5TaALB758Y+Ug0vxxVQ2BOBsxNSmv5Y+PuTIQcszVuDfekk6L15CWtUNji3xFqJ0R eAVEZfunD0oPAQQjAYjGg1DNf4xRTQXB3HFiLbwhqm8f0LXBMgaDhV4Jc31uQ1VlsgF4 icFA== 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=k3e79AYNtwHX2CN5cEq6TICYh88ATpzgNJ1qn3tb3v0=; b=htIc4Jw1duF5OtUPfr3eR/+k+T3rIjUu65SHDx64jElgtIHx10VUT32QRdqHDcMd1E 0Q8XwAUJC2ls4w6yh2NkclIIiRNTLVdI6joFjwcneT3MFMmTWFAS1peq5cNcyPi4F7iF eBl0G1EWDwazwGqba0NcLAGqT0GtmTlk43kyVQL8oD9Vfm8dSdtVBUGAAlMAR8c4KlSu 42PGz86NZbvS3ChU5NCfT2WBpkLrZzXz/pP5llH5+z3bV1nlcfjaK5eTtQfoSu/Aer2u 5eyVhXahr3wq1HdqpJeR9p3BnIxZMcyY85/Q18EY/4Z1pLfXP+6r34q9IsWTWoMbe5dH j+GA== 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 ka14-20020a170907990e00b0078358970513si12060799ejc.367.2022.10.19.05.11.47; Wed, 19 Oct 2022 05:12:26 -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 S232693AbiJSMKq (ORCPT + 99 others); Wed, 19 Oct 2022 08:10:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233245AbiJSMJh (ORCPT ); Wed, 19 Oct 2022 08:09:37 -0400 Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF4F93C16D; Wed, 19 Oct 2022 04:45:43 -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 1ol5lb-00B8K8-Cj; Wed, 19 Oct 2022 11:56:29 +0200 From: Alexander Atanasov To: Jonathan Corbet Cc: kernel@openvz.org, Alexander Atanasov , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org Subject: [RFC PATCH v5 3/8] mm: Display inflated memory to users Date: Wed, 19 Oct 2022 12:56:15 +0300 Message-Id: <20221019095620.124909-4-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?1747117981449446815?= X-GMAIL-MSGID: =?utf-8?q?1747117981449446815?= Add InflatedTotal and InflatedFree to /proc/meminfo Signed-off-by: Alexander Atanasov --- Documentation/filesystems/proc.rst | 6 ++++++ fs/proc/meminfo.c | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst index 898c99eae8e4..d88828a27383 100644 --- a/Documentation/filesystems/proc.rst +++ b/Documentation/filesystems/proc.rst @@ -992,6 +992,8 @@ Example output. You may not have all of these fields. VmallocUsed: 40444 kB VmallocChunk: 0 kB Percpu: 29312 kB + InflatedTotal: 2097152 kB + InflatedFree: 0 kB HardwareCorrupted: 0 kB AnonHugePages: 4149248 kB ShmemHugePages: 0 kB @@ -1142,6 +1144,10 @@ VmallocChunk Percpu Memory allocated to the percpu allocator used to back percpu allocations. This stat excludes the cost of metadata. +InflatedTotal and InflatedFree + Amount of memory that is inflated by the balloon driver. + Due to differences among the drivers inflated memory + is subtracted from TotalRam or from MemFree. HardwareCorrupted The amount of RAM/memory in KB, the kernel identifies as corrupted. diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c index 5101131e6047..d9e059b0b25d 100644 --- a/fs/proc/meminfo.c +++ b/fs/proc/meminfo.c @@ -16,6 +16,9 @@ #ifdef CONFIG_CMA #include #endif +#ifdef CONFIG_MEMORY_BALLOON +#include +#endif #include #include "internal.h" @@ -155,6 +158,13 @@ static int meminfo_proc_show(struct seq_file *m, void *v) global_zone_page_state(NR_FREE_CMA_PAGES)); #endif +#ifdef CONFIG_MEMORY_BALLOON + seq_printf(m, "InflatedTotal: %8ld kB\n", + atomic_long_read(&mem_balloon_inflated_total_kb)); + seq_printf(m, "InflatedFree: %8ld kB\n", + atomic_long_read(&mem_balloon_inflated_free_kb)); +#endif + hugetlb_report_meminfo(m); arch_report_meminfo(m); From patchwork Wed Oct 19 09:56:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Atanasov X-Patchwork-Id: 5269 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp275947wrs; Wed, 19 Oct 2022 04:48:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5nHGYE4DMZG/YjAHAlY/9HP1zh5Zm0NfHe9CMJhauTqLnZxQJnZPpXmdEvQKT9MFlinkBG X-Received: by 2002:a17:906:5a4b:b0:78d:8790:d4a1 with SMTP id my11-20020a1709065a4b00b0078d8790d4a1mr6370905ejc.329.1666180122422; Wed, 19 Oct 2022 04:48:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666180122; cv=none; d=google.com; s=arc-20160816; b=hyCXyeIDDxI3KoQwJ+WSBwXQyHrUuNw27n0qaxsHD5swZ4gbLQZwNYRqgDZelpilJK zV7WdLhJ4YUpFniN0IeOurbaMG+dDH6EQszau+lzUdySXMWVQwRFJmDzNvyWDZ1bOqCO LGeM7iV/awP00hDs/UR6J1KWBVZxtiP3RkVKsBiFiuFJQl//+bmwMDVivKNUJXY5P3m1 P22VkRS2kU6NXhRc2ejiDVtycujspe4WyUIU0yCOutNrSV3xkOQ4IE8fuK9CitJtd7+S YiMnBbBQqGlV9+qK2jCR3vsCkHgTNxjSlEW2Wbpylc3sehZ3QYJ6amtnI1U6vt+sK4T6 fmSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from; bh=KfR1yiQyvGWILXvQgDdmh9/mTjqO7etqhZK5eWBc8oc=; b=i0yZq9BiegacQBXSrJkg5kcWPLk9AqG+fxJgo9tFROsFivJYmOPjzB2pOm+UeXg/2B diBjAolBANvTImi3XEOhneip1JNHoEiIYB08sRHBTGWnDkNpHCPHd3fEekKUtnlFJwcf md+4ZSsQ7tsMRjkOiIbLDM2iqsK9XhLm+ni61nDzCR+2SQeeSsTbmuXXHWFaD8muwr5Y YJL9EH+swlxRsVXWOx4ntz7bKfMG0tXMwH1RvbK2se+A1A/QLiPOCDmn/r8UN7G8yitW VxrAIRTVCbVuq8KgQshDYsgnOzD0OHncqc39U/eaug1xkr81YESu65Ho/+kkMyXvnchx Ug7Q== 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 jz18-20020a17090775f200b0078d00203ab4si10915414ejc.691.2022.10.19.04.48.14; Wed, 19 Oct 2022 04:48:42 -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 S230348AbiJSLq5 (ORCPT + 99 others); Wed, 19 Oct 2022 07:46:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230238AbiJSLq2 (ORCPT ); Wed, 19 Oct 2022 07:46:28 -0400 Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78455136401 for ; Wed, 19 Oct 2022 04:25:47 -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 1ol5lc-00B8K8-Jy; Wed, 19 Oct 2022 11:56:31 +0200 From: Alexander Atanasov Cc: kernel@openvz.org, Alexander Atanasov , linux-kernel@vger.kernel.org Subject: [RFC PATCH v5 4/8] mm: Display inflated memory in logs Date: Wed, 19 Oct 2022 12:56:16 +0300 Message-Id: <20221019095620.124909-5-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 To: unlisted-recipients:; (no To-header on input) 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?1747116488043649041?= X-GMAIL-MSGID: =?utf-8?q?1747116488043649041?= Add InflatedTotal and InflatedFree to show_mem(...) so it is visible in the logs. Signed-off-by: Alexander Atanasov --- lib/show_mem.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/show_mem.c b/lib/show_mem.c index 0d7585cde2a6..20b5964d498e 100644 --- a/lib/show_mem.c +++ b/lib/show_mem.c @@ -7,6 +7,9 @@ #include #include +#ifdef CONFIG_MEMORY_BALLOON +#include +#endif void __show_mem(unsigned int filter, nodemask_t *nodemask, int max_zone_idx) { @@ -41,4 +44,9 @@ void __show_mem(unsigned int filter, nodemask_t *nodemask, int max_zone_idx) #ifdef CONFIG_MEMORY_FAILURE printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages)); #endif +#ifdef CONFIG_MEMORY_BALLOON + printk("Balloon InflatedTotal:%ldkB InflatedFree:%ldkB\n", + atomic_long_read(&mem_balloon_inflated_total_kb), + atomic_long_read(&mem_balloon_inflated_free_kb)); +#endif } From patchwork Wed Oct 19 09:56:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Atanasov X-Patchwork-Id: 5251 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp273707wrs; Wed, 19 Oct 2022 04:42:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM64DUgrArQXaYlt+oHwCdCAuMFE73QhbiRQmPfWG6FsVxOYUOVRuy4TIFlEmla8JrhvK5if X-Received: by 2002:a63:5b58:0:b0:452:2ba4:f86b with SMTP id l24-20020a635b58000000b004522ba4f86bmr6638666pgm.223.1666179774574; Wed, 19 Oct 2022 04:42:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666179774; cv=none; d=google.com; s=arc-20160816; b=Ke1oTFyqpzn9VIz9QM55wAbRHV41dtJ5MpLI+1Q135WiAc2AnjF+vaPnd26DE9CjJw 7YiKnRNCAUw5f4SeHBZQb3Mh3BNLPwcYzhYWjV53xraBt6QeG74QmbgOped/54n8UAel NMj4gUYxCAnivv6h497H7Wwh2qT74+k5er6EZ+ylbjaSnRyilDUqUsamigKNvtXE0cAp 5Sfn+rA7gawIOsrzBnB/6qXM4NnyrJY7XBwGC3KOLR9pnavztQEdBxzdDjgKsKJUHUpP dkXa3QMig/j3HXnxlVhGEpJjUTxRCQI+GqC9Ud74dup0fmq5z3M3uZ0P9HkI9IH7AiQl 5RbQ== 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=sYj27dKX8Rv12ooaEz8IuPPdzjjPlZMP20coOWWqT5g=; b=PzpQ9XxNrYp2EREuF+6H/bJeSFdjRm9Fj88dV6pCf0qmvTGxO9/FqO7/WtP+kS4FYX HvOyxfhz8EROUHq3Gc/aLGZQDgu/U5EkdUP7cL6+CASOWSdfP/BCYuhYhSHrE6HC970j H29+/JPnxFdj3cxiJfEVzl0WhxGFXTlQ/j0ma2+OXyd6bQPzjDrz106Q7woEAh/ZMN+c aUdMkVE9+7qaDW37Mcww2Mn7aDPWOZDy6E8DaVAwJ6vU6lNfwgmgrzOQRJipk5CBe5et Hd+SKNCBlerudjXFB253dV+VpVyhs5z/71NgOwWnz5xDKz9hUznaZT3pvIOoNZsNuLXU 7ArQ== 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 m10-20020a638c0a000000b00439f6781389si22758118pgd.662.2022.10.19.04.42.41; Wed, 19 Oct 2022 04:42: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 S231536AbiJSLao (ORCPT + 99 others); Wed, 19 Oct 2022 07:30:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231474AbiJSLaT (ORCPT ); Wed, 19 Oct 2022 07:30:19 -0400 Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E28089958 for ; Wed, 19 Oct 2022 04:04:53 -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 1ol5ld-00B8K8-RP; Wed, 19 Oct 2022 11:56:32 +0200 From: Alexander Atanasov To: "Michael S. Tsirkin" , David Hildenbrand , Jason Wang Cc: kernel@openvz.org, Alexander Atanasov , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v5 5/8] drivers: virtio: balloon - report inflated memory Date: Wed, 19 Oct 2022 12:56:17 +0300 Message-Id: <20221019095620.124909-6-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?1747116123566441633?= X-GMAIL-MSGID: =?utf-8?q?1747116123566441633?= Update the inflated memory in the mm core when it changes. Signed-off-by: Alexander Atanasov --- drivers/virtio/virtio_balloon.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index d0c27c680721..e9c3642eef17 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -450,10 +450,15 @@ static void virtballoon_changed(struct virtio_device *vdev) static void update_balloon_size(struct virtio_balloon *vb) { u32 actual = vb->num_pages; + long inflated_kb = actual << (VIRTIO_BALLOON_PFN_SHIFT - 10); /* Legacy balloon config space is LE, unlike all other devices. */ virtio_cwrite_le(vb->vdev, struct virtio_balloon_config, actual, &actual); + if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) + balloon_set_inflated_free(inflated_kb); + else + balloon_set_inflated_total(inflated_kb); } static void update_balloon_stats_func(struct work_struct *work) From patchwork Wed Oct 19 09:56:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Atanasov X-Patchwork-Id: 5336 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp287721wrs; Wed, 19 Oct 2022 05:12:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6wfaTottadie7B+ZUl2BXm850ptQ1yKFvhIR2CR71Y2P2QFmqYSfJ1wCAgYBTuvKoVVYrB X-Received: by 2002:a05:6402:5485:b0:459:147a:d902 with SMTP id fg5-20020a056402548500b00459147ad902mr7402554edb.263.1666181525798; Wed, 19 Oct 2022 05:12:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666181525; cv=none; d=google.com; s=arc-20160816; b=IxVuYufsks8xFOvM8SFy/pTJpKRQg60I6XF1bGeStZ3PkO5K7TczlCvuHIclbbIaNf YReqdW/SF1W0/SS0e5fTk9iQI5QhKks524KBwV/DBWwBDKGKxo/vWyeDYiQx9J6T8z1h 2YWOWGxkUckKuA57TRmce5J0C8PtyC9H0/PCDkjcznfWGSJu4fmgH2zzLLiIvj/zgM8G 8f72OF9OIbjIh/kPCXpBOOZPsu5p1CE6qlpcZd4Zkr4JeTaRbo7NnSi11YBus1Owsv/B O2rzl1dYlwFY23yBFNMl0+GPf0NqpQaM3Hq7ulyOg72bNxHeJHExqK6HHyX2UzUkmoVM 6Lcg== 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=GjBwKBFhSfpea4acgA05YoTMbnyS9dt3lQhmZ4rO6zQ=; b=n5kpIknYQiYSrdI47qqjJhNanPDDflTIvy+aXa9scNvhOZDe7VsaE2vrRpm3LTq83L +phRgihyG5JQGb5aZsHwr9N+jYtnnTShbrM1bgRdGUrFJ+SbNFpitsVsh/NsacmIZWfV YoPEf+UgXkS8cjRHWo3kPs5U4yPXSQYR6OBDLMGp2bqb2J+zOmKUHxvjfQ/FpbLRpABB dEk7fhrzxg0iL5RsL1a5LTwvEyPEqpTkh8xJz4mwPQn5qoJxPqfUzZILSw+T9gvwSHpH f6+ZFbTFeB8gzNHrShRZ4NHAH/bxLbVgsiia57Gd3QNYyxk9Rn+mk0jdFCZuGqWDkp2U +s6A== 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 hb7-20020a170907160700b0078decbc3f73si14873097ejc.460.2022.10.19.05.11.25; Wed, 19 Oct 2022 05:12:05 -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 S232545AbiJSMKm (ORCPT + 99 others); Wed, 19 Oct 2022 08:10:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233219AbiJSMJf (ORCPT ); Wed, 19 Oct 2022 08:09:35 -0400 Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF74645F6D for ; Wed, 19 Oct 2022 04:45:31 -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 1ol5lf-00B8K8-EO; Wed, 19 Oct 2022 11:56:33 +0200 From: Alexander Atanasov To: Nadav Amit , VMware PV-Drivers Reviewers , Arnd Bergmann , Greg Kroah-Hartman Cc: kernel@openvz.org, Alexander Atanasov , linux-kernel@vger.kernel.org Subject: [RFC PATCH v5 6/8] drivers: vmware: balloon - report inflated memory Date: Wed, 19 Oct 2022 12:56:18 +0300 Message-Id: <20221019095620.124909-7-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?1747113282608983732?= X-GMAIL-MSGID: =?utf-8?q?1747117959767673912?= Update the inflated memory in the mm core on change. Signed-off-by: Alexander Atanasov --- drivers/misc/vmw_balloon.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c index 91d4d2a285c5..3bfd845898f5 100644 --- a/drivers/misc/vmw_balloon.c +++ b/drivers/misc/vmw_balloon.c @@ -1507,6 +1507,7 @@ static void vmballoon_work(struct work_struct *work) queue_delayed_work(system_freezable_wq, dwork, round_jiffies_relative(HZ)); + balloon_set_inflated_free(atomic64_read(&b->size) << 2); } /** 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; From patchwork Wed Oct 19 09:56:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Atanasov X-Patchwork-Id: 5243 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp273295wrs; Wed, 19 Oct 2022 04:41:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5XHMK525RtGY4xbX6BZsw63x8bQa+3n55NT6bX7It43/wRFoVzqAwqmfImXSvON7ZNqsQb X-Received: by 2002:a63:5a1b:0:b0:461:9934:6f62 with SMTP id o27-20020a635a1b000000b0046199346f62mr6854406pgb.266.1666179708942; Wed, 19 Oct 2022 04:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666179708; cv=none; d=google.com; s=arc-20160816; b=ZDjeEwkGYf+y72E0lpizqosJct5M+5Eq+JU5ze4blmjCW1bMYMEormfoYxkfqhPE2U Mr0/Q5UJkDi6epeSNd1mrOIYsQQpXXMJpda//f2chriSVAMElkuhgU6YwLkOtLXgNGMJ NRh1SQvPIg2o1IvpGZiTvAPQwajql0iC9HVuPZKyRvkH++JBNNcQkRAEMWCUqnBjBvdR xR860HkyDjHg8oo1ao/z26FBfk7nedwKV7Zc7DYVO54DNkPTEfr5OPiUPrwA8BYtzydW SrG6oiU7QqnNBOTYBAo1IzBSkoGSjLTOnqUXi7SlZ6FW3DUOo57B+qGP70byQ96Igsoc jEXg== 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=mlUNaGdiAFpWacLP9hLYr4pXPq7YxVe3/nvVJNAsxzY=; b=YgztqcLzHi9Mj7jEMmsagtHYvb/T0hAyCxUJ+z0U4njP2nptj3mUKb/Z/rn+6oM8we JlY+pY8O7VutIqSGoMeavhQHEF46zVcfOT6QNqwgNTFg9dqMlvGA9lI7ZbqrEyL95Sd2 DbTXPQP0KFsATUZKMH+7DcskG4rZh3RTcv0wtb08PL7nGfMctrBOtaWSPnwfIYbcWBUZ nJsQD9YUrDeCDCNabEG2q1O3DXlzJdaShkRIl8rz2O4U3JJ6NrVaPzXlM3D3ONi4ql3Y MuIqtv0j0FIbiEq3LI8ZyRCi/skSsVQDWH5QzHdx9M5iAIcjkieMqx1qGweHt1MW34W2 pwvA== 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 ob18-20020a17090b391200b0020a8db1db79si25055384pjb.155.2022.10.19.04.41.36; Wed, 19 Oct 2022 04:41: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 S230283AbiJSL3n (ORCPT + 99 others); Wed, 19 Oct 2022 07:29:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233269AbiJSL3Y (ORCPT ); Wed, 19 Oct 2022 07:29:24 -0400 Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07BE316C211; Wed, 19 Oct 2022 04:03:32 -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 1ol5li-00B8K8-3z; Wed, 19 Oct 2022 11:56:36 +0200 From: Alexander Atanasov To: Jonathan Corbet Cc: kernel@openvz.org, Alexander Atanasov , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v5 8/8] documentation: create a document about how balloon drivers operate Date: Wed, 19 Oct 2022 12:56:20 +0300 Message-Id: <20221019095620.124909-9-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?1747116054814185386?= X-GMAIL-MSGID: =?utf-8?q?1747116054814185386?= Describe ballooning and how it works. Explain the two values and why they are there. Point the places where a user can see more balloon information and how each driver operates. Signed-off-by: Alexander Atanasov --- Documentation/mm/balloon.rst | 138 +++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 Documentation/mm/balloon.rst diff --git a/Documentation/mm/balloon.rst b/Documentation/mm/balloon.rst new file mode 100644 index 000000000000..9fe9e7b228de --- /dev/null +++ b/Documentation/mm/balloon.rst @@ -0,0 +1,138 @@ +=========================================== +Balloon: usage information visible by guest +=========================================== +Background: +=========== +The ballooning mechanism allows VM guests to reduce their memory size +(thus relinquishing memory to the Host) and to increase it back (thus +taking back memory from the Host). +During OOM guest issues or guest low-performance issues +investigations it is important to know if the Host has grabbed some of the +Guest memory via the ballooning mechanism. + +Implementation description: +=========================== +/proc/meminfo:: + + InflatedTotal: 2097152 kB + InflatedFree: 0 kB + +The difference comes from the way drivers account for inflated memory: + - Drivers that call adjust_managed_page_count InflateTotal + - Drivers that do NOT call adjust_managed_page_count InflateFree + + * It is possible for one driver to operate in both modes depending on config options. + + +The balloon statistics are also printed by show_mem() function, which +is called on OOM condition or Alt+SysRQ+m is pressed. +The show_mem() string is similar to /proc/meminfo and it is like:: + + Balloon InflatedTotal:XXXkB InflatedFree:YYYkB + +Additional balloon information is available via debugfs: + - KVM features file: /sys/devices/pci\*/\*/virtio\*/features + - Hyper-V balloon guest file: /sys/kernel/debug/hv-balloon + - VMware balloon guest file: /sys/kernel/debug/vmmemctl + +KVM balloon +----------- +The ballooning is implemented via virtio balloon device. +Depending on the options the ballooned memory is accounted for in two ways: + +1. If deflate on OOM is enabled - ballooned memory is accounted as used. +2. If deflate on OOM is not enabled - ballooned memory is subtracted + from total RAM. + +Q: How to check if "deflate on OOM" feature is enabled? +A: Check balloon "features" file content. +To decipher balloon bits are defined in include/uapi/linux/virtio_balloon.h +Currently "deflate on OOM" feature is stored in the 2nd bit:: + #define VIRTIO_BALLOON_F_DEFLATE_ON_OOM 2 /* Deflate balloon on OOM */ +Examples:: + + Without deflate on OOM: + # cat /sys/devices/pci0000:00/0000:00:03.0/virtio0/features + 0100000000000000000000000000110010000000000000000000000000000000 + With deflate on OOM: + # cat /sys/devices/pci0000:00/0000:00:03.0/virtio0/features + 0110000000000000000000000000110010000000000000000000000000000000 +How to find virtio balloon device among other virtio devices? +(check if the "virtio_balloon" module is loaded):: + # ls -l /sys/bus/virtio/drivers/virtio_balloon/virtio* + /sys/bus/virtio/drivers/virtio_balloon/virtio3 -> + ../../../../devices/pci0000:00/0000:00:07.0/virtio3 + +To check virtio_balloon features:: + + # cat /sys/bus/virtio/drivers/virtio_balloon/virtio*/features + 0110000000000000000000000000110010000000000000000000000000000000 +Balloon guest statistics output example:: + + # cat /sys/kernel/debug/virtio-balloon + InflatedTotal: 0 kB + InflatedFree: 0 kB + +- If "InflatedTotal" is not zero, it means the "deflate on OOM" feature is + **not** set and the provided amount of memory is subtracted from the total RAM + inside the Guest. +- If "InflatedFree" is not zero, it means "deflate on OOM" feature is set and + the provided amount of memory is accounted as "used" inside the Guest. +- Both "InflatedTotal" and "InflatedFree" cannot be non-zero at the same time. + +Hyper-V balloon +--------------- +Balloon guest statistics output example:: + + # cat /sys/kernel/debug/hv-balloon + host_version : 2.0 // Hyper-V version the Guest is running under + capabilities : enabled hot_add + state : 1 (Initialized) + page_size : 4096 + pages_added : 0 // pages that are hot_add-ed to the Guest + pages_onlined : 0 // pages that are added and then put online + // as available/used + pages_ballooned_out : 0 // pages the Host have taken back + vm_pages_commited : 795365 // total pages used by the Guest userspace + total_pages_commited : 977790 // total pages used by the Guest user+kernel + max_dynamic_page_count: 268435456 // maximum pages the Guest can have added + // via hot_add +Hyper-V balloon driver changes the total RAM size reported by the Guest, +thus the "InflatedTotal" counter will be non-zero in memory statistic +reported during OOM or upon Alt+SysRQ+m. + +VMWare balloon +--------------- +Balloon guest statistics output example:: + + # cat /sys/kernel/debug/vmmemctl + balloon capabilities: 0x1e + used capabilities: 0x6 + is resetting: n + target: 0 pages + current: 0 pages + rateSleepAlloc: 2048 pages/sec + timer: 118 + doorbell: 0 + start: 1 ( 0 failed) + guestType: 1 ( 0 failed) + 2m-lock: 0 ( 0 failed) + lock: 0 ( 0 failed) + 2m-unlock: 0 ( 0 failed) + unlock: 0 ( 0 failed) + target: 118 ( 0 failed) + prim2mAlloc: 0 ( 0 failed) + primNoSleepAlloc: 0 ( 0 failed) + primCanSleepAlloc: 0 ( 0 failed) + prim2mFree: 0 + primFree: 0 + err2mAlloc: 0 + errAlloc: 0 + err2mFree: 0 + errFree: 0 + doorbellSet: 0 + doorbellUnset: 1 + +VMware balloon driver makes ballooned pages accounted as "used" in the +Guest OS thus the "InflatedFree" counter will be non-zero in memory +the statistic reported during OOM or upon Alt+SysRQ+m.