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: <20170822092731.k6zpoezpee5sal6w@hirez.programming.kicks-ass.net>
Date:   Tue, 22 Aug 2017 11:27:31 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Lukas Wunner <lukas@...ner.de>
Cc:     Bart Van Assche <Bart.VanAssche@....com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Neil Brown <neilb@...e.com>, Ingo Molnar <mingo@...hat.com>,
        Theodore Ts'o <tytso@....edu>, Borislav Petkov <bp@...en8.de>,
        "H. Peter Anvin" <hpa@...or.com>,
        Denys Vlasenko <dvlasenk@...hat.com>,
        "linus.walleij@...aro.org" <linus.walleij@...aro.org>,
        "agk@...hat.com" <agk@...hat.com>,
        "phil@...pberrypi.org" <phil@...pberrypi.org>,
        "linux-gpio@...r.kernel.org" <linux-gpio@...r.kernel.org>,
        "m.duckeck@...bus.de" <m.duckeck@...bus.de>,
        "snitzer@...hat.com" <snitzer@...hat.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/4] bitops: Introduce assign_bit()

On Tue, Aug 22, 2017 at 10:30:50AM +0200, Lukas Wunner wrote:
> diff --git a/include/linux/bitops.h b/include/linux/bitops.h
> index a83c822c35c2..097af36887c0 100644
> --- a/include/linux/bitops.h
> +++ b/include/linux/bitops.h
> @@ -226,6 +226,30 @@ static inline unsigned long __ffs64(u64 word)
>  	return __ffs((unsigned long)word);
>  }
>  
> +/**
> + * assign_bit - Assign value to a bit in memory
> + * @value: the value to assign
> + * @nr: the bit to set
> + * @addr: the address to start counting from
> + */
> +static __always_inline void assign_bit(bool value, long nr,
> +				       volatile unsigned long *addr)
> +{
> +	if (value)
> +		set_bit(nr, addr);
> +	else
> +		clear_bit(nr, addr);
> +}
> +
> +static __always_inline void __assign_bit(bool value, long nr,
> +					 volatile unsigned long *addr)
> +{
> +	if (value)
> +		__set_bit(nr, addr);
> +	else
> +		__clear_bit(nr, addr);
> +}
> +

I dislike the argument order, in C you naturally write: dst = src. So I
would have expected:

	assign_bit(nr, addr, val);

but we have quite a few of these backwards functions in the kernel (like
most of the atomic_t family) and I didn't check to see if the existing
bitops are part of that 'tradition'.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