Re: [PATCH v2 1/2] maple_tree: Disable mas_wr_append() when other readers are possible

From: Liam R. Howlett
Date: Tue Sep 12 2023 - 13:39:15 EST


* Christophe Leroy <christophe.leroy@xxxxxxxxxx> [230912 13:09]:
>
>
> Le 12/09/2023 à 17:44, Liam R. Howlett a écrit :
> > diff --git a/init/main.c b/init/main.c
> > index dbe1fe76be34..fd4739918a94 100644
> > --- a/init/main.c
> > +++ b/init/main.c
> > @@ -696,7 +696,7 @@ noinline void __ref __noreturn rest_init(void)
> > */
> > rcu_read_lock();
> > tsk = find_task_by_pid_ns(pid, &init_pid_ns);
> > - tsk->flags |= PF_NO_SETAFFINITY;
> > + tsk->flags |= PF_NO_SETAFFINITY & PF_IDLE;
>
> Is it really what you want to do ?
>
> PF_NO_SETAFFINITY is 0x04000000 and PF_IDLE is 0x00000002 so
>
> PF_NO_SETAFFINITY & PF_IDLE is 0
>
>
> Didn't you mean to do PF_NO_SETAFFINITY | PF_IDLE ?

Yes, certainly.

>
>
> Regardless, with either change I don't get the warning anymore.

I don't have it fully tested but we avoid getting the call_rcu() setting
the TIF_... flag by avoiding the task having PF_IDLE set in the flags.
I'm not entirely sure if I have added the set/clear in the best
locations either.

The largest concern I have is that this could potentially change arch or
platfrom code if anything depends on this being idle.

>
>
>
> > set_cpus_allowed_ptr(tsk, cpumask_of(smp_processor_id()));
> > rcu_read_unlock();
> >
> > @@ -943,6 +943,7 @@ void start_kernel(void)
> > * time - but meanwhile we still have a functioning scheduler.
> > */
> > sched_init();
> > + current->flags &= ~PF_IDLE;
> >
> > if (WARN(!irqs_disabled(),
> > "Interrupts were enabled *very* early, fixing it\n"))
> >