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 D3BF0EB64D7 for ; Tue, 27 Jun 2023 03:05:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229670AbjF0DFr (ORCPT ); Mon, 26 Jun 2023 23:05:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229562AbjF0DFq (ORCPT ); Mon, 26 Jun 2023 23:05:46 -0400 Received: from lobo.ruivo.org (lobo.ruivo.org [173.14.175.98]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7C04BB for ; Mon, 26 Jun 2023 20:05:42 -0700 (PDT) Received: by lobo.ruivo.org (Postfix, from userid 1011) id B811753150; Mon, 26 Jun 2023 23:05:41 -0400 (EDT) Received: from jake.ruivo.org (bob.qemu.ruivo [192.168.72.19]) by lobo.ruivo.org (Postfix) with ESMTPA id 7C7CC529A0; Mon, 26 Jun 2023 23:05:23 -0400 (EDT) Received: by jake.ruivo.org (Postfix, from userid 1000) id 57DC6220039; Mon, 26 Jun 2023 23:05:23 -0400 (EDT) Date: Mon, 26 Jun 2023 23:05:23 -0400 From: Aristeu Rozanski To: "Luck, Tony" Cc: "linux-edac@vger.kernel.org" , Borislav Petkov , "aris@redhat.com" Subject: Re: [PATCH v2] mce: prevent concurrent polling of MCE events Message-ID: <20230627030523.GY4090740@cathedrallabs.org> References: <20230626203712.GW4090740@cathedrallabs.org> <20230626223220.GX4090740@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 Mon, Jun 26, 2023 at 10:52:01PM +0000, Luck, Tony wrote: > topology_physical_package_id(cpu); > > But it seems like that adds a lot of work to find out how many packages there > are and initialize a spin lock for each one. Just to reduce what is likely to be > quite low contention on a lock in a rare code path. OK, I'll update the description then. > > Or is this OK because this will always return false on AMD? > > > > That was my intention. I could use a static to only call > > cmci_supported_hw() once (that in fact could be useful for users of > > cmci_supported() that actually just want cmci_supported_hw() but I didn't > > want to mix it with this change) if you prefer: > > Maybe the function just needs a better name. Calling something > with an "intel_cmci_" prefix from generic code is what's causing me > to step back. > > What if the code read: > > if (mce_available(this_cpu_ptr(&cpu_info))) { > + bool locked = serialize_mc_bank_access(); > machine_check_poll(0, this_cpu_ptr(&mce_poll_banks)); > + unserialize_mc_bank_access(locked); > > As an intermediate functions. With core.c declaring: > > static bool serialize_mc_bank_access(void) > { > if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL) > return false; > > return intel_cmci_poll_lock(); > } > > static void unserialize_mc_bank_access(bool locked) > { > if (!locked || boot_cpu_data.x86_vendor != X86_VENDOR_INTEL) > return false; > > return intel_cmci_poll_unlock(); > } > > That would be in-lined and almost all disappear for CONFIG_X86_MCE_INTEL=n Ah, I see. Makes sense. I'll update and send it tomorrow. -- Aristeu