From patchwork Tue Apr 7 06:33:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 11477611 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 33919912 for ; Tue, 7 Apr 2020 06:33:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0106420748 for ; Tue, 7 Apr 2020 06:33:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="f0awkIQP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726635AbgDGGdz (ORCPT ); Tue, 7 Apr 2020 02:33:55 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:34753 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbgDGGdz (ORCPT ); Tue, 7 Apr 2020 02:33:55 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id fc413e04; Tue, 7 Apr 2020 06:25:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:mime-version:content-transfer-encoding; s=mail; bh=DM9NrDkjXWpH4zu4SJmHj2Mdn+k=; b=f0awkIQPRVQo9hlCsQF4 GvF9MJdapgxLuHNpSOZvBlY0debaS6aHicQQHZIBdH1jBG3bh8dUwkj4rAw/F350 C6hOWMHuC0QYhFhd5iI8Oi7QfxSH0QEpUegjdZ3ZpjeUnyrZX4vqG3TCrxkvyrwd hLjBRvr7Gd6ebmXeP1tvuq7RJBJzd2Dsi9GobMc7sEz0ymLAiX0ASCGHlp7dP0AA gm926jwHIdGs0QGf3v8cJwHXhTPrHdrMOtN0QMsHuYDDuhvmq5hFjbI9h+Choj0v KPQCCKC0Nincy4Fn4BO48rxRaRxgGGAOFgIzrCUJI2NM0DuXxULLa3XtnQepTGyx Hw== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 0bb34400 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Tue, 7 Apr 2020 06:25:00 +0000 (UTC) From: "Jason A. Donenfeld" To: linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, x86@kernel.org, arnd@arndb.de, srinivas.pandruvada@linux.intel.com, bberg@redhat.com, bp@suse.de Cc: "Jason A. Donenfeld" Subject: [PATCH 1/3] x86/mce/therm_throt: remove unused platform_thermal_notify function pointer Date: Tue, 7 Apr 2020 00:33:43 -0600 Message-Id: <20200407063345.4484-1-Jason@zx2c4.com> MIME-Version: 1.0 Sender: linux-edac-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org A long time ago platform_thermal_notify was added as some generic mechanism for platform drivers to hook thermal events. It seems as though this has been entirely superseded, and nothing uses it. Remove the plumbing for this, since this code runs in an interrupt hot path. Signed-off-by: Jason A. Donenfeld Reviewed-by: Pandruvada, Srinivas --- arch/x86/include/asm/mce.h | 3 --- arch/x86/kernel/cpu/mce/therm_throt.c | 25 ------------------------- 2 files changed, 28 deletions(-) diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h index 4359b955e0b7..ee30cb60ad36 100644 --- a/arch/x86/include/asm/mce.h +++ b/arch/x86/include/asm/mce.h @@ -257,9 +257,6 @@ extern void (*deferred_error_int_vector)(void); void intel_init_thermal(struct cpuinfo_x86 *c); -/* Interrupt Handler for core thermal thresholds */ -extern int (*platform_thermal_notify)(__u64 msr_val); - /* Interrupt Handler for package thermal thresholds */ extern int (*platform_thermal_package_notify)(__u64 msr_val); diff --git a/arch/x86/kernel/cpu/mce/therm_throt.c b/arch/x86/kernel/cpu/mce/therm_throt.c index f36dc0742085..f904e85eb68f 100644 --- a/arch/x86/kernel/cpu/mce/therm_throt.c +++ b/arch/x86/kernel/cpu/mce/therm_throt.c @@ -105,10 +105,6 @@ struct thermal_state { struct _thermal_state pkg_thresh1; }; -/* Callback to handle core threshold interrupts */ -int (*platform_thermal_notify)(__u64 msr_val); -EXPORT_SYMBOL(platform_thermal_notify); - /* Callback to handle core package threshold_interrupts */ int (*platform_thermal_package_notify)(__u64 msr_val); EXPORT_SYMBOL_GPL(platform_thermal_package_notify); @@ -551,24 +547,6 @@ static void notify_package_thresholds(__u64 msr_val) platform_thermal_package_notify(msr_val); } -static void notify_thresholds(__u64 msr_val) -{ - /* check whether the interrupt handler is defined; - * otherwise simply return - */ - if (!platform_thermal_notify) - return; - - /* lower threshold reached */ - if ((msr_val & THERM_LOG_THRESHOLD0) && - thresh_event_valid(CORE_LEVEL, 0)) - platform_thermal_notify(msr_val); - /* higher threshold reached */ - if ((msr_val & THERM_LOG_THRESHOLD1) && - thresh_event_valid(CORE_LEVEL, 1)) - platform_thermal_notify(msr_val); -} - /* Thermal transition interrupt handler */ static void intel_thermal_interrupt(void) { @@ -579,9 +557,6 @@ static void intel_thermal_interrupt(void) rdmsrl(MSR_IA32_THERM_STATUS, msr_val); - /* Check for violation of core thermal thresholds*/ - notify_thresholds(msr_val); - therm_throt_process(msr_val & THERM_STATUS_PROCHOT, THERMAL_THROTTLING_EVENT, CORE_LEVEL); From patchwork Tue Apr 7 06:33:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 11477613 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9437992C for ; Tue, 7 Apr 2020 06:34:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 729252072A for ; Tue, 7 Apr 2020 06:34:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="fXiQ1qW3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727104AbgDGGd5 (ORCPT ); Tue, 7 Apr 2020 02:33:57 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:34753 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbgDGGd5 (ORCPT ); Tue, 7 Apr 2020 02:33:57 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 6917a9d6; Tue, 7 Apr 2020 06:25:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=mail; bh=BzxdK8qX7RPMFKrWffaobEdiW Aw=; b=fXiQ1qW3kilIqRdGH9MIIuHs+vzTNW4T/NuK8lAzfJzSjQbhm/qNou8NZ OV3ylqBANDqhURB9qTb8wE89Sq7RpWLpE2s+EMf+8OH8QTRXEiCaEkjn0468f6yl YwWkVcDkIZUvkE6wpNamzA/ZktpKbCTuEjvUMQOlTvAWzTWt83mLb8ZfTrix+THW nlxw36s5r/2lABHK67dP5GTrFkTh2v0J2aSkBHvmyatVSLWEssWGMhWZJb1XaySu rXy8Zn6BSax1+wsV8QP1iiAq2d8dUQwm5OAS4RmIZZkEKB22g4oUX/AkLMep7sEf GAef5h9L8TjainUlvq0EwLhdRAkww== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 715c3be1 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Tue, 7 Apr 2020 06:25:01 +0000 (UTC) From: "Jason A. Donenfeld" To: linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, x86@kernel.org, arnd@arndb.de, srinivas.pandruvada@linux.intel.com, bberg@redhat.com, bp@suse.de Cc: "Jason A. Donenfeld" Subject: [PATCH 2/3] x86/mce/therm_throt: allow disabling verbose logging Date: Tue, 7 Apr 2020 00:33:44 -0600 Message-Id: <20200407063345.4484-2-Jason@zx2c4.com> In-Reply-To: <20200407063345.4484-1-Jason@zx2c4.com> References: <20200407063345.4484-1-Jason@zx2c4.com> MIME-Version: 1.0 Sender: linux-edac-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org There is an enormous amount of fiddly book keeping and an auxiliary workqueue just for the purpose of ratelimiting and reliably printing messages regarding thermal events and throttling, which uses CPU in a rather common interrupt. Add an option to disable this verbose reporting. Signed-off-by: Jason A. Donenfeld --- arch/x86/Kconfig | 9 +++++++++ arch/x86/kernel/cpu/mce/therm_throt.c | 3 +++ 2 files changed, 12 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index beea77046f9b..39e7444353af 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1159,6 +1159,15 @@ config X86_THERMAL_VECTOR def_bool y depends on X86_MCE_INTEL +config X86_MCE_THERMAL_VERBOSE + bool "Verbose logging for thermal events" + depends on X86_THERMAL_VECTOR + ---help--- + Display messages in the kernel log when thermal events are triggered, + such as overheating and throttling. This mostly only uses extra CPU + for ratelimiting and book keeping, so unless you need these logs, it + is safe to say N. + source "arch/x86/events/Kconfig" config X86_LEGACY_VM86 diff --git a/arch/x86/kernel/cpu/mce/therm_throt.c b/arch/x86/kernel/cpu/mce/therm_throt.c index f904e85eb68f..6d726190a40a 100644 --- a/arch/x86/kernel/cpu/mce/therm_throt.c +++ b/arch/x86/kernel/cpu/mce/therm_throt.c @@ -313,6 +313,9 @@ static void therm_throt_process(bool new_event, int event, int level) u64 now; struct thermal_state *pstate = &per_cpu(thermal_state, this_cpu); + if (!IS_ENABLED(CONFIG_X86_MCE_THERMAL_VERBOSE)) + return; + now = get_jiffies_64(); if (level == CORE_LEVEL) { if (event == THERMAL_THROTTLING_EVENT) From patchwork Tue Apr 7 06:33:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 11477615 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CDCE014DD for ; Tue, 7 Apr 2020 06:34:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A1BAF2072A for ; Tue, 7 Apr 2020 06:34:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="3gcwL1+W" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726448AbgDGGeB (ORCPT ); Tue, 7 Apr 2020 02:34:01 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:34753 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727089AbgDGGd6 (ORCPT ); Tue, 7 Apr 2020 02:33:58 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 9ab397b9; Tue, 7 Apr 2020 06:25:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=mail; bh=jnfqAcB3FkJJghojQNXETQmiD XM=; b=3gcwL1+WjA8BQ7Cevgi80DvJ02fa2QeAaH8mhH3zDS8mraY/l/jPs30/x oV/1oXf5jR59xrff0vmfJsq2ruGKk149PwCwgoJcexA+CECBVs3JD23dH6DyUAqr lO7Lf7AgWQWbwd3xrTziEajJcRbZkuWNyeZwEVwtwJGutp96H71oh9xSEJrnltjI DBtFvmBj24FbF5WgFG2K9fA2O5MvZrKQ8yNMSYS+dOsgKvz7zgI8X4d749uUUFep bEBrd6FWjly/stvpyE5NapE8Z+MmVyxRAFCtPYPERS8zYFIlDXPK6Zsm3O5kxk8B hkWqeMcNp+84MMhDAFx0K3/g2oDyg== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id d2fa65a3 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Tue, 7 Apr 2020 06:25:02 +0000 (UTC) From: "Jason A. Donenfeld" To: linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, x86@kernel.org, arnd@arndb.de, srinivas.pandruvada@linux.intel.com, bberg@redhat.com, bp@suse.de Cc: "Jason A. Donenfeld" Subject: [PATCH 3/3] x86/mce/therm_throt: allow disabling the thermal vector altogether Date: Tue, 7 Apr 2020 00:33:45 -0600 Message-Id: <20200407063345.4484-3-Jason@zx2c4.com> In-Reply-To: <20200407063345.4484-1-Jason@zx2c4.com> References: <20200407063345.4484-1-Jason@zx2c4.com> MIME-Version: 1.0 Sender: linux-edac-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org The thermal IRQ handler uses 1.21% CPU on my system when it's hot from compiling things. Indeed looking at /proc/interrupts reveals quite a lot of events coming in. Beyond logging them, the existing drivers on the system don't appear to do very much that I'm interested in. So, add a way to disable this entirely so that I can regain precious CPU cycles. Signed-off-by: Jason A. Donenfeld --- arch/x86/Kconfig | 4 ++++ arch/x86/kernel/cpu/mce/intel.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 39e7444353af..3125a11932f2 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1157,7 +1157,11 @@ config X86_MCE_INJECT config X86_THERMAL_VECTOR def_bool y + prompt "Machine check thermal vector" depends on X86_MCE_INTEL + ---help--- + Provide support for capturing thermal events, logging them, and + passing them off to other drivers. config X86_MCE_THERMAL_VERBOSE bool "Verbose logging for thermal events" diff --git a/arch/x86/kernel/cpu/mce/intel.c b/arch/x86/kernel/cpu/mce/intel.c index f996ffb887bc..d14f1922fb49 100644 --- a/arch/x86/kernel/cpu/mce/intel.c +++ b/arch/x86/kernel/cpu/mce/intel.c @@ -511,7 +511,8 @@ static void intel_ppin_init(struct cpuinfo_x86 *c) void mce_intel_feature_init(struct cpuinfo_x86 *c) { - intel_init_thermal(c); + if (IS_ENABLED(CONFIG_X86_THERMAL_VECTOR)) + intel_init_thermal(c); intel_init_cmci(); intel_init_lmce(); intel_ppin_init(c);