From patchwork Tue Aug 15 12:52:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjiang Tu X-Patchwork-Id: 13353756 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78749C04A6A for ; Tue, 15 Aug 2023 11:58:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2A70A8D0009; Tue, 15 Aug 2023 07:58:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 27E6C8D0001; Tue, 15 Aug 2023 07:58:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 06B858D0009; Tue, 15 Aug 2023 07:57:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D50BE8D0001 for ; Tue, 15 Aug 2023 07:57:59 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 9A370A0801 for ; Tue, 15 Aug 2023 11:57:59 +0000 (UTC) X-FDA: 81126190278.08.A51EE60 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf01.hostedemail.com (Postfix) with ESMTP id 2278A40007 for ; Tue, 15 Aug 2023 11:57:56 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.hostedemail.com: domain of tujinjiang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=tujinjiang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692100677; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vbbcIfUTDqboMEX0sE2+NtB1fLzGastILWeXfwoFBJ8=; b=xY68n+5Hn3pAjU3DojDd4NwQGui5hvnPlzl2nH8WGPpbytngBaFMHQa3PO0yaGqHkGaspv sgRZRbN9BDrBuuU3ni9XIgUFV6ugotEb0x0GR1nXEZSFal4AfBEW9PJSKzCYbYjvd7/AZn tuxDuBqxibe0iCoD50qq4IpK6jQq1Lo= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.hostedemail.com: domain of tujinjiang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=tujinjiang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692100677; a=rsa-sha256; cv=none; b=Wdq5Hp45D3/TC7t5sQR+z0ZjgpUK5nNUP31DY/Zq1377FdyRSsuiowTCeBZ3s06pc3AyIg vMitgfQDTqbc4wRDl8s2jZilkmtggFd79FujDt/+SDNdGux0tbHoNOIEWk6UkYdHY+rbIS cR2iAN0iSASTTz1g4LEbVFHRLuxwz+g= Received: from dggpeml500011.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RQ8nN2VPNztRvk; Tue, 15 Aug 2023 19:54:16 +0800 (CST) Received: from huawei.com (10.175.113.32) by dggpeml500011.china.huawei.com (7.185.36.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 15 Aug 2023 19:57:51 +0800 From: Jinjiang Tu To: , , , , CC: Subject: [PATCH 1/6] mm/page_owner: support identifying pages allocated by modules Date: Tue, 15 Aug 2023 20:52:46 +0800 Message-ID: <20230815125251.2865852-2-tujinjiang@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815125251.2865852-1-tujinjiang@huawei.com> References: <20230815125251.2865852-1-tujinjiang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500011.china.huawei.com (7.185.36.84) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2278A40007 X-Stat-Signature: nno4qed8ekttka53xtm9pgduiycetacc X-HE-Tag: 1692100676-548078 X-HE-Meta: U2FsdGVkX18DiLLMzmdDMCmOBXMBzEyoKXi/cYZAGT5TtMCBoqfN7PAcX9HT/hthdzo6DVI46E5/ngv/xZpNALpKCpAohNDoSw5t/Gm7rTEDGy0XT6CYzn1+IB/MuOCuBgCGFr1nBLXDRXMLrM0xd6ltL3qm4cQJeAvxV4z/kHVN9ukeoeIOlr1PSI8bJje4q2hIKQ9/nK1IIsCyUjV8YLQffuLpP5+v3ymCCjJIIA6uJpeNCk6vI8RbZ0oTVPnnaSfndXwYQxPpM4kmlnvHaHKPS8AVhCAQV8cTvVEMiQPSePeD5BxAa7HSBrBHwvcQA01Ha9NP85J2UhUmU/GRFnqws62QP6nK+MZ3SSxbOfI08h+YoxUhPx6MVKjbSHQWkNc364ut134LiJUjjDm6LGLqiR/2c1+P1fYwg+ToSoJCo5uCoOKu0PPch+MgQpFXguzqnQ9Hme7aQXvWPwV7WVm6TmikZTTH6s0WE6j7sVPoho721bfcKnKPtOk0mWZQFr5fuxQfq2jITt+YOOGKAXuxcnG/TcsQtB+3Fb+eUBr+Z/k/7slER2scsx3FC0Dz9Y2QHRjIBglNmy5ayKzKgusZ1/NoZ7ksuupzm1OHYGSHQgXmMHeuJ9JZVjNto5Himhl6B4jJf16tkWz5I/A6yXpbcLTglWQhstELHg8z7kLlKGyXpsqJ5h0c/LdrSmPCuR+ppun7HK47TrDLa/1L67VYyHxGj4E/KKCPBCgTx0u6AgbenReNuuVH/igBlwkMDzXTFH+SDnzMfyiiEM+/ZjzQBjuwhZqJ+GJJKE6TBOW0LTwPwPK/euBdLD9aTPHIqzajzBXCeuQk3ojkrZuAaOsnpg3kjwQhbD3Y/Svv/uwrfIwyWJjrDQRzcgF8+sRKFT+gw28Dq7R8LtDXQ39z2uj+YlkvK9/TdT18ohbUj5Ux/FtglpY7dylwd3SLFEYiXdqQnDpxbU1fISIobsj HgGM97x+ FrTRA5L970zrYFJJXZ9L4a3wad3Jo52+QNACYrICIRBdWGvwTHybmxyeXw9H+4rnqoqbfY6hCWn9z31Ebg1VLsMbz8utJ6EEjFmG00nVek1/MHV3NUWWFSUmUzSlV3HdLKUDMxCx9SX00ki4xka7i09r2FNhb9J2I/MMLJwyPULwN7jk3M3Q3J99706ZwUz0I4Gxj 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: Identify if the pages are allocated by modules according to stackstrace. By traversing the stacktrace and querying if the address of each entry is located in a module, we gets the module who allocated/freed the page. If several modules are found in stacktrace, we choose the one that is closet to the allocation/free function. We record the module name in struct page_owner and print it when a user reads from page_owner interface. Signed-off-by: Jinjiang Tu --- mm/page_owner.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/mm/page_owner.c b/mm/page_owner.c index c93baef0148f..ef8fe1857d42 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "internal.h" @@ -32,6 +33,9 @@ struct page_owner { char comm[TASK_COMM_LEN]; pid_t pid; pid_t tgid; +#ifdef CONFIG_MODULES + char module_name[MODULE_NAME_LEN]; +#endif }; static bool page_owner_enabled __initdata; @@ -134,6 +138,78 @@ static noinline depot_stack_handle_t save_stack(gfp_t flags) return handle; } +#ifdef CONFIG_MODULES +static char *find_module_name(depot_stack_handle_t handle) +{ + int i; + struct module *mod = NULL; + unsigned long *entries; + unsigned int nr_entries; + + nr_entries = stack_depot_fetch(handle, &entries); + for (i = 0; i < nr_entries; i++) { + if (core_kernel_text(entries[i])) + continue; + + preempt_disable(); + mod = __module_address(entries[i]); + preempt_enable(); + + if (!mod) + continue; + + return mod->name; + } + + return NULL; +} + +static void set_module_name(struct page_owner *page_owner, char *mod_name) +{ + if (mod_name) + strscpy(page_owner->module_name, mod_name, MODULE_NAME_LEN); + else + memset(page_owner->module_name, 0, MODULE_NAME_LEN); +} + +static int module_name_snprint(struct page_owner *page_owner, + char *kbuf, size_t size) +{ + if (strlen(page_owner->module_name) != 0) + return scnprintf(kbuf, size, "Page allocated by module %s\n", + page_owner->module_name); + + return 0; +} + +static inline void copy_module_name(struct page_owner *old_page_owner, + struct page_owner *new_page_owner) +{ + set_module_name(new_page_owner, old_page_owner->module_name); +} +#else +static inline char *find_module_name(depot_stack_handle_t handle) +{ + return NULL; +} + +static inline void set_module_name(struct page_owner *page_owner, + char *mod_name) +{ +} + +static inline int module_name_snprint(struct page_owner *page_owner, + char *kbuf, size_t size) +{ + return 0; +} + +static inline void copy_module_name(struct page_owner *old_page_owner, + struct page_owner *new_page_owner) +{ +} +#endif + void __reset_page_owner(struct page *page, unsigned short order) { int i; @@ -141,17 +217,20 @@ void __reset_page_owner(struct page *page, unsigned short order) depot_stack_handle_t handle; struct page_owner *page_owner; u64 free_ts_nsec = local_clock(); + char *mod_name; page_ext = page_ext_get(page); if (unlikely(!page_ext)) return; handle = save_stack(GFP_NOWAIT | __GFP_NOWARN); + mod_name = find_module_name(handle); for (i = 0; i < (1 << order); i++) { __clear_bit(PAGE_EXT_OWNER_ALLOCATED, &page_ext->flags); page_owner = get_page_owner(page_ext); page_owner->free_handle = handle; page_owner->free_ts_nsec = free_ts_nsec; + set_module_name(page_owner, mod_name); page_ext = page_ext_next(page_ext); } page_ext_put(page_ext); @@ -164,6 +243,9 @@ static inline void __set_page_owner_handle(struct page_ext *page_ext, struct page_owner *page_owner; int i; u64 ts_nsec = local_clock(); + char *mod_name; + + mod_name = find_module_name(handle); for (i = 0; i < (1 << order); i++) { page_owner = get_page_owner(page_ext); @@ -176,6 +258,7 @@ static inline void __set_page_owner_handle(struct page_ext *page_ext, page_owner->ts_nsec = ts_nsec; strscpy(page_owner->comm, current->comm, sizeof(page_owner->comm)); + set_module_name(page_owner, mod_name); __set_bit(PAGE_EXT_OWNER, &page_ext->flags); __set_bit(PAGE_EXT_OWNER_ALLOCATED, &page_ext->flags); @@ -256,6 +339,7 @@ void __folio_copy_owner(struct folio *newfolio, struct folio *old) new_page_owner->ts_nsec = old_page_owner->ts_nsec; new_page_owner->free_ts_nsec = old_page_owner->ts_nsec; strcpy(new_page_owner->comm, old_page_owner->comm); + copy_module_name(new_page_owner, old_page_owner); /* * We don't clear the bit on the old folio as it's going to be freed @@ -425,6 +509,8 @@ print_page_owner(char __user *buf, size_t count, unsigned long pfn, migratetype_names[pageblock_mt], &page->flags); + ret += module_name_snprint(page_owner, kbuf + ret, count - ret); + ret += stack_depot_snprint(handle, kbuf + ret, count - ret, 0); if (ret >= count) goto err; From patchwork Tue Aug 15 12:52:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjiang Tu X-Patchwork-Id: 13353755 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95BC3C0015E for ; Tue, 15 Aug 2023 11:58:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E05E08D0006; Tue, 15 Aug 2023 07:57:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DFAE68D0008; Tue, 15 Aug 2023 07:57:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C69BD8D0006; Tue, 15 Aug 2023 07:57:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B7D968D0001 for ; Tue, 15 Aug 2023 07:57:59 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 908881608C1 for ; Tue, 15 Aug 2023 11:57:59 +0000 (UTC) X-FDA: 81126190278.07.887395A Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf10.hostedemail.com (Postfix) with ESMTP id 523E8C001D for ; Tue, 15 Aug 2023 11:57:55 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of tujinjiang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=tujinjiang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692100677; a=rsa-sha256; cv=none; b=S7CyHJyHYzOb3cEeDngNDNvZezoqo1jEFaR/Bz08B2XsbNyP13Fy7Is8Ai63ZKS+1TA73e FHt+Fb4qywmbWW0x7cIZCj/1XC0WlEV7lkeP2EaoskeAnJznlPS4Q5xN1EP5lDxee8EUs7 krHxdICQ0ROgCjyygBJJTUdJuok68EY= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of tujinjiang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=tujinjiang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692100677; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sOJwRWVbCMC8QCq703jqA0C4R5/n4HEDt6cLXNSSTDE=; b=xWESqjOiyFZBVycs/gf1oND8d23i7Kco2dgFm62TOvGqKuvBq67SQsRTM8PpcNhKghC3RY cL5SZKStCMhbjJnGDOAIc9qWayw0BA5lGR4xpN8doVrz4mY/1/xpsY2gAL5hgLepPefPDV sYLDA+YnG4Pw8M50gAocyiJMqLSEOjA= Received: from dggpeml500011.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RQ8nN5H8CztRw0; Tue, 15 Aug 2023 19:54:16 +0800 (CST) Received: from huawei.com (10.175.113.32) by dggpeml500011.china.huawei.com (7.185.36.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 15 Aug 2023 19:57:52 +0800 From: Jinjiang Tu To: , , , , CC: Subject: [PATCH 2/6] mm/page_owner: show modules allocating pages when oom occurred Date: Tue, 15 Aug 2023 20:52:47 +0800 Message-ID: <20230815125251.2865852-3-tujinjiang@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815125251.2865852-1-tujinjiang@huawei.com> References: <20230815125251.2865852-1-tujinjiang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500011.china.huawei.com (7.185.36.84) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 523E8C001D X-Stat-Signature: ozeoxc7srot6xc81iri1qk53ow54aekt X-HE-Tag: 1692100675-252701 X-HE-Meta: U2FsdGVkX1/AazssRrwMv4w4aFvME/r+jcEnaeFFsdSWS31gag0la11EUaW+Nx14jT7eds2LspOFFoNvlMxY3VV3QR2J1UPCdVj6qF2wO258ClULFUEgZlUPKqa2R6auWufunPAGBNcPr5IGeYjT3fk+e+PH+s62R+HA4zmBhVnIBMvIxQ00VKwseS2L/DpZP1bhRnfVfMmBZ/K1vuKkBKccmL6DgEp+3AdsnVV0EteT7FUFBYYcs6UGXyIDmiZyo6ms32N5devfZjiddC88V/j9eRPwWg7ldPPdUvqWnB2Wy/IuSKlHVMk4cnqITfpO67UoN9ati6z8i8s9QGNBjqd977J9CMqK3EL9t/+UAFV3zUNSlO5yrZ71Dj04gABLrcxdmL8W/yEDH3dMfpCij6e0xB1rHwxOXwlVreBXEdh8UxClWVAcz+tsxGZ8U5bmdMTabP1bAQKOsFxYxjKzhWDqF6Q2LaEiE2xts82BOIyeDuS0SBWuVRKHKffD3dM/pgSoHZ11bcSrHscYzDMwgpQmnJ8CEPCjOngjKf1XORLPQW14c2dz2dY8a+davnjdmBR/rzxuWB7TfCIe+Ah7F4qRE1EMwCyn7Nc0wAKOs70qUhIBr4Z6QUqbYpkR5SxEF1HNulBsElS1q0pM0vVGogZs2SY3OKF4oiF358wBEQK5j+lYzJ6mGCUbLZf1T6HrM1FJBlZZml9yH+xi6nLFG0mLJWAKMIA9Ii5rxEv5RvhSelTUXlrT6VYND/JQeFXh3hZLad4PItBNTobipV/ML8aA4D8+CJ0n8LCTFRmYbPbwcDpOyR5EWUSvrWWwVMLG5Lr/cM22CJkz/ObZ2Wn5RrLvrkF5lTl6Iu7SFm59FkbQPw5+4SXllHNBsWQMtJltJg3f4vixPmKfEvQl/HEFPsQuamBRxovIIYrgnSoeoD9jXJ5C7ls6GZE3aioIIkCp6NlpwvaUWwiET1HVB49 7PqrK7sy 1+P4/DSaRxAtx2UEOHglFNka8sgMWUh/H6HXquPr29PSdurXHjwdRyc/qKLYT1FxaA7ICzEyJxPqwceaaTxrDEe+I0kNBaGpUyIvUX9mIWuuJkjngGfj5BrPbTxxjBqrbWR2HEeQE7HL+uPpt4g9jhaVs3MjYdxYjKPvOBq36ohuszAtYRBXJ3bNtlSZkxRz+cvXv 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: This patch records the pages allocated by each module and dump the modules when oom occurred. The dump info is as follows: -------------------------------- Modules state: module nr_pages_allocated: ext4 14383 mbcache 9 jbd2 94 -------------------------------- Signed-off-by: Jinjiang Tu --- include/linux/module.h | 4 ++++ kernel/module/Makefile | 1 + kernel/module/main.c | 4 ++++ kernel/module/page_owner.c | 38 ++++++++++++++++++++++++++++++++++++++ mm/page_owner.c | 18 ++++++++++++++---- 5 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 kernel/module/page_owner.c diff --git a/include/linux/module.h b/include/linux/module.h index a98e188cf37b..be374968cbdb 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -583,6 +583,10 @@ struct module { #ifdef CONFIG_DYNAMIC_DEBUG_CORE struct _ddebug_info dyndbg_info; #endif + +#ifdef CONFIG_PAGE_OWNER + atomic_t nr_pages_allocated; +#endif } ____cacheline_aligned __randomize_layout; #ifndef MODULE_ARCH_INIT #define MODULE_ARCH_INIT {} diff --git a/kernel/module/Makefile b/kernel/module/Makefile index a10b2b9a6fdf..b973a3956131 100644 --- a/kernel/module/Makefile +++ b/kernel/module/Makefile @@ -23,3 +23,4 @@ obj-$(CONFIG_KGDB_KDB) += kdb.o obj-$(CONFIG_MODVERSIONS) += version.o obj-$(CONFIG_MODULE_UNLOAD_TAINT_TRACKING) += tracking.o obj-$(CONFIG_MODULE_STATS) += stats.o +obj-$(CONFIG_PAGE_OWNER) += page_owner.o diff --git a/kernel/module/main.c b/kernel/module/main.c index 59b1d067e528..e021c7f6dd24 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -2888,6 +2888,10 @@ static int load_module(struct load_info *info, const char __user *uargs, init_param_lock(mod); +#ifdef CONFIG_PAGE_OWNER + atomic_set(&mod->nr_pages_allocated, 0); +#endif + /* * Now we've got everything in the final locations, we can * find optional sections. diff --git a/kernel/module/page_owner.c b/kernel/module/page_owner.c new file mode 100644 index 000000000000..bcf2a15e7ed3 --- /dev/null +++ b/kernel/module/page_owner.c @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include +#include "internal.h" + +static int po_oom_notify(struct notifier_block *self, + unsigned long val, void *data) +{ + struct module *mod; + int nr; + int ret = notifier_from_errno(0); + + preempt_disable(); + pr_info("Modules state:\n"); + pr_info("module nr_page_allocated\n"); + list_for_each_entry_rcu(mod, &modules, list) { + nr = atomic_read(&mod->nr_pages_allocated); + if (nr <= 0) + continue; + + pr_info("%-20s %d\n", mod->name, nr); + } + preempt_enable(); + + return ret; +} + +static struct notifier_block po_oom_nb = { + .notifier_call = po_oom_notify, + .priority = 0 +}; + +void po_register_oom_notifier(void) +{ + if (register_oom_notifier(&po_oom_nb)) + pr_warn("Failed to register pageowner oom notifier\n"); +} diff --git a/mm/page_owner.c b/mm/page_owner.c index ef8fe1857d42..bbbf5a518a41 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -139,7 +139,7 @@ static noinline depot_stack_handle_t save_stack(gfp_t flags) } #ifdef CONFIG_MODULES -static char *find_module_name(depot_stack_handle_t handle) +static char *find_module_name(depot_stack_handle_t handle, int nr_pages) { int i; struct module *mod = NULL; @@ -158,6 +158,7 @@ static char *find_module_name(depot_stack_handle_t handle) if (!mod) continue; + atomic_add(nr_pages, &mod->nr_pages_allocated); return mod->name; } @@ -187,8 +188,11 @@ static inline void copy_module_name(struct page_owner *old_page_owner, { set_module_name(new_page_owner, old_page_owner->module_name); } + +void po_register_oom_notifier(void); #else -static inline char *find_module_name(depot_stack_handle_t handle) +static inline char *find_module_name(depot_stack_handle_t handle, + int nr_pages) { return NULL; } @@ -208,6 +212,10 @@ static inline void copy_module_name(struct page_owner *old_page_owner, struct page_owner *new_page_owner) { } + +void po_register_oom_notifier(void) +{ +} #endif void __reset_page_owner(struct page *page, unsigned short order) @@ -224,7 +232,7 @@ void __reset_page_owner(struct page *page, unsigned short order) return; handle = save_stack(GFP_NOWAIT | __GFP_NOWARN); - mod_name = find_module_name(handle); + mod_name = find_module_name(handle, -(1 << order)); for (i = 0; i < (1 << order); i++) { __clear_bit(PAGE_EXT_OWNER_ALLOCATED, &page_ext->flags); page_owner = get_page_owner(page_ext); @@ -245,7 +253,7 @@ static inline void __set_page_owner_handle(struct page_ext *page_ext, u64 ts_nsec = local_clock(); char *mod_name; - mod_name = find_module_name(handle); + mod_name = find_module_name(handle, 1 << order); for (i = 0; i < (1 << order); i++) { page_owner = get_page_owner(page_ext); @@ -809,6 +817,8 @@ static int __init pageowner_init(void) debugfs_create_file("page_owner", 0400, NULL, NULL, &proc_page_owner_operations); + po_register_oom_notifier(); + return 0; } late_initcall(pageowner_init) From patchwork Tue Aug 15 12:52:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjiang Tu X-Patchwork-Id: 13353759 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEBE7C0015E for ; Tue, 15 Aug 2023 11:58:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ABD0C8D000B; Tue, 15 Aug 2023 07:58:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A6CFD8D0008; Tue, 15 Aug 2023 07:58:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 941798D000C; Tue, 15 Aug 2023 07:58:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 839BE8D000B for ; Tue, 15 Aug 2023 07:58:00 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 54F671C9CB6 for ; Tue, 15 Aug 2023 11:58:00 +0000 (UTC) X-FDA: 81126190320.29.886871B Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf12.hostedemail.com (Postfix) with ESMTP id 321104000A for ; Tue, 15 Aug 2023 11:57:56 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of tujinjiang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=tujinjiang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692100678; a=rsa-sha256; cv=none; b=nYwFwWACr+E/rGPm8eX1K2AaplP4dslsCxKlDZfPEUiWR0b6QeWv3ExZVx8vkvgUGscEGg FFd2BWh3dclDwL8D6oO3Z+7VdZUDA52p+hxJBXOJp9esOE0cl9PI7Ch2zfiFXavEfWLFkp XrnUmYG6AHWS4pdFJSY6VEFx0NZLgjM= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of tujinjiang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=tujinjiang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692100678; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AmqJMJDCupGWzT3gJ/B0Aeo1P7ty/LJ9a5q1IP9DHUQ=; b=m41oe01C5Y0oqiHKjLauNEHV8Uv84qNPAIZHcwqJnOYtkH9KWen7xY1EQgFhPPTCTQVYoD 84IicIlCEtakVV3EsRRuzuHf3VXQERz/KAxWMeCUJu2AUk6vh6oOmpvxC8uG/aepEqxvtl Iupq4CQtK49vc5R/5EKuG9+mXeQ1zbg= Received: from dggpeml500011.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RQ8r10p1SzrSBP; Tue, 15 Aug 2023 19:56:33 +0800 (CST) Received: from huawei.com (10.175.113.32) by dggpeml500011.china.huawei.com (7.185.36.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 15 Aug 2023 19:57:52 +0800 From: Jinjiang Tu To: , , , , CC: Subject: [PATCH 3/6] tools/vm/page_owner_sort: support for selecting by module name Date: Tue, 15 Aug 2023 20:52:48 +0800 Message-ID: <20230815125251.2865852-4-tujinjiang@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815125251.2865852-1-tujinjiang@huawei.com> References: <20230815125251.2865852-1-tujinjiang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500011.china.huawei.com (7.185.36.84) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 321104000A X-Stat-Signature: sge1w95ck8jtgs498yfj91y1rxrrhrh9 X-HE-Tag: 1692100676-826273 X-HE-Meta: U2FsdGVkX19/T8vqjbD/4rTeuhhvC/5KHIumZeDyoGQ+i4bXu31J3N8VxR24x1Ffiw8cyOuj7PFs64QWdraIHA4dLgOH/UFGiqERW57sez/oqW0VI4VvHQ7/0tZzo7KkNk/MBcNc8o7RUg7bmt+UvMr3GHP4j2e2VKoGLGTQGwxSawiLDS0+SLny+tlxBTUyt2wjiIlAhpl0miyI3lmKfS9fhoDzbOELVJayls+JEwCcRG1WhJAjev1e1p6NSuo5oPCurdlIm0JESFLT7DX7KHKra9U4gV4OodCvzu7GB84H/BujyYR9nMEE2jvdfGQJOC44rZ38WGFBc+SPDLhvXIMsUOTcM2406czxHWjo2ISdlXYbwxWC27xqkI9j8k1VFLj7kaKZqAGeLoykHNIk6CNUKCYoB3y7oVkEogq/7i0prCTUgiW8/XtdAB5UwsB0/PJkJFfEjXZHFXibn1w3vkDldT244ws7kQnB61/yiRPB7C6Iwi3r5C/F3Dqcf1OLNK/88q1smLhmRE+7Sq6pgH4MyZ+tppLpkDfsTZ7+la0qxUP6T6CqfmaLeUKXfFhYD7Tj8o2q1VtOa7munzN/WyNcpkc2poLTdaQZCf6D/+1G5oZ1HUHLx2bFxcTJtpJ3AQvDSSIPa7uubJLc04QmFV/UfFrTZUfshtgB5VvpQEBoYUm6lVoNACtcG+zF9sL55BtNREo4orrVMCJh/rL5It9ORcnEWEvbp8LZGD5UzLayRsIwwbQ8Rj0/PlwyYoBka9oqbQImn+EpUCexl0nQqdbtZjy0kyVGv9O5mQ7awmRHN3SJEOawzNaBuYIOy/sPut6ayqK137qH2uhFucOCFpFJ+6LfwX/Oxwcjdb0KDtI+ZqXCLOGLXnpZEvijC+nw1OGN0Lf9hqaUhHhOk/k3RyjPzQ5PgoGIX/Z7p8bEdxZn+Cm2mgXmU808ki2J0kyldgO/fduxXcXiGUA3zwr CtmkwJnq LD2Bi1CMejCengsbBdoFCmC+wHe4JrWSkhGHDi5LKDhu3ArPudnXifjM0RvFg+7c0Jlo4f7na22N/2Y8kzLRQpW5rJkhdfrmoFEIK+pykNywvloy/eJG2sOsUNb1O9Vmq2NbpyVwIRrDeqtX4K7ZypPkrB9r0V1Xf5rfcy2KMoIhlmzr4HdHHVQd2yqMzS8koohmG 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: Add -M and --module options to support selecting modules. -M option allows to filtering all the items except the ones allcating by modules. --module option allows to only select one or more modules. For example, --module=mod1,mod2 will only select items allocating by mod1 or mod2. Signed-off-by: Jinjiang Tu --- tools/mm/page_owner_sort.c | 84 +++++++++++++++++++++++++++++++++----- 1 file changed, 73 insertions(+), 11 deletions(-) diff --git a/tools/mm/page_owner_sort.c b/tools/mm/page_owner_sort.c index 99798894b879..6fd689199789 100644 --- a/tools/mm/page_owner_sort.c +++ b/tools/mm/page_owner_sort.c @@ -27,6 +27,7 @@ #define true 1 #define false 0 #define TASK_COMM_LEN 16 +#define MODULE_NAME_LEN (64 - sizeof(unsigned long)) struct block_list { char *txt; @@ -40,12 +41,14 @@ struct block_list { pid_t pid; pid_t tgid; int allocator; + char *module; }; enum FILTER_BIT { FILTER_UNRELEASE = 1<<1, FILTER_PID = 1<<2, FILTER_TGID = 1<<3, - FILTER_COMM = 1<<4 + FILTER_COMM = 1<<4, + FILTER_MODULE = 1<<5 }; enum CULL_BIT { CULL_UNRELEASE = 1<<1, @@ -74,9 +77,11 @@ struct filter_condition { pid_t *pids; pid_t *tgids; char **comms; + char **modules; int pids_size; int tgids_size; int comms_size; + int modules_size; }; struct sort_condition { int (**cmps)(const void *, const void *); @@ -91,6 +96,7 @@ static regex_t tgid_pattern; static regex_t comm_pattern; static regex_t ts_nsec_pattern; static regex_t free_ts_nsec_pattern; +static regex_t module_pattern; static struct block_list *list; static int list_size; static int max_size; @@ -100,10 +106,12 @@ static bool debug_on; static void set_single_cmp(int (*cmp)(const void *, const void *), int sign); -int read_block(char *buf, char *ext_buf, int buf_size, FILE *fin) +int read_block(char *buf, char *ext_buf, char *mod_buf, int buf_size, FILE *fin) { char *curr = buf, *const buf_end = buf + buf_size; + char *mod_string = "Page allocated by module"; + mod_buf[0] = '\0'; while (buf_end - curr > 1 && fgets(curr, buf_end - curr, fin)) { if (*curr == '\n') { /* empty line */ return curr - buf; @@ -112,6 +120,10 @@ int read_block(char *buf, char *ext_buf, int buf_size, FILE *fin) strcpy(ext_buf, curr); continue; } + if (!strncmp(curr, mod_string, strlen(mod_string))) { + strcpy(mod_buf, curr); + continue; + } curr += strlen(curr); } @@ -401,6 +413,16 @@ static char *get_comm(char *buf) return comm_str; } +static char *get_module(char *buf) +{ + char *mod = malloc(MODULE_NAME_LEN); + + memset(mod, 0, MODULE_NAME_LEN); + search_pattern(&module_pattern, mod, buf); + + return mod; +} + static int get_arg_type(const char *arg) { if (!strcmp(arg, "pid") || !strcmp(arg, "p")) @@ -469,7 +491,24 @@ static bool match_str_list(const char *str, char **list, int list_size) return false; } -static bool is_need(char *buf) +static bool is_module_filtered(char *mod_buf) +{ + char *mod = get_module(mod_buf); + int ret = true; + + if (!strlen(mod)) + goto out; + + if (fc.modules_size == 0 || + match_str_list(mod, fc.modules, fc.modules_size)) + ret = false; + +out: + free(mod); + return ret; +} + +static bool is_need(char *buf, char *mod_buf) { __u64 ts_nsec, free_ts_nsec; @@ -484,6 +523,9 @@ static bool is_need(char *buf) !match_num_list(get_tgid(buf), fc.tgids, fc.tgids_size)) return false; + if (filter & FILTER_MODULE && is_module_filtered(mod_buf)) + return false; + char *comm = get_comm(buf); if ((filter & FILTER_COMM) && @@ -495,7 +537,7 @@ static bool is_need(char *buf) return true; } -static bool add_list(char *buf, int len, char *ext_buf) +static bool add_list(char *buf, int len, char *ext_buf, char *mod_buf) { if (list_size != 0 && len == list[list_size-1].len && @@ -508,7 +550,7 @@ static bool add_list(char *buf, int len, char *ext_buf) fprintf(stderr, "max_size too small??\n"); return false; } - if (!is_need(buf)) + if (!is_need(buf, mod_buf)) return true; list[list_size].pid = get_pid(buf); list[list_size].tgid = get_tgid(buf); @@ -530,6 +572,7 @@ static bool add_list(char *buf, int len, char *ext_buf) list[list_size].ts_nsec = get_ts_nsec(buf); list[list_size].free_ts_nsec = get_free_ts_nsec(buf); list[list_size].allocator = get_allocator(buf, ext_buf); + list[list_size].module = get_module(mod_buf); list_size++; if (list_size % 1000 == 0) { printf("loaded %d\r", list_size); @@ -681,19 +724,21 @@ static void usage(void) "-a\t\tSort by memory allocate time.\n" "-r\t\tSort by memory release time.\n" "-f\t\tFilter out the information of blocks whose memory has been released.\n" + "-M\t\tFilter out the information of blocks whose memory isn't allocated by modules.\n" "-d\t\tPrint debug information.\n" "--pid \tSelect by pid. This selects the information of blocks whose process ID numbers appear in .\n" "--tgid \tSelect by tgid. This selects the information of blocks whose Thread Group ID numbers appear in .\n" "--name \n\t\tSelect by command name. This selects the information of blocks whose command name appears in .\n" "--cull \tCull by user-defined rules. is a single argument in the form of a comma-separated list with some common fields predefined\n" "--sort \tSpecify sort order as: [+|-]key[,[+|-]key[,...]]\n" + "--module \tSelect by module. This selects the information of blocks whose memory is allocated by modules appear in .\n" ); } int main(int argc, char **argv) { FILE *fin, *fout; - char *buf, *ext_buf; + char *buf, *ext_buf, *mod_buf; int i, count; struct stat st; int opt; @@ -703,10 +748,11 @@ int main(int argc, char **argv) { "name", required_argument, NULL, 3 }, { "cull", required_argument, NULL, 4 }, { "sort", required_argument, NULL, 5 }, + { "module", required_argument, NULL, 6 }, { 0, 0, 0, 0}, }; - while ((opt = getopt_long(argc, argv, "adfmnprstP", longopts, NULL)) != -1) + while ((opt = getopt_long(argc, argv, "adfmnprstPM", longopts, NULL)) != -1) switch (opt) { case 'a': set_single_cmp(compare_ts, SORT_ASC); @@ -738,6 +784,11 @@ int main(int argc, char **argv) case 'n': set_single_cmp(compare_comm, SORT_ASC); break; + case 'M': + filter = filter | FILTER_MODULE; + fc.modules_size = 0; + fc.modules = NULL; + break; case 1: filter = filter | FILTER_PID; fc.pids = parse_nums_list(optarg, &fc.pids_size); @@ -774,6 +825,10 @@ int main(int argc, char **argv) exit(1); } break; + case 6: + filter = filter | FILTER_MODULE; + fc.modules = explode(',', optarg, &fc.modules_size); + break; default: usage(); exit(1); @@ -804,6 +859,8 @@ int main(int argc, char **argv) goto out_ts; if (!check_regcomp(&free_ts_nsec_pattern, "free_ts\\s*([0-9]*)\\s*ns")) goto out_free_ts; + if (!check_regcomp(&module_pattern, "Page allocated by module (.*)")) + goto out_module; fstat(fileno(fin), &st); max_size = st.st_size / 100; /* hack ... */ @@ -811,17 +868,18 @@ int main(int argc, char **argv) list = malloc(max_size * sizeof(*list)); buf = malloc(BUF_SIZE); ext_buf = malloc(BUF_SIZE); - if (!list || !buf || !ext_buf) { + mod_buf = malloc(BUF_SIZE); + if (!list || !buf || !ext_buf || !mod_buf) { fprintf(stderr, "Out of memory\n"); goto out_free; } for ( ; ; ) { - int buf_len = read_block(buf, ext_buf, BUF_SIZE, fin); + int buf_len = read_block(buf, ext_buf, mod_buf, BUF_SIZE, fin); if (buf_len < 0) break; - if (!add_list(buf, buf_len, ext_buf)) + if (!add_list(buf, buf_len, ext_buf, mod_buf)) goto out_free; } @@ -848,8 +906,10 @@ int main(int argc, char **argv) for (i = 0; i < count; i++) { if (cull == 0) { fprintf(fout, "%d times, %d pages, ", list[i].num, list[i].page_num); + if (strlen(list[i].module) != 0) + fprintf(fout, "allocated by module %s, ", list[i].module); print_allocator(fout, list[i].allocator); - fprintf(fout, ":\n%s\n", list[i].txt); + fprintf(fout, " :\n%s\n", list[i].txt); } else { fprintf(fout, "%d times, %d pages", @@ -880,6 +940,8 @@ int main(int argc, char **argv) free(buf); if (list) free(list); +out_module: + regfree(&module_pattern); out_free_ts: regfree(&free_ts_nsec_pattern); out_ts: From patchwork Tue Aug 15 12:52:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjiang Tu X-Patchwork-Id: 13353758 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26D08C04A6A for ; Tue, 15 Aug 2023 11:58:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 73B298D000A; Tue, 15 Aug 2023 07:58:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C49F8D0008; Tue, 15 Aug 2023 07:58:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B3F38D000B; Tue, 15 Aug 2023 07:58:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 450F08D0008 for ; Tue, 15 Aug 2023 07:58:00 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id EAAD5408B0 for ; Tue, 15 Aug 2023 11:57:59 +0000 (UTC) X-FDA: 81126190278.01.EA60246 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf04.hostedemail.com (Postfix) with ESMTP id 2EF2D4000A for ; Tue, 15 Aug 2023 11:57:56 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of tujinjiang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=tujinjiang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692100678; a=rsa-sha256; cv=none; b=C0Iwy/eCG0QzKdLhTNU4mHa2IihWIau6F5agvIdqpDAWBs7HqrRz4riF4a6UMp8Gw72aya W2vUPKjEG9tw153E5mBKWR3NiWpcSoVccyIB/RSl1SbD2cWjUGDLPyaauTFsp0XN/903S3 NZ6wRxARKSgBV6/rP9wSYEAZbCDzwQw= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of tujinjiang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=tujinjiang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692100678; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SyouQmDbo9ydF8jAbb2wKGNqt0xyDu8xZkF/Ds9sQtA=; b=0K24rCoi/JDiURZY+ok9DEPC6SaUd0md2llDO+xpgusFb0IMYvnZFHxjHyViosrgT8UWUG 2ibutD3cC1j3PW8NkopGbJ0zaG2PkudczPb0WsESlGev898O2SleVTC+HuP9LMwjF8NM53 XA9kj/WxvxKhTyVdIJTzF1WtUtL7iw8= Received: from dggpeml500011.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RQ8nV0P2VzNmln; Tue, 15 Aug 2023 19:54:22 +0800 (CST) Received: from huawei.com (10.175.113.32) by dggpeml500011.china.huawei.com (7.185.36.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 15 Aug 2023 19:57:52 +0800 From: Jinjiang Tu To: , , , , CC: Subject: [PATCH 4/6] tools/vm/page_owner_sort: support for culling by module name Date: Tue, 15 Aug 2023 20:52:49 +0800 Message-ID: <20230815125251.2865852-5-tujinjiang@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815125251.2865852-1-tujinjiang@huawei.com> References: <20230815125251.2865852-1-tujinjiang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500011.china.huawei.com (7.185.36.84) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 2EF2D4000A X-Stat-Signature: bbrttrra768et3x6izkhfwyougbc5sde X-HE-Tag: 1692100676-732341 X-HE-Meta: U2FsdGVkX18QzQIPnC2RWT4iC14rSaJmbMCVUvy8rH70Ywx9YWKjLui92NjhUqjAXAGWQZ+rFRDbQMTiXkmOjPlCnu77DZr32X9996nH4X86yGPtuz6u0FPK7s7pO06T2A1wmu6jiCVQ23Ifr6raEM7Pr37aXFbHf30F2nkCx3u8eg/r55AGxR+CYR4q9rq+k8evqeMI5kqaWmjdEtMHC9ReIe/+k/HxpiSy+Guct3p2pgEs9WWrO+60WBn9F9nJzlY7I2IwfIx9lUxio8q53BbISp80jtR8jTc6/g6k+vlHe1ZphHBlJFVJce7m9lfnM/ks8kB/vlI1EvELl7mCc6eVzRasIIDcve16ofKnyfs7vRU2udVWf4BAkpX9hO4HEqvWP9J44h/WYBl/URt8KWxcTJ82X2Vpp9w00UpS+fyp/gElHOXfnh3KDgTogxdKpF+AXy7/gqFLFM5ixLEmJeibMp5jYq4nta3amQKaHOScnkqRJskVDDU5X8sLuJrlKU8r3DDGpp9If7Ivn5mYh96FA14LQ96ANaEyV+nXBaNilp+1G7d5gz+1kS0/WljRyt0GLsyRO5dVpepvfX4rPhMnOYnzzIMmgixrFhtXHP1O8jTzxCHV60mLbK5Gr2TDv4bX6lQXbZiBM7UmZX3jucJ3C6+rLg41gEmqb7+MVIHRvuA5X6o4nDsKz5mO4Deu/Y0BBHdDGKXVUyBO1VBEhaQeCJl1nz4xlDW8hMfMOEveqPHNmzATGJI+MZBDyyBzs8iXbyo9Q7YaZTs1m3zFNZMQZttQ8OMKXEKHfqqZTQv/pbYHvv7RSdgT4OQDgJEVOS+YuNyOIJCQTy6DnVTFSIB/QLg09tBQ6sPFPiZ4oaoiG/6o6aqnd9e2QLoDosabXNx1vf9/xIEXk2fmPt475bInj3j4HO3QsUEarH3WPPPFY/t/LlK0/pY/lLQKif6jATAHmu5DBO8ccifK5mn GwOlCMuE jpYTKsHDliN+lhujBUq2aLk6b/ovuFT9zwyPUrcJubHDvNcwPFMyzUKjcfO1heOgvv6LkyGykw1iK9MZA1tIbi0Tzue25UOk0xF+CqOJxb0ndUdyGvOoX6lMTm1awOwvdvoO9csdTc4Tje/IEf2cZfrLVm1h6mQnyTV1MZix0+P5YoVIPp+jBBMDdEMxydWNF34Cq 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: The --cull option allows the items that have the same information to be culled, such as pid, command name, stacktrace. This patch supports new cull arg (i.e. module) to cull the items by who allocates the page. For example, with --cull=module option, the items will be culled as follows: 314842 times, 334218 pages, module: 202508 times, 206389 pages, module: ext4 16711 times, 16753 pages, module: zram For the first line, there is no string afther "module:", which means the pages are allocated by the kernel core, not by modules. Signed-off-by: Jinjiang Tu --- tools/mm/page_owner_sort.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tools/mm/page_owner_sort.c b/tools/mm/page_owner_sort.c index 6fd689199789..35acf6932d78 100644 --- a/tools/mm/page_owner_sort.c +++ b/tools/mm/page_owner_sort.c @@ -56,7 +56,8 @@ enum CULL_BIT { CULL_TGID = 1<<3, CULL_COMM = 1<<4, CULL_STACKTRACE = 1<<5, - CULL_ALLOCATOR = 1<<6 + CULL_ALLOCATOR = 1<<6, + CULL_MODULE = 1 << 7 }; enum ALLOCATOR_BIT { ALLOCATOR_CMA = 1<<1, @@ -67,7 +68,7 @@ enum ALLOCATOR_BIT { enum ARG_TYPE { ARG_TXT, ARG_COMM, ARG_STACKTRACE, ARG_ALLOC_TS, ARG_FREE_TS, ARG_CULL_TIME, ARG_PAGE_NUM, ARG_PID, ARG_TGID, ARG_UNKNOWN, ARG_FREE, - ARG_ALLOCATOR + ARG_ALLOCATOR, ARG_MODULE }; enum SORT_ORDER { SORT_ASC = 1, @@ -211,6 +212,13 @@ static int compare_release(const void *p1, const void *p2) return l1->free_ts_nsec ? 1 : -1; } +static int compare_module(const void *p1, const void *p2) +{ + const struct block_list *l1 = p1, *l2 = p2; + + return strcmp(l1->module, l2->module); +} + static int compare_cull_condition(const void *p1, const void *p2) { if (cull == 0) @@ -227,6 +235,8 @@ static int compare_cull_condition(const void *p1, const void *p2) return compare_release(p1, p2); if ((cull & CULL_ALLOCATOR) && compare_allocator(p1, p2)) return compare_allocator(p1, p2); + if ((cull & CULL_MODULE) && compare_module(p1, p2)) + return compare_module(p1, p2); return 0; } @@ -443,6 +453,8 @@ static int get_arg_type(const char *arg) return ARG_ALLOC_TS; else if (!strcmp(arg, "allocator") || !strcmp(arg, "ator")) return ARG_ALLOCATOR; + else if (!strcmp(arg, "module") || !strcmp(arg, "mod")) + return ARG_MODULE; else { return ARG_UNKNOWN; } @@ -601,6 +613,8 @@ static bool parse_cull_args(const char *arg_str) cull |= CULL_UNRELEASE; else if (arg_type == ARG_ALLOCATOR) cull |= CULL_ALLOCATOR; + else if (arg_type == ARG_MODULE) + cull |= CULL_MODULE; else { free_explode(args, size); return false; @@ -920,6 +934,8 @@ int main(int argc, char **argv) fprintf(fout, ", TGID %d", list[i].tgid); if (cull & CULL_COMM || filter & FILTER_COMM) fprintf(fout, ", task_comm_name: %s", list[i].comm); + if (cull & CULL_MODULE || filter & FILTER_MODULE) + fprintf(fout, ", module: %s", list[i].module); if (cull & CULL_ALLOCATOR) { fprintf(fout, ", "); print_allocator(fout, list[i].allocator); From patchwork Tue Aug 15 12:52:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjiang Tu X-Patchwork-Id: 13353757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51680C001DB for ; Tue, 15 Aug 2023 11:58:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E49E8D0001; Tue, 15 Aug 2023 07:58:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3418B8D000A; Tue, 15 Aug 2023 07:58:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 22FDC8D0008; Tue, 15 Aug 2023 07:58:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 100CE8D0001 for ; Tue, 15 Aug 2023 07:58:00 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id CA48D120B5C for ; Tue, 15 Aug 2023 11:57:59 +0000 (UTC) X-FDA: 81126190278.04.DC0E476 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf16.hostedemail.com (Postfix) with ESMTP id 3B20A180011 for ; Tue, 15 Aug 2023 11:57:56 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf16.hostedemail.com: domain of tujinjiang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=tujinjiang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692100677; a=rsa-sha256; cv=none; b=NTNrDtFB1+gUo+gQa6wAEm2lWiiUq0s4+Y84weYNmurS5XNxt9Q27LNbqoKp7ZVGmGKaLu CDti9t5crAoLoIVte2La37hrRvfpHuMYrgr2ZDGkS46StzGiBWm2El9kNmkLqCaDccqLYR tc8GhKzudDf05aQPcEs9pXUt3+YYyBI= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf16.hostedemail.com: domain of tujinjiang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=tujinjiang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692100677; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VR2wqDunnk+vkBNof130LBjS77jKWechGovbdZsUFho=; b=YsEsFHwyq48MtDsD4QzX2NZ7La3zvkg9Rv1+cIyHR0baxk9GwClCbIK8uULv52CXpzviQe N91iPQbLkWSsJA0ElH3QlWFFzAo7zc6iYh0De9JZGOGCxAr8NMGVGmHxNCT0GO+t0ZvH1Q kcd0cZTSHAX+vyCXiY5y3R+izKR1yCo= Received: from dggpeml500011.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RQ8nV39tczNmnP; Tue, 15 Aug 2023 19:54:22 +0800 (CST) Received: from huawei.com (10.175.113.32) by dggpeml500011.china.huawei.com (7.185.36.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 15 Aug 2023 19:57:53 +0800 From: Jinjiang Tu To: , , , , CC: Subject: [PATCH 5/6] tools/vm/page_owner_sort: support sorting by module name Date: Tue, 15 Aug 2023 20:52:50 +0800 Message-ID: <20230815125251.2865852-6-tujinjiang@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815125251.2865852-1-tujinjiang@huawei.com> References: <20230815125251.2865852-1-tujinjiang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500011.china.huawei.com (7.185.36.84) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 3B20A180011 X-Stat-Signature: 5jsfn54gswibyzkpr1pduhsq3wu4bakk X-Rspam-User: X-HE-Tag: 1692100676-111928 X-HE-Meta: U2FsdGVkX19SAQ0vFUWAiiUrhx2iDRvV0xZ2KA8/wyguSheVwPciXW+UNpk/yu7o9LTZiqB5b4fscHgmoF2ZJXnIdFAsVGKGTb4YPtCmkji8kbBcHhaEJu6qjRJXlrmGjJM209I+EgQYqMx8bfSFxQ8vACv9JGCzu/20r2+VvmR1ljznYzqNfzwDfpQb6bPPKy66emPsJdUdIu0lnYtOriTLBKcyHGfC7GMUD/ZbegHkIdIrVtK2nwZ7nKtNEHBvxZ/E7kdoPGVtCo1gdqtk5fkNdnKK2pC6ufA/hixcgAFlGdmlG8bir1IcZ0SJ3o8w/dd2KlCiE7Pf+PfXXWQcwqjiU8AuLstAGoQQKCKEDRaFgS5F//2ibUUjkd5p+Lu1H5IdJG67dsjABBHP/A/LZY76E1a6+2Lu+UJnzTzqWfh/9iTB/4XakNKYPOQUjuGJjbxIP3E9gjZBZcJE9YHyPxm6xVA7/OcClmXJI3fPQ3VEQVzA5ORl59WzPXxOIFohNum+Sotu1TjRju1DRbv1ABXzWQ3UXO7wc+6KoJyjfyjRXoFvIGS0ZP7Pue+yXtJWCLeiOdBLrI2DhniZBbnrbPcJkOF7aCZscvbGPVkcCo9LhsRb8SEQ2i/pB+92WRMCTmFfEIOkdCC/kkympAVdtE8PBGcUva9xdlaD2HwNuvm+HAbdXiPaqQN2TVgpEBtDCEm8OkuJc4mQL4x1bC/LYK6BU3/Tp9ixsFcMc7QBe73BuT/bXss71RwUny3lHkuECyY/NC9CAc6TwYEcfkwS0G/61wZLDSaV3SE5QzePkP1dp4+OZn2LdStov5e9YzcqzRP1wLEBtW2gezJ3H5j+xSTeBT3qv32P/UlV+0EIB3LPX3h5j70z7TOGgDV9soe0+4zut/5jbeAlR3HI+SoGPK7SSBq4EVEbOTVQ8YRY6bzVaMzbBoROxgMaRQ6qmnhFqDPMC1E4lLnc/xygr2I qHasfpxh piE9u2fSXzxvBkv8QqxPK/JtSxVNJC557MpB9D1bEKuTG51mzB5WzSPtBHZ4WNrFcmLitde3dMUvcStxk9K+wMRTp4kWNVjbCorhD/gTsxMKh4njz8ihiTBPRa9Mhb+ajccV5E9s4twaESzzLYKa856YnDkQHJ/NSHE4lX3RzqInZxZf/vma4gRS9/NKHMOlEXOBn 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: This patch adds new argument (i.e. source) for --sort option, allows the items sorted by module name. Signed-off-by: Jinjiang Tu --- tools/mm/page_owner_sort.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/mm/page_owner_sort.c b/tools/mm/page_owner_sort.c index 35acf6932d78..c2dc0b58a214 100644 --- a/tools/mm/page_owner_sort.c +++ b/tools/mm/page_owner_sort.c @@ -679,6 +679,8 @@ static bool parse_sort_args(const char *arg_str) sc.cmps[i] = compare_txt; else if (arg_type == ARG_ALLOCATOR) sc.cmps[i] = compare_allocator; + else if (arg_type == ARG_MODULE) + sc.cmps[i] = compare_module; else { free_explode(args, size); sc.size = 0; From patchwork Tue Aug 15 12:52:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjiang Tu X-Patchwork-Id: 13353761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DABCCC04A94 for ; Tue, 15 Aug 2023 11:58:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 084408D000D; Tue, 15 Aug 2023 07:58:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 037A28D0008; Tue, 15 Aug 2023 07:58:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C93B38D000D; Tue, 15 Aug 2023 07:58:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B786A8D0008 for ; Tue, 15 Aug 2023 07:58:02 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 743BA1A0C04 for ; Tue, 15 Aug 2023 11:58:02 +0000 (UTC) X-FDA: 81126190404.16.95400D3 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf26.hostedemail.com (Postfix) with ESMTP id 197A414001A for ; Tue, 15 Aug 2023 11:57:59 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of tujinjiang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=tujinjiang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692100680; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TwVJ+gorvMrP60gLsXPGEKAmOkjMLywUTPVCX7Om7sU=; b=wN68L5GaTU2OKrQfAgDCmIE5SQrk7X1IsgjtzlfD2VyVAB8u/okVDFwlYbEGXiXUmeB+QQ iLxI5b3b7vC6sJ8u86Quifkb70RNTr9Mo6bVwzB+krT2bsww+Hk68UwlZtwtelGezakzuS fdcoAK+r+Ypxf//Gd2umZV15nyZK/Qc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692100680; a=rsa-sha256; cv=none; b=eOQcfEjwygZYhRDjbw3roLJMDL3vDgFm7/idDTnb5LTXp6wQ5TtnZRLE5UL+LvthcweG7p X3rXML/R9D3YBOi6Bu1pSyMAC+rtLIdeCuAfE5qh/QyDeFMI5OJRttbJfCFY8UEanCaU8h d1+Ospg+P/IfXR8H2PeJjBLYz30w4XA= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of tujinjiang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=tujinjiang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from dggpeml500011.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RQ8q96v19zVk1s; Tue, 15 Aug 2023 19:55:49 +0800 (CST) Received: from huawei.com (10.175.113.32) by dggpeml500011.china.huawei.com (7.185.36.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 15 Aug 2023 19:57:53 +0800 From: Jinjiang Tu To: , , , , CC: Subject: [PATCH 6/6] Documentation: update document for page_owner Date: Tue, 15 Aug 2023 20:52:51 +0800 Message-ID: <20230815125251.2865852-7-tujinjiang@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230815125251.2865852-1-tujinjiang@huawei.com> References: <20230815125251.2865852-1-tujinjiang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500011.china.huawei.com (7.185.36.84) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 197A414001A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: u7brgc64kr368j5p1xqdwbfsazuyeu6r X-HE-Tag: 1692100679-267926 X-HE-Meta: U2FsdGVkX1/UGO5ZLBuFnTiQhKxdFsPJTUCSU1czGWGEjLvNxb3a/NuefxD43fqVkMKtn7+7bUrLgKpIfPWArmWFrupEVMFucErSvml1Q8sL1srAsfA4xtdofIkYdONq+bdDT+OrSRc9ipHWcOL+FFBc0la5agHi2Eeu+01NS5hcJVpOlKMC1ScpK3kZDYuWCR5/8d8sJHSU+asSppIb+9lUZlpc36sN9c3zslVs5s9GssOEZKZ3nhb5Qo1ssc9uoL81twvT/R2IsEirGmC+A+UK2nopAUyDpl2mX//rK9F4KaZsrFefpxF3IKZC+4QW/L62IOrQBELVMC8S8xs7psl2MqPTwYgiSAuAaAdsSg4F9BIaTeKSNVY75gcKjtoi1RSy5rtN0wuHagCw1hJEpzyWbVX7/RQoag0LpwE9ja4JkmNrl9DjwsuXlru29ktd1glvyLeBKQRHUhBWsds69RynMeTtWDdbqtms6IA2LBkTbG/LVKtdMTY9czXRN6VOdD6gg2MBpo79/T4WY+246scT1Thdcf/iRuwsbuVC7S5gqiBxz4zX8iCzcu+WEvJNs5+d7Msy8VNs1gAiU7OFhKiPqEEVO7+vpKDJk/BK81GnRhDSzB41sOLzRqP+a4g3Ga8DBug243UKk580epRFjU1uvm+KpbcznatloN3U8OeS6rem7Cez/+xKijGDaZP/r8YP1QIXkfaZbEr7W5sRQ2z8a1kIou9yElgTCXIudAEJ85NDCi8qqFRvDxa9WKlCAUCj5IhG2UMfw2ymfGuBFW7fof3kvYJ/Z5lerRkqZdTKVTL6ly49xnsQC4rCgb6MZmwILY45IwLZjo742C3urbN9BPifuX3yPU3LpayH0SbTSMpZnQ/H9LoLwWjr9faSokOsfP6Qdk0++FG+WXCAannofVwKvi0TZgkYZ/m/D+P1Aij5sZJQ9zxF1z1/8bnhOoFplp/mu+PWIMo8cxX u0JrK6GY GT/+3WgeiQduFUUoI3RqCNZiT8OeYl7SAsdYPzMiS6ptjzqKIIAwz+c+xYvjW41m0drOxfknQ6H39zok2GDQjKXIGeq7FDoEmkY6F/W4b4leSIK87UVQRpixY2eBn008dgFESBSdf8MnD4vm0lSSdembQYFeMMxQ9zezvj5jnf2eVgxptox2MfnpkUf3MqZvxsZ1zc4ygf5WMNzmAdEBoXqClqrOsicKXAI6X 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: page_owner currently supports recording and filtering pages allocates/freed by modules. Also, page_owner supports dumping name and the nr of pages allocated for each module when oom occurs. Update the document for the new features. Signed-off-by: Jinjiang Tu --- Documentation/mm/page_owner.rst | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Documentation/mm/page_owner.rst b/Documentation/mm/page_owner.rst index 62e3f7ab23cc..2231c16cd993 100644 --- a/Documentation/mm/page_owner.rst +++ b/Documentation/mm/page_owner.rst @@ -54,6 +54,12 @@ are caught and marked, although they are mostly allocated from struct page extension feature. Anyway, after that, no page is left in un-tracking state. +page owner is able to track if the pages are allocated by modules. If a page +is allocated by a module, the information dumped from page_owner interface +will show the module name. Users can use the user-space helper to analyze the +allocation situation of modules. Besides, the modules that allocate pages will +be dumped when oom occurs. + Usage ===== @@ -142,6 +148,7 @@ Usage Filter: -f Filter out the information of blocks whose memory has been released. + -M Filter out the information of blocks whose memory isn't allocated by modules. Select: --pid Select by pid. This selects the blocks whose process ID @@ -150,8 +157,10 @@ Usage group ID numbers appear in . --name Select by task command name. This selects the blocks whose task command name appear in . + --module Select by module. This selects the information of blocks whose + memory is allocated by modules appear in . - , , are single arguments in the form of a comma-separated list, + , , , are single arguments in the form of a comma-separated list, which offers a way to specify individual selecting rules. @@ -175,6 +184,7 @@ STANDARD FORMAT SPECIFIERS ft free_ts timestamp of the page when it was released at alloc_ts timestamp of the page when it was allocated ator allocator memory allocator for pages + mod module the name of the module that the page is allocated by For --cull option: @@ -185,3 +195,4 @@ STANDARD FORMAT SPECIFIERS f free whether the page has been released or not st stacktrace stack trace of the page allocation ator allocator memory allocator for pages + mod module the name of the module that the page is allocated by