lkml.org 
[lkml]   [2017]   [Nov]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v3 10/36] hrtimer: Switch for loop to _ffs() evaluation
From
Date
On Wed, 2017-11-29 at 16:30 +0100, Anna-Maria Gleixner wrote:
> Looping over all clock bases to find active bits is suboptimal if not all
> bases are active.
>
> Avoid this by converting it to a __ffs() evaluation. The functionallity is
> outsourced into an own function and is called via a macro as suggested by
> Peter Zijlstra.

style trivia: ignore at your pleasure...

> diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
[]
> @@ -448,6 +448,23 @@ static inline void debug_deactivate(struct hrtimer *timer)
> trace_hrtimer_cancel(timer);
> }
>
> +static struct hrtimer_clock_base *
> +__next_base(struct hrtimer_cpu_base *cpu_base, unsigned int *active)
> +{
> + struct hrtimer_clock_base *base = NULL;
> +
> + if (*active) {
> + unsigned int idx = __ffs(*active);
> + *active &= ~(1U << idx);
> + base = &cpu_base->clock_base[idx];
> + }
> +
> + return base;
> +}

This might be nicer using an initial test and return like:

{
unsigned int idx;

if (!*active)
return NULL;

idx = __ffs(*active);
*active &= ~(1U << idx);

return &cpu_base->clock_base[idx];
}

\
 
 \ /
  Last update: 2017-11-29 17:07    [W:0.117 / U:0.252 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site