From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752851AbcELW5P (ORCPT ); Thu, 12 May 2016 18:57:15 -0400 Received: from g1t6220.austin.hp.com ([15.73.96.84]:37999 "EHLO g1t6220.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751111AbcELW5N (ORCPT ); Thu, 12 May 2016 18:57:13 -0400 From: Waiman Long To: Peter Zijlstra , Ingo Molnar Cc: linux-kernel@vger.kernel.org, Davidlohr Bueso , Jason Low , Dave Chinner , Peter Hurley , Scott J Norton , Douglas Hatch , Waiman Long Subject: [PATCH v3 2/4] locking/rwsem: Don't wake up one's own task Date: Thu, 12 May 2016 18:56:49 -0400 Message-Id: <1463093811-10684-3-git-send-email-Waiman.Long@hpe.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1463093811-10684-1-git-send-email-Waiman.Long@hpe.com> References: <1463093811-10684-1-git-send-email-Waiman.Long@hpe.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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