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.
To prepare for this, first patch updates '->active_bases' before calling
hrtimer_force_reprogram(), otherwise kernel will throw NULL pointer dereference
errors and will crash.
Second patch creates for_each_active_base() and converts other routines to use
it.
git://git.linaro.org/people/viresh.kumar/linux.git cleanup-hrtimer-for-each-active
V1->V2:
- Added reviewed-by's from Preeti
- Merged 1/3 and 3/3 to form 2/2 as suggested by Frederic
- Added a coverletter as well..
Viresh Kumar (2):
hrtimer: update '->active_bases' before calling
hrtimer_force_reprogram()
hrtimer: create for_each_active_base() to iterate over active
clock-bases
kernel/hrtimer.c | 74 +++++++++++++++++++++++++++++---------------------------
1 file changed, 38 insertions(+), 36 deletions(-)
--
2.0.0.rc2
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(a)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.
*/
--
2.0.0.rc2