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

Skip to content
Commit 8fbf3c9e authored by Junjie Wu's avatar Junjie Wu Committed by Gerrit - the friendly Code Review server
Browse files

cpufreq: interactive: Avoid down_read_trylock if down_write() is held



down_read_trylock is not always non-blocking if the same thread calls
down_write() before.

CPU1					CPU2
					down_read()
down_write()
  __down_write_nested()
    schedule()
      __down_read_trylock()
					up_read()
					  acquires sem->wait_lock
					    __rwsem_wake_one_writer()
	tries to lock sem->wait_lock

Now CPU2 is waiting for CPU1's schedule() to complete, while holding
sem->wait_lock. CPU1 needs sem->wait_lock to continue.

This problem only happens after cpufreq_interactive introduced load
change notification that could be called within schedule().

Add a separate flag to ignore notification if current thread is in
middle of down_write(). This avoids attempting to hold sem->wait_lock.
The additional flag doesn't have any side effects because
down_read_trylock() would have failed anyway.

Change-Id: Iff97cac36c170cf6d03f36de695141289c3d6930
Signed-off-by: default avatarJunjie Wu <junjiew@codeaurora.org>
parent 27c53051
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