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


Groups > linux.kernel > #1578168

[PATCH] sched: Enhance readability of iterating wake_list

From Byungchul Park <byungchul.park@lge.com>
Newsgroups linux.kernel
Subject [PATCH] sched: Enhance readability of iterating wake_list
Date 2017-02-10 05:20 +0100
Message-ID <t9aQF-6XG-3@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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

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


Thread

[PATCH] sched: Enhance readability of iterating wake_list Byungchul Park <byungchul.park@lge.com> - 2017-02-10 05:20 +0100
  Re: [PATCH] sched: Enhance readability of iterating wake_list Peter Zijlstra <peterz@infradead.org> - 2017-02-10 09:00 +0100
    Re: [PATCH] sched: Enhance readability of iterating wake_list Byungchul Park <byungchul.park@lge.com> - 2017-02-10 11:20 +0100
    Re: [PATCH] sched: Enhance readability of iterating wake_list Byungchul Park <byungchul.park@lge.com> - 2017-02-10 12:00 +0100

csiph-web