From: David Laight <David.Laight@ACULAB.COM>
To: 'Tejun Heo' <tj@kernel.org>, Nathan Chancellor <nathan@kernel.org>
Cc: Josef Bacik <josef@toxicpanda.com>, Jens Axboe <axboe@kernel.dk>,
"cgroups@vger.kernel.org" <cgroups@vger.kernel.org>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"llvm@lists.linux.dev" <llvm@lists.linux.dev>,
"patches@lists.linux.dev" <patches@lists.linux.dev>,
Linux Kernel Functional Testing <lkft@linaro.org>,
kernel test robot <lkp@intel.com>
Subject: RE: [PATCH] blk-iocost: Avoid using clamp() on inuse in __propagate_weights()
Date: Thu, 12 Dec 2024 17:28:44 +0000 [thread overview]
Message-ID: <5231409257664f8097c82f79869fb52b@AcuMS.aculab.com> (raw)
In-Reply-To: <Z1sbG2zh8xmb-lxu@slm.duckdns.org>
From: Tejun Heo <tj@kernel.org>
> 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@AcuMS.aculab.com/ [1]
> > Suggested-by: David Laight <david.laight@aculab.com>
> > Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
> > Closes: https://lore.kernel.org/llvm/CA+G9fYsD7mw13wredcZn0L-KBA3yeoVSTuxnss-
> AEWMN3ha0cA@mail.gmail.com/
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202412120322.3GfVe3vF-lkp@intel.com/
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
>
> Acked-by: Tejun Heo <tj@kernel.org>
>
> This likely deserves:
>
> Fixes: 7caa47151ab2 ("blkcg: implement blk-iocost")
> Cc: stable@vger.kernel.org # 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)
next prev parent reply other threads:[~2024-12-12 17:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-12 17:13 [PATCH] blk-iocost: Avoid using clamp() on inuse in __propagate_weights() Nathan Chancellor
2024-12-12 17:19 ` Tejun Heo
2024-12-12 17:28 ` David Laight [this message]
2024-12-12 17:44 ` Nathan Chancellor
2024-12-12 18:48 ` Jens Axboe
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=5231409257664f8097c82f79869fb52b@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=axboe@kernel.dk \
--cc=cgroups@vger.kernel.org \
--cc=josef@toxicpanda.com \
--cc=linux-block@vger.kernel.org \
--cc=lkft@linaro.org \
--cc=lkp@intel.com \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=patches@lists.linux.dev \
--cc=tj@kernel.org \
/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