From: Waiman Long <longman@redhat.com>
To: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Jonathan Corbet <corbet@lwn.net>
Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Davidlohr Bueso <dave@stgolabs.net>,
Mike Galbraith <umgwanakikbuti@gmail.com>,
Scott J Norton <scott.norton@hpe.com>,
Waiman Long <longman@redhat.com>
Subject: [PATCH-tip v5 20/21] sched, TP-futex: Make wake_up_q() return wakeup count
Date: Fri, 3 Feb 2017 13:03:53 -0500 [thread overview]
Message-ID: <1486145034-22210-21-git-send-email-longman@redhat.com> (raw)
In-Reply-To: <1486145034-22210-1-git-send-email-longman@redhat.com>
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 <longman@redhat.com>
---
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 9a32f17..2b2bc9d 100644
--- a/include/linux/sched/wake_q.h
+++ b/include/linux/sched/wake_q.h
@@ -49,6 +49,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 16c63b8..6bf5304 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -4257,11 +4257,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 679093d..668a094 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -452,9 +452,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;
@@ -469,9 +470,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
next prev parent reply other threads:[~2017-02-03 18:04 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-03 18:03 [PATCH-tip v5 00/21] futex: Introducing throughput-optimized (TP) futexes Waiman Long
2017-02-03 18:03 ` [PATCH-tip v5 01/21] perf bench: New microbenchmark for userspace mutex performance Waiman Long
2017-02-03 18:03 ` [PATCH-tip v5 02/21] perf bench: New microbenchmark for userspace rwlock performance Waiman Long
2017-02-03 18:03 ` [PATCH-tip v5 03/21] futex: Consolidate duplicated timer setup code Waiman Long
2017-02-03 18:03 ` [PATCH-tip v5 04/21] futex: Rename futex_pi_state to futex_state Waiman Long
2017-02-03 18:03 ` [PATCH-tip v5 05/21] futex: Add helpers to get & cmpxchg futex value without lock Waiman Long
2017-02-03 18:03 ` [PATCH-tip v5 06/21] futex: Consolidate pure pi_state_list add & delete codes to helpers Waiman Long
2017-02-03 18:03 ` [PATCH-tip v5 07/21] futex: Add a new futex type field into futex_state Waiman Long
2017-02-03 18:03 ` [PATCH-tip v5 08/21] futex: Allow direct attachment of futex_state objects to hash bucket Waiman Long
2017-02-03 18:03 ` [PATCH-tip v5 09/21] futex: Introduce throughput-optimized (TP) futexes Waiman Long
2017-02-03 18:03 ` [PATCH-tip v5 10/21] TP-futex: Enable robust handling Waiman Long
2017-02-03 18:03 ` [PATCH-tip v5 11/21] TP-futex: Implement lock handoff to prevent lock starvation Waiman Long
2017-02-03 18:03 ` [PATCH-tip v5 12/21] TP-futex: Return status code on FUTEX_LOCK calls Waiman Long
2017-02-03 18:03 ` [PATCH-tip v5 13/21] TP-futex: Add timeout support Waiman Long
2017-02-03 18:03 ` [PATCH-tip v5 14/21] TP-futex, doc: Add TP futexes documentation Waiman Long
2017-02-03 18:03 ` [PATCH-tip v5 15/21] TP-futex: Support userspace reader/writer locks Waiman Long
2017-02-03 18:03 ` [PATCH-tip v5 16/21] TP-futex: Enable kernel reader lock stealing Waiman Long
2017-02-03 18:03 ` [PATCH-tip v5 17/21] TP-futex: Group readers together in wait queue Waiman Long
2017-02-03 18:23 ` valdis.kletnieks
2017-02-03 18:42 ` Waiman Long
2017-02-03 19:26 ` valdis.kletnieks
2017-02-03 18:03 ` [PATCH-tip v5 18/21] TP-futex, doc: Update TP futexes document on shared locking Waiman Long
2017-02-03 18:03 ` [PATCH-tip v5 19/21] perf bench: Extend mutex/rwlock futex suite to test TP futexes Waiman Long
2017-02-03 18:03 ` Waiman Long [this message]
2017-02-03 18:03 ` [PATCH-tip v5 21/21] futex: Dump internal futex state via debugfs Waiman Long
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1486145034-22210-21-git-send-email-longman@redhat.com \
--to=longman@redhat.com \
--cc=acme@kernel.org \
--cc=corbet@lwn.net \
--cc=dave@stgolabs.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=scott.norton@hpe.com \
--cc=tglx@linutronix.de \
--cc=umgwanakikbuti@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®