All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] timer: Use static_branch_likely() for timers_nohz_active
@ 2021-06-24  8:32 Jisheng Zhang
  2021-08-10 16:00 ` Thomas Gleixner
  0 siblings, 1 reply; 3+ messages in thread
From: Jisheng Zhang @ 2021-06-24  8:32 UTC (permalink / raw)
  To: John Stultz, Thomas Gleixner, Stephen Boyd; +Cc: linux-kernel

The static key timers_nohz_active is likely to be true, so use
static_branch_likely() to reflect this fact.

Per include/linux/jump_label.h:

 * type\branch|	likely (1)	      |	unlikely (0)
 * -----------+-----------------------+------------------
 *            |                       |
 *  true (1)  |	   ...		      |	   ...
 *            |    NOP		      |	   JMP L
 *            |    <br-stmts>	      |	1: ...
 *            |	L: ...		      |
 *            |			      |
 *            |			      |	L: <br-stmts>
 *            |			      |	   jmp 1b
 *            |                       |
 * -----------+-----------------------+------------------

This could improve the finally generated code a bit for the most likely
scenario, I.E save two "jmp" instructions.

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
---
Since v1:
 - update the commit msg to avoid confusing and add some descriptions about
   where's the improvement from.

 kernel/time/timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index d111adf4a0cb..40d4fe7fa207 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -265,7 +265,7 @@ int timer_migration_handler(struct ctl_table *table, int write,
 
 static inline bool is_timers_nohz_active(void)
 {
-	return static_branch_unlikely(&timers_nohz_active);
+	return static_branch_likely(&timers_nohz_active);
 }
 #else
 static inline bool is_timers_nohz_active(void) { return false; }
-- 
2.31.0


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

* Re: [PATCH v2] timer: Use static_branch_likely() for timers_nohz_active
  2021-06-24  8:32 [PATCH v2] timer: Use static_branch_likely() for timers_nohz_active Jisheng Zhang
@ 2021-08-10 16:00 ` Thomas Gleixner
  2021-08-20 10:18   ` Jisheng Zhang
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Gleixner @ 2021-08-10 16:00 UTC (permalink / raw)
  To: Jisheng Zhang, John Stultz, Stephen Boyd; +Cc: linux-kernel

Jisheng,

On Thu, Jun 24 2021 at 16:32, Jisheng Zhang wrote:

> The static key timers_nohz_active is likely to be true, so use
> static_branch_likely() to reflect this fact.

you still lack any justification for your statement that NOHZ active is
likely.

It might be likely for your system, but is this true in general?

Thanks,

        tglx

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

* Re: [PATCH v2] timer: Use static_branch_likely() for timers_nohz_active
  2021-08-10 16:00 ` Thomas Gleixner
@ 2021-08-20 10:18   ` Jisheng Zhang
  0 siblings, 0 replies; 3+ messages in thread
From: Jisheng Zhang @ 2021-08-20 10:18 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: John Stultz, Stephen Boyd, linux-kernel

On Tue, 10 Aug 2021 18:00:16 +0200 Thomas Gleixner wrote:

> 
> 
> Jisheng,

Hi Thomas,

> 
> On Thu, Jun 24 2021 at 16:32, Jisheng Zhang wrote:
> 
> > The static key timers_nohz_active is likely to be true, so use
> > static_branch_likely() to reflect this fact.  
> 
> you still lack any justification for your statement that NOHZ active is
> likely.

This patch only affects NO_HZ_COMMON=y code path which is enabled if either
NO_HZ_IDLE or NO_HZ_FULL = y.
Per my understanding, when the system has oneshot tick device, NOHZ active
is likely true. After going through drivers/clocksource/*, I found there are
about 86 drivers, 69(occupies 80%) of which support CLOCK_EVT_FEAT_ONESHOT.
Then I browsed apic, hpet and xen timer source code in x86 directory, they
all support oneshot feature.

I'm not sure whether I misunderstood the code or not.

Thanks

> 
> It might be likely for your system, but is this true in general?
> 



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

end of thread, other threads:[~2021-08-20 10:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-24  8:32 [PATCH v2] timer: Use static_branch_likely() for timers_nohz_active Jisheng Zhang
2021-08-10 16:00 ` Thomas Gleixner
2021-08-20 10:18   ` Jisheng Zhang

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.