public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
* s390: block/blk-iocost.c:1101:11: error: call to '__compiletime_assert_557' declared with 'error' attribute: clamp() low limit 1 greater than high limit active
@ 2024-12-04 10:31 Naresh Kamboju
  2024-12-04 14:39 ` Dan Carpenter
  0 siblings, 1 reply; 7+ messages in thread
From: Naresh Kamboju @ 2024-12-04 10:31 UTC (permalink / raw)
  To: linux-s390, clang-built-linux, linux-block, open list,
	lkft-triage, Linux Regressions
  Cc: Anders Roxell, Arnd Bergmann, Dan Carpenter, Nathan Chancellor,
	Jens Axboe

The s390 builds failed with clang-19 with defconfig on the
Linux next-20241203 tag due to following build warnings / errors.
Build pass with gcc-13 defconfig for s390.

First seen on Linux next-20241203 tag
GOOD: Linux next-20241128 tag
BAD: Linux next-20241203 tag

List of arch and toolchains :
  s390 defconfig with clang-19

s390:
  build:
    * clang-19-defconfig
    * korg-clang-19-lkftconfig-lto-full
    * korg-clang-19-lkftconfig-hardening
    * korg-clang-19-lkftconfig-lto-thing

Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>

Build log:
===========
block/blk-iocost.c:1101:11: error: call to '__compiletime_assert_557'
declared with 'error' attribute: clamp() low limit 1 greater than high
limit active
 1101 |                 inuse = clamp_t(u32, inuse, 1, active);
      |                         ^
include/linux/minmax.h:218:36: note: expanded from macro 'clamp_t'
  218 | #define clamp_t(type, val, lo, hi) __careful_clamp(type, val, lo, hi)
      |                                    ^
include/linux/minmax.h:195:2: note: expanded from macro '__careful_clamp'
  195 |         __clamp_once(type, val, lo, hi, __UNIQUE_ID(v_),
__UNIQUE_ID(l_), __UNIQUE_ID(h_))
      |         ^
include/linux/minmax.h:188:2: note: expanded from macro '__clamp_once'
  188 |         BUILD_BUG_ON_MSG(statically_true(ulo > uhi),
                 \
      |         ^
note: (skipping 2 expansions in backtrace; use
-fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:530:2: note: expanded from macro
'_compiletime_assert'
  530 |         __compiletime_assert(condition, msg, prefix, suffix)
      |         ^
include/linux/compiler_types.h:523:4: note: expanded from macro
'__compiletime_assert'
  523 |                         prefix ## suffix();
         \
      |                         ^
<scratch space>:38:1: note: expanded from here
   38 | __compiletime_assert_557
      | ^
block/blk-iocost.c:1101:11: error: call to '__compiletime_assert_557'
declared with 'error' attribute: clamp() low limit 1 greater than high
limit active
include/linux/minmax.h:218:36: note: expanded from macro 'clamp_t'
  218 | #define clamp_t(type, val, lo, hi) __careful_clamp(type, val, lo, hi)
      |                                    ^
include/linux/minmax.h:195:2: note: expanded from macro '__careful_clamp'
  195 |         __clamp_once(type, val, lo, hi, __UNIQUE_ID(v_),
__UNIQUE_ID(l_), __UNIQUE_ID(h_))
      |         ^
include/linux/minmax.h:188:2: note: expanded from macro '__clamp_once'
  188 |         BUILD_BUG_ON_MSG(statically_true(ulo > uhi),
                 \
      |         ^
note: (skipping 2 expansions in backtrace; use
-fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:530:2: note: expanded from macro
'_compiletime_assert'
  530 |         __compiletime_assert(condition, msg, prefix, suffix)
      |         ^
include/linux/compiler_types.h:523:4: note: expanded from macro
'__compiletime_assert'
  523 |                         prefix ## suffix();
         \
      |                         ^
<scratch space>:38:1: note: expanded from here
   38 | __compiletime_assert_557
      | ^
2 errors generated.

Links:
---
- https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20241203/testrun/26188938/suite/build/test/clang-19-defconfig/log
- https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20241203/testrun/26188938/suite/build/test/clang-19-defconfig/history/
- https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20241203/testrun/26188938/suite/build/test/clang-19-defconfig/details/

Steps to reproduce:
------------
# tuxmake --runtime podman --target-arch s390 --toolchain clang-19
--kconfig defconfig LLVM_IAS=1

metadata:
----
  git describe: next-20241203
  git repo: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
  git sha: c245a7a79602ccbee780c004c1e4abcda66aec32
  kernel config:
https://storage.tuxsuite.com/public/linaro/lkft/builds/2pjAPS9UrJkbAKFHktQei7eqW4Y/config
  build url: https://storage.tuxsuite.com/public/linaro/lkft/builds/2pjAPS9UrJkbAKFHktQei7eqW4Y/
  toolchain: clang-19
  config: clang-19-defconfig
  arch: s390

--
Linaro LKFT
https://lkft.linaro.org

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: s390: block/blk-iocost.c:1101:11: error: call to '__compiletime_assert_557' declared with 'error' attribute: clamp() low limit 1 greater than high limit active
  2024-12-04 10:31 s390: block/blk-iocost.c:1101:11: error: call to '__compiletime_assert_557' declared with 'error' attribute: clamp() low limit 1 greater than high limit active Naresh Kamboju
@ 2024-12-04 14:39 ` Dan Carpenter
  2024-12-04 16:11   ` David Laight
  0 siblings, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2024-12-04 14:39 UTC (permalink / raw)
  To: Naresh Kamboju, David Laight
  Cc: linux-s390, clang-built-linux, linux-block, open list,
	lkft-triage, Linux Regressions, Anders Roxell, Arnd Bergmann,
	Nathan Chancellor, Jens Axboe

Let's add David to the Cc list because he's the expert on clamp().

regards,
dan carpenter

On Wed, Dec 04, 2024 at 04:01:09PM +0530, Naresh Kamboju wrote:
> The s390 builds failed with clang-19 with defconfig on the
> Linux next-20241203 tag due to following build warnings / errors.
> Build pass with gcc-13 defconfig for s390.
> 
> First seen on Linux next-20241203 tag
> GOOD: Linux next-20241128 tag
> BAD: Linux next-20241203 tag
> 
> List of arch and toolchains :
>   s390 defconfig with clang-19
> 
> s390:
>   build:
>     * clang-19-defconfig
>     * korg-clang-19-lkftconfig-lto-full
>     * korg-clang-19-lkftconfig-hardening
>     * korg-clang-19-lkftconfig-lto-thing
> 
> Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
> 
> Build log:
> ===========
> block/blk-iocost.c:1101:11: error: call to '__compiletime_assert_557'
> declared with 'error' attribute: clamp() low limit 1 greater than high
> limit active
>  1101 |                 inuse = clamp_t(u32, inuse, 1, active);
>       |                         ^
> include/linux/minmax.h:218:36: note: expanded from macro 'clamp_t'
>   218 | #define clamp_t(type, val, lo, hi) __careful_clamp(type, val, lo, hi)
>       |                                    ^
> include/linux/minmax.h:195:2: note: expanded from macro '__careful_clamp'
>   195 |         __clamp_once(type, val, lo, hi, __UNIQUE_ID(v_),
> __UNIQUE_ID(l_), __UNIQUE_ID(h_))
>       |         ^
> include/linux/minmax.h:188:2: note: expanded from macro '__clamp_once'
>   188 |         BUILD_BUG_ON_MSG(statically_true(ulo > uhi),
>                  \
>       |         ^
> note: (skipping 2 expansions in backtrace; use
> -fmacro-backtrace-limit=0 to see all)
> include/linux/compiler_types.h:530:2: note: expanded from macro
> '_compiletime_assert'
>   530 |         __compiletime_assert(condition, msg, prefix, suffix)
>       |         ^
> include/linux/compiler_types.h:523:4: note: expanded from macro
> '__compiletime_assert'
>   523 |                         prefix ## suffix();
>          \
>       |                         ^
> <scratch space>:38:1: note: expanded from here
>    38 | __compiletime_assert_557
>       | ^
> block/blk-iocost.c:1101:11: error: call to '__compiletime_assert_557'
> declared with 'error' attribute: clamp() low limit 1 greater than high
> limit active
> include/linux/minmax.h:218:36: note: expanded from macro 'clamp_t'
>   218 | #define clamp_t(type, val, lo, hi) __careful_clamp(type, val, lo, hi)
>       |                                    ^
> include/linux/minmax.h:195:2: note: expanded from macro '__careful_clamp'
>   195 |         __clamp_once(type, val, lo, hi, __UNIQUE_ID(v_),
> __UNIQUE_ID(l_), __UNIQUE_ID(h_))
>       |         ^
> include/linux/minmax.h:188:2: note: expanded from macro '__clamp_once'
>   188 |         BUILD_BUG_ON_MSG(statically_true(ulo > uhi),
>                  \
>       |         ^
> note: (skipping 2 expansions in backtrace; use
> -fmacro-backtrace-limit=0 to see all)
> include/linux/compiler_types.h:530:2: note: expanded from macro
> '_compiletime_assert'
>   530 |         __compiletime_assert(condition, msg, prefix, suffix)
>       |         ^
> include/linux/compiler_types.h:523:4: note: expanded from macro
> '__compiletime_assert'
>   523 |                         prefix ## suffix();
>          \
>       |                         ^
> <scratch space>:38:1: note: expanded from here
>    38 | __compiletime_assert_557
>       | ^
> 2 errors generated.
> 
> Links:
> ---
> - https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20241203/testrun/26188938/suite/build/test/clang-19-defconfig/log
> - https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20241203/testrun/26188938/suite/build/test/clang-19-defconfig/history/
> - https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20241203/testrun/26188938/suite/build/test/clang-19-defconfig/details/
> 
> Steps to reproduce:
> ------------
> # tuxmake --runtime podman --target-arch s390 --toolchain clang-19
> --kconfig defconfig LLVM_IAS=1
> 
> metadata:
> ----
>   git describe: next-20241203
>   git repo: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
>   git sha: c245a7a79602ccbee780c004c1e4abcda66aec32
>   kernel config:
> https://storage.tuxsuite.com/public/linaro/lkft/builds/2pjAPS9UrJkbAKFHktQei7eqW4Y/config
>   build url: https://storage.tuxsuite.com/public/linaro/lkft/builds/2pjAPS9UrJkbAKFHktQei7eqW4Y/
>   toolchain: clang-19
>   config: clang-19-defconfig
>   arch: s390
> 
> --
> Linaro LKFT
> https://lkft.linaro.org

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: s390: block/blk-iocost.c:1101:11: error: call to '__compiletime_assert_557' declared with 'error' attribute: clamp() low limit 1 greater than high limit active
  2024-12-04 14:39 ` Dan Carpenter
