[RFC patch 2/5] hrtimer: Make use of the active bases bitfield
From: Thomas Gleixner
Date: Fri Feb 21 2014 - 12:57:03 EST
Instead of looping through all bases, find the active ones via the
cpu_base->active_bases bit field.
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
---
kernel/hrtimer.c | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
Index: tip/kernel/hrtimer.c
===================================================================
--- tip.orig/kernel/hrtimer.c
+++ tip/kernel/hrtimer.c
@@ -1284,7 +1284,8 @@ void hrtimer_interrupt(struct clock_even
{
struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
ktime_t expires_next, now, entry_time, delta;
- int i, retries = 0;
+ unsigned long bases;
+ int retries = 0;
BUG_ON(!cpu_base->hres_active);
cpu_base->nr_events++;
@@ -1302,16 +1303,18 @@ retry:
* this CPU.
*/
cpu_base->expires_next.tv64 = KTIME_MAX;
+ bases = cpu_base->active_bases;
- for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) {
+ while (bases) {
struct hrtimer_clock_base *base;
struct timerqueue_node *node;
ktime_t basenow;
+ int idx;
- if (!(cpu_base->active_bases & (1 << i)))
- continue;
+ idx = __ffs(bases);
+ bases &= ~(1 << idx);
- base = cpu_base->clock_base + i;
+ base = cpu_base->clock_base + idx;
basenow = ktime_add(now, base->offset);
while ((node = timerqueue_getnext(&base->active))) {
@@ -1479,18 +1482,24 @@ void hrtimer_run_pending(void)
*/
void hrtimer_run_queues(void)
{
- struct timerqueue_node *node;
struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
- struct hrtimer_clock_base *base;
- int index, gettime = 1;
+ unsigned long bases;
+ int gettime = 1;
if (hrtimer_hres_active())
return;
- for (index = 0; index < HRTIMER_MAX_CLOCK_BASES; index++) {
- base = &cpu_base->clock_base[index];
- if (!timerqueue_getnext(&base->active))
- continue;
+ bases = cpu_base->active_bases;
+
+ while (bases) {
+ struct hrtimer_clock_base *base;
+ struct timerqueue_node *node;
+ int idx;
+
+ idx = __ffs(bases);
+ bases &= ~(1 << idx);
+
+ base = &cpu_base->clock_base[idx];
if (gettime) {
hrtimer_get_softirq_time(cpu_base);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/