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

From: Zhongqiu Han
Date: Wed Jan 15 2025 - 22:37:13 EST


On 1/16/2025 5:12 AM, Thomas Gleixner wrote:
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().

Acknowledged.

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.

Acknowledged.

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
Hi tglx / Frederic,
Thanks for the review.
Since you will help modify the commit message when applying, I will not
arise patchset2. Thanks~



--
Thx and BRs,
Zhongqiu Han