Re: [PATCH] timers: Optimize get_timer_cpu_base() to reduce potentially redundant per_cpu_ptr() calls

From: Thomas Gleixner
Date: Wed Jan 15 2025 - 16:13:06 EST


On Tue, Dec 31 2024 at 23:01, Zhongqiu Han wrote:
> If the timer is deferrable and NO_HZ_COMMON is enabled, the function
> get_timer_cpu_base() will call per_cpu_ptr() twice. Optimize the function
> to avoid potentially redundant per_cpu_ptr() calls.

This lacks an explanation for the second hunk which changes
get_timer_this_cpu_base().

> One of the call paths of the get_timer_cpu_base() function is through the
> lock_timer_base() function, which contains a loop. Within this loop, the
> get_timer_base() func is called, and in turn, it calls the
> get_timer_cpu_base() function. And in such a path, get_timer_cpu_base is
> a hotspot function. It is called approximately 13,000 times in 12 seconds
> on test x86 KVM machines.

Which is roughly once per millisecond and depending on the number of
CPUs that's far from a hotspot.

I'm not against the change per se, but this change log is a bit over the
top aside of ot mentioning the second hunk. I'll fix it up when
applying.

Thanks,

tglx