Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp19010561ybl; Fri, 3 Jan 2020 13:44:56 -0800 (PST) X-Google-Smtp-Source: APXvYqyGY/AhCgyXofOMzFZdR5MaZnldIeGq51ygLRZjfO6cOizq5FIsDGXIHDiqUNwJCzNXsEUF X-Received: by 2002:a9d:588d:: with SMTP id x13mr95633323otg.6.1578087896508; Fri, 03 Jan 2020 13:44:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578087896; cv=none; d=google.com; s=arc-20160816; b=ds2mR8hXKMUrsT8xAADAUveSF7ohp1nHLRt+6gPv8lnOHWTSB1JqvVHYRi5Yui5MK0 Ba8izBNIFRA+8KRU4APSn7+RDX6Rx2ninjZTGOlWN7leLNUKlQTgDWOsxz96DO2xm5EZ asQ1SbiVmEwuKiMT/21D6Z/y4Lqv/yW2693ZnscpWf123gFlGYuIJ8771cgw5NxH3PT2 UXIy8IIyBc6dAnRIUuaR4jrCEyh5ahCamA1RtJcJDm8um5PcC0+4ij+5iFFP+tAJD0S2 WBtjV4ylI+nZdJHOdKL1sThjljvS9mNCgR4BrKXGBn24DFAYBpQWoXi2UshItQ6onOMJ BanQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Q+ZVe3WOG3KNgBt/90h8JnD39kPKjU1QaYmyEZfqa9E=; b=pWZ35/4g/GE3vyte8Jki1rVbUxNVJJdFFxAjfQC6RAfdZ4Hhx+pEOWjgKyHc/mu9bF /ZY4PoS9sDYCs638r8iPGsg7WmeaspryHwbRshyHPZSBvbOYGg0G7fI9EX5zp8rzvqcS om51drU5wlloD6JP81sw3mFHV5EJCnzl3U59Ll4dOUf6pDld5QI5KezSzLkzfaMoV7YI EHqWc4DgjD9Q+k1x0zHBbHIQAGrpfl8p6oen2+Ml5a/+z9qDMoFfmlUQZ68B9c+xnUPA RnPfDKIYdEX+jx26x+roH0ucPHdoJxW67TorNPEm1laOtu2ZiIpYW/0d8B2k0AUNmCG4 1yTA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j9si31609817otq.317.2020.01.03.13.44.32; Fri, 03 Jan 2020 13:44:56 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728722AbgACVmc (ORCPT + 99 others); Fri, 3 Jan 2020 16:42:32 -0500 Received: from mga11.intel.com ([192.55.52.93]:35860 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728664AbgACVmb (ORCPT ); Fri, 3 Jan 2020 16:42:31 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jan 2020 13:42:31 -0800 X-IronPort-AV: E=Sophos;i="5.69,392,1571727600"; d="scan'208";a="421549597" Received: from agluck-desk2.sc.intel.com (HELO agluck-desk2.amr.corp.intel.com) ([10.3.52.68]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jan 2020 13:42:31 -0800 Date: Fri, 3 Jan 2020 13:42:29 -0800 From: "Luck, Tony" To: Jan =?iso-8859-1?Q?H=2E_Sch=F6nherr?= Cc: Borislav Petkov , Yazen Ghannam , linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org Subject: Re: [PATCH v2 6/6] x86/mce: Dynamically register default MCE handler Message-ID: <20200103214229.GA10677@agluck-desk2.amr.corp.intel.com> References: <20200103150722.20313-1-jschoenh@amazon.de> <20200103150722.20313-7-jschoenh@amazon.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200103150722.20313-7-jschoenh@amazon.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 03, 2020 at 04:07:22PM +0100, Jan H. Sch?nherr wrote: > The default MCE handler takes action, when no external MCE handler is > registered. Instead of checking for external handlers within the default > MCE handler, only register the default MCE handler when there are no > external handlers in the first place. > > Signed-off-by: Jan H. Sch?nherr > --- > New in v2. This is something that became possible due to patch 4. > I'm not entirely happy with it. > > One the one hand, I'm wondering whether there's a nicer way to handle > (de-)registration races. > Instead of unregistering/registering the default notifier depending on whether there are other notifiers, couldn't you just make the default notifier check to see if it should print. E.g. static int mce_default_notifier(struct notifier_block *nb, unsigned long val, void *data) { struct mce *m = (struct mce *)data; if (m && !atomic_read(&num_notifiers)) __print_mce(m); return NOTIFY_DONE; } > On the other hand, I'm starting to question the whole logic to "only print > the MCE if nothing else in the kernel has a handler registered". Is that > really how it should be? For example, there are handlers that filter for a > specific subset of MCEs. If one of those is registered, we're losing all > information for MCEs that don't match. Maybe put control of this into the hands of the notifiers ... if a notifier thinks that it does something useful with the log that makes the console log redundant, then it could call a function to bump the count to suppress the __print_mce(). Simple filter functions on the chain wouldn't do that. If we go this path the variable should be named something like "suppress_console_mce" rather than num_notifiers. Might also be useful to have some command line option or debugfs knob to force printing for those cases where bad stuff is happening and we don't see what was logged before a crash drops all the bits on the floor. -Tony