All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Wiesner <jwiesner@suse.de>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: linux-kernel@vger.kernel.org, John Stultz <jstultz@google.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Stephen Boyd <sboyd@kernel.org>, Feng Tang <feng.tang@intel.com>
Subject: Re: [PATCH v3] clocksource: Skip watchdog check for large watchdog intervals
Date: Wed, 24 Jan 2024 17:48:03 +0100	[thread overview]
Message-ID: <20240124164803.GN3303@incl> (raw)
In-Reply-To: <616658ba-0e69-447b-8b52-5051a5aa9bc0@paulmck-laptop>

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).
-- 
Jiri Wiesner
SUSE Labs

  reply	other threads:[~2024-01-24 16:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-22 17:23 [PATCH v3] clocksource: Skip watchdog check for large watchdog intervals Jiri Wiesner
2024-01-24 16:03 ` Paul E. McKenney
2024-01-24 16:48   ` Jiri Wiesner [this message]
2024-01-24 17:12     ` Paul E. McKenney
2024-01-25  8:17 ` [tip: timers/urgent] " tip-bot2 for Jiri Wiesner

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=20240124164803.GN3303@incl \
    --to=jwiesner@suse.de \
    --cc=feng.tang@intel.com \
    --cc=jstultz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.