From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB3FEC77B7C for ; Fri, 12 May 2023 17:33:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232713AbjELRdN (ORCPT ); Fri, 12 May 2023 13:33:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231327AbjELRdM (ORCPT ); Fri, 12 May 2023 13:33:12 -0400 Received: from lobo.ruivo.org (lobo.ruivo.org [173.14.175.98]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81E871B8 for ; Fri, 12 May 2023 10:33:10 -0700 (PDT) Received: by lobo.ruivo.org (Postfix, from userid 1011) id 0305A52E27; Fri, 12 May 2023 13:33:08 -0400 (EDT) Received: from jake.ruivo.org (bob.qemu.ruivo [192.168.72.19]) by lobo.ruivo.org (Postfix) with ESMTPA id AA0425299B; Fri, 12 May 2023 13:32:51 -0400 (EDT) Received: by jake.ruivo.org (Postfix, from userid 1000) id 9C0E72200DF; Fri, 12 May 2023 13:32:51 -0400 (EDT) Date: Fri, 12 May 2023 13:32:51 -0400 From: Aristeu Rozanski To: Tony Luck Cc: Borislav Petkov , "linux-edac@vger.kernel.org" , "aris@redhat.com" Subject: Re: [RFC PATCH] mce: prevent concurrent polling of MCE events Message-ID: <20230512173251.GB4090740@cathedrallabs.org> References: <20230428155102.GE2449174@cathedrallabs.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.2.9 (2022-11-12) Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org On Thu, May 11, 2023 at 04:38:57PM -0700, Tony Luck wrote: > 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! Thanks Tony. You want me to resend it or the original is enough? -- Aristeu