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

From: Oleg Nesterov
Date: Fri Jun 02 2023 - 13:41:19 EST


On 06/01, Wander Lairson Costa wrote:
>
> On Thu, Jun 1, 2023 at 3:14 PM Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
> >
> > > but only in the RT kernel
> >
> > this again suggests that your testing was wrong or I am totally confused (quite
> > possible, I know nothing about RT). I did the testing without CONFIG_PREEMPT_RT.
> >
>
> Hrm, could you please share your .config?

Sure. I do not want to spam the list, I'll send you a private email.

Can you share your kernel module code?

Did you verify that debug_locks != 0 as I asked in my previous email ?

> > > But running the reproducer for put_task_struct(), works fine.
> >
> > which reproducer ?
> >
>
> Only now I noticed I didn't add the reproducer to the commit message:
>
> while true; do
> stress-ng --sched deadline --sched-period 1000000000
> --sched-runtime 800000000 --sched-deadline 1000000000 --mmapfork 23 -t
> 20
> done

Cough ;) I think we need something more simple to ensure that
refcount_sub_and_test(nr, &t->usage) returns true under raw_spin_lock()
and then __put_task_struct() actually takes spin_lock().

Oleg.