mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sched: Enhance readability of iterating wake_list
@ 2017-02-10  4:09 Byungchul Park
  2017-02-10  7:55 ` Peter Zijlstra
  0 siblings, 1 reply; 4+ messages in thread
From: Byungchul Park @ 2017-02-10  4:09 UTC (permalink / raw)
  To: peterz, mingo; +Cc: linux-kernel

This is just for enhancing readability and a trivial one. Please take
this only if you agree.

-----8<-----
>From bb8cfcaa21ce157fb890a3e878fed2f2b7dadf81 Mon Sep 17 00:00:00 2001
From: Byungchul Park <byungchul.park@lge.com>
Date: Fri, 10 Feb 2017 12:53:14 +0900
Subject: [PATCH] sched: Enhance readability of iterating wake_list

Code for interating wake_list can be simpler so that it becomes more
readable and can be seen at a glance.

Signed-off-by: Byungchul Park <byungchul.park@lge.com>
---
 kernel/sched/core.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index d01f9d0..66e7743 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1769,6 +1769,11 @@ static int ttwu_remote(struct task_struct *p, int wake_flags)
 }
 
 #ifdef CONFIG_SMP
+#define for_each_wake_list(task, node) \
+	for ((task) = llist_entry((node), struct task_struct, wake_entry); \
+	     node; (node) = llist_next(node), \
+	     (task) = llist_entry((node), struct task_struct, wake_entry))
+
 void sched_ttwu_pending(void)
 {
 	struct rq *rq = this_rq();
@@ -1783,17 +1788,8 @@ void sched_ttwu_pending(void)
 	raw_spin_lock_irqsave(&rq->lock, flags);
 	rq_pin_lock(rq, &rf);
 
-	while (llist) {
-		int wake_flags = 0;
-
-		p = llist_entry(llist, struct task_struct, wake_entry);
-		llist = llist_next(llist);
-
-		if (p->sched_remote_wakeup)
-			wake_flags = WF_MIGRATED;
-
-		ttwu_do_activate(rq, p, wake_flags, &rf);
-	}
+	for_each_wake_list(p, llist)
+		ttwu_do_activate(rq, p, p->sched_remote_wakeup ? WF_MIGRATED : 0, &rf);
 
 	rq_unpin_lock(rq, &rf);
 	raw_spin_unlock_irqrestore(&rq->lock, flags);
-- 
1.9.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-02-10 10:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-10  4:09 [PATCH] sched: Enhance readability of iterating wake_list Byungchul Park
2017-02-10  7:55 ` Peter Zijlstra
2017-02-10  9:55   ` Byungchul Park
2017-02-10 10:49   ` Byungchul Park

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®