Re: [PATCH v2] posix-cpu-timers: Dequeue per-thread timers before exchange_tids()

From: Thomas Gleixner

Date: Tue Sep 01 2026 - 13:42:35 EST


On Tue, Sep 01 2026 at 16:50, Thomas Gleixner wrote:
> On Mon, Aug 31 2026 at 20:24, Oleg Nesterov wrote:
>> On 08/31, Thomas Gleixner wrote:
>>>
>>> On Wed, Aug 26 2026 at 14:55, Oleg Nesterov wrote:
>>> > Can we move posix_cpu_timers_exit() or the whole CONFIG_POSIX_TIMERS
>>> > sequence in begin_new_exec() up, right after de_thread() before the
>>> > "if (retval)" check?
>>>
>>> Yes, but that does not buy us anything.
>>
>> I didn't mean this makes sense, I just tried to understand the Hyunwoo's
>> fix, in particular the placement of additional posix_cpu_timers_exit().
>
> Fair enough. But as I was staring at it some more, I thought more about
> it. Yes, we can do:
>
> ret = de_thread()
> if (ret)
> goto out;
>
> mop_up_posix_timers();
>
> de_thread() only returns failure _before_ the TID swap, so that's safe
> and spares sprinkling this extra invocation into de_thread().
>
> What a mess.

I'm still thinking that an indicator for a task doing exec(), which is
set _before_ de_thread() and removed afterwards would be more sensible
than relying on subtle ordering constraints.

Along with the nonsense to keep timers queued on a task until
release_task(). There is no real benefit from keeping them around at
after PF_EXITING is set. Sure someone might argue that the precious CPU
cycles consumed in do_exit() afterwards won't be accounted, but
seriously?

Thanks,

tglx