@ 2024-12-04 16:11   ` David Laight
  2024-12-04 16:50     ` Dan Carpenter
  0 siblings, 1 reply; 7+ messages in thread
From: David Laight @ 2024-12-04 16:11 UTC (permalink / raw)
  To: 'Dan Carpenter', Naresh Kamboju
  Cc: linux-s390@vger.kernel.org, clang-built-linux, linux-block,
	open list, lkft-triage@lists.linaro.org, Linux Regressions,
	Anders Roxell, Arnd Bergmann, Nathan Chancellor, Jens Axboe

From: Dan Carpenter <dan.carpenter@linaro.org>
> Sent: 04 December 2024 14:39
> 
> Let's add David to the Cc list because he's the expert on clamp().

The traceback info misses the important point.
I can't see the 'inlined from line 2225' message.

We have (line 1084):
static void __propagate_weights(struct ioc_gq *iocg, u32 active, u32 inuse,
				bool save, struct ioc_now *now)
followed by:
		inuse = clamp_t(u32, inuse, 1, active);

But line 2225 has:
	__propagate_weights(iocg, 0, 0, false, now);

With aggressive inlining the compiler sees 'active == 0'
and the lo > hi test correctly triggers.

The previous version only verified 'lo <= hi' if it was a constant
integer expression - which it isn't here.

