[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230911075437.74027-4-zeil@nebius.com>
Date: Mon, 11 Sep 2023 07:55:23 +0000
From: "Yakunin, Dmitry (Nebius)" <zeil@...ius.com>
To: "cgroups@...r.kernel.org" <cgroups@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-mm@...ck.org" <linux-mm@...ck.org>
CC: NB-Core Team <NB-CoreTeam@...ius.com>,
"tj@...nel.org" <tj@...nel.org>,
"hannes@...xchg.org" <hannes@...xchg.org>,
"mhocko@...nel.org" <mhocko@...nel.org>,
"Yakunin, Dmitry (Nebius)" <zeil@...ius.com>,
Konstantin Khlebnikov <khlebnikov@...dex-team.ru>,
Andrey Ryabinin <arbn@...dex-team.com>
Subject: [RFC PATCH 3/3] tools/mm/page-types: add flag for showing inodes of
offline cgroups
With flag -R|--real-cgroup page-types will report real owner.
Link: https://lore.kernel.org/lkml/153414349419.737150.8224164787883146532.stgit@buzz
Suggested-by: Konstantin Khlebnikov <khlebnikov@...dex-team.ru>
Reviewed-by: Andrey Ryabinin <arbn@...dex-team.com>
Signed-off-by: Dmitry Yakunin <zeil@...ius.com>
---
tools/mm/page-types.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/tools/mm/page-types.c b/tools/mm/page-types.c
index 8d5595b6c59f..f26035b362d2 100644
--- a/tools/mm/page-types.c
+++ b/tools/mm/page-types.c
@@ -161,6 +161,7 @@ static pid_t opt_pid; /* process to walk */
const char *opt_file; /* file or directory path */
static uint64_t opt_cgroup; /* cgroup inode */
static int opt_list_cgroup;/* list page cgroup */
+static int opt_real_cgroup;/* list page cgroup */
static int opt_list_mapcnt;/* list page map count */
static const char *opt_kpageflags;/* kpageflags file to parse */
@@ -837,6 +838,7 @@ static void usage(void)
" -l|--list Show page details in ranges\n"
" -L|--list-each Show page details one by one\n"
" -C|--list-cgroup Show cgroup inode for pages\n"
+" -R|--real-cgroup Show real offline cgroups\n"
" -M|--list-mapcnt Show page map count\n"
" -N|--no-summary Don't show summary info\n"
" -X|--hwpoison hwpoison pages\n"
@@ -1257,6 +1259,7 @@ static const struct option opts[] = {
{ "list" , 0, NULL, 'l' },
{ "list-each" , 0, NULL, 'L' },
{ "list-cgroup", 0, NULL, 'C' },
+ { "real-cgroup", 0, NULL, 'R' },
{ "list-mapcnt", 0, NULL, 'M' },
{ "no-summary", 0, NULL, 'N' },
{ "hwpoison" , 0, NULL, 'X' },
@@ -1273,7 +1276,7 @@ int main(int argc, char *argv[])
page_size = getpagesize();
while ((c = getopt_long(argc, argv,
- "rp:f:a:b:d:c:CilLMNXxF:h",
+ "rp:f:a:b:d:c:CRilLMNXxF:h",
opts, NULL)) != -1) {
switch (c) {
case 'r':
@@ -1297,6 +1300,9 @@ int main(int argc, char *argv[])
case 'C':
opt_list_cgroup = 1;
break;
+ case 'R':
+ opt_real_cgroup = 1;
+ break;
case 'd':
describe_flags(optarg);
exit(0);
@@ -1338,7 +1344,15 @@ int main(int argc, char *argv[])
if (!opt_kpageflags)
opt_kpageflags = PROC_KPAGEFLAGS;
- if (opt_cgroup || opt_list_cgroup)
+ if (opt_real_cgroup) {
+ uint64_t flags = 1;
+
+ kpagecgroup_fd = checked_open(PROC_KPAGECGROUP, O_RDWR);
+ if (write(kpagecgroup_fd, &flags, sizeof(flags)) < 0) {
+ perror(PROC_KPAGECGROUP);
+ exit(EXIT_FAILURE);
+ }
+ } else if (opt_cgroup || opt_list_cgroup)
kpagecgroup_fd = checked_open(PROC_KPAGECGROUP, O_RDONLY);
if (opt_list && opt_list_mapcnt)
--
2.25.1
Powered by blists - more mailing lists