Skip to contentSkip to conversation

sched/fair: code clean up for __sched_period()

PATCH In review Boqun Feng 4 participants 8 messages Jul 2, 2015 – Jul 7, 2015 Scheduler

lore
Share & tools
lore

Boqun Feng

author
#0 lore raw

PATCH 1/1 sched/fair: code clean up for __sched_period()

Since commit: 4bf0b77158 ("sched: remove do_div() from __sched_slice()"), the logic of __sched_period() can be implemented as a single if-else without any local variable, so this patch cleans it up with an if-else statement, which expresses the function's logic straightforwardly.

---
 kernel/sched/fair.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
kernel/sched/fair.c +4 -9
index 4b6e5f6..341a51f 100644
@@ -616,15 +616,10 @@ static inline u64 calc_delta_fair(u64 delta, struct sched_entity *se)
  */
 static u64 __sched_period(unsigned long nr_running)
 {
-	u64 period = sysctl_sched_latency;
-	unsigned long nr_latency = sched_nr_latency;
-
-	if (unlikely(nr_running > nr_latency)) {
-		period = sysctl_sched_min_granularity;
-		period *= nr_running;
-	}
-
-	return period;
+	if (unlikely(nr_running > sched_nr_latency))
+		return nr_running * sysctl_sched_min_granularity;
+	else
+		return sysctl_sched_latency;
 }
 
 /*
Signature · 1 line
2.4.5
author
#1 lore raw

Ping. Any idea on this one?

Quoted 7 lines · Boqun Feng

Since commit: 4bf0b77158 ("sched: remove do_div() from __sched_slice()"), the logic of __sched_period() can be implemented as a single if-else without any local variable, so this patch cleans it up with an if-else statement, which expresses the function's logic straightforwardly.

<...>

Thanks,
Boqun

maintainer
#2 lore raw
Quoted 1 line · Boqun Feng

Ping. Any idea on this one?

I think I queued this one.

#3 lore raw
Quoted 4 lines · Peter Zijlstra
Quoted 1 line · Boqun Feng

Ping. Any idea on this one?

I think I queued this one.

Yeah, and I applied it from you earlier today - it's still being a tested, will push it out later today.

Thanks,

Ingo

author
#4 lore raw

Hi Ingo,

Quoted 11 lines · Ingo Molnar
Quoted 4 lines · Peter Zijlstra
Quoted 1 line · Boqun Feng

Ping. Any idea on this one?

I think I queued this one.

Yeah, and I applied it from you earlier today - it's still being a tested, will push it out later today.

Clearly, I'm not very familiar with the patch processing flow for scheduler.. sorry about that. Much clear now, Thank you!

Regards,
Boqun

author
#5 lore raw
In reply to Peter Zijlstra

Hi Peter,

Quoted 4 lines · Peter Zijlstra
Quoted 1 line · Boqun Feng

Ping. Any idea on this one?

I think I queued this one.

Sorry, I only had looked up in the "tip" tree.. just found it on your tree. Thank you!

Regards,
Boqun

#6 lore raw

[tip:sched/core] sched/fair: Clean up the __sched_period() code

In reply to Boqun Feng
sched/fair: Clean up the __sched_period() code
Commit-ID:  42d1c60e15ff89150a3b3537fec579f8a8f36a8a
Gitweb:     http://git.kernel.org/tip/42d1c60e15ff89150a3b3537fec579f8a8f36a8a
Author:     Boqun Feng <[email protected]>
AuthorDate: Thu, 2 Jul 2015 22:25:52 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 6 Jul 2015 15:29:56 +0200

sched/fair: Clean up the __sched_period() code

Since commit:

4bf0b77158 ("sched: remove do_div() from __sched_slice()")

... the logic of __sched_period() can be implemented as a single if-else without any local variables, so this patch cleans it up with an if-else statement, which expresses the function's logic straightforwardly.

---
 kernel/sched/fair.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
kernel/sched/fair.c +4 -9
index a53a610..03ea05b 100644
@@ -616,15 +616,10 @@ static inline u64 calc_delta_fair(u64 delta, struct sched_entity *se)
  */
 static u64 __sched_period(unsigned long nr_running)
 {
-	u64 period = sysctl_sched_latency;
-	unsigned long nr_latency = sched_nr_latency;
-
-	if (unlikely(nr_running > nr_latency)) {
-		period = sysctl_sched_min_granularity;
-		period *= nr_running;
-	}
-
-	return period;
+	if (unlikely(nr_running > sched_nr_latency))
+		return nr_running * sysctl_sched_min_granularity;
+	else
+		return sysctl_sched_latency;
 }
 
 /*
#7 lore raw

[tip:sched/core] sched/fair: Clean up the __sched_period() code

In reply to Boqun Feng
sched/fair: Clean up the __sched_period() code
Commit-ID:  8e2b0bf397279878babcb39b021edcafe7c945eb
Gitweb:     http://git.kernel.org/tip/8e2b0bf397279878babcb39b021edcafe7c945eb
Author:     Boqun Feng <[email protected]>
AuthorDate: Thu, 2 Jul 2015 22:25:52 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 7 Jul 2015 08:46:10 +0200

sched/fair: Clean up the __sched_period() code

Since commit:

4bf0b77158 ("sched: remove do_div() from __sched_slice()")

... the logic of __sched_period() can be implemented as a single if-else without any local variables, so this patch cleans it up with an if-else statement, which expresses the function's logic straightforwardly.

---
 kernel/sched/fair.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
kernel/sched/fair.c +4 -9
index a53a610..03ea05b 100644
@@ -616,15 +616,10 @@ static inline u64 calc_delta_fair(u64 delta, struct sched_entity *se)
  */
 static u64 __sched_period(unsigned long nr_running)
 {
-	u64 period = sysctl_sched_latency;
-	unsigned long nr_latency = sched_nr_latency;
-
-	if (unlikely(nr_running > nr_latency)) {
-		period = sysctl_sched_min_granularity;
-		period *= nr_running;
-	}
-
-	return period;
+	if (unlikely(nr_running > sched_nr_latency))
+		return nr_running * sysctl_sched_min_granularity;
+	else
+		return sysctl_sched_latency;
 }
 
 /*