RE: [PATCH] blk-iocost: Avoid using clamp() on inuse in __propagate_weights()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Tejun Heo <tj@xxxxxxxxxx>
> Sent: 12 December 2024 17:19
> 
> On Thu, Dec 12, 2024 at 10:13:29AM -0700, Nathan Chancellor wrote:
> > After a recent change to clamp() and its variants [1] that increases the
> > coverage of the check that high is greater than low because it can be
> > done through inlining, certain build configurations (such as s390
> > defconfig) fail to build with clang with:
> >
...
> > __propagate_weights() is called with an active value of zero in
> > ioc_check_iocgs(), which results in the high value being less than the
> > low value, which is undefined because the value returned depends on the
> > order of the comparisons.
> >
> > The purpose of this expression is to ensure inuse is not more than
> > active and at least 1. This could be written more simply with a ternary
> > expression that uses min(inuse, active) as the condition so that the
> > value of that condition can be used if it is not zero and one if it is.
> > Do this conversion to resolve the error and add a comment to deter
> > people from turning this back into clamp().
> >
> > Link: https://lore.kernel.org/r/34d53778977747f19cce2abb287bb3e6@xxxxxxxxxxxxxxxx/ [1]
> > Suggested-by: David Laight <david.laight@xxxxxxxxxx>
> > Reported-by: Linux Kernel Functional Testing <lkft@xxxxxxxxxx>
> > Closes: https://lore.kernel.org/llvm/CA+G9fYsD7mw13wredcZn0L-KBA3yeoVSTuxnss-
> AEWMN3ha0cA@xxxxxxxxxxxxxx/
> > Reported-by: kernel test robot <lkp@xxxxxxxxx>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202412120322.3GfVe3vF-lkp@xxxxxxxxx/
> > Signed-off-by: Nathan Chancellor <nathan@xxxxxxxxxx>
> 
> Acked-by: Tejun Heo <tj@xxxxxxxxxx>
> 
> This likely deserves:
> 
> Fixes: 7caa47151ab2 ("blkcg: implement blk-iocost")
> Cc: stable@xxxxxxxxxxxxxxx # v5.4+

Especially since the old defn was:

#define __clamp(val, lo, hi)	\
	((val) >= (hi) ? (hi) : ((val) <= (lo) ? (lo) : (val)))

so:
-		inuse = clamp_t(u32, inuse, 1, active);

is zero if active is zero.

	David

> 
> Thanks.
> 
> --
> tejun

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






[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [Monitors]

  Powered by Linux