[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b437c9c7-b2e6-432d-89c1-eb2497bc742a@paulmck-laptop>
Date: Wed, 24 Jan 2024 09:12:11 -0800
From: "Paul E. McKenney" <paulmck@...nel.org>
To: Jiri Wiesner <jwiesner@...e.de>
Cc: linux-kernel@...r.kernel.org, John Stultz <jstultz@...gle.com>,
Thomas Gleixner <tglx@...utronix.de>,
Stephen Boyd <sboyd@...nel.org>, Feng Tang <feng.tang@...el.com>
Subject: Re: [PATCH v3] clocksource: Skip watchdog check for large watchdog
intervals
On Wed, Jan 24, 2024 at 05:48:03PM +0100, Jiri Wiesner wrote:
> On Wed, Jan 24, 2024 at 08:03:42AM -0800, Paul E. McKenney wrote:
> > On Mon, Jan 22, 2024 at 06:23:50PM +0100, Jiri Wiesner wrote:
> > > diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
> > > index c108ed8a9804..3052b1f1168e 100644
> > > --- a/kernel/time/clocksource.c
> > > +++ b/kernel/time/clocksource.c
> > > @@ -99,6 +99,7 @@ static u64 suspend_start;
> > > * Interval: 0.5sec.
> > > */
> > > #define WATCHDOG_INTERVAL (HZ >> 1)
> > > +#define WATCHDOG_INTERVAL_MAX_NS ((2 * WATCHDOG_INTERVAL) * (NSEC_PER_SEC / HZ))
> >
> > We need something here to force 64-bit arithmetic on 32-bit systems
> > correct?
>
> I think it is not strictly necessary because
> (2 * HZ / 2) * (NSEC_PER_SEC / HZ) = HZ * (NSEC_PER_SEC / HZ)
> so even a 32-bit integer would not overflow when NSEC_PER_SEC / HZ is
> bracketed. But I could make a change to:
> +#define WATCHDOG_INTERVAL_MAX_NS ((int64_t)(2ULL * WATCHDOG_INTERVAL * NSEC_PER_SEC / HZ))
> to make it explicit and remove the risk of overflow if the constant was
> increased (for testing purposes for instance).
Good point, and this is just a timeout, so roundoff error from doing the
division first is not a problem. This should be good as it is, thank you!
I will pull in your v3 for testing and further review, and if it passes
testing, send it along to -next.
Thanx, Paul
Powered by blists - more mailing lists