Re: [PATCH 5/6] sched/isolation: Introduce isolated task work

From: Frederic Weisbecker
Date: Fri Apr 11 2025 - 18:00:14 EST


Le Fri, Apr 11, 2025 at 12:25:56PM +0200, Oleg Nesterov a écrit :
> I know nothing about this code so I can't review, but let me
> ask anyway...
>
> On 04/10, Frederic Weisbecker wrote:
> >
> > +int __isolated_task_work_queue(void)
> > +{
> > + unsigned long flags;
> > + int ret;
> > +
> > + if (current->flags & PF_KTHREAD)
> > + return -EINVAL;
>
> What about PF_USER_WORKER's ? IIUC, these (in fact kernel) threads
> never return to userspace and never call task_work_run().

Ah good catch! (though I'm having a hard time finding out what this is
about)...

>
> Or PF_IO_WORKER's, they too run only in kernel mode... But iirc they
> do call task_work_run().

At least I see a lot of task_work usage in io_uring, and there are some
explicit calls to task_work_run() there...

>
> > + local_irq_save(flags);
> > + if (task_work_queued(&current->nohz_full_work)) {
> > + ret = 0;
> > + goto out;
> > + }
> > +
> > + ret = task_work_add(current, &current->nohz_full_work, TWA_RESUME);
> > +out:
> > + local_irq_restore(flags);
> > + return ret;
>
> Hmm, why not
>
> local_irq_save(flags);
> if (task_work_queued(...))
> ret = 0;
> else
> ret = task_work_add(...);

Hehe, yes indeed!

Thanks!

--
Frederic Weisbecker
SUSE Labs