All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Emmanuel Deloget <emmanuel.deloget@efixo.com>
Cc: "[ML] linux-kernel" <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@redhat.com>
Subject: Re: /proc/$PID/sched does not take PID namespace into account
Date: Mon, 9 Sep 2013 13:01:41 +0200	[thread overview]
Message-ID: <20130909110141.GM31370@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <5225F0A9.5040100@efixo.com>

On Tue, Sep 03, 2013 at 04:22:33PM +0200, Emmanuel Deloget wrote:
> The issue (if this is really an issue) lies in kernel/sched/debug.c,
> function proc_sched_show_task(). The code says [1]:
> 
>     SEQ_printf(m, "%s (%d, #threads: %d)\n", p->comm, p->pid,
>                         get_nr_threads(p));
> 

> I see a few options:
> 
> * either it's a bug and it should be corrected (I'm not sure how to
>   do it; the printed PID should reflect the current PID namespace
>   and I don't how how to get this information).

I suppose something like the below ought to work? -- completely
untested, please confirm.

---
Subject: sched, debug: Use PID namespaces

Emmanuel reported that /proc/sched_debug didn't report the right PIDs
when using namespaces, cure this.

Reported-by: Emmanuel Deloget <emmanuel.deloget@efixo.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
---
 kernel/sched/debug.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index e076bdd..e30bf44 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -124,7 +124,7 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p)
 		SEQ_printf(m, " ");
 
 	SEQ_printf(m, "%15s %5d %9Ld.%06ld %9Ld %5d ",
-		p->comm, p->pid,
+		p->comm, task_pid(p),,
 		SPLIT_NS(p->se.vruntime),
 		(long long)(p->nvcsw + p->nivcsw),
 		p->prio);
@@ -289,7 +289,7 @@ do {									\
 	P(nr_load_updates);
 	P(nr_uninterruptible);
 	PN(next_balance);
-	P(curr->pid);
+	P(task_pid(curr));
 	PN(clock);
 	P(cpu_load[0]);
 	P(cpu_load[1]);
@@ -492,7 +492,7 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m)
 {
 	unsigned long nr_switches;
 
-	SEQ_printf(m, "%s (%d, #threads: %d)\n", p->comm, p->pid,
+	SEQ_printf(m, "%s (%d, #threads: %d)\n", p->comm, task_pid(p),
 						get_nr_threads(p));
 	SEQ_printf(m,
 		"---------------------------------------------------------"

  reply	other threads:[~2013-09-09 11:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-03 14:22 /proc/$PID/sched does not take PID namespace into account Emmanuel Deloget
2013-09-09 11:01 ` Peter Zijlstra [this message]
2013-09-09 13:58   ` Emmanuel Deloget
2013-09-10  9:18   ` Peter Zijlstra
2013-09-12 18:05   ` [tip:sched/core] sched/debug: Take " tip-bot for Peter Zijlstra

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=20130909110141.GM31370@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=emmanuel.deloget@efixo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.