From: Jinjiang Tu <tujinjiang@huawei.com>
To: <linux-mm@kvack.org>, <akpm@linux-foundation.org>,
<wangkefeng.wang@huawei.com>, <sunnanyong@huawei.com>,
<liushixin2@huawei.com>
Cc: <tujinjiang@huawei.com>
Subject: [PATCH 4/6] tools/vm/page_owner_sort: support for culling by module name
Date: Tue, 15 Aug 2023 20:52:49 +0800 [thread overview]
Message-ID: <20230815125251.2865852-5-tujinjiang@huawei.com> (raw)
In-Reply-To: <20230815125251.2865852-1-tujinjiang@huawei.com>
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 <tujinjiang@huawei.com>
---
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);
--
2.25.1
next prev parent reply other threads:[~2023-08-15 11:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-15 12:52 [PATCH 0/6] page_owner: support filtering by module Jinjiang Tu
2023-08-15 12:52 ` [PATCH 1/6] mm/page_owner: support identifying pages allocated by modules Jinjiang Tu
2023-08-15 12:52 ` [PATCH 2/6] mm/page_owner: show modules allocating pages when oom occurred Jinjiang Tu
2023-08-15 14:24 ` kernel test robot
2023-08-15 15:48 ` kernel test robot
2023-08-15 12:52 ` [PATCH 3/6] tools/vm/page_owner_sort: support for selecting by module name Jinjiang Tu
2023-08-15 12:52 ` Jinjiang Tu [this message]
2023-08-15 12:52 ` [PATCH 5/6] tools/vm/page_owner_sort: support sorting " Jinjiang Tu
2023-08-15 12:52 ` [PATCH 6/6] Documentation: update document for page_owner Jinjiang Tu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230815125251.2865852-5-tujinjiang@huawei.com \
--to=tujinjiang@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=liushixin2@huawei.com \
--cc=sunnanyong@huawei.com \
--cc=wangkefeng.wang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox