From patchwork Fri Mar 27 09:22:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 6104581 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AB2B99F2A9 for ; Fri, 27 Mar 2015 09:25:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7F3422041B for ; Fri, 27 Mar 2015 09:25:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9B440203ED for ; Fri, 27 Mar 2015 09:25:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753827AbbC0JZg (ORCPT ); Fri, 27 Mar 2015 05:25:36 -0400 Received: from mail.skyhub.de ([78.46.96.112]:58680 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753508AbbC0JYx (ORCPT ); Fri, 27 Mar 2015 05:24:53 -0400 X-Virus-Scanned: Nedap ESD1 at mail.skyhub.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alien8.de; s=alien8; t=1427448290; bh=8zZxJsrGQs/y/u2D+yXoV1NVgnYw0Nc17+vaNUnFUCM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=eVGj RdziRpbD67cqJC0DT2r62l85LMA3RwJhqDx63RpKDqsZDnngkdEM+rc55slgsgRR/eg fsGKA7lC1hbnMJqEDqr33t9ls5fzzrsEoJq4BoqrJ5RW13LSBFYJfg8BcacqQf2MYQL spDcDowGHCnkHkQUxx7FhbXOC4tmH2bL0= Received: from mail.skyhub.de ([127.0.0.1]) by localhost (door.skyhub.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id yhSdJYviO-3i; Fri, 27 Mar 2015 10:24:49 +0100 (CET) Received: from pd.tnic (p5DDC6BAA.dip0.t-ipconnect.de [93.220.107.170]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 433671D99AD; Fri, 27 Mar 2015 10:24:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alien8.de; s=alien8; t=1427448289; bh=8zZxJsrGQs/y/u2D+yXoV1NVgnYw0Nc17+vaNUnFUCM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=fwrF 6CfVfuK6UFeW/X3jSZIMuxqN5VCUuYep9dIz5YrYOnRq+pph5qAijTSmMz7FGussfoi CiIyaFqav3CZvcS0m9ewmdts8YHq+JanNPbAD0Y42dxWqq6TcofdBetI2UDQNlFXxcz pp6sZh/CKtb9ddAcQP/iNRMWc+vqNMaTY= Received: by pd.tnic (Postfix, from userid 1000) id 3ED8A1617C8; Fri, 27 Mar 2015 10:23:01 +0100 (CET) From: Borislav Petkov To: linux-edac Cc: Jiri Kosina , Borislav Petkov , "Rafael J. Wysocki" , Len Brown , Tony Luck , Tomasz Nowicki , "Chen, Gong" , Wolfram Sang , Lv Zheng , Naoya Horiguchi , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 5/5] GHES: Make NMI handler have a single reader Date: Fri, 27 Mar 2015 10:22:58 +0100 Message-Id: <1427448178-20689-6-git-send-email-bp@alien8.de> X-Mailer: git-send-email 2.3.3 In-Reply-To: <1427448178-20689-1-git-send-email-bp@alien8.de> References: <1427448178-20689-1-git-send-email-bp@alien8.de> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jiri Kosina Since GHES sources are global, we theoretically need only a single CPU reading them per NMI instead of a thundering herd of CPUs waiting on a spinlock in NMI context for no reason at all. Do that. Signed-off-by: Jiri Kosina Signed-off-by: Borislav Petkov --- drivers/acpi/apei/ghes.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 94a44bad5576..2bfd53cbfe80 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -729,10 +729,10 @@ static struct llist_head ghes_estatus_llist; static struct irq_work ghes_proc_irq_work; /* - * NMI may be triggered on any CPU, so ghes_nmi_lock is used for - * mutual exclusion. + * NMI may be triggered on any CPU, so ghes_in_nmi is used for + * having only one concurrent reader. */ -static DEFINE_RAW_SPINLOCK(ghes_nmi_lock); +static atomic_t ghes_in_nmi = ATOMIC_INIT(0); static LIST_HEAD(ghes_nmi); @@ -840,7 +840,9 @@ static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs) struct ghes *ghes; int sev, ret = NMI_DONE; - raw_spin_lock(&ghes_nmi_lock); + if (!atomic_add_unless(&ghes_in_nmi, 1, 1)) + return ret; + list_for_each_entry_rcu(ghes, &ghes_nmi, list) { if (ghes_read_estatus(ghes, 1)) { ghes_clear_estatus(ghes); @@ -863,7 +865,7 @@ static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs) #ifdef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG irq_work_queue(&ghes_proc_irq_work); #endif - raw_spin_unlock(&ghes_nmi_lock); + atomic_dec(&ghes_in_nmi); return ret; }