From patchwork Tue Jul 31 09:06:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 10550491 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8692613BF for ; Tue, 31 Jul 2018 09:07:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73C4229FB4 for ; Tue, 31 Jul 2018 09:07:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67E222A206; Tue, 31 Jul 2018 09:07:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2BD529FB4 for ; Tue, 31 Jul 2018 09:07:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED2576B0010; Tue, 31 Jul 2018 05:07:03 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EA8846B000C; Tue, 31 Jul 2018 05:07:03 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3A4C6B0010; Tue, 31 Jul 2018 05:07:03 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 470436B0266 for ; Tue, 31 Jul 2018 05:07:03 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id u13-v6so2916985pfm.8 for ; Tue, 31 Jul 2018 02:07:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=mW6+9YTAWwathwufRY0fsrPlMQhXnCW1ekmWuTUyq7w=; b=fIkdImGbwnKI/1CJABK2bmHJfJjnxcLFVMBhpkifrbvRVdngEgxCyOLzQLjsVIkM1W hJ0zQr0UJ9+8QotcA7QLzxK2kSILFKpQMrkm0nW5sMcL7fwoNQkHX/QNi0ruXuiP4iZs GR4vovfBNEINsnZZFGU1J+F8YnH4yshdywKs0chehZNm1tzTu+16Xrf6HbllpblI4y+J qgmIhhkE/dzk0yao+UsJvN+oCQE8XkuWRhNadZPhf9QQKAUyl/mi+37A+CBd3qS/1LkT mtNiTKS4XrnScIY396XFXGSHLBUk6FEeiw3Fa+OGVRGLJmDK7E7unnoC7vHgQJ6+tC+2 Ag9A== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of vbabka@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Gm-Message-State: AOUpUlE4ko04NX/i2QbXULVdx6WWzHOgI61AH7CbKZutPN1i5re7W5m5 s06O5FWo7ugZP6KD0RW4QV2WbdK//9+oR88UfT3qoPpdqh+jGU9F08Hmjb6Gt7vDjgclDSEYybr 2mK6465X5uXHJdRiYfSdBbZe6u5eBlZSC+GFkVrWAqlN6R8Nzu16oCiuy6O5p9x8yyQ== X-Received: by 2002:a17:902:9348:: with SMTP id g8-v6mr19575317plp.302.1533028022848; Tue, 31 Jul 2018 02:07:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpch1JnJxhMVhhTp28lR86tFWH2L1JfX+AyQOJnpYWrL4kRwWub+gMIfny1nmMcwR4QCh4Pl X-Received: by 2002:a17:902:9348:: with SMTP id g8-v6mr19575262plp.302.1533028021779; Tue, 31 Jul 2018 02:07:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533028021; cv=none; d=google.com; s=arc-20160816; b=Z1EPILSAqn0aFV32dyxqD9j32uRsPCAUomE2fgQgjw7FgkcYPtwsm91BlafEs2pC7/ x2SRCYrvpslpqds8RE1mv0xi0t74i0Dvs4b5JX8V5575HJCZz3XCNb5TvVenobuHADe1 l+m5pDqhTUEvCmkVEDQXZYdmIM15GPXmcgD0WBtDKB52gn8RQeuIeuiaGg8KNt1e63ba HztuwGMfe9GKvhdUgPx6FPsIhYBuyBnFJk1ETOztZA+bbtZyE8aSfDoqCaCgZXdEonYm WuajMK0qZs1aDM0mLHIqZwqBFdvxnYOtR/JUuFoJS/5jkvxzRp2HTc9heJd0+G+J8GRw M0sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=mW6+9YTAWwathwufRY0fsrPlMQhXnCW1ekmWuTUyq7w=; b=FdAY4z4/MVrZtQK4ToOuo8B2nV9W4vQLkciZAa6g1dWcufys8Al1pxEIC5zkt7Jg7g GfKiCSNIxDWdiyRCvj7ZIEuMQbb1YQNzPgwIHB6dEVynlNchQ+Qcb/md1DPHKf980AM0 uwLpfInF+LVVw9r4AbjbeCxFyZIW9CWUqQrMbGuXGQ9uPHOjZqIgDIVn0CwS5WrevKwN ri+Z4qTUPPwuXgZ+Sf7UTLu4+po+80ZZUyAsuxoSzqLWczwXAJ9ow8a8SCw6+dShLT22 xEytV+MAJeMHkyP7JEUuDiIchNwg1E25ZW3zEjznsnXYz4Cv+3U03UH1t4Lu7RcRVS1B mupQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of vbabka@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=vbabka@suse.cz Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id y92-v6si8601870plb.378.2018.07.31.02.07.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Jul 2018 02:07:01 -0700 (PDT) Received-SPF: pass (google.com: domain of vbabka@suse.cz designates 195.135.220.15 as permitted sender) client-ip=195.135.220.15; Authentication-Results: mx.google.com; spf=pass (google.com: domain of vbabka@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 957A4AEC0; Tue, 31 Jul 2018 09:06:58 +0000 (UTC) From: Vlastimil Babka To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Roman Gushchin , Michal Hocko , Johannes Weiner , Christoph Lameter , David Rientjes , Joonsoo Kim , Mel Gorman , Matthew Wilcox , Vlastimil Babka Subject: [PATCH v4 5/6] mm, proc: add KReclaimable to /proc/meminfo Date: Tue, 31 Jul 2018 11:06:48 +0200 Message-Id: <20180731090649.16028-6-vbabka@suse.cz> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180731090649.16028-1-vbabka@suse.cz> References: <20180731090649.16028-1-vbabka@suse.cz> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The vmstat NR_KERNEL_MISC_RECLAIMABLE counter is for kernel non-slab allocations that can be reclaimed via shrinker. In /proc/meminfo, we can show the sum of all reclaimable kernel allocations (including slab) as "KReclaimable". Add the same counter also to per-node meminfo under /sys With this counter, users will have more complete information about kernel memory usage. Non-slab reclaimable pages (currently just the ION allocator) will not be missing from /proc/meminfo, making users wonder where part of their memory went. More precisely, they already appear in MemAvailable, but without the new counter, it's not obvious why the value in MemAvailable doesn't fully correspond with the sum of other counters participating in it. Signed-off-by: Vlastimil Babka Acked-by: Roman Gushchin --- Documentation/filesystems/proc.txt | 4 ++++ drivers/base/node.c | 19 ++++++++++++------- fs/proc/meminfo.c | 16 ++++++++-------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt index 520f6a84cf50..6a255f960ab5 100644 --- a/Documentation/filesystems/proc.txt +++ b/Documentation/filesystems/proc.txt @@ -858,6 +858,7 @@ Writeback: 0 kB AnonPages: 861800 kB Mapped: 280372 kB Shmem: 644 kB +KReclaimable: 168048 kB Slab: 284364 kB SReclaimable: 159856 kB SUnreclaim: 124508 kB @@ -921,6 +922,9 @@ AnonHugePages: Non-file backed huge pages mapped into userspace page tables ShmemHugePages: Memory used by shared memory (shmem) and tmpfs allocated with huge pages ShmemPmdMapped: Shared memory mapped into userspace with huge pages +KReclaimable: Kernel allocations that the kernel will attempt to reclaim + under memory pressure. Includes SReclaimable (below), and other + direct allocations with a shrinker. Slab: in-kernel data structures cache SReclaimable: Part of Slab, that might be reclaimed, such as caches SUnreclaim: Part of Slab, that cannot be reclaimed on memory pressure diff --git a/drivers/base/node.c b/drivers/base/node.c index a5e821d09656..81cef8031eae 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -67,8 +67,11 @@ static ssize_t node_read_meminfo(struct device *dev, int nid = dev->id; struct pglist_data *pgdat = NODE_DATA(nid); struct sysinfo i; + unsigned long sreclaimable, sunreclaimable; si_meminfo_node(&i, nid); + sreclaimable = node_page_state(pgdat, NR_SLAB_RECLAIMABLE); + sunreclaimable = node_page_state(pgdat, NR_SLAB_UNRECLAIMABLE); n = sprintf(buf, "Node %d MemTotal: %8lu kB\n" "Node %d MemFree: %8lu kB\n" @@ -118,6 +121,7 @@ static ssize_t node_read_meminfo(struct device *dev, "Node %d NFS_Unstable: %8lu kB\n" "Node %d Bounce: %8lu kB\n" "Node %d WritebackTmp: %8lu kB\n" + "Node %d KReclaimable: %8lu kB\n" "Node %d Slab: %8lu kB\n" "Node %d SReclaimable: %8lu kB\n" "Node %d SUnreclaim: %8lu kB\n" @@ -138,20 +142,21 @@ static ssize_t node_read_meminfo(struct device *dev, nid, K(node_page_state(pgdat, NR_UNSTABLE_NFS)), nid, K(sum_zone_node_page_state(nid, NR_BOUNCE)), nid, K(node_page_state(pgdat, NR_WRITEBACK_TEMP)), - nid, K(node_page_state(pgdat, NR_SLAB_RECLAIMABLE) + - node_page_state(pgdat, NR_SLAB_UNRECLAIMABLE)), - nid, K(node_page_state(pgdat, NR_SLAB_RECLAIMABLE)), + nid, K(sreclaimable + + node_page_state(pgdat, NR_KERNEL_MISC_RECLAIMABLE)), + nid, K(sreclaimable + sunreclaimable), + nid, K(sreclaimable), + nid, K(sunreclaimable) #ifdef CONFIG_TRANSPARENT_HUGEPAGE - nid, K(node_page_state(pgdat, NR_SLAB_UNRECLAIMABLE)), + , nid, K(node_page_state(pgdat, NR_ANON_THPS) * HPAGE_PMD_NR), nid, K(node_page_state(pgdat, NR_SHMEM_THPS) * HPAGE_PMD_NR), nid, K(node_page_state(pgdat, NR_SHMEM_PMDMAPPED) * - HPAGE_PMD_NR)); -#else - nid, K(node_page_state(pgdat, NR_SLAB_UNRECLAIMABLE))); + HPAGE_PMD_NR) #endif + ); n += hugetlb_report_node_meminfo(nid, buf + n); return n; } diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c index 2fb04846ed11..61a18477bc07 100644 --- a/fs/proc/meminfo.c +++ b/fs/proc/meminfo.c @@ -37,6 +37,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v) long cached; long available; unsigned long pages[NR_LRU_LISTS]; + unsigned long sreclaimable, sunreclaim; int lru; si_meminfo(&i); @@ -52,6 +53,8 @@ static int meminfo_proc_show(struct seq_file *m, void *v) pages[lru] = global_node_page_state(NR_LRU_BASE + lru); available = si_mem_available(); + sreclaimable = global_node_page_state(NR_SLAB_RECLAIMABLE); + sunreclaim = global_node_page_state(NR_SLAB_UNRECLAIMABLE); show_val_kb(m, "MemTotal: ", i.totalram); show_val_kb(m, "MemFree: ", i.freeram); @@ -93,14 +96,11 @@ static int meminfo_proc_show(struct seq_file *m, void *v) show_val_kb(m, "Mapped: ", global_node_page_state(NR_FILE_MAPPED)); show_val_kb(m, "Shmem: ", i.sharedram); - show_val_kb(m, "Slab: ", - global_node_page_state(NR_SLAB_RECLAIMABLE) + - global_node_page_state(NR_SLAB_UNRECLAIMABLE)); - - show_val_kb(m, "SReclaimable: ", - global_node_page_state(NR_SLAB_RECLAIMABLE)); - show_val_kb(m, "SUnreclaim: ", - global_node_page_state(NR_SLAB_UNRECLAIMABLE)); + show_val_kb(m, "KReclaimable: ", sreclaimable + + global_node_page_state(NR_KERNEL_MISC_RECLAIMABLE)); + show_val_kb(m, "Slab: ", sreclaimable + sunreclaim); + show_val_kb(m, "SReclaimable: ", sreclaimable); + show_val_kb(m, "SUnreclaim: ", sunreclaim); seq_printf(m, "KernelStack: %8lu kB\n", global_zone_page_state(NR_KERNEL_STACK_KB)); show_val_kb(m, "PageTables: ",