No idea what the code is trying to do, nor what value it expects
clamp(val, 1, 0) to generate - likely to be 0 or 1 depending on
the order of the comparisons.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: s390: block/blk-iocost.c:1101:11: error: call to '__compiletime_assert_557' declared with 'error' attribute: clamp() low limit 1 greater than high limit active
  2024-12-04 16:11   ` David Laight
@ 2024-12-04 16:50     ` Dan Carpenter
  2024-12-04 17:40       ` Tejun Heo
  0 siblings, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2024-12-04 16:50 UTC (permalink / raw)
  To: David Laight, Tejun Heo
  Cc: Naresh Kamboju, linux-s390@vger.kernel.org, clang-built-linux,
	linux-block, open list, lkft-triage@lists.linaro.org,
	Linux Regressions, Anders Roxell, Arnd Bergmann,
	Nathan Chancellor, Jens Axboe

Tejun probably reads everything to linux-block, but let's CC him explicitly.

block/blk-iocost.c
  2222                          TRACE_IOCG_PATH(iocg_idle, iocg, now,
  2223                                          atomic64_read(&iocg->active_period),
  2224                                          atomic64_read(&ioc->cur_period), vtime);
  2225                          __propagate_weights(iocg, 0, 0, false, now);
                                                          ^
Why is "active" zero?  __propagate_weights() does a clamp() to 1 as minimum and
we've added new build time asserts so this breaks the build.

  2226                          list_del_init(&iocg->active_list);

The other way to solve this would be to something stupid like:

diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index 384aa15e8260..551edd2f661f 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -1094,7 +1094,7 @@ static void __propagate_weights(struct ioc_gq *iocg, u32 active, u32 inuse,
         * @active. An active internal node's inuse is solely determined by the
         * inuse to active ratio of its children regardless of @inuse.
         */
-       if (list_empty(&iocg->active_list) && iocg->child_active_sum) {
+       if ((list_empty(&iocg->active_list) && iocg->child_active_sum) || active == 0) {
                inuse = DIV64_U64_ROUND_UP(active * iocg->child_inuse_sum,
                                           iocg->child_active_sum);
        } else {

But that seems really stupid.

regards,
dan carpenter

On Wed, Dec 04, 2024 at 04:11:33PM +0000, David Laight wrote:
> From: Dan Carpenter <dan.carpenter@linaro.org>
> > Sent: 04 December 2024 14:39
> > 
> > Let's add David to the Cc list because he's the expert on clamp().
> 
> The traceback info misses the important point.
> I can't see the 'inlined from line 2225' message.
> 
> We have (line 1084):
> static void __propagate_weights(struct ioc_gq *iocg, u32 active, u32 inuse,
> 				bool save, struct ioc_now *now)
> followed by:
> 		inuse = clamp_t(u32, inuse, 1, active);
> 
> But line 2225 has:
> 	__propagate_weights(iocg, 0, 0, false, now);
> 
> With aggressive inlining the compiler sees 'active == 0'
> and the lo > hi test correctly triggers.
> 
> The previous version only verified 'lo <= hi' if it was a constant
> integer expression - which it isn't here.
> 
> No idea what the code is trying to do, nor what value it expects
> clamp(val, 1, 0) to generate - likely to be 0 or 1 depending on
> the order of the comparisons.
> 
> 	David
> 
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: s390: block/blk-iocost.c:1101:11: error: call to '__compiletime_assert_557' declared with 'error' attribute: clamp() low limit 1 greater than high limit active
  2024-12-04 16:50     ` Dan Carpenter
