Re: [PATCH v8] kernel/fork: beware of __put_task_struct calling context

From: Wander Lairson Costa
Date: Mon May 15 2023 - 13:16:41 EST


On Mon, May 15, 2023 at 1:43 PM Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
>
> Certainly I have missed something...
>
> but,
>
> On 05/15, Wander Lairson Costa wrote:
> >
> > -extern void __put_task_struct(struct task_struct *t);
> > +extern void ___put_task_struct(struct task_struct *t);
> > +extern void __put_task_struct_rcu_cb(struct rcu_head *rhp);
>
> I don't understand these renames, why can't you simply put this fix
> into put_task_struct() ?
>

No particular reason, it was just a matter of style and keep the parts simple.

> but this is minor,
>
> > +static inline void __put_task_struct(struct task_struct *tsk)
> > +{
> ...
> > + if (IS_ENABLED(CONFIG_PREEMPT_RT) && !preemptible())
> > + call_rcu(&tsk->rcu, __put_task_struct_rcu_cb);
> > + else
> > + ___put_task_struct(tsk);
> > +}
>
> did you see the emails from Peter? In particular, this one:
>
> https://lore.kernel.org/lkml/20230505133902.GC38236@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/
>

I didn't notice the lock_acquire/lock_release part. However, I tested
the patch with CONFIG_PROVE_RAW_LOCK_NESTING and there was no warning.

> Oleg.
>