Linux EDAC development
 help / color / mirror / Atom feed
From: Tony Luck <tony.luck@intel.com>
To: Aristeu Rozanski <aris@ruivo.org>
Cc: Borislav Petkov <bp@alien8.de>,
	"linux-edac@vger.kernel.org" <linux-edac@vger.kernel.org>,
	"aris@redhat.com" <aris@redhat.com>
Subject: Re: [RFC PATCH] mce: prevent concurrent polling of MCE events
Date: Thu, 11 May 2023 16:38:57 -0700	[thread overview]
Message-ID: <ZF18kdWCWKqFc23p@agluck-desk3.sc.intel.com> (raw)
In-Reply-To: <SJ1PR11MB6083083A8C72CAC6E39DF924FC6B9@SJ1PR11MB6083.namprd11.prod.outlook.com>

On Fri, Apr 28, 2023 at 04:43:46PM +0000, Luck, Tony wrote:
> > One option to avoid this might be to change from a fixed five minute
> > > polling interval to "five minute plus/minus rand(50) jiffies". Then even
> > > if some CPUs did sync up, they'd quickly diverge again.
> >
> > I did experiment different ranges including forcing a minimum difference
> > based on cpu number but eventually I'd see repeated events. Perhaps a
> > combination would be acceptable? Set the first run of each cpu spaced based on
> > CPU number then use a spinlock to synchronize it? That way we minimize the
> > chance of a big number of CPUs stuck on the same lock but at same time
> > guarantee we won't have duplicated events.
> 
> Aristeu,
> 
> Yes. A variable poll interval (to avoid CPUs all bunching together) with
> the spinlock to serialize the cases where some CPUs do line up their
> polling would work.

I just ran a test on a system booted with mce=no_cmci and saw the
duplicate reporting.  Digging into the code I see that I'm not the
first to think that a little randomness in timers on different CPUs
would be a good idea. The MCE code starts/restarts timers with:

	mod_timer(t, round_jiffies(when));

Looking at the round_jiffies() function I sw that it is grabbing
the current CPU number.

unsigned long round_jiffies(unsigned long j)
{
        return round_jiffies_common(j, raw_smp_processor_id(), false);
}

And round_jiffies_common() explains with this comment:

        /*
         * We don't want all cpus firing their timers at once hitting the
         * same lock or cachelines, so we skew each extra cpu with an extra
         * 3 jiffies. This 3 jiffies came originally from the mm/ code which
         * already did this.
         * The skew is done by adding 3*cpunr, then round, then subtract this
         * extra offset again.
         */
        j += cpu * 3;

	rem = j % HZ;

So your original patch https://lore.kernel.org/all/Y8WtE7BNJ0gTrqIS@cathedrallabs.org/
that just added the spinlock should be fine!

-Tony




  reply	other threads:[~2023-05-11 23:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-16 20:01 [RFC PATCH] mce: prevent concurrent polling of MCE events Aristeu Rozanski
2023-01-17 17:42 ` Luck, Tony
2023-01-17 18:44   ` Aristeu Rozanski
2023-01-17 18:54     ` Luck, Tony
2023-01-17 18:58       ` Aristeu Rozanski
2023-04-28 15:51   ` Aristeu Rozanski
2023-04-28 16:43     ` Luck, Tony
2023-05-11 23:38       ` Tony Luck [this message]
2023-05-12 17:32         ` Aristeu Rozanski
2023-05-12 19:19           ` Luck, Tony

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=ZF18kdWCWKqFc23p@agluck-desk3.sc.intel.com \
    --to=tony.luck@intel.com \
    --cc=aris@redhat.com \
    --cc=aris@ruivo.org \
    --cc=bp@alien8.de \
    --cc=linux-edac@vger.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