public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
From: "Yakunin, Dmitry (Nebius)" <zeil-2iiexdXeLXzQT0dZR+AlfA@public.gmane.org>
To: "cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org"
	<linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org>
Cc: NB-Core Team
	<NB-CoreTeam-2iiexdXeLXzQT0dZR+AlfA@public.gmane.org>,
	"tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org"
	<tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	"hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org"
	<hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>,
	"mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org"
	<mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	"Yakunin,
	Dmitry (Nebius)" <zeil-2iiexdXeLXzQT0dZR+AlfA@public.gmane.org>,
	Konstantin Khlebnikov
	<khlebnikov-XoJtRXgx1JseBXzfvpsJ4g@public.gmane.org>,
	Andrey Ryabinin <arbn-XoJtRXgx1JtgGdypvdXH1w@public.gmane.org>
Subject: [RFC PATCH 3/3] tools/mm/page-types: add flag for showing inodes of offline cgroups
Date: Mon, 11 Sep 2023 07:55:23 +0000	[thread overview]
Message-ID: <20230911075437.74027-4-zeil@nebius.com> (raw)
In-Reply-To: <20230911075437.74027-1-zeil-2iiexdXeLXzQT0dZR+AlfA@public.gmane.org>

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-XoJtRXgx1JseBXzfvpsJ4g@public.gmane.org>
Reviewed-by: Andrey Ryabinin <arbn-XoJtRXgx1JtgGdypvdXH1w@public.gmane.org>
Signed-off-by: Dmitry Yakunin <zeil-2iiexdXeLXzQT0dZR+AlfA@public.gmane.org>
---
 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


      parent reply	other threads:[~2023-09-11  7:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-11  7:55 [RFC PATCH 0/3] Helpers for debugging dying cgroups Yakunin, Dmitry (Nebius)
     [not found] ` <20230911075437.74027-1-zeil-2iiexdXeLXzQT0dZR+AlfA@public.gmane.org>
2023-09-11  7:55   ` [RFC PATCH 1/3] cgroup: list all subsystem states in debugfs files Yakunin, Dmitry (Nebius)
2023-09-11 18:55     ` tj
     [not found]       ` <ZP9itivlZQIb5wZ0-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2023-09-13 10:33         ` Dmitry Yakunin
     [not found]     ` <20230911075437.74027-2-zeil-2iiexdXeLXzQT0dZR+AlfA@public.gmane.org>
2023-09-11 22:16       ` Yosry Ahmed
     [not found]         ` <CAJD7tkYM0JBukPMWCWtx-nrzGgPw4Y6m1p2_Ynb9fzSgsS0igg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-09-13 10:35           ` Dmitry Yakunin
2023-09-11  7:55   ` [RFC PATCH 2/3] proc/kpagecgroup: report also inode numbers of offline cgroups Yakunin, Dmitry (Nebius)
2023-09-11  7:55   ` Yakunin, Dmitry (Nebius) [this message]

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=20230911075437.74027-4-zeil@nebius.com \
    --to=zeil-2iiexdxelxzqt0dzr+alfa@public.gmane.org \
    --cc=NB-CoreTeam-2iiexdXeLXzQT0dZR+AlfA@public.gmane.org \
    --cc=arbn-XoJtRXgx1JtgGdypvdXH1w@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
    --cc=khlebnikov-XoJtRXgx1JseBXzfvpsJ4g@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
    --cc=mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    /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