linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: coretemp: avoid RDMSR interruptions to isolated CPUs
@ 2022-12-15 12:42 Marcelo Tosatti
  2022-12-15 14:22 ` Guenter Roeck
  2022-12-23 10:48 ` [PATCH] " Dan Carpenter
  0 siblings, 2 replies; 8+ messages in thread
From: Marcelo Tosatti @ 2022-12-15 12:42 UTC (permalink / raw)
  To: Fenghua Yu; +Cc: linux-kernel, linux-hwmon, Frederic Weisbecker


The coretemp driver uses rdmsr_on_cpu calls to read
MSR_IA32_PACKAGE_THERM_STATUS/MSR_IA32_THERM_STATUS registers,
which contain information about current core temperature.

For certain low latency applications, the RDMSR interruption exceeds    
the applications requirements.

So disable reading of crit_alarm and temp files via /sys, in case
CPU isolation is enabled.

Temperature information from the housekeeping cores should be
sufficient to infer die temperature.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 9bee4d33fbdf..30a35f4130d5 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -27,6 +27,7 @@
 #include <asm/msr.h>
 #include <asm/processor.h>
 #include <asm/cpu_device_id.h>
+#include <linux/sched/isolation.h>
 
 #define DRVNAME	"coretemp"
 
@@ -121,6 +122,10 @@ static ssize_t show_crit_alarm(struct device *dev,
 	struct platform_data *pdata = dev_get_drvdata(dev);
 	struct temp_data *tdata = pdata->core_data[attr->index];
 
+
+	if (!housekeeping_cpu(tdata->cpu, HK_TYPE_MISC))
+		return -EINVAL;
+
 	mutex_lock(&tdata->update_lock);
 	rdmsr_on_cpu(tdata->cpu, tdata->status_reg, &eax, &edx);
 	mutex_unlock(&tdata->update_lock);
@@ -158,6 +163,8 @@ static ssize_t show_temp(struct device *dev,
 
 	/* Check whether the time interval has elapsed */
 	if (!tdata->valid || time_after(jiffies, tdata->last_updated + HZ)) {
+		if (!housekeeping_cpu(tdata->cpu, HK_TYPE_MISC))
+			return -EINVAL;
 		rdmsr_on_cpu(tdata->cpu, tdata->status_reg, &eax, &edx);
 		/*
 		 * Ignore the valid bit. In all observed cases the register





^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-12-28 15:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-15 12:42 [PATCH] hwmon: coretemp: avoid RDMSR interruptions to isolated CPUs Marcelo Tosatti
2022-12-15 14:22 ` Guenter Roeck
2022-12-16 14:07   ` [PATCH v2] " Marcelo Tosatti
2022-12-16 17:56     ` Guenter Roeck
2022-12-16 20:24       ` [PATCH v3] " Marcelo Tosatti
2022-12-28 15:59         ` Guenter Roeck
2022-12-23 10:48 ` [PATCH] " Dan Carpenter
2022-12-26 12:43   ` Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).