From nobody Fri Oct 2 09:21:37 2026 Received: from out-171.mta0.migadu.com (out-171.mta0.migadu.com [91.218.175.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CA3B397B1B for ; Mon, 3 Aug 2026 06:21:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785738119; cv=none; b=jn49na2TRquQnqgBnWR8MLksmv5LaDk7myZcXPHd1TtW7pdOTYJT13YR/ZGc+OJDgsrh1nFlImw09pAJLbHxSsCdYELjy4pHXhe9a01Wp+o2UA3k72Zj74whUa8z9jxqSB2AkBehV1RSI3Q0z3E/x5qz4nrQLuZjV5fsoRhDwX0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785738119; c=relaxed/simple; bh=4DyyJbipMEPACZ2LD/I923Gcn9JElwaTtLTVtkRNdnk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iGiSnNl3i0PRqMGOB9leiVWBIUE1gk1Qvzzip9QES5sZ40FgcfMqO+walf4NUf9Utn3mxSDEAb/u/LlFXLw4ialM5j4k1CFZOwcj/a/MEAkxbp/K7MVLmvnSDOqk3jAaoWOnm/0AyWxXHJ0VXz0aEIvGeBDNxQlEW25wGoQycgk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=P06mjlhE; arc=none smtp.client-ip=91.218.175.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="P06mjlhE" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785738115; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0NUjMF0YZdO+mWLr8nRUv6rJ891UqYSF7C3pZ4ivN0E=; b=P06mjlhEuN+V17oxIDVJfMATXr41BvX4ARgCP6fw47r45jdjZnHiVfGlCJmOyapK1ZEkIF eDeARBohXJIE+gxZUqW6eLr/vAVNmbtXx3aEKKGl9PPyCCUKK8uFTSBYoj2/MQpLgckMw+ teIp1bU31RMRj+W+yBnFcP1bUJKZUvg= From: Ye Liu To: Andrew Morton Cc: Ye Liu , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Shuah Khan , linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3] tools/mm/page_owner_sort: fix --sort option being silently ignored Date: Mon, 3 Aug 2026 14:20:54 +0800 Message-Id: <20260803062056.1518070-2-ye.liu@linux.dev> In-Reply-To: <20260803062056.1518070-1-ye.liu@linux.dev> References: <20260803062056.1518070-1-ye.liu@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Ye Liu When --sort is used without any short option (-a, -m, -p, etc.), compare_flag remains COMP_NO_FLAG. The switch (compare_flag) then falls through to the COMP_NUM case and calls set_single_cmp(), which unconditionally overwrites the sort conditions that parse_sort_args() already configured. This makes --sort silently ineffective unless a short option is also supplied. Split COMP_NO_FLAG out of the COMP_NUM fallthrough so that --sort is respected when no short option is present. Reproduction: # Before fix: ascending order (ignored --sort=3D-pid) ./page_owner_sort --sort=3D-pid input.txt output.txt # After fix: descending order as expected Signed-off-by: Ye Liu --- tools/mm/page_owner_sort.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/mm/page_owner_sort.c b/tools/mm/page_owner_sort.c index 35d3d254941c..3c86c8d0618c 100644 --- a/tools/mm/page_owner_sort.c +++ b/tools/mm/page_owner_sort.c @@ -821,6 +821,10 @@ int main(int argc, char **argv) set_single_cmp(compare_stacktrace, SORT_ASC); break; case COMP_NO_FLAG: + if (sc.size > 0) + break; + set_single_cmp(compare_num, SORT_DESC); + break; case COMP_NUM: set_single_cmp(compare_num, SORT_DESC); break; --=20 2.25.1 From nobody Fri Oct 2 09:21:37 2026 Received: from out-183.mta0.migadu.com (out-183.mta0.migadu.com [91.218.175.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6137E395AC6; Mon, 3 Aug 2026 06:22:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.183 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785738124; cv=none; b=pMop3XoP3AmWvEh9blf0Ua0mWYQO97G/OXq4rg62rBihTJ4pwAmMDD5QgWDbsjRRBFceQK25h5A6Pa7DX/sX+jb+UE3T4VH6OVE0XCcygMn1gN/hSPx1AyvZxSzY/ggNByU5+I+iCduLWVppsihEp3E7ccclte4x1bZ/b6tCb8A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785738124; c=relaxed/simple; bh=xRGBANW9bcYijvcSkfg5CGZTCw4yo15w6eJPXxAvOAQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NLieABh9y+hLDKJDmTJDhVppwL1ZEpIC/URzbj7ce/WJ31KTum/qhksec0g70R5z1j+pXCKeGDmAXADRu4YL1Ikv0bFz4bOYIDRq7J58QOHR0Nclrn5L3DXbDsO9KPWXLfdY0yI8KG7/JyKuS07TCawbAiwve4U5Fw1kSPM1CfA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=KCU29XDw; arc=none smtp.client-ip=91.218.175.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="KCU29XDw" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785738120; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3uU5YwZr2W4zWFkp8ifsuxS5rKiKev6qcptuc9TGJzI=; b=KCU29XDwBtUUAwWlG8F2bF0vUhkzQLVh1r7/SIjTAQB86VLoaMs9Gs/wUcftwof0gk2dpr NyX9z0nwLSXzZ8myut6o/X/6soTDQMbeGd/Jw9CSSbR/o4DKxGgdUjjaWrKbjMxyOO6Mza zVCOf3Vt3LRp+NVF3BadXueg2vEXsuc= From: Ye Liu To: Andrew Morton , David Hildenbrand , Jonathan Corbet Cc: Ye Liu , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Shuah Khan , linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] tools/mm/page_owner_sort: add module name sort/cull/filter support Date: Mon, 3 Aug 2026 14:20:55 +0800 Message-Id: <20260803062056.1518070-3-ye.liu@linux.dev> In-Reply-To: <20260803062056.1518070-1-ye.liu@linux.dev> References: <20260803062056.1518070-1-ye.liu@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Ye Liu Page owner stack traces already contain kernel module names in the "function+0xNN/0xNN [module]" format produced by %pS, but page_owner_sort has no way to sort, cull, or filter by module. Extract the first module name from each record's stack trace using an anchored regex that matches the stack trace frame format "+0x[0-9a-f]+/0x[0-9a-f]+\\s*\\[([a-zA-Z0-9_-]+)\\]". The regex is anchored to the stack trace frame to avoid false matches on kernel thread comm names such as [khugepaged] that appear in the record header. The character class includes '-' so modules with hyphens (e.g. aa-bb-cc) are correctly matched. Records whose stack traces contain no module frames are assigned "vmlinux". New options: -M Sort by module name --sort=3Dmod Sort by module name (supports +/- prefix) --cull=3Dmod Cull (aggregate) by module name --module Filter to records matching the given module(s) The module field is also printed in cull output when relevant. Signed-off-by: Ye Liu --- Documentation/mm/page_owner.rst | 8 ++- tools/mm/page_owner_sort.c | 122 +++++++++++++++++++++++++++----- 2 files changed, 110 insertions(+), 20 deletions(-) diff --git a/Documentation/mm/page_owner.rst b/Documentation/mm/page_owner.= rst index a6bd3fe6423a..bd027377dff6 100644 --- a/Documentation/mm/page_owner.rst +++ b/Documentation/mm/page_owner.rst @@ -199,6 +199,7 @@ Usage -p Sort by pid. -P Sort by tgid. -n Sort by task command name. + -M Sort by module name. -r Sort by memory release time. -s Sort by stack trace. -t Sort by times (default). @@ -240,8 +241,10 @@ Usage group ID numbers appear in . --name Select by task command name. This selects the blocks wh= ose task command name appear in . + --module Select by module name. This selects the blocks whose + module name appear in . =20 - , , are single arguments in the form of a c= omma-separated list, + , , , are single arguments in the = form of a comma-separated list, which offers a way to specify individual selecting rules. =20 =20 @@ -249,6 +252,7 @@ Usage ./page_owner_sort --pid=3D1 ./page_owner_sort --tgid=3D1,2,3 ./page_owner_sort --name name1,name2 + ./page_owner_sort --module xfs,ext4 =20 STANDARD FORMAT SPECIFIERS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D @@ -265,6 +269,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 kernel module name =20 For --cull option: =20 @@ -275,6 +280,7 @@ 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 kernel module name =20 Filtering page_owner output =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D diff --git a/tools/mm/page_owner_sort.c b/tools/mm/page_owner_sort.c index 3c86c8d0618c..70d1c76561e8 100644 --- a/tools/mm/page_owner_sort.c +++ b/tools/mm/page_owner_sort.c @@ -25,11 +25,13 @@ #include =20 #define TASK_COMM_LEN 16 +#define MODULE_NAME_LEN 64 =20 struct block_list { char *txt; char *comm; // task command name char *stacktrace; + char *module; // kernel module name __u64 ts_nsec; int len; int num; @@ -41,7 +43,8 @@ struct block_list { enum FILTER_BIT { FILTER_PID =3D 1<<1, FILTER_TGID =3D 1<<2, - FILTER_COMM =3D 1<<3 + FILTER_COMM =3D 1<<3, + FILTER_MODULE =3D 1<<4 }; =20 enum FILTER_RESULT { @@ -55,7 +58,8 @@ enum CULL_BIT { CULL_TGID =3D 1<<2, CULL_COMM =3D 1<<3, CULL_STACKTRACE =3D 1<<4, - CULL_ALLOCATOR =3D 1<<5 + CULL_ALLOCATOR =3D 1<<5, + CULL_MODULE =3D 1<<6 }; enum ALLOCATOR_BIT { ALLOCATOR_CMA =3D 1<<1, @@ -65,7 +69,8 @@ enum ALLOCATOR_BIT { }; enum ARG_TYPE { ARG_TXT, ARG_COMM, ARG_STACKTRACE, ARG_ALLOC_TS, ARG_CULL_TIME, - ARG_PAGE_NUM, ARG_PID, ARG_TGID, ARG_UNKNOWN, ARG_ALLOCATOR + ARG_PAGE_NUM, ARG_PID, ARG_TGID, ARG_UNKNOWN, ARG_ALLOCATOR, + ARG_MODULE }; enum SORT_ORDER { SORT_ASC =3D 1, @@ -79,15 +84,18 @@ enum COMP_FLAG { COMP_STACK =3D 1<<3, COMP_NUM =3D 1<<4, COMP_TGID =3D 1<<5, - COMP_COMM =3D 1<<6 + COMP_COMM =3D 1<<6, + COMP_MODULE =3D 1<<7 }; 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 *); @@ -101,6 +109,7 @@ static regex_t pid_pattern; static regex_t tgid_pattern; static regex_t comm_pattern; static regex_t ts_nsec_pattern; +static regex_t module_pattern; static struct block_list *list; static int list_size; static int max_size; @@ -184,6 +193,13 @@ static int compare_comm(const void *p1, const void *p2) return strcmp(l1->comm, l2->comm); } =20 +static int compare_module(const void *p1, const void *p2) +{ + const struct block_list *l1 =3D p1, *l2 =3D p2; + + return strcmp(l1->module, l2->module); +} + static int compare_ts(const void *p1, const void *p2) { const struct block_list *l1 =3D p1, *l2 =3D p2; @@ -207,6 +223,8 @@ static int compare_cull_condition(const void *p1, const= void *p2) return compare_tgid(p1, p2); if ((cull & CULL_COMM) && compare_comm(p1, p2)) return compare_comm(p1, p2); + if ((cull & CULL_MODULE) && compare_module(p1, p2)) + return compare_module(p1, p2); if ((cull & CULL_ALLOCATOR) && compare_allocator(p1, p2)) return compare_allocator(p1, p2); return 0; @@ -411,9 +429,33 @@ static char *get_comm(char *buf) return comm_str; } =20 +static char *get_module(char *buf) +{ + char *module_str =3D malloc(MODULE_NAME_LEN); + regmatch_t pmatch[2]; + int val_len; + + if (!module_str) + return NULL; + memset(module_str, 0, MODULE_NAME_LEN); + if (regexec(&module_pattern, buf, 2, pmatch, REG_NOTBOL) !=3D 0 || pmatch= [1].rm_so =3D=3D -1) { + strcpy(module_str, "vmlinux"); + return module_str; + } + + val_len =3D pmatch[1].rm_eo - pmatch[1].rm_so; + if ((size_t)val_len >=3D MODULE_NAME_LEN) + val_len =3D MODULE_NAME_LEN - 1; + memcpy(module_str, buf + pmatch[1].rm_so, val_len); + module_str[val_len] =3D '\0'; + + return module_str; +} + static void free_block_list(struct block_list *block) { free(block->comm); + free(block->module); free(block->txt); } =20 @@ -433,6 +475,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; } @@ -483,25 +527,36 @@ static bool match_str_list(const char *str, char **li= st, int list_size) =20 static enum FILTER_RESULT filter_record(char *buf) { - char *comm; + char *comm, *module; =20 if ((filter & FILTER_PID) && !match_num_list(get_pid(buf), fc.pids, fc.pi= ds_size)) return FILTER_SKIP; if ((filter & FILTER_TGID) && !match_num_list(get_tgid(buf), fc.tgids, fc.tgids_size)) return FILTER_SKIP; - if (!(filter & FILTER_COMM)) + if (!(filter & (FILTER_COMM | FILTER_MODULE))) return FILTER_MATCH; =20 - comm =3D get_comm(buf); - if (!comm) - return FILTER_ERROR; - - if (!match_str_list(comm, fc.comms, fc.comms_size)) { + if (filter & FILTER_COMM) { + comm =3D get_comm(buf); + if (!comm) + return FILTER_ERROR; + if (!match_str_list(comm, fc.comms, fc.comms_size)) { + free(comm); + return FILTER_SKIP; + } free(comm); - return FILTER_SKIP; } - free(comm); + if (filter & FILTER_MODULE) { + module =3D get_module(buf); + if (!module) + return FILTER_ERROR; + if (!match_str_list(module, fc.modules, fc.modules_size)) { + free(module); + return FILTER_SKIP; + } + free(module); + } return FILTER_MATCH; } =20 @@ -547,6 +602,12 @@ static bool add_list(char *buf, int len, char *ext_buf) list[list_size].stacktrace++; list[list_size].ts_nsec =3D get_ts_nsec(buf); list[list_size].allocator =3D get_allocator(buf, ext_buf); + list[list_size].module =3D get_module(buf); + if (!list[list_size].module) { + fprintf(stderr, "Out of memory\n"); + free_block_list(&list[list_size]); + return false; + } list_size++; if (list_size % 1000 =3D=3D 0) { printf("loaded %d\r", list_size); @@ -573,6 +634,8 @@ static bool parse_cull_args(const char *arg_str) cull |=3D CULL_STACKTRACE; else if (arg_type =3D=3D ARG_ALLOCATOR) cull |=3D CULL_ALLOCATOR; + else if (arg_type =3D=3D ARG_MODULE) + cull |=3D CULL_MODULE; else { free_explode(args, size); return false; @@ -635,6 +698,8 @@ static bool parse_sort_args(const char *arg_str) sc.cmps[i] =3D compare_txt; else if (arg_type =3D=3D ARG_ALLOCATOR) sc.cmps[i] =3D compare_allocator; + else if (arg_type =3D=3D ARG_MODULE) + sc.cmps[i] =3D compare_module; else { free_explode(args, size); sc.size =3D 0; @@ -691,7 +756,8 @@ static void usage(void) "-p\t\t\tSort by pid.\n" "-P\t\t\tSort by tgid.\n" "-s\t\t\tSort by the stacktrace.\n" - "-t\t\t\tSort by number of times record is seen (default).\n\n" + "-t\t\t\tSort by number of times record is seen (default).\n" + "-M\t\t\tSort by module name.\n\n" "--pid \t\tSelect by pid. This selects the information" " of\n\t\t\tblocks whose process ID numbers appear in .\n" "--tgid \tSelect by tgid. This selects the information" @@ -700,10 +766,11 @@ static void usage(void) "--name \tSelect by command name. This selects the" " information\n\t\t\tof blocks whose command name appears in" " .\n" - "--cull \t\tCull by user-defined rules. is a " - "single\n\t\t\targument in the form of a comma-separated list " - "with some\n\t\t\tcommon fields predefined (pid, tgid, comm, " - "stacktrace, allocator)\n" + "--module \tSelect by module name. This selects the information= \n" + "\t\t\tof blocks whose module name appears in .\n" + "--cull \t\tCull by user-defined rules. is a single\n" + "\t\t\targument in the form of a comma-separated list with some\n" + "\t\t\tcommon fields predefined (pid, tgid, comm, stacktrace, allocator,= module)\n" "--sort \t\tSpecify sort order as: [+|-]key[,[+|-]key[,...]]\n" ); } @@ -721,13 +788,14 @@ 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 }, { "help", no_argument, NULL, 'h' }, { 0, 0, 0, 0}, }; =20 compare_flag =3D COMP_NO_FLAG; =20 - while ((opt =3D getopt_long(argc, argv, "admnpstPh", longopts, NULL)) != =3D -1) + while ((opt =3D getopt_long(argc, argv, "admnpstPMh", longopts, NULL)) != =3D -1) switch (opt) { case 'a': compare_flag |=3D COMP_ALLOC; @@ -753,6 +821,9 @@ int main(int argc, char **argv) case 'n': compare_flag |=3D COMP_COMM; break; + case 'M': + compare_flag |=3D COMP_MODULE; + break; case 'h': usage(); exit(0); @@ -792,6 +863,10 @@ int main(int argc, char **argv) exit(1); } break; + case 6: + filter =3D filter | FILTER_MODULE; + fc.modules =3D explode(',', optarg, &fc.modules_size); + break; default: usage(); exit(1); @@ -834,6 +909,9 @@ int main(int argc, char **argv) case COMP_COMM: set_single_cmp(compare_comm, SORT_ASC); break; + case COMP_MODULE: + set_single_cmp(compare_module, SORT_ASC); + break; default: usage(); exit(1); @@ -857,6 +935,8 @@ int main(int argc, char **argv) goto out_comm; if (!check_regcomp(&ts_nsec_pattern, "ts\\s*([0-9]*)\\s*ns")) goto out_ts; + if (!check_regcomp(&module_pattern, "\\+0x[0-9a-f]+/0x[0-9a-f]+\\s*\\[([a= -zA-Z0-9_-]+)\\]")) + goto out_module; =20 fstat(fileno(fin), &st); max_size =3D st.st_size / 100; /* hack ... */ @@ -915,6 +995,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); @@ -935,6 +1017,8 @@ int main(int argc, char **argv) free_block_list(&list[i]); free(list); } +out_module: + regfree(&module_pattern); out_ts: regfree(&ts_nsec_pattern); out_comm: --=20 2.25.1 From nobody Fri Oct 2 09:21:37 2026 Received: from out-189.mta0.migadu.com (out-189.mta0.migadu.com [91.218.175.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9AAF9396D36 for ; Mon, 3 Aug 2026 06:22:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785738127; cv=none; b=SIA3YMGdR7C8KICP1SeM9GSf3XI3/2lDznDrvIM0HqrO+z3kNQF5B1+l37zNrq/xPhQ6crmOBoTsRXNqxr4eAKh8cjH0pMzrZkg7vUlpte2JonTuKnmceTuBS3JsR8rxD87Wf8ZmsN/Zk1+g2KxMj3lpDdRI8WIYuMaL80UPqs0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785738127; c=relaxed/simple; bh=RGVucR04hfZ25inLk7EYpUcqpdjuyQS/+ajU7ajzzrQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bRRO+BHyap/fNaCUg8O+Rf/xN19kKXRNb+gGycWXcUF0TI1WucpGpwK9ICLDRBh1hmRu7BBvEMnWp8yHK+eRGUb/hy5BcRLnuTNFwoudzUVmMqyos3H2W5ENjeVpJTv4Pysdzqs1rNrZq/UiXKlMS3MnHWPOJn3I8vFrH/6MRkE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=QR4RRCzo; arc=none smtp.client-ip=91.218.175.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="QR4RRCzo" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785738123; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l14XFaHja8SkCVrzQL34bHRSsjPVNxuVLQml/d9+YaA=; b=QR4RRCzoJMvQic8P0H2GCo2necBHge0T2l4fn2VBtwgq8BASSaU3qhIbt2jHuC1ARmESLP XDq7v2vSz4XRM7vXN/Pc2J1+9z+j0yezogPli2LhV8Jl0QSD9h5UdHBx5IhW48my8TRLo4 JIbg7JU9CGdrCIhEKN3Eecig49j4bMw= From: Ye Liu To: Andrew Morton Cc: Ye Liu , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonathan Corbet , Shuah Khan , linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] tools/mm/page_owner_sort: show available sort keys in usage text Date: Mon, 3 Aug 2026 14:20:56 +0800 Message-Id: <20260803062056.1518070-4-ye.liu@linux.dev> In-Reply-To: <20260803062056.1518070-1-ye.liu@linux.dev> References: <20260803062056.1518070-1-ye.liu@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Ye Liu The --sort option accepts abbreviated or complete key names, but the usage text never listed them. Users had to read the source or the documentation to discover valid keys. List all available keys (full form and abbreviation) with a brief description and examples directly in the --sort help section. Signed-off-by: Ye Liu Acked-by: David Hildenbrand (Arm) --- tools/mm/page_owner_sort.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/mm/page_owner_sort.c b/tools/mm/page_owner_sort.c index 70d1c76561e8..c5bc3b524c0a 100644 --- a/tools/mm/page_owner_sort.c +++ b/tools/mm/page_owner_sort.c @@ -772,6 +772,15 @@ static void usage(void) "\t\t\targument in the form of a comma-separated list with some\n" "\t\t\tcommon fields predefined (pid, tgid, comm, stacktrace, allocator,= module)\n" "--sort \t\tSpecify sort order as: [+|-]key[,[+|-]key[,...]]\n" + "\t\t\tAvailable keys:\n" + "\t\t\t pid(p), tgid(tg), name(n), stacktrace(st),\n" + "\t\t\t txt(T), alloc_ts(at), allocator(ator), module(mod)\n" + "\t\t\tThe \"+\" is optional since default direction is\n" + "\t\t\tincreasing numerical or lexicographic order.\n" + "\t\t\tMixed use of abbreviated and complete-form is allowed.\n" + "\t\t\tExamples:\n" + "\t\t\t --sort=3Dn,+pid,-tgid\n" + "\t\t\t --sort=3Dmod,at\n" ); } =20 --=20 2.25.1