Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1400410

[PATCH v3 2/4] locking/rwsem: Don't wake up one's own task

From Waiman Long <Waiman.Long@hpe.com>
Newsgroups linux.kernel
Subject [PATCH v3 2/4] locking/rwsem: Don't wake up one's own task
Date 2016-05-13 01:00 +0200
Message-ID <ry7Ki-7bF-15@gated-at.bofh.it> (permalink)
References <ry7Kh-7bF-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.

Signed-off-by: Waiman Long <Waiman.Long@hpe.com>
---
 kernel/locking/rwsem-xadd.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/kernel/locking/rwsem-xadd.c b/kernel/locking/rwsem-xadd.c
index 7ccab5c..22f7d58 100644
--- a/kernel/locking/rwsem-xadd.c
+++ b/kernel/locking/rwsem-xadd.c
@@ -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 (tsk != current)
+			wake_up_process(tsk);
 		put_task_struct(tsk);
 	} while (--loop);
 
-- 
1.7.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v3 0/4] locking/rwsem: Add reader-owned state to the owner field Waiman Long <Waiman.Long@hpe.com> - 2016-05-13 01:00 +0200
  [PATCH v3 2/4] locking/rwsem: Don't wake up one's own task Waiman Long <Waiman.Long@hpe.com> - 2016-05-13 01:00 +0200
    Re: [PATCH v3 2/4] locking/rwsem: Don't wake up one's own task Peter Hurley <peter@hurleysoftware.com> - 2016-05-17 19:50 +0200

csiph-web