At several instances we iterate over all possible clock-bases for a particular cpu-base. Whereas, we only need to iterate over active bases.
We already have per cpu-base 'active_bases' field which is updated on addition/removal of hrtimers.
This patch creates for_each_active_base() which uses this existing infrastructure to only iterate over active bases.
Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- Hi,
I am trying to upstream useful parts of my long cleanup series which never got attention due to my bad approach. Please see if it looks fine, I will send it upstream then.
It doesn't have anything to do with ONESHOT_STOPPED series :).
kernel/hrtimer.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index 3ab2899..c751322 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c @@ -109,6 +109,19 @@ static inline int hrtimer_clockid_to_base(clockid_t clock_id)
/* + * for_each_active_base: iterate over all active clock bases + * @_index: 'int' variable for internal purpose + * @_base: holds pointer to a active clock base + * @_cpu_base: cpu base to iterate on + * @_active_bases: 'unsigned int' variable for internal purpose + */ +#define for_each_active_base(_index, _base, _cpu_base, _active_bases) \ + for ((_active_bases) = (_cpu_base)->active_bases; \ + (_index) = ffs(_active_bases), \ + (_base) = (_cpu_base)->clock_base + (_index) - 1, (_index); \ + (_active_bases) &= ~(1 << ((_index) - 1))) + +/* * Get the coarse grained time at the softirq based on xtime and * wall_to_monotonic. */