Linux-arch Archive mirror
 help / color / mirror / Atom feed
From: "Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>
To: Thorsten Blum <thorsten.blum@toblux.com>, Arnd Bergmann <arnd@arndb.de>
Cc: Xiao Wang <xiao.w.wang@intel.com>,
	Palmer Dabbelt <palmer@rivosinc.com>,
	Charlie Jenkins <charlie@rivosinc.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Huacai Chen <chenhuacai@kernel.org>,
	Youling Tang <tangyouling@loongson.cn>,
	Tiezhu Yang <yangtiezhu@loongson.cn>,
	Jinyang He <hejinyang@loongson.cn>,
	linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] bitops: Change function return types from long to int
Date: Mon, 22 Apr 2024 09:44:40 +0200	[thread overview]
Message-ID: <42e6a510-9000-44a4-b6bf-2bca9cf74d5e@linux.intel.com> (raw)
In-Reply-To: <20240420223836.241472-1-thorsten.blum@toblux.com>

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@toblux.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

  parent reply	other threads:[~2024-04-22  7:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-20 22:38 [PATCH] bitops: Change function return types from long to int Thorsten Blum
2024-04-22  5:24 ` Wang, Xiao W
2024-04-22  9:15   ` Thorsten Blum
2024-04-22  7:44 ` Amadeusz Sławiński [this message]
2024-04-22 14:30   ` Thorsten Blum
2024-04-22 15:55     ` Arnd Bergmann
2024-04-23 11:45       ` Thorsten Blum
2024-05-03 14:49         ` Thorsten Blum
2024-05-03 15:05           ` Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42e6a510-9000-44a4-b6bf-2bca9cf74d5e@linux.intel.com \
    --to=amadeuszx.slawinski@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=charlie@rivosinc.com \
    --cc=chenhuacai@kernel.org \
    --cc=hejinyang@loongson.cn \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=palmer@rivosinc.com \
    --cc=tangyouling@loongson.cn \
    --cc=thorsten.blum@toblux.com \
    --cc=xiao.w.wang@intel.com \
    --cc=yangtiezhu@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).