@ 2024-12-04 17:40       ` Tejun Heo
  2024-12-04 18:26         ` David Laight
  0 siblings, 1 reply; 7+ messages in thread
From: Tejun Heo @ 2024-12-04 17:40 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: David Laight, Naresh Kamboju, linux-s390@vger.kernel.org,
	clang-built-linux, linux-block, open list,
	lkft-triage@lists.linaro.org, Linux Regressions, Anders Roxell,
	Arnd Bergmann, Nathan Chancellor, Jens Axboe

Hello,

On Wed, Dec 04, 2024 at 07:50:14PM +0300, Dan Carpenter wrote:
> Tejun probably reads everything to linux-block, but let's CC him explicitly.

Oh, I'm not. Thanks for cc'ing.

> block/blk-iocost.c
>   2222                          TRACE_IOCG_PATH(iocg_idle, iocg, now,
>   2223                                          atomic64_read(&iocg->active_period),
>   2224                                          atomic64_read(&ioc->cur_period), vtime);
>   2225                          __propagate_weights(iocg, 0, 0, false, now);
>                                                           ^
> Why is "active" zero?  __propagate_weights() does a clamp() to 1 as minimum and
> we've added new build time asserts so this breaks the build.
> 
>   2226                          list_del_init(&iocg->active_list);
> 
> The other way to solve this would be to something stupid like:
> 
> diff --git a/block/blk-iocost.c b/block/blk-iocost.c
> index 384aa15e8260..551edd2f661f 100644
> --- a/block/blk-iocost.c
> +++ b/block/blk-iocost.c
> @@ -1094,7 +1094,7 @@ static void __propagate_weights(struct ioc_gq *iocg, u32 active, u32 inuse,
>          * @active. An active internal node's inuse is solely determined by the
>          * inuse to active ratio of its children regardless of @inuse.
>          */
> -       if (list_empty(&iocg->active_list) && iocg->child_active_sum) {
> +       if ((list_empty(&iocg->active_list) && iocg->child_active_sum) || active == 0) {
>                 inuse = DIV64_U64_ROUND_UP(active * iocg->child_inuse_sum,
>                                            iocg->child_active_sum);
>         } else {
> 
> But that seems really stupid.

This is a good catch. It's impressive that this can be caught at compile
time. The upper limit can become zero but the lower limit should win as
that's there to protect against divide by zero, so I think the right thinig
to do is replacing clamp() with max(min()). Is someone interested in writing
up the patch and sending it Jens' way?

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: s390: block/blk-iocost.c:1101:11: error: call to '__compiletime_assert_557' declared with 'error' attribute: clamp() low limit 1 greater than high limit active
  2024-12-04 17:40       ` Tejun Heo
@ 2024-12-04 18:26         ` David Laight
  2024-12-04 18:32           ` 'Tejun Heo'
  0 siblings, 1 reply; 7+ messages in thread
From: David Laight @ 2024-12-04 18:26 UTC (permalink / raw)
  To: 'Tejun Heo', Dan Carpenter
  Cc: Naresh Kamboju, linux-s390@vger.kernel.org, clang-built-linux,
	linux-block, open list, lkft-triage@lists.linaro.org,
	Linux Regressions, Anders Roxell, Arnd Bergmann,
	Nathan Chancellor, Jens Axboe

From: Tejun Heo
> Sent: 04 December 2024 17:41
> 
> Hello,
> 
> On Wed, Dec 04, 2024 at 07:50:14PM +0300, Dan Carpenter wrote:
> > Tejun probably reads everything to linux-block, but let's CC him explicitly.
> 
> Oh, I'm not. Thanks for cc'ing.
> 
> > block/blk-iocost.c
> >   2222                          TRACE_IOCG_PATH(iocg_idle, iocg, now,
> >   2223                                          atomic64_read(&iocg->active_period),
> >   2224                                          atomic64_read(&ioc->cur_period), vtime);
> >   2225                          __propagate_weights(iocg, 0, 0, false, now);
> >                                                           ^
> > Why is "active" zero?  __propagate_weights() does a clamp() to 1 as minimum and
> > we've added new build time asserts so this breaks the build.
> >
> >   2226                          list_del_init(&iocg->active_list);
> >
...
> 
> This is a good catch. It's impressive that this can be caught at compile
> time. The upper limit can become zero but the lower limit should win as
> that's there to protect against divide by zero, so I think the right thinig
> to do is replacing clamp() with max(min()). Is someone interested in writing
> up the patch and sending it Jens' way?

Perhaps if written as:
	inuse = min(inuse, active) ?: 1;
it might stop someone changing it back.

	David

	

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: s390: block/blk-iocost.c:1101:11: error: call to '__compiletime_assert_557' declared with 'error' attribute: clamp() low limit 1 greater than high limit active
  2024-12-04 18:26         ` David Laight
@ 2024-12-04 18:32           ` 'Tejun Heo'
  0 siblings, 0 replies; 7+ messages in thread
From: 'Tejun Heo' @ 2024-12-04 18:32 UTC (permalink / raw)
  To: David Laight
  Cc: Dan Carpenter, Naresh Kamboju, linux-s390@vger.kernel.org,
	clang-built-linux, linux-block, open list,
	lkft-triage@lists.linaro.org, Linux Regressions, Anders Roxell,
	Arnd Bergmann, Nathan Chancellor, Jens Axboe

Hello,

On Wed, Dec 04, 2024 at 06:26:16PM +0000, David Laight wrote:
> > This is a good catch. It's impressive that this can be caught at compile
> > time. The upper limit can become zero but the lower limit should win as
> > that's there to protect against divide by zero, so I think the right thinig
> > to do is replacing clamp() with max(min()). Is someone interested in writing
> > up the patch and sending it Jens' way?
> 
> Perhaps if written as:
> 	inuse = min(inuse, active) ?: 1;
> it might stop someone changing it back.

And maybe some comments too. When I was writing that clamp(), the case of
min and max crossing each other didn't even cross my mind and I was dumbly
thinking just "oh, this protects the value on both fronts", so yeah, there's
some chance of someone (including myself) converting it back to clamp().

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-12-04 18:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-04 10:31 s390: block/blk-iocost.c:1101:11: error: call to '__compiletime_assert_557' declared with 'error' attribute: clamp() low limit 1 greater than high limit active Naresh Kamboju
2024-12-04 14:39 ` Dan Carpenter
2024-12-04 16:11   ` David Laight
2024-12-04 16:50     ` Dan Carpenter
2024-12-04 17:40       ` Tejun Heo
2024-12-04 18:26         ` David Laight
2024-12-04 18:32           ` 'Tejun Heo'

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox