From patchwork Wed Mar 11 03:44:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 11430629 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 05418138D for ; Wed, 11 Mar 2020 03:45:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B8B7821D56 for ; Wed, 11 Mar 2020 03:45:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="WmyJ2sFP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B8B7821D56 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 62E646B0007; Tue, 10 Mar 2020 23:45:03 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5E2606B000A; Tue, 10 Mar 2020 23:45: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 3C2476B000C; Tue, 10 Mar 2020 23:45:03 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0228.hostedemail.com [216.40.44.228]) by kanga.kvack.org (Postfix) with ESMTP id 17F766B0007 for ; Tue, 10 Mar 2020 23:45:03 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C91926135 for ; Wed, 11 Mar 2020 03:45:02 +0000 (UTC) X-FDA: 76581690444.19.sugar37_2bf01fc94e023 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,jaewon31.kim@samsung.com,,RULES_HIT:30029:30054,0,RBL:203.254.224.24:@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:22,LUA_SUMMARY:none X-HE-Tag: sugar37_2bf01fc94e023 X-Filterd-Recvd-Size: 10195 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Wed, 11 Mar 2020 03:45:01 +0000 (UTC) Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20200311034457epoutp01191d9ee3c2e2ce106f5a76158f1d3fdb~7IxwHQt9S1774817748epoutp01N for ; Wed, 11 Mar 2020 03:44:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20200311034457epoutp01191d9ee3c2e2ce106f5a76158f1d3fdb~7IxwHQt9S1774817748epoutp01N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1583898297; bh=5O3DmxQG7sUQ77ojFXxku3rR8wOYI+x01rUSJILEbhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WmyJ2sFP6IOEwCK1B8lQUXoK7GQmrNrozV2xHo8SM25d+qpbiflc2Wi3gMgb8msnH wDqqFTBLBU26Oq2zmrAu5CFzeRdd0nQ8HdH6Lmp222j/IFga4PbikMjOdiQNtPhuJx HZRj/EAeT8JGjjeai7dIN8BDW8/TdJg1Bz/7+Fdw= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20200311034456epcas1p18e1ae32617ab3a5cf2224860af11bd0a~7Ixv2BQjT2430724307epcas1p1d; Wed, 11 Mar 2020 03:44:56 +0000 (GMT) Received: from epsmges1p5.samsung.com (unknown [182.195.40.163]) by epsnrtp2.localdomain (Postfix) with ESMTP id 48cdBZ4vpczMqYkZ; Wed, 11 Mar 2020 03:44:54 +0000 (GMT) Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmges1p5.samsung.com (Symantec Messaging Gateway) with SMTP id 26.D7.51241.6BE586E5; Wed, 11 Mar 2020 12:44:54 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200311034454epcas1p184680d40f89d37eec7f934074c4a9fcf~7IxtYjwaN2904129041epcas1p1m; Wed, 11 Mar 2020 03:44:54 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200311034454epsmtrp12e13bf7399fb43470e88d9be6283a377~7IxtXmZZc3056330563epsmtrp1t; Wed, 11 Mar 2020 03:44:54 +0000 (GMT) X-AuditID: b6c32a39-163ff7000001c829-16-5e685eb65692 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 01.12.06569.6BE586E5; Wed, 11 Mar 2020 12:44:54 +0900 (KST) Received: from jaewon-linux.10.32.193.11 (unknown [10.253.104.82]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200311034454epsmtip141d22e83ba5049ba4a80164f7943e6df~7IxtN312B1922919229epsmtip1i; Wed, 11 Mar 2020 03:44:54 +0000 (GMT) From: Jaewon Kim To: 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 Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com, Jaewon Kim Subject: [RFC PATCH 1/3] proc/meminfo: introduce extra meminfo Date: Wed, 11 Mar 2020 12:44:39 +0900 Message-Id: <20200311034441.23243-2-jaewon31.kim@samsung.com> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20200311034441.23243-1-jaewon31.kim@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA02Se0hTYRjG+3a2szN1cVi3j5nLjhRYqFtzdjQnRhanNLALRBKug542aTd2 Ni8RpvNeLnWElmkYWdGozCmSsvrDoiRCootFaKSYlV0kzQua2raj1H/P+76/h+/h/V4MkThR KZZltDIWI60n0AB+x6PwyIiOdF26fNS1mawr3Ec2tNxGyXNtlwDpGBvlkbc8MzzyVVcDSn64 vSggb0yOCcl7xfVCcqjaySOfDUwIEwOpzvoBIeV2VaCUe9wppPr7PCjVc3GOT409fINS59td gOocbxNQE25ZqihNH69j6EzGEsoYM0yZWUatmkg+pNmlUcXIFRGKWHI7EWqkDYyaSEpJjdiT pfemJUKzab3N20qlWZaISoi3mGxWJlRnYq1qgjFn6s0KuTmSpQ2szaiNzDAZ4hRy+TaVlzyu 1y0OORBzXVjuYN8sWgDOhZwFIgzi0XB4ugI9CwIwCX4fwOt1bYArxgHsfVwCfJQEnwKwaHr/ sqP1eQOfgx4A2O4aFnDFNICeP7WIj0LxrXCsyekfrMbvADhvb+b7Bghugz++9/ihVXgCbLa/ RH2aj2+Cxb0er8YwMa6GQx/zfRLiG+DVRT8t8tIT/e/96SD+FoU1g/0IlygJdrkvoJxeBUef tgs5LYVfq0qFnKEIwB+X2pbcxQAOuB2Ao5TQUfkC8b2G4OGwpSuKa2+EnXONgMu8Ev6crBRw gcSwvFTCIZth8cikgNPr4fzCyJKmYJnn1tIaawCs+vwAqQay+n8vNAHgAmsZM2vQMqzCrPr/ y9zAf49bYu+DJ70p3QDHABEk/pKvTZcI6Gw2z9ANIIYQq8WaDd6WOJPOO8VYTBqLTc+w3UDl 3WQNIl2TYfJet9GqUai2KZVKMjpme4xKSawTDx4NT5fgWtrKnGQYM2NZ9vEwkbQAyKjTJ8Ls JbLCmOY9syE7ahPE0zktist2c5oQuxm7e/SKZTh8r4RucX5KDP61MUd2SBQ8t7MycoQ/xXOe uSw1BF07XB5FJvUeODZQUnvswsLdOElQYP35efWNuIqZwMCZ30blitcV4taDjYTtXZ++4Ftu 2JG8tWWtEw02oudgbjLBZ3W0YgtiYem/p0BoqaUDAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrBLMWRmVeSWpSXmKPExsWy7bCSnO62uIw4gx9veS2mN3pZzFm/hs2i e/NMRove96+YLFbu+cFkcXnXHDaLe2v+s1os+/qe3WJDyyx2i0cTJjFZnLr7md2B22PnrLvs HptWdbJ5bPo0id3jzrU9bB4nZvxm8Xi/7yqbR9+WVYweOz9tZvX4vEkugDOKyyYlNSezLLVI 3y6BK+P/o17mgunKFQ+v/WJrYOyW7WLk5JAQMJHYeGYOSxcjF4eQwG5GiT3brjBDJGQk3px/ CpTgALKFJQ4fLoao+coocWTvSzaQGjYBbYn3CyaxgiREBLYySnz4s54FJMEsUCnx7/YtVhBb WMBOYknTJbAGFgFViZZze9hAhvIK2Eo8elAHMV9eYuF/sLWcQNWf79xiBAkLAVVseGA5gZFv ASPDKkbJ1ILi3PTcYsMCo7zUcr3ixNzi0rx0veT83E2M4PDV0trBeOJE/CFGAQ5GJR7eF3Xp cUKsiWXFlbmHGCU4mJVEeOPlgUK8KYmVValF+fFFpTmpxYcYpTlYlMR55fOPRQoJpCeWpGan phakFsFkmTg4pRoY2axspvbWH750z91t2ealXdc6YgtCgs8tXfyxcs3EPZaHsmwOVJ2eoruu UuYky7SVxqcN5kkvmC8ouODV5+PqXyvZU0wfFQaUGBWrGX6Sef3lna1SouFJZi9D3htPZgam Zpxb8NNZ+Kf/ryt8vBz1gnnBLfGy+uIiT9SLCmXCNK5zv2v/UntHiaU4I9FQi7moOBEAS3x9 oFsCAAA= X-CMS-MailID: 20200311034454epcas1p184680d40f89d37eec7f934074c4a9fcf X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200311034454epcas1p184680d40f89d37eec7f934074c4a9fcf References: <20200311034441.23243-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. int register_extra_meminfo(atomic_long_t *val, int shift, const char *name); int unregister_extra_meminfo(atomic_long_t *val); Signed-off-by: Jaewon Kim --- fs/proc/meminfo.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mm.h | 4 +++ lib/show_mem.c | 1 + 3 files changed, 108 insertions(+) diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c index 8c1f1bb1a5ce..12b1f77b091b 100644 --- a/fs/proc/meminfo.c +++ b/fs/proc/meminfo.c @@ -13,6 +13,7 @@ #include #include #include +#include #ifdef CONFIG_CMA #include #endif @@ -30,6 +31,106 @@ static void show_val_kb(struct seq_file *m, const char *s, unsigned long num) 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 extra_meminfo { + 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_extra_meminfo(atomic_long_t *val, int shift, const char *name) +{ + struct extra_meminfo *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(memtemp, &meminfo_head, list) { + if (memtemp->val == val) { + error = -EINVAL; + break; + } + } + if (!error) + list_add_tail(&meminfo->list, &meminfo_head); + spin_unlock(&meminfo_lock); + if (error) + kfree(meminfo); +out: + + return error; +} +EXPORT_SYMBOL(register_extra_meminfo); + +int unregister_extra_meminfo(atomic_long_t *val) +{ + struct extra_meminfo *memtemp, *memtemp2; + int error = -EINVAL; + + spin_lock(&meminfo_lock); + list_for_each_entry_safe(memtemp, memtemp2, &meminfo_head, list) { + if (memtemp->val == val) { + list_del(&memtemp->list); + error = 0; + break; + } + } + spin_unlock(&meminfo_lock); + kfree(memtemp); + + return error; +} +EXPORT_SYMBOL(unregister_extra_meminfo); + +static void __extra_meminfo(struct seq_file *m) +{ + struct extra_meminfo *memtemp; + unsigned long nr_page; + + spin_lock(&meminfo_lock); + list_for_each_entry(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); + } + spin_unlock(&meminfo_lock); +} + +void extra_meminfo_log(void) +{ + __extra_meminfo(NULL); +} + +static void extra_meminfo_proc(struct seq_file *m) +{ + __extra_meminfo(m); +} + static int meminfo_proc_show(struct seq_file *m, void *v) { struct sysinfo i; @@ -148,6 +249,8 @@ static int meminfo_proc_show(struct seq_file *m, void *v) arch_report_meminfo(m); + extra_meminfo_proc(m); + return 0; } diff --git a/include/linux/mm.h b/include/linux/mm.h index c54fb96cb1e6..457570ddd17c 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2902,6 +2902,10 @@ void __init setup_nr_node_ids(void); static inline void setup_nr_node_ids(void) {} #endif +void extra_meminfo_log(void); +int register_extra_meminfo(atomic_long_t *val, int shift, const char *name); +int unregister_extra_meminfo(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/lib/show_mem.c b/lib/show_mem.c index 1c26c14ffbb9..48be5afaca0a 100644 --- a/lib/show_mem.c +++ b/lib/show_mem.c @@ -14,6 +14,7 @@ void show_mem(unsigned int filter, nodemask_t *nodemask) unsigned long total = 0, reserved = 0, highmem = 0; printk("Mem-Info:\n"); + extra_meminfo_log(); show_free_areas(filter, nodemask); for_each_online_pgdat(pgdat) { From patchwork Wed Mar 11 03:44:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 11430627 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 AE554138D for ; Wed, 11 Mar 2020 03:45:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6E17721D56 for ; Wed, 11 Mar 2020 03:45:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="fs63vccb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6E17721D56 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 BEFEE6B0003; Tue, 10 Mar 2020 23:45:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BA8796B0007; Tue, 10 Mar 2020 23:45:01 -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 A4DDB6B000A; Tue, 10 Mar 2020 23:45:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0079.hostedemail.com [216.40.44.79]) by kanga.kvack.org (Postfix) with ESMTP id 86B3F6B0003 for ; Tue, 10 Mar 2020 23:45:01 -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 3BC6B180AD81F for ; Wed, 11 Mar 2020 03:45:01 +0000 (UTC) X-FDA: 76581690402.14.uncle36_2ba6f1a0c1054 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,jaewon31.kim@samsung.com,,RULES_HIT:30054,0,RBL:203.254.224.24:@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:1:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: uncle36_2ba6f1a0c1054 X-Filterd-Recvd-Size: 7001 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Wed, 11 Mar 2020 03:44:59 +0000 (UTC) Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20200311034456epoutp01f2422f35a89d0795d1be22d7cc070874~7IxvdBCGD1762917629epoutp01X for ; Wed, 11 Mar 2020 03:44:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20200311034456epoutp01f2422f35a89d0795d1be22d7cc070874~7IxvdBCGD1762917629epoutp01X DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1583898296; bh=1oA52aVZG3c059yyJ7IvF/BZO+09kGIaHbRpZ+wX6ro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fs63vccbJPnbH1VZM+on+DRbNmvx19xsrOLKWWw2ekpGsKN9y+6DdCjeYD+ZUakEZ LFsfJabpxDKPkhUv31EjSnrsxeWeeTczLKHtG8VCSsswpi9HTUeu+VBqI8eeeHr63n wnGE7J5SqxmAjW2Cp8ngYah3lVQH5qHGILzPc4Ho= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20200311034456epcas1p2985c1929c0e75d9e48c650b0db07d96d~7IxvCpV3X2746527465epcas1p23; Wed, 11 Mar 2020 03:44:56 +0000 (GMT) Received: from epsmges1p3.samsung.com (unknown [182.195.40.159]) by epsnrtp1.localdomain (Postfix) with ESMTP id 48cdBZ710qzMqYls; Wed, 11 Mar 2020 03:44:54 +0000 (GMT) Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmges1p3.samsung.com (Symantec Messaging Gateway) with SMTP id 65.06.52419.6BE586E5; Wed, 11 Mar 2020 12:44:54 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200311034454epcas1p13f7806e51b19c7848148c20ce3841b1b~7IxtgFiST2430724307epcas1p1Q; Wed, 11 Mar 2020 03:44:54 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200311034454epsmtrp1140101c0c7cf1fc5a6192126a94d44aa~7IxtfXGtg3056530565epsmtrp1r; Wed, 11 Mar 2020 03:44:54 +0000 (GMT) X-AuditID: b6c32a37-59fff7000001ccc3-e0-5e685eb65295 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 5F.9E.10238.6BE586E5; Wed, 11 Mar 2020 12:44:54 +0900 (KST) Received: from jaewon-linux.10.32.193.11 (unknown [10.253.104.82]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200311034454epsmtip1c6fc620abd3ff4722880b4805b3e790f~7IxtQqSXg2352723527epsmtip1y; Wed, 11 Mar 2020 03:44:54 +0000 (GMT) From: Jaewon Kim To: 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 Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com, Jaewon Kim Subject: [RFC PATCH 2/3] mm: zsmalloc: include zs page size in proc/meminfo Date: Wed, 11 Mar 2020 12:44:40 +0900 Message-Id: <20200311034441.23243-3-jaewon31.kim@samsung.com> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20200311034441.23243-1-jaewon31.kim@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA01SWUwTURTN67QzU7RmLKgvaLSO0QSF0lpKx6VEo9FR/ECNKCZQJnRs0S6T TovCh1EpREFckCg0kuASEotaKciW4gcaBFeiURMUiQtEjdCERYyK2HYw+nfuuee8u7yLI/Jz aCyea3OyDhtjIdEocdPdOGVCU5Y5SzVap6MuHN1KXfRdR6nShipAlQW/iKhrge8i6nnbRZR6 e31KQtWOBzHqltuDUe/PlIuoB32j2LoZdKunD6P93hMo7R8px+g3LwMo3VX5U0wH77xA6VON XkC3jjRI6FH/wjTpXstaM8sYWYeCteXYjbk2k55M3WnYYNAmq9QJ6lWUjlTYGCurJzduS0vY lGsJdUsq8hiLK0SlMTxPJqasddhdTlZhtvNOPclyRgunVnFKnrHyLptJmWO3rlarVCu1IWW2 xfyt6grCuaMO1XU/lhwBp/ASIMUhkQTrOyexEhCFy4kWAM//+oAKwQiAnc1jIiH4BmDp5Smk BOARS+NRlcC3A1h43jttnwDwU8UxLPwuSqyAwZpySTgRQ9wAcPLYVXE4gRAuOPS1CwnjaCIV vp4ojBjExFI4MDYsCmMZoYe9H5swodoieGkqIpcSKXD0TS8IvwmJfhR29j9FhCE2wkfublTA 0fDL/UZMwLHw8+liTDAUAjhU1TDtdgPY5y8DgkoDy072RGZDiDjoa0sU6MWw9Wc1EJqeBYfH T0qEhmTweLFckCyD7sFxiYAXwMnfg9OYhq+aJ4CwlbMAvvW1YGfAQs+/CjUAeMFcluOtJpZX c5r//8wPIge5XNcCbj3Z1gEIHJAzZZ8Om7LkEiaPz7d2AIgjZIzMsChEyYxMfgHrsBscLgvL dwBtaJVnkdg5OfbQeducBrV2pUajoZKSdclaDTlP9i4jLktOmBgne4BlOdbx1yfCpbFHwL6U jObte8YDAwPDXA+e2VM7siZvfkXhqrj0wO3ZnrIAa3Re/fFh/Zb24MMJqTIt4N2k+Zz7JKVi QS3aXfosM7V/5/PEKvNpFWXIz1vvmFvQfvweSOfqN/v274r39CbpFQeLltRVVy6eeVNapGvL HN4s6SmPL8h+NLhbzO1oy2wlxbyZUS9HHDzzB3rK2D6mAwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrOLMWRmVeSWpSXmKPExsWy7bCSnO62uIw4g78fhSymN3pZzFm/hs2i e/NMRove96+YLFbu+cFkcXnXHDaLe2v+s1os+/qe3WJDyyx2i0cTJjFZnLr7md2B22PnrLvs HptWdbJ5bPo0id3jzrU9bB4nZvxm8Xi/7yqbR9+WVYweOz9tZvX4vEkugDOKyyYlNSezLLVI 3y6BK+PbzMXMBS1cFatPnmVtYOzj6GLk4JAQMJHY0mjQxcjJISSwm1Hi77kEEFtCQEbizfmn LBAlwhKHDxd3MXIBlXxllPj97g0LSA2bgLbE+wWTWEESIgJbGSU+/FkPlmAWqJT4d/sWK4gt LOAtcft7MzuIzSKgKvH0yzsmEJtXwFbi1pNt7BAL5CUW/mcGCXMK2El8vnOLESQsBFSy4YHl BEa+BYwMqxglUwuKc9Nziw0LDPNSy/WKE3OLS/PS9ZLzczcxgoNXS3MH4+Ul8YcYBTgYlXh4 X9SlxwmxJpYVV+YeYpTgYFYS4Y2XBwrxpiRWVqUW5ccXleakFh9ilOZgURLnfZp3LFJIID2x JDU7NbUgtQgmy8TBKdXAuOLNJZuot18r7CYUznaY5J/5nK3rwvusmtknL4eerLEP3mizPOze sXXJk2eVXj528glTyL1Jzz8VfD4z66njmpJDjs4GMzJk5UPqp696/sGR02H6RvN1Yoybmtqd NjHlrfjxIfV66snt899ax3GbToy3spXedsPvp5dBtuwsGbvVi16tqbn06KsSS3FGoqEWc1Fx IgBoRCGDWgIAAA== X-CMS-MailID: 20200311034454epcas1p13f7806e51b19c7848148c20ce3841b1b X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200311034454epcas1p13f7806e51b19c7848148c20ce3841b1b References: <20200311034441.23243-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: 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, it will be better to see system wide memory usage at a glance. To include heap size, use register_extra_meminfo introduced in previous patch. i.e) cat /proc/meminfo | 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..9e45d7e0cd69 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -2566,6 +2566,7 @@ static int __init zs_init(void) zs_stat_init(); + register_extra_meminfo(&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_extra_meminfo(&vm_zone_stat[NR_ZSPAGES]); } module_init(zs_init); From patchwork Wed Mar 11 03:44:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 11430623 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 3FBDD1800 for ; Wed, 11 Mar 2020 03:45:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F2D49215A4 for ; Wed, 11 Mar 2020 03:45:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="Lg8Psrxp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F2D49215A4 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 983716B0006; Tue, 10 Mar 2020 23:45:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 918036B000C; Tue, 10 Mar 2020 23:45:01 -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 77AD76B000A; Tue, 10 Mar 2020 23:45:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0021.hostedemail.com [216.40.44.21]) by kanga.kvack.org (Postfix) with ESMTP id 524E26B0006 for ; Tue, 10 Mar 2020 23:45:01 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 1A5AC181AEF00 for ; Wed, 11 Mar 2020 03:45:01 +0000 (UTC) X-FDA: 76581690402.13.lamp74_2bacaf2c6ef2c X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,jaewon31.kim@samsung.com,,RULES_HIT:30051:30054,0,RBL:203.254.224.33:@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:23,LUA_SUMMARY:none X-HE-Tag: lamp74_2bacaf2c6ef2c X-Filterd-Recvd-Size: 8471 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Wed, 11 Mar 2020 03:45:00 +0000 (UTC) Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20200311034456epoutp030bea400136235dfa0f8b567c4343de65~7IxvS6CLj1412114121epoutp03L for ; Wed, 11 Mar 2020 03:44:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20200311034456epoutp030bea400136235dfa0f8b567c4343de65~7IxvS6CLj1412114121epoutp03L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1583898296; bh=g9/Soy66OC22nAKgazf5iA56h4uOPCS4a1ETM2dLFpo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lg8Psrxp/bm8AG21OtRAU6c2mGgcEE3gYLtCi+QHt9Rlhfrbkj/MHlnDHTMYOaD2O UrWh4V4mk0u/l+ei2RzDEL41EIw1UJj9EReaaRapVwHY8nD768yUk9BH+y83KEiF/i hRv6/GEOa+MEUSXaROwR2ByLQHIaDilhyfN5AMTE= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20200311034455epcas1p49a471398213ae95d722d296eba01af54~7Ixu5CM8h1814418144epcas1p4L; Wed, 11 Mar 2020 03:44:55 +0000 (GMT) Received: from epsmges1p2.samsung.com (unknown [182.195.40.165]) by epsnrtp3.localdomain (Postfix) with ESMTP id 48cdBZ6jtSzMqYkb; Wed, 11 Mar 2020 03:44:54 +0000 (GMT) Received: from epcas1p1.samsung.com ( [182.195.41.45]) by epsmges1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 8F.7A.48498.6BE586E5; Wed, 11 Mar 2020 12:44:54 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p4.samsung.com (KnoxPortal) with ESMTPA id 20200311034454epcas1p46f44b4c1e75fa52b7598749566228a11~7Ixtek13a2104521045epcas1p4X; Wed, 11 Mar 2020 03:44:54 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200311034454epsmtrp131c0cb622dc4d191f256ded94186c246~7Ixtdn5343001830018epsmtrp1c; Wed, 11 Mar 2020 03:44:54 +0000 (GMT) X-AuditID: b6c32a36-a55ff7000001bd72-f1-5e685eb69487 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id C1.12.06569.6BE586E5; Wed, 11 Mar 2020 12:44:54 +0900 (KST) Received: from jaewon-linux.10.32.193.11 (unknown [10.253.104.82]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200311034454epsmtip1b642b362ae1283f0e23af46aeb7c0353~7IxtV5C8A1922919229epsmtip1j; Wed, 11 Mar 2020 03:44:54 +0000 (GMT) From: Jaewon Kim To: 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 Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com, Jaewon Kim Subject: [RFC PATCH 3/3] android: ion: include system heap size in proc/meminfo Date: Wed, 11 Mar 2020 12:44:41 +0900 Message-Id: <20200311034441.23243-4-jaewon31.kim@samsung.com> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20200311034441.23243-1-jaewon31.kim@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIJsWRmVeSWpSXmKPExsWy7bCmru62uIw4gxOHzC2mN3pZzFm/hs2i e/NMRove96+YLFbu+cFkcXnXHDaLe2v+s1os+/qe3WJDyyx2i0cTJjFZnLr7md2B22PnrLvs HptWdbJ5bPo0id3jzrU9bB4nZvxm8Xi/7yqbR9+WVYweOz9tZvX4vEkugDMqxyYjNTEltUgh NS85PyUzL91WyTs43jne1MzAUNfQ0sJcSSEvMTfVVsnFJ0DXLTMH6FolhbLEnFKgUEBicbGS vp1NUX5pSapCRn5xia1SakFKToGhQYFecWJucWleul5yfq6VoYGBkSlQZUJOxutTOgVHRCsu LZNvYJwq1MXIySEhYCLx8vt75i5GLg4hgR2MEht3LWOHcD4xSqy7+ZQJwvnGKHHz4V5mmJZN uxawQCT2Mkp0zL7BCuF8Z5S4u2U/K0gVm4C2xPsFk8ASIgJrGSX+Ni1hAUkwC5RKvH1zAmyU sECgxJlJr9lAbBYBVYmzh58D7ePg4BWwlZj/PgzElBCQl1j4H6yaU8BO4vOdW4wgIyUErrNJ HH67lgXiIheJh/sWMkLYwhKvjm9hh7ClJF72t7FDNDQzSryduRmquwXo0k29UB3GEr09F5hB tjELaEqs36UPEVaU2Pl7LiPEzXwS7772sEIcxCvR0QYNPDWJlmdfWSFsGYm//55B2R4SzX+W QwN1IqPE9I67zBMY5WYhbFjAyLiKUSy1oDg3PbXYsMAIOcY2MYKTo5bZDsZF53wOMQpwMCrx 8L6oS48TYk0sK67MPcQowcGsJMIbLw8U4k1JrKxKLcqPLyrNSS0+xGgKDMmJzFKiyfnAxJ1X Em9oamRsbGxhYmZuZmqsJM77MFIzTkggPbEkNTs1tSC1CKaPiYNTqoGxfioPw+SHhy7ZrbWp 4/nnJSXp2uEt2sff/c8oLla5V/vNOfHM6UcOGzEftZ071ePEs++/286vtA/fnLC93W/uBZ4u R9FvEzn8Y/Szb3/hMBcJ8vVN3c4QMv/DhnLxq8+EFuoyyd65vkduqUnHIpWuYqFtlr+mJkXu O3xP5v0Un19n5x061rdNiaU4I9FQi7moOBEAW8WhQ6QDAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGLMWRmVeSWpSXmKPExsWy7bCSnO62uIw4g2sHRS2mN3pZzFm/hs2i e/NMRove96+YLFbu+cFkcXnXHDaLe2v+s1os+/qe3WJDyyx2i0cTJjFZnLr7md2B22PnrLvs HptWdbJ5bPo0id3jzrU9bB4nZvxm8Xi/7yqbR9+WVYweOz9tZvX4vEkugDOKyyYlNSezLLVI 3y6BK+P1KZ2CI6IVl5bJNzBOFepi5OSQEDCR2LRrAUsXIxeHkMBuRon/2+YzQSRkJN6cfwqU 4ACyhSUOHy6GqPnKKHFk1iQWkBo2AW2J9wsmsYIkRAS2Mkp8+LMeLMEsUCnx7/YtVhBbWMBf YuKlaWBxFgFVibOHnzOBDOUVsJWY/z4MYr68xML/zCAVnAJ2Ep/v3GIECQsBVWx4YDmBkW8B I8MqRsnUguLc9NxiwwKjvNRyveLE3OLSvHS95PzcTYzg0NXS2sF44kT8IUYBDkYlHt4Xdelx QqyJZcWVuYcYJTiYlUR44+WBQrwpiZVVqUX58UWlOanFhxilOViUxHnl849FCgmkJ5akZqem FqQWwWSZODilGhgt9LY6377H0v2g7ITB/jfLo48dkLAsvtwQHGRlYHWZ9z3TNnX1gofPWVkX LntuEvuHW7QiYp6c75kDJnJv+MQPFsWGx7QoiO119We99n7TgZq+V1412S37Lcq/P/BJ9PhS ei7zxTe5e2u8mEV2X72g6+c9Y06jn96KWVNe1KzMUgm+6FhULaXEUpyRaKjFXFScCAAuE9e/ WQIAAA== X-CMS-MailID: 20200311034454epcas1p46f44b4c1e75fa52b7598749566228a11 X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200311034454epcas1p46f44b4c1e75fa52b7598749566228a11 References: <20200311034441.23243-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. To include heap size, use register_extra_meminfo 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 | 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..2cc568e2bc9c 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_extra_meminfo(&heap->heap.total_allocated, PAGE_SHIFT, + "IonSystemHeap"); return &heap->heap; free_heap: