All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched/clock: Remove pointless test in cpu_clock/local_clock
@ 2016-04-01 13:46 Daniel Lezcano
  2016-04-01 15:10 ` Peter Zijlstra
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Lezcano @ 2016-04-01 13:46 UTC (permalink / raw)
  To: peterz; +Cc: Ingo Molnar, open list:SCHEDULER

In case the HAVE_UNSTABLE_SCHED_CLOCK config is set, the cpu_clock() version
checks if sched_clock_stable() is not set and calls sched_clock_cpu(),
otherwise it calls sched_clock().

sched_clock_cpu() checks also if sched_clock_stable() is set and, if true,
calls sched_clock().

sched_clock() will be called in sched_clock_cpu() if sched_clock_stable() is
true.

Remove the duplicate test by directly calling sched_clock_cpu() and let the
static key act in this function instead. We can assume gcc is smart enough to
inline cpu_clock()/local_clock() to sched_clock_cpu().

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 kernel/sched/clock.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c
index fedb967..30c4b20 100644
--- a/kernel/sched/clock.c
+++ b/kernel/sched/clock.c
@@ -375,10 +375,7 @@ EXPORT_SYMBOL_GPL(sched_clock_idle_wakeup_event);
  */
 u64 cpu_clock(int cpu)
 {
-	if (!sched_clock_stable())
-		return sched_clock_cpu(cpu);
-
-	return sched_clock();
+	return sched_clock_cpu(cpu);
 }
 
 /*
@@ -390,10 +387,7 @@ u64 cpu_clock(int cpu)
  */
 u64 local_clock(void)
 {
-	if (!sched_clock_stable())
-		return sched_clock_cpu(raw_smp_processor_id());
-
-	return sched_clock();
+	return sched_clock_cpu(raw_smp_processor_id());
 }
 
 #else /* CONFIG_HAVE_UNSTABLE_SCHED_CLOCK */
-- 
1.9.1

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

* Re: [PATCH] sched/clock: Remove pointless test in cpu_clock/local_clock
  2016-04-01 13:46 [PATCH] sched/clock: Remove pointless test in cpu_clock/local_clock Daniel Lezcano
@ 2016-04-01 15:10 ` Peter Zijlstra
  2016-04-01 17:59   ` Daniel Lezcano
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2016-04-01 15:10 UTC (permalink / raw)
  To: Daniel Lezcano; +Cc: Ingo Molnar, open list:SCHEDULER

On Fri, Apr 01, 2016 at 03:46:48PM +0200, Daniel Lezcano wrote:

> Remove the duplicate test by directly calling sched_clock_cpu() and let the
> static key act in this function instead. We can assume gcc is smart enough to
> inline cpu_clock()/local_clock() to sched_clock_cpu().

Why assume if you can easily check; so does it indeed inline?

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

* Re: [PATCH] sched/clock: Remove pointless test in cpu_clock/local_clock
  2016-04-01 15:10 ` Peter Zijlstra
@ 2016-04-01 17:59   ` Daniel Lezcano
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Lezcano @ 2016-04-01 17:59 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: Ingo Molnar, open list:SCHEDULER

On 04/01/2016 05:10 PM, Peter Zijlstra wrote:
> On Fri, Apr 01, 2016 at 03:46:48PM +0200, Daniel Lezcano wrote:
>
>> Remove the duplicate test by directly calling sched_clock_cpu() and let the
>> static key act in this function instead. We can assume gcc is smart enough to
>> inline cpu_clock()/local_clock() to sched_clock_cpu().
>
> Why assume if you can easily check; so does it indeed inline?

Actually, no. They are not inlined.

With this patch we end up with one line functions:

#ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK

u64 cpu_clock(int cpu)
{
	return sched_clock_cpu(cpu);
}

u64 local_clock(void)
{
	return sched_clock_cpu(raw_smp_processor_id());
}

#else

u64 cpu_clock(int cpu)
{
	return sched_clock();
}

u64 local_clock(void)
{
	return sched_clock();
}

#endif

is it worth to convert them to static inline function ?

(static inline does effectively inline those functions).

-- 
  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

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

end of thread, other threads:[~2016-04-01 17:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-01 13:46 [PATCH] sched/clock: Remove pointless test in cpu_clock/local_clock Daniel Lezcano
2016-04-01 15:10 ` Peter Zijlstra
2016-04-01 17:59   ` Daniel Lezcano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.