Re: [PATCH -next v2 07/11] rcu: Simplify rcu_do_batch() by applying clamp()
From: Frederic Weisbecker
Date: Wed May 20 2026 - 08:26:58 EST
Le Tue, May 19, 2026 at 09:45:20PM +0200, Uladzislau Rezki (Sony) a écrit :
> From: "Paul E. McKenney" <paulmck@xxxxxxxxxx>
>
> This commit replaces a nested ?: sequence with clamp(). This does not
> reduce the number of lines of code, but it does simplify the line that
> it modifies.
>
> Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxx>
> Signed-off-by: Uladzislau Rezki (Sony) <urezki@xxxxxxxxx>
Reviewed-by: Frederic Weisbecker <frederic@xxxxxxxxxx>
> ---
> kernel/rcu/tree.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> index 55df6d37145e..e46a5124c3eb 100644
> --- a/kernel/rcu/tree.c
> +++ b/kernel/rcu/tree.c
> @@ -2584,7 +2584,7 @@ static void rcu_do_batch(struct rcu_data *rdp)
> const long npj = NSEC_PER_SEC / HZ;
> long rrn = READ_ONCE(rcu_resched_ns);
>
> - rrn = rrn < NSEC_PER_MSEC ? NSEC_PER_MSEC : rrn > NSEC_PER_SEC ? NSEC_PER_SEC : rrn;
> + rrn = clamp(rrn, NSEC_PER_MSEC, NSEC_PER_SEC);
> tlimit = local_clock() + rrn;
> jlimit = jiffies + (rrn + npj + 1) / npj;
> jlimit_check = true;
> --
> 2.47.3
>
>
--
Frederic Weisbecker
SUSE Labs