Skip to contentSkip to conversation

locking/rwsem: Don't wake up one's own task

PATCH RESEND New Waiman Long 1 participant 1 message May 20, 2016 Locking primitives

lore
Share & tools
lore
#0 lore raw

PATCH RESEND v4 3/5 locking/rwsem: Don't wake up one's own task

As rwsem_down_read_failed() will queue itself and potentially call __rwsem_do_wake(sem, RWSEM_WAKE_ANY), it is possible that a reader will try to wake up its own task. This patch adds a check to make sure that this won't happen.

---
 kernel/locking/rwsem-xadd.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
kernel/locking/rwsem-xadd.c +2 -1
index c278f5a..007814f 100644
@@ -202,7 +202,8 @@ __rwsem_do_wake(struct rw_semaphore *sem, enum rwsem_wake_type wake_type)
 		 */
 		smp_mb();
 		waiter->task = NULL;
-		wake_up_process(tsk);
+		if (likely(tsk != current))
+			wake_up_process(tsk);
 		put_task_struct(tsk);
 	} while (--loop);
 
Signature · 1 line
1.7.1