Messages in this thread | | | From | Thomas Gleixner <> | Subject | Re: [PATCH v3] irq/core: synchronize irq_thread startup | Date | Tue, 03 May 2022 09:38:01 +0200 |
| |
Hillf,
On Tue, May 03 2022 at 08:42, Hillf Danton wrote: > On Mon, 02 May 2022 21:24:45 +0200 Thomas Gleixner wrote: >> On Tue, May 03 2022 at 00:01, Hillf Danton wrote: >> > + if (!waked) >> > + wake_threads_waitq(desc); >> >> That's a guarantee to make desc->threads_active go negative in the case >> that the thread was never woken by a hard interrupt handler. IOW, you >> created a new problem which did not exist before. > > The count of active threads would not drop below zero with the change, > given the comment in __irq_wake_thread(). It is incremented before > wakeup.
There is no guarantee that the wake-up happens via __irq_wake_thread(). kthread_stop() does a wake-up too, but that obviously _cannot_ increment the active counter because it does not know about it at all.
create_thread() thread_fn() woken = false; wait_for_wakeup_or_stop() <- Stop is set, no interrupt happened <- ergo woken == false if (!woken) wake_threads_waitq(desc) atomic_dec_and_test(..) <- underflow
>> The problem discussed here is not a problem in irq_thread(), it's a >> problem of not reaching this function in the first place. See the on >> point analysis in Thomas Pfaffs patch. > > Well why is the count above zero without wakeup? IOW why is there imbalance > in count if the irq thread never gets a CPU to run?
Look at kthread() and the condition under which threadfn() is invoked.
Thanks,
tglx
| |