Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit c797384e authored by Suren Baghdasaryan's avatar Suren Baghdasaryan
Browse files

ANDROID: kthread: break dependency between worker->lock and task_struct->pi_lock

A number of kthread-related functions indirectly take task_struct->pi_lock
while holding worker->lock in the call chain like this:
    spin_lock(&worker->lock)
    kthread_insert_work
    wake_up_process
    try_to_wake_up
    raw_spin_lock_irqsave(&p->pi_lock, flags)

This lock dependency exists whenever kthread_insert_work is called either
directly or indirectly via __kthread_queue_delayed_work in the following
functions:
    kthread_queue_work
    kthread_delayed_work_timer_fn
    kthread_queue_delayed_work
    kthread_flush_work
    kthread_mod_delayed_work

This creates possibilities for circular dependencies like the one reported
at [1]. Break this lock dependency by moving task wakeup after worker->lock
has been released.

[1]: https://lore.kernel.org/lkml/CAJuCfpG4NkhpQvZjgXZ_3gm6Hf1QgN_eUOQ8iX9Cv1k9whLwSQ@mail.gmail.com



Reported-by: default avatarKe Wang <ke.wang@unisoc.com>
Reported-by: default avatarShakeel Butt <shakeelb@google.com>
Suggested-by: default avatarPeter Zijlstra <peterz@infradead.org>
Tested-by: default avatarShakeel Butt <shakeelb@google.com>
Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>

Link: https://lkml.org/lkml/2020/5/4/1148


Cherry picked instead of commit 461daba06bdcb9c7a3f92b9bbd110e1f7d093ffc
as an alternative solution for the lockdep error that does not break KMI.
Bug: 174875976
Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>
Change-Id: I2478847f66c85dca953846cd77955928d690c97c
parent 9c7cbdf8
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment