From patchwork Mon Mar 23 08:05:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 11452447 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AFA7F17D4 for ; Mon, 23 Mar 2020 08:05:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 61BF320789 for ; Mon, 23 Mar 2020 08:05:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="OZoLDFOb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 61BF320789 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 52E506B0008; Mon, 23 Mar 2020 04:05:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3EF9B6B000A; Mon, 23 Mar 2020 04:05:18 -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 2B94E6B000C; Mon, 23 Mar 2020 04:05:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0131.hostedemail.com [216.40.44.131]) by kanga.kvack.org (Postfix) with ESMTP id 05A7E6B0008 for ; Mon, 23 Mar 2020 04:05:18 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id CCD39181AC9B6 for ; Mon, 23 Mar 2020 08:05:17 +0000 (UTC) X-FDA: 76625891874.17.quill49_683f7bea5d941 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,jaewon31.kim@samsung.com,,RULES_HIT:30029:30054:30070:30075,0,RBL:203.254.224.34:@samsung.com:.lbl8.mailshell.net-62.18.1.2 64.10.201.10,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: quill49_683f7bea5d941 X-Filterd-Recvd-Size: 11147 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Mon, 23 Mar 2020 08:05:16 +0000 (UTC) Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20200323080511epoutp04edf558e13202110bd974680134b6c9cb~_4EZnC_vM1426914269epoutp04q for ; Mon, 23 Mar 2020 08:05:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20200323080511epoutp04edf558e13202110bd974680134b6c9cb~_4EZnC_vM1426914269epoutp04q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1584950711; bh=TRbGcx9ZV+IqrIG8JwLR8QmselJK4B5I11L2jHQXF2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OZoLDFObUL+8iKuF0f2Jp0KWDPMp7OSILQblDvr9QiOcp0kjk2d7w1c4Fj7pcfzYV 6NhStdhtLs4IP0cAau9bH4MuRRXSZy691sjcOrFPL/6vLjVE1CEr50b/10DdM1M/GP IUF2L33PFGUOAASj+PCm5jMpJgRQLrON0PJBzWRk= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20200323080511epcas1p2d7cdcc4edcce296e22135a322e7c704b~_4EZI67xg2102421024epcas1p2l; Mon, 23 Mar 2020 08:05:11 +0000 (GMT) Received: from epsmges1p5.samsung.com (unknown [182.195.40.164]) by epsnrtp4.localdomain (Postfix) with ESMTP id 48m6PL2KbPzMqYkd; Mon, 23 Mar 2020 08:05:10 +0000 (GMT) Received: from epcas1p1.samsung.com ( [182.195.41.45]) by epsmges1p5.samsung.com (Symantec Messaging Gateway) with SMTP id 95.2A.04074.4BD687E5; Mon, 23 Mar 2020 17:05:08 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p3.samsung.com (KnoxPortal) with ESMTPA id 20200323080508epcas1p387c9c19b480da53be40fe5d51e76a477~_4EWBfKY43019030190epcas1p3C; Mon, 23 Mar 2020 08:05:08 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200323080507epsmtrp18e52c71f3a54794974a1c99e59279abe~_4EWAYGbR0063700637epsmtrp1e; Mon, 23 Mar 2020 08:05:07 +0000 (GMT) X-AuditID: b6c32a39-58bff70000000fea-59-5e786db4b413 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 67.15.04158.3BD687E5; Mon, 23 Mar 2020 17:05:07 +0900 (KST) Received: from jaewon-linux.10.32.193.11 (unknown [10.253.104.82]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200323080507epsmtip15ad9b6907ccc4b094399b05cc333e9db~_4EVz4Cu80126401264epsmtip1M; Mon, 23 Mar 2020 08:05:07 +0000 (GMT) From: Jaewon Kim To: gregkh@linuxfoundation.org, leon@kernel.org, vbabka@suse.cz, adobriyan@gmail.com, akpm@linux-foundation.org, labbott@redhat.com, sumit.semwal@linaro.org, minchan@kernel.org, ngupta@vflare.org, sergey.senozhatsky.work@gmail.com, kasong@redhat.com, bhe@redhat.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com, linux-api@vger.kernel.org, kexec@lists.infradead.org, Jaewon Kim Subject: [RFC PATCH v2 1/3] meminfo_extra: introduce meminfo extra Date: Mon, 23 Mar 2020 17:05:01 +0900 Message-Id: <20200323080503.6224-2-jaewon31.kim@samsung.com> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20200323080503.6224-1-jaewon31.kim@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA02Tf0xTVxTHd9/re6+Y1rxU507QIL5EJi5ASy1eN7roZpY3xjIWEk32B+wF bihZf7z0FaUkGyCEKAhUonEiGATFDXGQtnEgCEuBsc3FLhB/xhK3bCZzExIM4srUtX0a99/3 nPP55px77r1a2jDBJmvLnR7idkp2gV2luTiRnpERdFQWGX2P0/Dx2jzcMdDP4vDdKIvregZY 3BQ4gXDzwn0Kn5u/gvDIlSUKfz36mMJHo2dpHFg+yOLZSx0snut/xuDepQUOD9a3c/g3XxuF f4o85PDJ2ha00yAOt0c40d93iBX9i22ceOf6KCv+8OWKRhzv7OfEwJlqcWHsGiu2BPuQ+HPX JCcOLwYY8aE/pUD3iT3XRqRS4k4lzhJXabmzzCp8UFj8brElx2jKMO3A24VUp+QgVmF3fkHG e+X22PGE1H2SvSKWKpAURch6O9ftqvCQVJtL8VgFIpfaZZNRzlQkh1LhLMsscTneNBmN2ZYY +and9uBUA5LbtlROjebVoJ5NjShJC/w2aDn0O9uIVmkN/BCCu7VTlBosIhj86lukBo8QnJs5 wr6wHPc/ouPawF9GEJrVqNAygtsBHxcvsPwbsNDVxsQLa/lWCroj3QmK5i8g6GuMUHFqDf8O HJ3uSWgNvxlunfehuNbzuTAyORczaGPtNsLpZ4luSbwVxmZuJ4YFvpeDiSc+Wh1pNxxonqZU vQbuTwc5VSfDn60NnGqoQ/DgRACpQT2CiL8ZqZQZmg//Qse70Xw6DFzKUtObYHilM4HQ/GqY XzrMqAPp4WCDQUXSoP7eEqPqDfDk6b3niAjhp2nqVnwIVmbnOR9KaX/ZoAuhPrSOyIqjjCgm 2fL/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pTsbT3yzO2he+jl84IXTRrFXzPvxwjbjEeCVsgbfw2/0TFd8XuJw2 ncjENH2VdF3fR/ELdivEdu7Z8CMsnkHjSPTPIq0XMxbob3nk2/KIS1qJpTgj0VCLuag4EQC6 tjChjQIAAA== X-CMS-MailID: 20200323080508epcas1p387c9c19b480da53be40fe5d51e76a477 X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200323080508epcas1p387c9c19b480da53be40fe5d51e76a477 References: <20200323080503.6224-1-jaewon31.kim@samsung.com> 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: Provide APIs to drivers so that they can show its memory usage on /proc/meminfo_extra. int register_meminfo_extra(atomic_long_t *val, int shift, const char *name); int unregister_meminfo_extra(atomic_long_t *val); Signed-off-by: Jaewon Kim --- v2: move to /proc/meminfo_extra as a new file, meminfo_extra.c use rcu to reduce lock overhead v1: print info at /proc/meminfo --- fs/proc/Makefile | 1 + fs/proc/meminfo_extra.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mm.h | 4 ++ mm/page_alloc.c | 1 + 4 files changed, 129 insertions(+) create mode 100644 fs/proc/meminfo_extra.c diff --git a/fs/proc/Makefile b/fs/proc/Makefile index bd08616ed8ba..83d2f55591c6 100644 --- a/fs/proc/Makefile +++ b/fs/proc/Makefile @@ -19,6 +19,7 @@ proc-y += devices.o proc-y += interrupts.o proc-y += loadavg.o proc-y += meminfo.o +proc-y += meminfo_extra.o proc-y += stat.o proc-y += uptime.o proc-y += util.o diff --git a/fs/proc/meminfo_extra.c b/fs/proc/meminfo_extra.c new file mode 100644 index 000000000000..bd3f0d2b7fb7 --- /dev/null +++ b/fs/proc/meminfo_extra.c @@ -0,0 +1,123 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include + +static void show_val_kb(struct seq_file *m, const char *s, unsigned long num) +{ + seq_put_decimal_ull_width(m, s, num << (PAGE_SHIFT - 10), 8); + seq_write(m, " kB\n", 4); +} + +static LIST_HEAD(meminfo_head); +static DEFINE_SPINLOCK(meminfo_lock); + +#define NAME_SIZE 15 +#define NAME_BUF_SIZE (NAME_SIZE + 2) /* ':' and '\0' */ + +struct meminfo_extra { + struct list_head list; + atomic_long_t *val; + int shift_for_page; + char name[NAME_BUF_SIZE]; + char name_pad[NAME_BUF_SIZE]; +}; + +int register_meminfo_extra(atomic_long_t *val, int shift, const char *name) +{ + struct meminfo_extra *meminfo, *memtemp; + int len; + int error = 0; + + meminfo = kzalloc(sizeof(*meminfo), GFP_KERNEL); + if (!meminfo) { + error = -ENOMEM; + goto out; + } + + meminfo->val = val; + meminfo->shift_for_page = shift; + strncpy(meminfo->name, name, NAME_SIZE); + len = strlen(meminfo->name); + meminfo->name[len] = ':'; + strncpy(meminfo->name_pad, meminfo->name, NAME_BUF_SIZE); + while (++len < NAME_BUF_SIZE - 1) + meminfo->name_pad[len] = ' '; + + spin_lock(&meminfo_lock); + list_for_each_entry_rcu(memtemp, &meminfo_head, list) { + if (memtemp->val == val) { + error = -EINVAL; + break; + } + } + if (!error) + list_add_tail_rcu(&meminfo->list, &meminfo_head); + spin_unlock(&meminfo_lock); + if (error) + kfree(meminfo); +out: + + return error; +} +EXPORT_SYMBOL(register_meminfo_extra); + +int unregister_meminfo_extra(atomic_long_t *val) +{ + struct meminfo_extra *memtemp; + int error = -EINVAL; + + spin_lock(&meminfo_lock); + list_for_each_entry_rcu(memtemp, &meminfo_head, list) { + if (memtemp->val == val) { + list_del_rcu(&memtemp->list); + error = 0; + break; + } + } + spin_unlock(&meminfo_lock); + if (!error) { + synchronize_rcu(); + kfree(memtemp); + } + + return error; +} +EXPORT_SYMBOL(unregister_meminfo_extra); + +static void __meminfo_extra(struct seq_file *m) +{ + struct meminfo_extra *memtemp; + unsigned long nr_page; + + rcu_read_lock(); + list_for_each_entry_rcu(memtemp, &meminfo_head, list) { + nr_page = (unsigned long)atomic_long_read(memtemp->val); + nr_page = nr_page >> memtemp->shift_for_page; + if (m) + show_val_kb(m, memtemp->name_pad, nr_page); + else + pr_cont("%s%lukB ", memtemp->name, nr_page); + } + rcu_read_unlock(); +} + +void show_meminfo_extra(void) +{ + __meminfo_extra(NULL); +} + +static int meminfo_extra_proc_show(struct seq_file *m, void *v) +{ + __meminfo_extra(m); + + return 0; +} + +static int __init proc_meminfo_extra_init(void) +{ + proc_create_single("meminfo_extra", 0, NULL, meminfo_extra_proc_show); + return 0; +} +fs_initcall(proc_meminfo_extra_init); diff --git a/include/linux/mm.h b/include/linux/mm.h index 52269e56c514..55317161ab57 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2898,6 +2898,10 @@ void __init setup_nr_node_ids(void); static inline void setup_nr_node_ids(void) {} #endif +void show_meminfo_extra(void); +int register_meminfo_extra(atomic_long_t *val, int shift, const char *name); +int unregister_meminfo_extra(atomic_long_t *val); + extern int memcmp_pages(struct page *page1, struct page *page2); static inline int pages_identical(struct page *page1, struct page *page2) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 3c4eb750a199..db1be9a39783 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5229,6 +5229,7 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask) struct zone *zone; pg_data_t *pgdat; + show_meminfo_extra(); for_each_populated_zone(zone) { if (show_mem_node_skip(filter, zone_to_nid(zone), nodemask)) continue; From patchwork Mon Mar 23 08:05:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 11452445 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E704915AB for ; Mon, 23 Mar 2020 08:05:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A9AFA20732 for ; Mon, 23 Mar 2020 08:05:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="c/Cq70Xu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A9AFA20732 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8F8FF6B0006; Mon, 23 Mar 2020 04:05:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8AA836B000A; Mon, 23 Mar 2020 04:05:16 -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 7574A6B0006; Mon, 23 Mar 2020 04:05:16 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0130.hostedemail.com [216.40.44.130]) by kanga.kvack.org (Postfix) with ESMTP id 579176B0006 for ; Mon, 23 Mar 2020 04:05:16 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 2B582180AD811 for ; Mon, 23 Mar 2020 08:05:16 +0000 (UTC) X-FDA: 76625891832.14.oil76_681915df24b1e X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,jaewon31.kim@samsung.com,,RULES_HIT:30054,0,RBL:203.254.224.34:@samsung.com:.lbl8.mailshell.net-64.10.201.10 62.18.1.2,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:1:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: oil76_681915df24b1e X-Filterd-Recvd-Size: 7320 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Mon, 23 Mar 2020 08:05:15 +0000 (UTC) Received: from epcas1p2.samsung.com (unknown [182.195.41.46]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20200323080511epoutp048051fb9550e22642b3a481cad1178c60~_4EZi9SW41413214132epoutp04- for ; Mon, 23 Mar 2020 08:05:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20200323080511epoutp048051fb9550e22642b3a481cad1178c60~_4EZi9SW41413214132epoutp04- DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1584950711; bh=dSYUW03bHzrs9o67DnwnF349vBuzWA6AMzTlkUXfLWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c/Cq70XueTavKVS2yaajtyGQISate4WyZ7oZSqtZQFwf4a6DvwjItBfnkm0OR2LVw 2VX/3auCyY7O2C7mw8yH5jkZ7Hswc50BfXw6jn/HRihKV0o0yrU0hAWDq5zfoShaHe krQpzu0Er2Cio6ru0MQmbAPIkhGgH0m+j9xLR008= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20200323080511epcas1p1e045fa882c46a59520affd8470248956~_4EZAIXBi2159621596epcas1p1G; Mon, 23 Mar 2020 08:05:11 +0000 (GMT) Received: from epsmges1p1.samsung.com (unknown [182.195.40.163]) by epsnrtp2.localdomain (Postfix) with ESMTP id 48m6PJ58TyzMqYkg; Mon, 23 Mar 2020 08:05:08 +0000 (GMT) Received: from epcas1p1.samsung.com ( [182.195.41.45]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id E1.70.04145.4BD687E5; Mon, 23 Mar 2020 17:05:08 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200323080508epcas1p2dfe6517169a65936e5ab10c4e63a19a7~_4EWKChal2331623316epcas1p28; Mon, 23 Mar 2020 08:05:08 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200323080508epsmtrp1e95a6cc4a2e1e35601c95ad2b01b48c9~_4EWIopZ50063700637epsmtrp1f; Mon, 23 Mar 2020 08:05:08 +0000 (GMT) X-AuditID: b6c32a35-2a5ff70000001031-37-5e786db4bb01 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id C7.73.04024.4BD687E5; Mon, 23 Mar 2020 17:05:08 +0900 (KST) Received: from jaewon-linux.10.32.193.11 (unknown [10.253.104.82]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200323080507epsmtip1af2b09b7d835e20c46018369fa326f2f~_4EV5mw5Z3157831578epsmtip1N; Mon, 23 Mar 2020 08:05:07 +0000 (GMT) From: Jaewon Kim To: gregkh@linuxfoundation.org, leon@kernel.org, vbabka@suse.cz, adobriyan@gmail.com, akpm@linux-foundation.org, labbott@redhat.com, sumit.semwal@linaro.org, minchan@kernel.org, ngupta@vflare.org, sergey.senozhatsky.work@gmail.com, kasong@redhat.com, bhe@redhat.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com, linux-api@vger.kernel.org, kexec@lists.infradead.org, Jaewon Kim Subject: [RFC PATCH v2 2/3] mm: zsmalloc: include zs page size in meminfo extra Date: Mon, 23 Mar 2020 17:05:02 +0900 Message-Id: <20200323080503.6224-3-jaewon31.kim@samsung.com> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20200323080503.6224-1-jaewon31.kim@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA01TbUxTVxjOube994J23FzdPEHC2E1mgkuhtbScTViWaLabQRRjJHFZ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ZnpnZ d3fHpq5u9W9j0ezpG/Tq8kItc5ZXyRZRv5Z0yuK/EJa4iNcDAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRmVeSWpSXmKPExsWy7bCSnO6W3Io4g5f3mC2mN3pZzFm/hs3i /INfbBbNi9ezWXRvnslo0fv+FZPF8nenGS12n/7KZLFyzw8miym/ljJbbP7ewWZxedccNot7 a/6zWiz7+p7dYkPLLHaLRxMmMVmcuvuZ3WJ2Yx+jg5DHzll32T02repk89j0aRK7x51re9g8 Tsz4zeKxf+4ado/NS+o93u+7yubRt2UVo8eZBUfYPXZ+2szq8XmTXABPFJdNSmpOZllqkb5d AldG260X7AUTuCo+vDzC0sA4i6OLkZNDQsBE4uPdOaxdjFwcQgK7GSWebX3NBpGQkXhz/ilL FyMHkC0scfhwMUhYSOAro8Tcy/EgNpuAtsT7BZNYQWwRgflMEv3t/CBzmAU2M0pMXNrMApIQ FvCXmDJpITOIzSKgKjGheztYnFfARmLlyjtQ8+UlFv4HK+EUsJXYd+kWG8QuG4mt3c+YJzDy LWBkWMUomVpQnJueW2xYYJiXWq5XnJhbXJqXrpecn7uJERwjWpo7GC8viT/EKMDBqMTDe6O3 PE6INbGsuDL3EKMEB7OSCO/m1Io4Id6UxMqq1KL8+KLSnNTiQ4zSHCxK4rxP845FCgmkJ5ak ZqemFqQWwWSZODilGhgdq2s3egb8jnmwbmcVnwPrn7bpync2HNa5MafyhfgS6edT4ltYw5nm zBU/Yb5BoDM7bEOEDW9Jz3f/Le90Nk2pOv774ZETNY5uDx62PYg9qRaYsfd19sGqubEuNxW1 nBp7zT2bEjTnK2jOZWzY9tp2upARu4BGpjXD8hWmHksYlxU3We7U7VRiKc5INNRiLipOBACx /fqvjQIAAA== X-CMS-MailID: 20200323080508epcas1p2dfe6517169a65936e5ab10c4e63a19a7 X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200323080508epcas1p2dfe6517169a65936e5ab10c4e63a19a7 References: <20200323080503.6224-1-jaewon31.kim@samsung.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000033, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On most of recent Android device use DRAM memory based compressed swap to save free memory. And the swap device size is also big enough. The zsmalloc page size is alread shown on vmstat by commit 91537fee0013 ("mm: add NR_ZSMALLOC to vmstat"). If the size is also shown in /proc/meminfo_extra, it will be better to see system wide memory usage at a glance. To include heap size, use register_meminfo_extra introduced in previous patch. i.e) cat /proc/meminfo_extra | grep ZsPages IonSystemHeap: 242620 kB ZsPages: 203860 kB i.e.) show_mem on oom <6>[ 420.856428] Mem-Info: <6>[ 420.856433] ZsPages:44114kB Signed-off-by: Jaewon Kim --- mm/zsmalloc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 22d17ecfe7df..9d5682aa44ac 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -2566,6 +2566,7 @@ static int __init zs_init(void) zs_stat_init(); + register_meminfo_extra(&vm_zone_stat[NR_ZSPAGES], 0, "ZsPages"); return 0; hp_setup_fail: @@ -2583,6 +2584,7 @@ static void __exit zs_exit(void) cpuhp_remove_state(CPUHP_MM_ZS_PREPARE); zs_stat_exit(); + unregister_meminfo_extra(&vm_zone_stat[NR_ZSPAGES]); } module_init(zs_init); From patchwork Mon Mar 23 08:05:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 11452443 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9CE471667 for ; Mon, 23 Mar 2020 08:05:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 530EE20784 for ; Mon, 23 Mar 2020 08:05:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="UcEXFM2W" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 530EE20784 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 835486B0005; Mon, 23 Mar 2020 04:05:15 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7E68B6B0006; Mon, 23 Mar 2020 04:05:15 -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 6ADF06B0007; Mon, 23 Mar 2020 04:05:15 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0008.hostedemail.com [216.40.44.8]) by kanga.kvack.org (Postfix) with ESMTP id 53C176B0005 for ; Mon, 23 Mar 2020 04:05:15 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 0E5A6181AC9B6 for ; Mon, 23 Mar 2020 08:05:15 +0000 (UTC) X-FDA: 76625891790.02.food36_67d9ea0161307 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,jaewon31.kim@samsung.com,,RULES_HIT:30051:30054,0,RBL:203.254.224.25:@samsung.com:.lbl8.mailshell.net-62.18.1.2 64.10.201.10,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:233,LUA_SUMMARY:none X-HE-Tag: food36_67d9ea0161307 X-Filterd-Recvd-Size: 8792 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Mon, 23 Mar 2020 08:05:13 +0000 (UTC) Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20200323080510epoutp0270c8ca9fde3b94b1e162c0b75645b1ff~_4EYMa7gx3028230282epoutp02t for ; Mon, 23 Mar 2020 08:05:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20200323080510epoutp0270c8ca9fde3b94b1e162c0b75645b1ff~_4EYMa7gx3028230282epoutp02t DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1584950710; bh=P4CavwZXkNCT7Ikw0Fe20I2u/uDn4BTxVIDGmLZRxuw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UcEXFM2WTcTtblyK758mlzUNgO3piXC6/70tFii6H5/ufSCHx6oWpXlZLJlgbZoNG eVTjUqrc/dY3OsBESsu2TKTg/xk0l5sECj+0r4xbwQpPd5+9ZvNYi+7VUZmOMCMsd/ f/+51c541VgWwscBiShDwttLL95ifxl8Q39Ii10Q= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20200323080509epcas1p188e0bb9b7848da53225cb7f3c86ec8ae~_4EXouD5b0465004650epcas1p1q; Mon, 23 Mar 2020 08:05:09 +0000 (GMT) Received: from epsmges1p4.samsung.com (unknown [182.195.40.162]) by epsnrtp3.localdomain (Postfix) with ESMTP id 48m6PJ5KSCzMqYl0; Mon, 23 Mar 2020 08:05:08 +0000 (GMT) Received: from epcas1p1.samsung.com ( [182.195.41.45]) by epsmges1p4.samsung.com (Symantec Messaging Gateway) with SMTP id DE.0E.04160.4BD687E5; Mon, 23 Mar 2020 17:05:08 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p3.samsung.com (KnoxPortal) with ESMTPA id 20200323080508epcas1p3c68190cd46635b9ff026a4ae70fc7a3b~_4EWPvhKj3019030190epcas1p3D; Mon, 23 Mar 2020 08:05:08 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200323080508epsmtrp1b7b626fbe636fd09f4fa64c04c8276d1~_4EWO2m150107001070epsmtrp1-; Mon, 23 Mar 2020 08:05:08 +0000 (GMT) X-AuditID: b6c32a38-297ff70000001040-11-5e786db41e39 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 08.73.04024.4BD687E5; Mon, 23 Mar 2020 17:05:08 +0900 (KST) Received: from jaewon-linux.10.32.193.11 (unknown [10.253.104.82]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200323080508epsmtip1996987f173182e8893721e72705829c8~_4EWBdNZ70114401144epsmtip1O; Mon, 23 Mar 2020 08:05:08 +0000 (GMT) From: Jaewon Kim To: gregkh@linuxfoundation.org, leon@kernel.org, vbabka@suse.cz, adobriyan@gmail.com, akpm@linux-foundation.org, labbott@redhat.com, sumit.semwal@linaro.org, minchan@kernel.org, ngupta@vflare.org, sergey.senozhatsky.work@gmail.com, kasong@redhat.com, bhe@redhat.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com, linux-api@vger.kernel.org, kexec@lists.infradead.org, Jaewon Kim Subject: [RFC PATCH v2 3/3] android: ion: include system heap size in meminfo extra Date: Mon, 23 Mar 2020 17:05:03 +0900 Message-Id: <20200323080503.6224-4-jaewon31.kim@samsung.com> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20200323080503.6224-1-jaewon31.kim@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCJsWRmVeSWpSXmKPExsWy7bCmru6W3Io4g/sz1C2mN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ueWV14WC1X/1XD 7avnLJ4ERidLngy4abm401ZvpxJLcUaioRZzUXEiAPhoS1HXAwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNLMWRmVeSWpSXmKPExsWy7bCSnO6W3Io4g1m7OC2mN3pZzFm/hs3i /INfbBbNi9ezWXRvnslo0fv+FZPF8nenGS12n/7KZLFyzw8miym/ljJbbP7ewWZxedccNot7 a/6zWiz7+p7dYkPLLHaLRxMmMVmcuvuZ3WJ2Yx+jg5DHzll32T02repk89j0aRK7x51re9g8 Tsz4zeKxf+4ado/NS+o93u+7yubRt2UVo8eZBUfYPXZ+2szq8XmTXABPFJdNSmpOZllqkb5d AlfGlafTGQsuiFZMvn6XtYFxoVAXIyeHhICJxMdrG5i6GLk4hAR2M0r0LexghkjISLw5/5Sl i5EDyBaWOHy4GKLmK6PEul0/WUFq2AS0Jd4vmARmiwjMZ5Lob+cHKWIW2MwoMXFpMwtIQlgg WGLu8X2MIDaLgKrE5A0zweK8AjYSKy5PhlogL7HwP9heTgFbiX2XbrGB2EJAJVu7nzFPYORb wMiwilEytaA4Nz232LDAMC+1XK84Mbe4NC9dLzk/dxMjOEq0NHcwXl4Sf4hRgINRiYf3Rm95 nBBrYllxZe4hRgkOZiUR3s2pFXFCvCmJlVWpRfnxRaU5qcWHGKU5WJTEeZ/mHYsUEkhPLEnN Tk0tSC2CyTJxcEo1MBovOqR8+WWsncxxd1+XvQYMhcK/OQ4+vlhzaWPopNxSkaqt56vep2aX POpNsr76QvGH0NJ/L/oks54niubs/J/y6PnsJGbhw7Gtui6XxJQfL+r/2Zl+LzwlxD/h7Nen M3gWibzpKPFeM0eWqYp3B+fDW1msS58kiLStmaDRLzNhsthi0b+sv5VYijMSDbWYi4oTAT2/ SM2OAgAA X-CMS-MailID: 20200323080508epcas1p3c68190cd46635b9ff026a4ae70fc7a3b X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200323080508epcas1p3c68190cd46635b9ff026a4ae70fc7a3b References: <20200323080503.6224-1-jaewon31.kim@samsung.com> 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: In Android system ion system heap size is huge like hundreds of MB. To know overal system memory usage, include ion system heap size in proc/meminfo_extra. To include heap size, use register_meminfo_extra introduced in previous patch. Prior to register we need to add stats to show the ion heap usage. Add total_allocated into ion heap and count it on allocation and freeing. In a ion heap using ION_HEAP_FLAG_DEFER_FREE, a buffer can be freed from user but still live on deferred free list. Keep stats until the buffer is finally freed so that we can cover situation of deferred free thread stuck problem. i.e) cat /proc/meminfo_extra | grep IonSystemHeap IonSystemHeap: 242620 kB i.e.) show_mem on oom <6>[ 420.856428] Mem-Info: <6>[ 420.856433] IonSystemHeap:32813kB Signed-off-by: Jaewon Kim --- drivers/staging/android/ion/ion.c | 2 ++ drivers/staging/android/ion/ion.h | 1 + drivers/staging/android/ion/ion_system_heap.c | 2 ++ 3 files changed, 5 insertions(+) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 38b51eace4f9..76db91a9f26a 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -74,6 +74,7 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap, INIT_LIST_HEAD(&buffer->attachments); mutex_init(&buffer->lock); + atomic_long_add(len, &heap->total_allocated); return buffer; err1: @@ -95,6 +96,7 @@ void ion_buffer_destroy(struct ion_buffer *buffer) buffer->heap->num_of_buffers--; buffer->heap->num_of_alloc_bytes -= buffer->size; spin_unlock(&buffer->heap->stat_lock); + atomic_long_sub(buffer->size, &buffer->heap->total_allocated); kfree(buffer); } diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h index 74914a266e25..10867a2e5728 100644 --- a/drivers/staging/android/ion/ion.h +++ b/drivers/staging/android/ion/ion.h @@ -157,6 +157,7 @@ struct ion_heap { u64 num_of_buffers; u64 num_of_alloc_bytes; u64 alloc_bytes_wm; + atomic_long_t total_allocated; /* protect heap statistics */ spinlock_t stat_lock; diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c index b83a1d16bd89..f7882fb7505d 100644 --- a/drivers/staging/android/ion/ion_system_heap.c +++ b/drivers/staging/android/ion/ion_system_heap.c @@ -259,6 +259,8 @@ static struct ion_heap *__ion_system_heap_create(void) if (ion_system_heap_create_pools(heap->pools)) goto free_heap; + register_meminfo_extra(&heap->heap.total_allocated, PAGE_SHIFT, + "IonSystemHeap"); return &heap->heap; free_heap: