Re: [PATCH v3 2/3] softirq: Provide a handshake for canceling tasklets via polling
From: Hillf Danton
Date: Fri Sep 19 2025 - 21:29:59 EST
On Thu, 18 Sep 2025 17:49:37 +0200 Sebastian Andrzej Siewior wrote:
>On 2025-09-18 21:47:52 [+0800], Hillf Danton wrote:
>> On Mon, 15 Sep 2025 09:39:33 +0200 Sebastian Andrzej Siewior wrote:
>> >On 2025-09-05 18:15:01 [+0800], Hillf Danton wrote:
>> >> CPU0 CPU1
>> >> ---- ----
>> >> lock A
>> >> tasklet C callback
>> >> lock A
>> >> cancel tasklet B
>> >> DEADLOCK-01
>> >>
>> >> After this work could DEADLOCK-01 be triggered, given no chance for DEADLOCK-02 ?
>> >>
>> >> CPU2 CPU3
>> >> ---- ----
>> >> lock A
>> >> timer C callback
>> >> lock A
>> >> timer_delete_sync(timer B)
>> >> DEADLOCK-02
>> >
>> > You are not supposed to acquire the lock, that is also acquired in the
>> > callback, while canceling the timer/ tasklet.
>> > Tell me please, how is this relevant?
>> >
>> > If lock A is acquired on CPU0/ 2 then tasklet/ timer on CPU1/ 3 can't
>> > make progress. Now CPU0/ 2 waits for the callback to complete. This
>> > deadlocks as of today regardless of PREEMPT_RT and this change.
>> >
>> In case of !RT, the chance for DEADLOCK-02 is zero because deadlock is
>> detected based on per-timer instead of per-cpu.
>
> But your "lock A" is global, isn't it?
>
IIUC whether lockA is global can be safely ignored here. DEADLOCK-02 can not
be detected with !RT because by define the callback of timerB has nothing to
do with timerC in addition to the current per-timer detecting mechanism.
This work however adds per-cpu detecting mechanism that fails to tell the
difference between timerB and timerC, thus false positive result comes. For
example the callback of timerB does not acquire lockA.