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


Groups > linux.kernel > #1573330

[PATCH-tip v5 20/21] sched, TP-futex: Make wake_up_q() return wakeup count

From Waiman Long <longman@redhat.com>
Newsgroups linux.kernel
Subject [PATCH-tip v5 20/21] sched, TP-futex: Make wake_up_q() return wakeup count
Date 2017-02-03 19:10 +0100
Message-ID <t6Qt4-57B-45@gated-at.bofh.it> (permalink)
References <t6Qt3-57B-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

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


Thread

[PATCH-tip v5 00/21] futex: Introducing throughput-optimized (TP) futexes Waiman Long <longman@redhat.com> - 2017-02-03 19:10 +0100
  [PATCH-tip v5 20/21] sched, TP-futex: Make wake_up_q() return wakeup count Waiman Long <longman@redhat.com> - 2017-02-03 19:10 +0100
  [PATCH-tip v5 21/21] futex: Dump internal futex state via debugfs Waiman Long <longman@redhat.com> - 2017-02-03 19:10 +0100
  [PATCH-tip v5 17/21] TP-futex: Group readers together in wait queue Waiman Long <longman@redhat.com> - 2017-02-03 19:10 +0100
    Re: [PATCH-tip v5 17/21] TP-futex: Group readers together in wait queue valdis.kletnieks@vt.edu - 2017-02-03 19:30 +0100
      Re: [PATCH-tip v5 17/21] TP-futex: Group readers together in wait  queue Waiman Long <longman@redhat.com> - 2017-02-03 19:50 +0100
        Re: [PATCH-tip v5 17/21] TP-futex: Group readers together in wait queue valdis.kletnieks@vt.edu - 2017-02-03 20:30 +0100
  [PATCH-tip v5 05/21] futex: Add helpers to get & cmpxchg futex value without lock Waiman Long <longman@redhat.com> - 2017-02-03 19:10 +0100
  [PATCH-tip v5 04/21] futex: Rename futex_pi_state to futex_state Waiman Long <longman@redhat.com> - 2017-02-03 19:10 +0100
  [PATCH-tip v5 10/21] TP-futex: Enable robust handling Waiman Long <longman@redhat.com> - 2017-02-03 19:10 +0100
  [PATCH-tip v5 08/21] futex: Allow direct attachment of futex_state objects to hash bucket Waiman Long <longman@redhat.com> - 2017-02-03 19:10 +0100
  [PATCH-tip v5 03/21] futex: Consolidate duplicated timer setup code Waiman Long <longman@redhat.com> - 2017-02-03 19:10 +0100
  [PATCH-tip v5 19/21] perf bench: Extend mutex/rwlock futex suite to test TP futexes Waiman Long <longman@redhat.com> - 2017-02-03 19:10 +0100
  [PATCH-tip v5 11/21] TP-futex: Implement lock handoff to prevent lock starvation Waiman Long <longman@redhat.com> - 2017-02-03 19:10 +0100

csiph-web