lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1511971563.19952.63.camel@perches.com>
Date:   Wed, 29 Nov 2017 08:06:03 -0800
From:   Joe Perches <joe@...ches.com>
To:     Anna-Maria Gleixner <anna-maria@...utronix.de>,
        LKML <linux-kernel@...r.kernel.org>
Cc:     Thomas Gleixner <tglx@...utronix.de>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>, keescook@...omium.org,
        Christoph Hellwig <hch@....de>,
        John Stultz <john.stultz@...aro.org>
Subject: Re: [PATCH v3 10/36] hrtimer: Switch for loop to _ffs() evaluation

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];
}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