From: Christian Kellner <christian@kellner.me>
To: Christian Brauner <christian.brauner@ubuntu.com>, jannh@google.com
Cc: aarcange@redhat.com, akpm@linux-foundation.org,
cyphar@cyphar.com, elena.reshetova@intel.com, guro@fb.com,
ldv@altlinux.org, linux-api@vger.kernel.org,
linux-kernel@vger.kernel.org, mhocko@suse.com, mingo@kernel.org,
peterz@infradead.org, tglx@linutronix.de,
viro@zeniv.linux.org.uk
Subject: Re: [PATCH] pidfd: add NSpid entries to fdinfo
Date: Mon, 14 Oct 2019 11:43:01 +0200 [thread overview]
Message-ID: <abc477fb3bd8fbf7b4d7e53d079dd1d8902e54af.camel@kellner.me> (raw)
In-Reply-To: <20191012102119.qq2adlnxjxrkslca@wittgenstein>
On Sat, 2019-10-12 at 12:21 +0200, Christian Brauner wrote:
> I think this might be more what we want.
Yep, indeed.
> I tried to think of cases where the first entry of Pid is not
> identical
> to the first entry of NSpid but I came up with none. Maybe you do,
> Jann?
Yeah, I don't think that can be the case. By looking at the source of
'pid_nr_ns(pid, ns)' a non-zero return means that a) 'pid' valid, ie.
non-null and b) 'ns' is in the pid namespace hierarchy of 'pid' (at
pid->level, i.e. "pid->numbers[ns->level].ns == ns").
> Christian, this is just a quick stab I took. Feel free to pick this
> up as a template.
Thanks! I slightly re-worked it, with the reasoning above in mind, to
get rid of one of the branches:
+#ifdef CONFIG_PID_NS
+ seq_put_decimal_ull(m, "\nNSpid:\t", nr);
+ if (nr) {
+ int i;
+
+ /* If nr is non-zero it means that 'pid' is valid and that
+ * ns, i.e. the pid namespace associated with the procfs
+ * instance, is in the pid namespace hierarchy of pid.
+ * Start at one level below and print all descending pids.
+ */
+ for (i = ns->level + 1; i <= pid->level; i++) {
+ ns = pid->numbers[i].ns;
+ seq_put_decimal_ull(m, "\t", pid_nr_ns(pid, ns));
+ }
+ }
+#endif
But I now just realized that with the very same reasoning, if nr is
non-zero, we don't need to redo all the checks and can just do:
for (i = ns->level + 1; i <= pid->level; i++)
seq_put_decimal_ull(m, "\t", pid->numbers[i].nr);
If this sounds good to you I resend the patches with the change above.
Thanks,
Christian
next prev parent reply other threads:[~2019-10-14 9:51 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-08 13:36 [PATCH] pidfd: show pids for nested pid namespaces in fdinfo Christian Kellner
2019-10-08 13:52 ` Christian Brauner
2019-10-08 14:00 ` Michal Hocko
2019-10-09 16:05 ` [PATCH v2 1/2] " Christian Kellner
2019-10-09 16:05 ` [PATCH v2 2/2] pidfd: add tests for NSpid info " Christian Kellner
2019-10-11 15:09 ` Jann Horn
2019-10-11 17:08 ` Christian Brauner
2019-10-09 17:29 ` [PATCH v2 1/2] pidfd: show pids for nested pid namespaces " Christian Brauner
2019-10-11 12:23 ` [PATCH v3 " Christian Kellner
2019-10-11 12:23 ` [PATCH v3 2/2] pidfd: add tests for NSpid info " Christian Kellner
2019-10-11 13:18 ` Christian Brauner
2019-10-11 13:17 ` [PATCH v3 1/2] pidfd: show pids for nested pid namespaces " Christian Brauner
2019-10-11 14:55 ` Jann Horn
2019-10-11 15:17 ` Christian Brauner
2019-10-11 15:30 ` Jann Horn
2019-10-11 16:58 ` Christian Brauner
2019-10-11 18:20 ` Jann Horn
2019-10-12 10:19 ` [PATCH] pidfd: add NSpid entries to fdinfo Christian Brauner
2019-10-12 10:21 ` Christian Brauner
2019-10-14 9:43 ` Christian Kellner [this message]
2019-10-14 10:31 ` Christian Brauner
2019-10-14 15:10 ` Jann Horn
2019-10-14 15:20 ` Christian Kellner
2019-10-14 15:09 ` Jann Horn
2019-10-14 17:06 ` Christian Brauner
2019-10-14 16:20 ` [PATCH v4 1/2] " Christian Kellner
2019-10-14 16:20 ` [PATCH v4 2/2] pidfd: add tests for NSpid info in fdinfo Christian Kellner
2019-10-15 10:07 ` Christian Brauner
2019-11-13 11:52 ` Naresh Kamboju
2019-11-13 12:20 ` Christian Brauner
2019-10-15 9:40 ` [PATCH v4 1/2] pidfd: add NSpid entries to fdinfo Christian Brauner
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=abc477fb3bd8fbf7b4d7e53d079dd1d8902e54af.camel@kellner.me \
--to=christian@kellner.me \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=christian.brauner@ubuntu.com \
--cc=cyphar@cyphar.com \
--cc=elena.reshetova@intel.com \
--cc=guro@fb.com \
--cc=jannh@google.com \
--cc=ldv@altlinux.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhocko@suse.com \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).