* Re: [linux-next:master 1617/1848] include/linux/compiler_types.h:630:45: error: call to '__compiletime_assert_612' declared with attribute error: min(((pos + len - 1) >> 12) - (pos >> 12) + 1, max_pages) signedness error
[not found] <202512160948.O7QqxHj2-lkp@intel.com>
@ 2025-12-16 11:02 ` David Laight
0 siblings, 0 replies; only message in thread
From: David Laight @ 2025-12-16 11:02 UTC (permalink / raw)
To: kernel test robot; +Cc: oe-kbuild-all, Christian Brauner, linux-fsdevel, miklos
On Tue, 16 Dec 2025 09:05:42 +0100
kernel test robot <lkp@intel.com> wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> head: 563c8dd425b59e44470e28519107b1efc99f4c7b
> commit: 0f5bb0cfb0b40a31d2fe146ecbef5727690fa547 [1617/1848] fs: use min() or umin() instead of min_t()
> config: i386-randconfig-2006-20250825 (https://download.01.org/0day-ci/archive/20251216/202512160948.O7QqxHj2-lkp@intel.com/config)
> compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251216/202512160948.O7QqxHj2-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202512160948.O7QqxHj2-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
> In file included from <command-line>:
> In function 'fuse_wr_pages',
> inlined from 'fuse_perform_write' at fs/fuse/file.c:1347:27:
> >> include/linux/compiler_types.h:630:45: error: call to '__compiletime_assert_612' declared with attribute error: min(((pos + len - 1) >> 12) - (pos >> 12) + 1, max_pages) signedness error
...
The definitions are:
loff_t pos - 64bit signed.
size_t len - unsigned long, 32bit for this i386 build.
unsigned int max_pages - 32 bit unsigned.
On a 64bit build 'len' is 64bits unsigned which promotes the LHS to
unsigned and min() is happy.
On a 32bit build this doesn't happen, the LHS remains signed and
min() is unhappy.
I'm not sure why file offsets are signed (apart from relative lseek()),
causes signedness issues in a few places.
In any case there are a few ways to fix this.
Clearly a cast could be used somewhere, the most subtle would be changing
the prototype to 'u64 len'.
Perhaps better is rewriting the conditional as:
min(((len + (pos & (PAGE_SIZE - 1)) - 1) >> PAGE_SHIFT) + 1,
max_pages);
Although the LHS is still signed 64bit, the compiler knows it can't
be negative.
This still contains a lot of 64bit maths, adding a cast:
min(((len + (size_t)(pos & (PAGE_SIZE - 1)) - 1) >> PAGE_SHIFT) + 1,
makes it 32bit and the generated code much, much better.
In theory the expression can overflow (fixable by masking off the high bit
of 'len' (eg (len << 1 >> 1)), but normal IO are limited to MAX_RW_COUNT
(INT_MAX & PAGE_MASK) even on 64bit.
I'm not sure io_uring enforces that limit (it should, a lot of drivers are
broken if the requested size exceeds 4G).
David
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-12-16 12:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <202512160948.O7QqxHj2-lkp@intel.com>
2025-12-16 11:02 ` [linux-next:master 1617/1848] include/linux/compiler_types.h:630:45: error: call to '__compiletime_assert_612' declared with attribute error: min(((pos + len - 1) >> 12) - (pos >> 12) + 1, max_pages) signedness error David Laight
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox