From patchwork Mon Jun 18 09:18:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 10470375 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2EC0E6032A for ; Mon, 18 Jun 2018 09:18:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8602028740 for ; Mon, 18 Jun 2018 09:18:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A8F128849; Mon, 18 Jun 2018 09:18:42 +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 92A1C28740 for ; Mon, 18 Jun 2018 09:18:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 687116B0269; Mon, 18 Jun 2018 05:18:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 413C96B000D; Mon, 18 Jun 2018 05:18:31 -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 1A41B6B026A; Mon, 18 Jun 2018 05:18:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr0-f199.google.com (mail-wr0-f199.google.com [209.85.128.199]) by kanga.kvack.org (Postfix) with ESMTP id 9F3C66B000D for ; Mon, 18 Jun 2018 05:18:30 -0400 (EDT) Received: by mail-wr0-f199.google.com with SMTP id k18-v6so11226452wrn.8 for ; Mon, 18 Jun 2018 02:18:30 -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=chOppOZXUv96JCnmKApANGkVw+faZggXlO+HBddhGOg=; b=MPg8nhqbNEBhO16l/SVdj1wsD75hr7Rh+Dns1kHHQ8+j5rwDpjISIi81fqt0ne304J KoMgb0CgXWDZOb1SuYPspdiDASgDzRF0PS/f8zHTY2HtoXap3Bymrz9ORmtX+oM1KlMN yAe+1RW5qcQudwTfTZSr+r+vejlN50+R7N5FjG3i8sLNjhPloLhmWZABzMUaCNYrH/oX glBV+pCz7qm+PsIG5+X6EcdTLfcsgDokJh0Yl9gAQklpGx3Yw3X4F0b7aMEF2isYde5u dTR7uDsSa10Kfbt8J0p0B0qgdjthWxxASOA4OYL1geINF11/vDxLw1H+oONraQH2SRn6 c0Pw== 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: APt69E0OjDX/2a2B11ex6pDXapA+p0uptqkQre/haYw8wuWVEK6Tfqtv xHCNyvOdfZnTcBgN4FuSfzQvEapnCkY1jrANiLbCbEmfnn0V1VGBbEd3HyJu+4H9jCcDW4CWMSc O+ZaKUg4omKqUqcJRPE4hDcCoUBtXZxsWK8HUmcPiz7b4+lyA9qB+2YSlm91x7oyycQ== X-Received: by 2002:a50:a8a2:: with SMTP id k31-v6mr10262885edc.161.1529313510189; Mon, 18 Jun 2018 02:18:30 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK9qkXIdPi79JxGXk1DhMIbHp1fdO/y5UXSbtAEB/OdCdBw39VaRGdhwzUPWLM4mObLbfpx X-Received: by 2002:a50:a8a2:: with SMTP id k31-v6mr10262828edc.161.1529313508760; Mon, 18 Jun 2018 02:18:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529313508; cv=none; d=google.com; s=arc-20160816; b=jhpBYB6KHi9XVHOZiDSC26FIkFj780cA9cKf1JeUSBf/pywxMA3QQB1doA8Jig+RJ/ M5ktY3k/ptgtkbXNZPHHfCf+seXw+bqncnYXNnLlVWBwKjyxPrKFJCPAshaqsTahwcBd jgIWJhYM4HmZBUOmtj6OpHwrJ3bl4Gec7hWiDLro2IQczD2clENV3VLhNWspIG3q5il1 1Sbu3OTqNoAi0RyzYFlRZjVzkVKk9Zw1VRTutPcWwv7CKRs81oY5SuyrNNftb9lJALzv RWzwynfaFhH4tgP26aa/pji/fg6hN3ljU1rw4h/6V/iBaU1SfEVD/7QviG+HDKWBF2Xx ZTMw== 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=chOppOZXUv96JCnmKApANGkVw+faZggXlO+HBddhGOg=; b=vr5Vn2xzQ+NvgYlGJFpENqVwRWPaOT3KRj1p06xEadrYozjuvs7PwFLtEngSAtQ92g gv4ptW/mku52P72Qqmw1u9r1zJ4SquGZNympZnCcK5JQuQ/wkflvtGSA0EVIwiUYkRXJ 6/zuMoU4LBdSyWT7nDJD1GXG8lBuwyQTr9gN41Saeg4OJ//SmsNXxjsnhmcXjm8n9OkY jC8LNLf9za5useAtAmAUKAVuDBE9BkpWveMALO0ayzwNqPjDUgjGqRRMUI+Dq4WhNaVO 7lrt1MGwEzR3WPqYTrDh+hBiucDWNOdFrnEEVAH5jRrl7g+XPTdX5741URSWp9TJCQ6c om+w== 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 mx2.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id l25-v6si10109114edd.239.2018.06.18.02.18.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 18 Jun 2018 02:18:28 -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 relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D9B0CAD4A; Mon, 18 Jun 2018 09:18:27 +0000 (UTC) From: Vlastimil Babka To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Roman Gushchin , Michal Hocko , Johannes Weiner , linux-api@vger.kernel.org, Christoph Lameter , David Rientjes , Mel Gorman , Matthew Wilcox , Vlastimil Babka Subject: [PATCH v2 6/7] mm, proc: add KReclaimable to /proc/meminfo Date: Mon, 18 Jun 2018 11:18:07 +0200 Message-Id: <20180618091808.4419-7-vbabka@suse.cz> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618091808.4419-1-vbabka@suse.cz> References: <20180618091808.4419-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 Signed-off-by: Vlastimil Babka --- 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: ",