From: Guenter Roeck <linux@roeck-us.net>
To: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Cc: david.nystrom@est.tech, linux-hwmon@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
ricardo.neri@intel.com
Subject: Re: [PATCH 2/3] hwmon: (coretemp) Read TjMax only when refreshing the temperature
Date: Fri, 25 Sep 2026 07:04:46 -0700 [thread overview]
Message-ID: <94dc8122-d6d7-40b0-adde-5e0cd7b645e9@roeck-us.net> (raw)
In-Reply-To: <20260924-coretemp-temp-fault-v1-2-1884f0ff97d5@linux.intel.com>
On Thu, Sep 24, 2026 at 07:33:21PM -0700, Ricardo Neri wrote:
> show_temp() reads TjMax before checking whether the cached temperature is
> still fresh, but consumes it only when recomputing that temperature. On a
> cache hit the value is discarded.
>
> Discarding it is not free. On CPUs that report TjMax in
> MSR_IA32_TEMPERATURE_TARGET, get_tjmax() returns the value it just read
> without storing it in tdata->tjmax, so every call reads the MSR again.
> That is a cross-CPU call whenever the CPU owning the sensor is not the
> current one, and it is made while holding tdata->update_lock.
>
> Read TjMax where it is used. The value cannot go stale in the meantime:
> bits 23:16 of MSR_IA32_TEMPERATURE_TARGET are read-only, and the register
> is package-scoped, so every CPU of the package reads the same value.
>
> The temperature reported to userspace does not change.
>
> Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Applied. No need to resend this or the previous patch.
Thanks,
Guenter
next prev parent reply other threads:[~2026-09-25 14:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-25 2:33 [PATCH 0/3] hwmon: (coretemp) Report unreliable temperature readings Ricardo Neri
2026-09-25 2:33 ` [PATCH 1/3] hwmon: (coretemp) Refresh the temperature on the first read Ricardo Neri
2026-09-25 14:03 ` Guenter Roeck
2026-09-25 2:33 ` [PATCH 2/3] hwmon: (coretemp) Read TjMax only when refreshing the temperature Ricardo Neri
2026-09-25 14:04 ` Guenter Roeck [this message]
2026-09-25 2:33 ` [PATCH 3/3] hwmon: (coretemp) Add temp%d_fault sysfs attribute Ricardo Neri
2026-09-25 2:37 ` [PATCH 0/3] hwmon: (coretemp) Report unreliable temperature readings Guenter Roeck
2026-09-25 18:21 ` Ricardo Neri
2026-09-25 21:23 ` Guenter Roeck
2026-09-26 3:58 ` Ricardo Neri
2026-09-28 11:01 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=94dc8122-d6d7-40b0-adde-5e0cd7b645e9@roeck-us.net \
--to=linux@roeck-us.net \
--cc=david.nystrom@est.tech \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ricardo.neri-calderon@linux.intel.com \
--cc=ricardo.neri@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox