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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 22 Apr 2024 09:44:40 +0200
From: Amadeusz Sławiński
 <amadeuszx.slawinski@...ux.intel.com>
To: Thorsten Blum <thorsten.blum@...lux.com>, Arnd Bergmann <arnd@...db.de>
Cc: Xiao Wang <xiao.w.wang@...el.com>, Palmer Dabbelt <palmer@...osinc.com>,
 Charlie Jenkins <charlie@...osinc.com>, Namhyung Kim <namhyung@...nel.org>,
 Huacai Chen <chenhuacai@...nel.org>, Youling Tang <tangyouling@...ngson.cn>,
 Tiezhu Yang <yangtiezhu@...ngson.cn>, Jinyang He <hejinyang@...ngson.cn>,
 linux-arch@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] bitops: Change function return types from long to int

On 4/21/2024 12:38 AM, Thorsten Blum wrote:
> Change the return types of bitops functions (ffs, fls, and fns) from
> long to int. The expected return values are in the range [0, 64], for
> which int is sufficient.
> 
> Additionally, int aligns well with the return types of the corresponding
> __builtin_* functions, potentially reducing overall type conversions.
> 
> Many of the existing bitops functions already return an int and don't
> need to be changed. The bitops functions in arch/ should be considered
> separately.
> 
> Adjust some return variables to match the function return types.
> 
> With GCC 13 and defconfig, these changes reduced the size of a test
> kernel image by 5,432 bytes on arm64 and by 248 bytes on riscv; there
> were no changes in size on x86_64, powerpc, or m68k.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@...lux.com>
> ---
>   include/asm-generic/bitops/__ffs.h         | 4 ++--
>   include/asm-generic/bitops/__fls.h         | 4 ++--
>   include/asm-generic/bitops/builtin-__ffs.h | 2 +-
>   include/asm-generic/bitops/builtin-__fls.h | 2 +-
>   include/linux/bitops.h                     | 6 +++---
>   tools/include/asm-generic/bitops/__ffs.h   | 4 ++--
>   tools/include/asm-generic/bitops/__fls.h   | 4 ++--
>   tools/include/linux/bitops.h               | 2 +-
>   8 files changed, 14 insertions(+), 14 deletions(-)

I don't mind the idea, but in the past I've send some patches trying to 
align some arch specific implementations with asm-generic ones. Now you 
are changing only asm-generic implementation and leaving arch specific 
ones untouched (that's probably why you see no size change on some of them).

For example on x86, there is:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/include/asm/bitops.h?id=ed30a4a51bb196781c8058073ea720133a65596f#n293
and you probably need to check all architectures for those implementations.

Thanks,
Amadeusz

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