Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp18699868ybl; Fri, 3 Jan 2020 07:24:07 -0800 (PST) X-Google-Smtp-Source: APXvYqxMDaimoYJFHXnZMpVJX4GfLrNBwAiIZ59qOp7ufSUnACi6+DwDMYZPvOOqM9jfIhgkHVT5 X-Received: by 2002:a05:6830:1199:: with SMTP id u25mr93560181otq.344.1578065047119; Fri, 03 Jan 2020 07:24:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578065047; cv=none; d=google.com; s=arc-20160816; b=k/kvNNGwbm4JTpwPkXXXiDbN62A4ymYCY3LUT+zbKE1h8dXYvdv7gEKiJle8wGNNY7 iRYS6rkdRmNewGVOn3wrWf2NFdKBbKxt3DRaWmL9duNo97Z07CVaGng5cRrlgwiOayTi 5wgnOFMDIWc+nm92MEezBcSXHVgjafyxlzHAOiKlDzZ/VOdwpFk2K3CdgNd+3ftALeEd iC/kMQRELDAOc6aUy+pO0MRtwT/epDDznw+kPwMWMzJLgVkAZz7lJHSchVN5+OWq5YGx dS6ckrCKa2CGWlqucssmf1MHmT9BJIe1AaIdk8S/QSOZSw/G0HXJKEPNpcXqW7qGC3DD R+Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:dkim-signature; bh=iHsaaNSb6QuBd5deQsg49o2tayu5boXDGXFCOP8fQzk=; b=cKQb/mIEZhpRIfyJp7ltlEcEDS6rWjX1JpH5mfdGo30TCYtXS8PRJIyBtiJ0imMChc p8AiAi9YCyZBL7hPxUHEmdi9xEqz8b1rm9PKOZaJnQcNQPJxqkiP7QcY18kK0vyoT8L9 5uXx6KHdovXAOSK5PAt0g5Dx6cJqo8xIoCwYWuXQMjPThEd2GrsdPDnvlm7Ry0v8oP2D 3NHAefMAHIpVhFWr87zMw3ylDs0P4HUBRUF1h8W0KZsWuCQpm1vpf6FWMk3CHhtIgO6w xI3WNW3xa0fpIE/w3goL0akob6DCUmGNokDioHkQSOk2DcJQ50DUOPoZ8RL2WZzk86zI zFpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=Fk6TLzpd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v23si27138135otk.321.2020.01.03.07.23.54; Fri, 03 Jan 2020 07:24:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=Fk6TLzpd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727780AbgACPHq (ORCPT + 99 others); Fri, 3 Jan 2020 10:07:46 -0500 Received: from smtp-fw-4101.amazon.com ([72.21.198.25]:2000 "EHLO smtp-fw-4101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727701AbgACPHp (ORCPT ); Fri, 3 Jan 2020 10:07:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1578064064; x=1609600064; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iHsaaNSb6QuBd5deQsg49o2tayu5boXDGXFCOP8fQzk=; b=Fk6TLzpdu7D3QWekW6/8JbQ6qiy+I3Y6wm0Z5KU9X3bJN7+e5Bvmpzd4 gvv5igoUd90w7nxGRwyacv26BSllz8JX2AjHwqJ0DEc/y9g7tVWmbyD5Z LFpdKN/GMUSxnKnQS/kzBNSEOxovQBzH29rqGT2mqzaVKb6gHcC3hF5qe A=; IronPort-SDR: dzSxum0Eg4ym7IdAnqI5ApmAWoDS4hbW1dA4MiC2R/lbhYUFwc/P4ZlINqPgjvjg++vg67PfRM Hl3Us7UKpoPg== X-IronPort-AV: E=Sophos;i="5.69,390,1571702400"; d="scan'208";a="10829622" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-27fb8269.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 03 Jan 2020 15:07:44 +0000 Received: from u7588a65da6b65f.ant.amazon.com (iad7-ws-svc-lb50-vlan3.amazon.com [10.0.93.214]) by email-inbound-relay-1e-27fb8269.us-east-1.amazon.com (Postfix) with ESMTPS id A32F0A1C46; Fri, 3 Jan 2020 15:07:40 +0000 (UTC) Received: from u7588a65da6b65f.ant.amazon.com (localhost [127.0.0.1]) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTPS id 003F7coI020473 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 3 Jan 2020 16:07:38 +0100 Received: (from jschoenh@localhost) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Submit) id 003F7cqx020472; Fri, 3 Jan 2020 16:07:38 +0100 From: =?UTF-8?q?Jan=20H=2E=20Sch=C3=B6nherr?= To: Borislav Petkov Cc: =?UTF-8?q?Jan=20H=2E=20Sch=C3=B6nherr?= , Yazen Ghannam , linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, Tony Luck , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org Subject: [PATCH v2 4/6] x86/mce: Allow a variable number of internal MCE decode notifiers Date: Fri, 3 Jan 2020 16:07:20 +0100 Message-Id: <20200103150722.20313-5-jschoenh@amazon.de> X-Mailer: git-send-email 2.22.0.3.gb49bb57c8208.dirty In-Reply-To: <20200103150722.20313-1-jschoenh@amazon.de> References: <20200103150722.20313-1-jschoenh@amazon.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Get rid of the compile time constant of internal (or mandatory) MCE decode notifiers in preparation for future changes. Instead, distinguish explicitly between internal and external MCE decode notifiers. Signed-off-by: Jan H. Schönherr --- New in v2, preparation for patches 5 and 6. --- arch/x86/kernel/cpu/mce/core.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 1d91ce956772..d48deb127071 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -157,21 +157,24 @@ void mce_log(struct mce *m) EXPORT_SYMBOL_GPL(mce_log); /* - * We run the default notifier if we have only the UC, the first and the - * default notifier registered. I.e., the mandatory NUM_DEFAULT_NOTIFIERS + * We run the default notifier as long as we have no external * notifiers registered on the chain. */ -#define NUM_DEFAULT_NOTIFIERS 3 static atomic_t num_notifiers; -void mce_register_decode_chain(struct notifier_block *nb) +static void mce_register_decode_chain_internal(struct notifier_block *nb) { if (WARN_ON(nb->priority > MCE_PRIO_MCELOG && nb->priority < MCE_PRIO_EDAC)) return; + blocking_notifier_chain_register(&x86_mce_decoder_chain, nb); +} + +void mce_register_decode_chain(struct notifier_block *nb) +{ atomic_inc(&num_notifiers); - blocking_notifier_chain_register(&x86_mce_decoder_chain, nb); + mce_register_decode_chain_internal(nb); } EXPORT_SYMBOL_GPL(mce_register_decode_chain); @@ -611,7 +614,7 @@ static int mce_default_notifier(struct notifier_block *nb, unsigned long val, if (!m) return NOTIFY_DONE; - if (atomic_read(&num_notifiers) > NUM_DEFAULT_NOTIFIERS) + if (atomic_read(&num_notifiers)) return NOTIFY_DONE; __print_mce(m); @@ -1966,9 +1969,9 @@ __setup("mce", mcheck_enable); int __init mcheck_init(void) { mcheck_intel_therm_init(); - mce_register_decode_chain(&first_nb); - mce_register_decode_chain(&mce_uc_nb); - mce_register_decode_chain(&mce_default_nb); + mce_register_decode_chain_internal(&first_nb); + mce_register_decode_chain_internal(&mce_uc_nb); + mce_register_decode_chain_internal(&mce_default_nb); mcheck_vendor_init_severity(); INIT_WORK(&mce_work, mce_gen_pool_process); -- 2.22.0.3.gb49bb57c8208.dirty