Re: [PATCH 11/12] pid: rewrite task helper functions avoidingtask->pid and task->tgid

From: Richard Guy Briggs
Date: Mon Dec 16 2013 - 12:36:24 EST


On 13/08/26, Richard Guy Briggs wrote:
> On Thu, Aug 22, 2013 at 09:08:48PM +0200, Oleg Nesterov wrote:
> > On 08/20, Richard Guy Briggs wrote:
> > >
> > > static inline int is_global_init(struct task_struct *tsk)
> > > {
> > > - return tsk->pid == 1;
> > > + return task_pid_nr(tsk) == 1;
> > > }
> >
> > Probably it would be better to simply kill it. Almost every usage is
> > wrong.
>
> Can you be more clear? I don't follow. It should instead return a
> boolean. Usage of is_global_init() or task_pid_nr()?
>
> If is_global_init(), is that because they could be unaware of pid
> namespaces?
>
> If task_pid_nr(), is that for the same reason?

Oleg, I still don't understand your comment above. Kill what,
"is_global_init()"? If so, how is almost every usage of it wrong?

There are a number of functions that call is_global_init(). Might any
of them be called from inside the namespace context of a container and
hence should return true?

> > > static inline bool is_idle_task(const struct task_struct *p)
> > > {
> > > - return p->pid == 0;
> > > + return task_pid(p) == &init_struct_pid;
> > > }
> >
> > hmm. there should be a simpler check for this...
>
> Other than the original, this one is pretty simple. What did you have
> in mind?

I vaguely remember a clarification to this, but don't remember and can't
find it. What sort of simplification did you have in mind? I'd like to
go at least to:
task_pid_nr(p) == 0

> > Oleg.
>
> - RGB

- RGB

--
Richard Guy Briggs <rbriggs@xxxxxxxxxx>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat
Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/