From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935678AbdCVRmR (ORCPT ); Wed, 22 Mar 2017 13:42:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40640 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965147AbdCVRlo (ORCPT ); Wed, 22 Mar 2017 13:41:44 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 716CC8E3F2 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=longman@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 716CC8E3F2 From: Waiman Long To: Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Jonathan Corbet Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Arnaldo Carvalho de Melo , Davidlohr Bueso , Mike Galbraith , Scott J Norton , Waiman Long Subject: [PATCH-tip v6 21/22] sched, TP-futex: Make wake_up_q() return wakeup count Date: Wed, 22 Mar 2017 13:38:57 -0400 Message-Id: <1490204338-1856-22-git-send-email-longman@redhat.com> In-Reply-To: <1490204338-1856-1-git-send-email-longman@redhat.com> References: <1490204338-1856-1-git-send-email-longman@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 22 Mar 2017 17:41:44 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Unlike wake_up_process(), wake_up_q() doesn't tell us how many tasks have been woken up. This information can sometimes be useful for tracking purpose. So wake_up_q() is now modified to return that information. Signed-off-by: Waiman Long --- include/linux/sched/wake_q.h | 2 +- kernel/futex.c | 8 +++----- kernel/sched/core.c | 6 ++++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/linux/sched/wake_q.h b/include/linux/sched/wake_q.h index d03d8a9..8b88fc0 100644 --- a/include/linux/sched/wake_q.h +++ b/include/linux/sched/wake_q.h @@ -48,6 +48,6 @@ static inline void wake_q_init(struct wake_q_head *head) extern void wake_q_add(struct wake_q_head *head, struct task_struct *task); -extern void wake_up_q(struct wake_q_head *head); +extern int wake_up_q(struct wake_q_head *head); #endif /* _LINUX_SCHED_WAKE_Q_H */ diff --git a/kernel/futex.c b/kernel/futex.c index 984b836..a199574 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -4298,11 +4298,9 @@ static int futex_unlock(u32 __user *uaddr, unsigned int flags, out_put_key: put_futex_key(&key); if (owner) { - /* - * No error would have happened if owner defined. - */ - wake_up_q(&wake_q); - return ret ? ret : 1; + int cnt = wake_up_q(&wake_q); + + return ret ? ret : cnt; } return ret; diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 6d6cad9..2193d59 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -447,9 +447,10 @@ void wake_q_add(struct wake_q_head *head, struct task_struct *task) head->lastp = &node->next; } -void wake_up_q(struct wake_q_head *head) +int wake_up_q(struct wake_q_head *head) { struct wake_q_node *node = head->first; + int wakecnt = 0; while (node != WAKE_Q_TAIL) { struct task_struct *task; @@ -464,9 +465,10 @@ void wake_up_q(struct wake_q_head *head) * wake_up_process() implies a wmb() to pair with the queueing * in wake_q_add() so as not to miss wakeups. */ - wake_up_process(task); + wakecnt += wake_up_process(task); put_task_struct(task); } + return wakecnt; } /* -- 1.8.3.1