From: Feng Tang <feng.tang@intel.com>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: Waiman Long <longman@redhat.com>,
John Stultz <jstultz@google.com>,
Thomas Gleixner <tglx@linutronix.de>,
Stephen Boyd <sboyd@kernel.org>, <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
"Jin Wang" <jin1.wang@intel.com>
Subject: Re: [PATCH] clocksource: Scale the max retry number of watchdog read according to CPU numbers
Date: Sun, 28 Jan 2024 19:36:21 +0800 [thread overview]
Message-ID: <ZbY8NVT+BqTVGDq1@feng-clx.sh.intel.com> (raw)
In-Reply-To: <2955c8b0-cdb5-459e-9d98-9db7a252f0ff@paulmck-laptop>
On Fri, Jan 26, 2024 at 11:28:36AM -0800, Paul E. McKenney wrote:
> On Fri, Jan 26, 2024 at 11:19:50AM -0500, Waiman Long wrote:
[...]
> > > > I also suggest doing the adjustment at boot time, for example, using
> > > > an early_initcall(). That way the test code also sees the scaled value.
> > > I also thought about doing the adjustment once in early boot phase
> > > using num_possible_cpus(), but gave up as that parameters could be
> > > changed runtime using sysfs's module parameter interface, and cpu
> > > runtime hotplugging.
> > >
> > > Since the watchdog timer only happens (if not skipped) every 500 ms,
> > > how about doing the ilog2 math everytime, like below:
> > >
> > > diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
> > > index 1d42d4b17327..9104bdecf34e 100644
> > > --- a/include/linux/clocksource.h
> > > +++ b/include/linux/clocksource.h
> > > @@ -291,7 +291,7 @@ static inline void timer_probe(void) {}
> > > #define TIMER_ACPI_DECLARE(name, table_id, fn) \
> > > ACPI_DECLARE_PROBE_ENTRY(timer, name, table_id, 0, NULL, 0, fn)
> > > -extern ulong max_cswd_read_retries;
> > > +extern long max_cswd_read_retries;
> > > void clocksource_verify_percpu(struct clocksource *cs);
> > > #endif /* _LINUX_CLOCKSOURCE_H */
> > > diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
> > > index c108ed8a9804..867bb36e6dad 100644
> > > --- a/kernel/time/clocksource.c
> > > +++ b/kernel/time/clocksource.c
> > > @@ -208,8 +208,8 @@ void clocksource_mark_unstable(struct clocksource *cs)
> > > spin_unlock_irqrestore(&watchdog_lock, flags);
> > > }
> > > -ulong max_cswd_read_retries = 2;
> > > -module_param(max_cswd_read_retries, ulong, 0644);
> > > +long max_cswd_read_retries = -1;
> > > +module_param(max_cswd_read_retries, long, 0644);
> > > EXPORT_SYMBOL_GPL(max_cswd_read_retries);
> > > static int verify_n_cpus = 8;
> > > module_param(verify_n_cpus, int, 0644);
> > > @@ -225,8 +225,17 @@ static enum wd_read_status cs_watchdog_read(struct clocksource *cs, u64 *csnow,
> > > unsigned int nretries;
> > > u64 wd_end, wd_end2, wd_delta;
> > > int64_t wd_delay, wd_seq_delay;
> > > + long max_retries = max_cswd_read_retries;
> > > +
> > > + if (max_cswd_read_retries <= 0) {
> > > + if (max_cswd_read_retries != -1)
> > > + pr_warn_once("max_cswd_read_retries has been set a invalid number: %d\n",
> > > + max_cswd_read_retries);
> > > - for (nretries = 0; nretries <= max_cswd_read_retries; nretries++) {
> > > + max_retries = ilog2(num_online_cpus()) + 1;
> > > + }
> > > +
> > > + for (nretries = 0; nretries <= max_retries; nretries++) {
> > > local_irq_disable();
> > > *wdnow = watchdog->read(watchdog);
> > > *csnow = cs->read(cs);
> > > @@ -238,7 +247,7 @@ static enum wd_read_status cs_watchdog_read(struct clocksource *cs, u64 *csnow,
> > > wd_delay = clocksource_cyc2ns(wd_delta, watchdog->mult,
> > > watchdog->shift);
> > > if (wd_delay <= WATCHDOG_MAX_SKEW) {
> > > - if (nretries > 1 || nretries >= max_cswd_read_retries) {
> > > + if (nretries > 1 || nretries >= max_retries) {
> > > pr_warn("timekeeping watchdog on CPU%d: %s retried %d times before success\n",
> > > smp_processor_id(), watchdog->name, nretries);
> > > }
> >
> > The max_cswd_read_retries value is also used in
> > kernel/time/clocksource-wdtest.c. You will have to apply similar logic to
> > clocksource-wdtest.c if it is not done once in early_init.
>
> Good point! If it is not done in an early_init(), could we please
> have a function for the common code?
Thanks Waiman for the catch! And sure, will add a new helper function
for that.
Thanks,
Feng
>
> Thanx, Paul
prev parent reply other threads:[~2024-01-28 11:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-26 9:12 Feng Tang
2024-01-26 12:27 ` Paul E. McKenney
2024-01-26 13:45 ` Feng Tang
2024-01-26 16:19 ` Waiman Long
2024-01-26 19:28 ` Paul E. McKenney
2024-01-28 11:36 ` Feng Tang [this message]
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=ZbY8NVT+BqTVGDq1@feng-clx.sh.intel.com \
--to=feng.tang@intel.com \
--cc=jin1.wang@intel.com \
--cc=jstultz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®