linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sched/clock: use static_branch_likely() check at sched_clock_running
@ 2019-11-27  8:37 Zhenzhong Duan
  2019-11-27 15:14 ` Steven Rostedt
  2019-11-29  9:59 ` [tip: sched/urgent] sched/clock: Use static_branch_likely() with sched_clock_running tip-bot2 for Zhenzhong Duan
  0 siblings, 2 replies; 3+ messages in thread
From: Zhenzhong Duan @ 2019-11-27  8:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
	rostedt, bsegall, mgorman, Zhenzhong Duan

sched_clock_running is enabled early at bootup stage and never
disabled. So hints that to compiler by using static_branch_likely()
rather than static_branch_unlikely().

Fixes: 46457ea464f5 ("sched/clock: Use static key for sched_clock_running")
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@oracle.com>
---
 kernel/sched/clock.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c
index 1152259..12bca64 100644
--- a/kernel/sched/clock.c
+++ b/kernel/sched/clock.c
@@ -370,7 +370,7 @@ u64 sched_clock_cpu(int cpu)
 	if (sched_clock_stable())
 		return sched_clock() + __sched_clock_offset;
 
-	if (!static_branch_unlikely(&sched_clock_running))
+	if (!static_branch_likely(&sched_clock_running))
 		return sched_clock();
 
 	preempt_disable_notrace();
@@ -393,7 +393,7 @@ void sched_clock_tick(void)
 	if (sched_clock_stable())
 		return;
 
-	if (!static_branch_unlikely(&sched_clock_running))
+	if (!static_branch_likely(&sched_clock_running))
 		return;
 
 	lockdep_assert_irqs_disabled();
@@ -460,7 +460,7 @@ void __init sched_clock_init(void)
 
 u64 sched_clock_cpu(int cpu)
 {
-	if (!static_branch_unlikely(&sched_clock_running))
+	if (!static_branch_likely(&sched_clock_running))
 		return 0;
 
 	return sched_clock();
-- 
1.8.3.1


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

end of thread, other threads:[~2019-11-29  9:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-27  8:37 [PATCH] sched/clock: use static_branch_likely() check at sched_clock_running Zhenzhong Duan
2019-11-27 15:14 ` Steven Rostedt
2019-11-29  9:59 ` [tip: sched/urgent] sched/clock: Use static_branch_likely() with sched_clock_running tip-bot2 for Zhenzhong Duan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).