mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
	 Daniel Lezcano <daniel.lezcano@kernel.org>,
	Zhang Rui <rui.zhang@intel.com>,
	 Lukasz Luba <lukasz.luba@arm.com>,
	 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: linux-pm@vger.kernel.org, linux-api@vger.kernel.org,
	 linux-kernel@vger.kernel.org, ricardo.neri@intel.com,
	 Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Subject: [PATCH 12/13] thermal: intel: dpti: Avoid nohz_full CPUs when possible
Date: Mon, 09 Nov 2026 19:36:39 -0800	[thread overview]
Message-ID: <20261109-dpti-custom-cpu-v1-12-ead8e2d2067e@linux.intel.com> (raw)
In-Reply-To: <20261109-dpti-custom-cpu-v1-0-ead8e2d2067e@linux.intel.com>

A single CPU of each package owns the directed package-level thermal
interrupt (DPTI). Automatic selection ranks every online CPU of the
package equally. Consequently, the package thermal interrupt could be
directed to a CPU isolated via the nohz_full= or isolcpus=nohz
command-line parameters.

Directing the interrupt to a nohz_full CPU degrades its tickless isolation.
Make the automatic ranking isolation-aware: split DPTI_RANK_ONLINE into
DPTI_RANK_HOUSEKEEPING for CPUs in the HK_TYPE_KERNEL_NOISE mask and
DPTI_RANK_ISOLATED for the nohz_full-isolated ones.

The CPU hotplug online callback reselects and migrates the DPTI on rank
improvement: a housekeeping CPU that comes online later takes over from an
isolated one that claimed the package earlier in boot.

A migration that the hardware does not acknowledge leaves the current owner
in place. Warn once about it rather than failing the online callback, whose
message would report the package as broadcasting. This cannot happen during
boot, so the boot-time teardown is unaffected.

Warn once when a package has to fall back to an isolated CPU.

Isolation changes at runtime via cpuset isolated partitions are not
tracked.

Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
---
 drivers/thermal/intel/therm_throt.c | 47 ++++++++++++++++++++++++++++++-------
 1 file changed, 38 insertions(+), 9 deletions(-)

diff --git a/drivers/thermal/intel/therm_throt.c b/drivers/thermal/intel/therm_throt.c
index c418471cf8f4..c8c91a621cf6 100644
--- a/drivers/thermal/intel/therm_throt.c
+++ b/drivers/thermal/intel/therm_throt.c
@@ -17,6 +17,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
+#include <linux/sched/isolation.h>
 #include <linux/syscore_ops.h>
 #include <linux/interrupt.h>
 #include <linux/notifier.h>
@@ -672,7 +673,8 @@ static void dpti_clear_all(void)
 /**
  * enum dpti_rank - How suitable a CPU is as a DPTI owner
  * @DPTI_RANK_NONE:		No eligible CPU.
- * @DPTI_RANK_ONLINE:		An online CPU of the package (automatic choice).
+ * @DPTI_RANK_ISOLATED:		nohz_full-isolated (last resort).
+ * @DPTI_RANK_HOUSEKEEPING:	Not isolated (ideal automatic choice).
  * @DPTI_RANK_PINNED:		Explicitly requested by the user; overrides any
  *				automatic choice.
  *
@@ -681,14 +683,21 @@ static void dpti_clear_all(void)
  */
 enum dpti_rank {
 	DPTI_RANK_NONE,
-	DPTI_RANK_ONLINE,
+	DPTI_RANK_ISOLATED,
+	DPTI_RANK_HOUSEKEEPING,
 	DPTI_RANK_PINNED,
 };
 
 static enum dpti_rank dpti_cpu_rank(unsigned int cpu)
 {
-	/* No concept of isolation yet: every online CPU ranks the same. */
-	return DPTI_RANK_ONLINE;
+	/*
+	 * Prefer a HK_TYPE_KERNEL_NOISE CPU to avoid disturbing nohz_full
+	 * isolated CPUs. The mask is boot-static. No locking needed.
+	 */
+	if (housekeeping_cpu(cpu, HK_TYPE_KERNEL_NOISE))
+		return DPTI_RANK_HOUSEKEEPING;
+
+	return DPTI_RANK_ISOLATED;
 }
 
 /*
@@ -731,9 +740,10 @@ static unsigned int dpti_select_cpu(unsigned int pkg_cpu, unsigned int skip,
 			best_rank = cpu_rank;
 			best = cpu;
 			/*
-			 * Nothing outranks an online CPU in automatic selection.
+			 * Nothing outranks a housekeeping CPU in automatic
+			 * selection.
 			 */
-			if (best_rank == DPTI_RANK_ONLINE)
+			if (best_rank == DPTI_RANK_HOUSEKEEPING)
 				break;
 		}
 	}
@@ -743,6 +753,13 @@ static unsigned int dpti_select_cpu(unsigned int pkg_cpu, unsigned int skip,
 	return best;
 }
 
+static void dpti_warn_if_isolated(unsigned int cpu, enum dpti_rank rank)
+{
+	if (rank == DPTI_RANK_ISOLATED)
+		pr_warn_once("Package %u thermal interrupt directed to nohz_full-isolated CPU%u; no housekeeping CPU available\n",
+			     topology_logical_package_id(cpu), cpu);
+}
+
 /*
  * Reselect the owner for @cpu's package and migrate to it, but only on a
  * strict rank improvement.
@@ -771,13 +788,18 @@ static int dpti_update_owner(unsigned int cpu)
 		return 0;
 
 	ret = dpti_program_on_cpu(new_cpu);
-	if (ret)
+	if (ret) {
+		if (old_cpu < nr_cpu_ids)
+			pr_warn_once("Failed to redirect package thermal interrupt from CPU%u to CPU%u; keeping CPU%u\n",
+				     old_cpu, new_cpu, old_cpu);
 		return ret;
+	}
 
 	if (old_cpu < nr_cpu_ids)
 		dpti_clear_on_cpu(old_cpu);
 
 	pkg->owner = new_cpu;
+	dpti_warn_if_isolated(new_cpu, new_rank);
 
 	return 0;
 }
@@ -801,9 +823,14 @@ static int dpti_online(unsigned int cpu)
 
 	/*
 	 * A CPU coming online may be a better owner than the one currently
-	 * programmed.
+	 * programmed. If the hardware does not acknowledge it, the current
+	 * owner keeps the interrupt: a valid outcome, already reported.
 	 */
-	return dpti_update_owner(cpu);
+	ret = dpti_update_owner(cpu);
+	if (ret && dpti_pkg_of_cpu_nocheck(cpu)->owner < nr_cpu_ids)
+		return 0;
+
+	return ret;
 }
 
 static void dpti_offline(unsigned int cpu)
@@ -841,6 +868,7 @@ static void dpti_offline(unsigned int cpu)
 			     cpu, new_cpu);
 
 		new_cpu = nr_cpu_ids;
+		new_rank = DPTI_RANK_NONE;
 	}
 
 	/*
@@ -850,6 +878,7 @@ static void dpti_offline(unsigned int cpu)
 	dpti_config_this_cpu(false);
 
 	dpti_pkgs[pkg_id].owner = new_cpu;
+	dpti_warn_if_isolated(new_cpu, new_rank);
 }
 
 /*

-- 
2.43.0


  parent reply	other threads:[~2026-11-10  3:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10  3:36 [PATCH 00/13] thermal: intel: dpti: Direct the package thermal interrupt to a chosen CPU Ricardo Neri
2026-11-10  3:36 ` [PATCH 01/13] thermal: intel: Keep directed package interrupts off after syscore shutdown Ricardo Neri
2026-11-10  3:36 ` [PATCH 02/13] thermal: intel: Prefix log messages via pr_fmt() Ricardo Neri
2026-11-10  3:36 ` [PATCH 03/13] thermal: intel: Move the sysfs device helpers next to their callers Ricardo Neri
2026-11-10  3:36 ` [PATCH 04/13] thermal: intel: dpti: Adopt the dpti_ prefix and the owner terminology Ricardo Neri
2026-11-10  3:36 ` [PATCH 05/13] thermal: intel: dpti: Tear down DPTI only during boot Ricardo Neri
2026-11-10  3:36 ` [PATCH 06/13] thermal: intel: dpti: Introduce struct dpti_pkg for per-package state Ricardo Neri
2026-11-10  3:36 ` [PATCH 07/13] thermal: intel: dpti: Configure the local CPU by value Ricardo Neri
2026-11-10  3:36 ` [PATCH 08/13] thermal: intel: dpti: Factor the programming sequence out into a helper Ricardo Neri
2026-11-10  3:36 ` [PATCH 09/13] thermal: intel: dpti: Program the directed interrupt on the target CPU Ricardo Neri
2026-11-10  3:36 ` [PATCH 10/13] thermal: intel: dpti: Add rank-based owner selection Ricardo Neri
2026-11-10  3:36 ` [PATCH 11/13] thermal: intel: dpti: Serialize updates to the directed interrupt state Ricardo Neri
2026-11-10  3:36 ` Ricardo Neri [this message]
2026-11-10  3:36 ` [PATCH 13/13] thermal: intel: dpti: Add sysfs control of interrupt owner Ricardo Neri

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=20261109-dpti-custom-cpu-v1-12-ead8e2d2067e@linux.intel.com \
    --to=ricardo.neri-calderon@linux.intel.com \
    --cc=daniel.lezcano@kernel.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=rafael@kernel.org \
    --cc=ricardo.neri@intel.com \
    --cc=rui.zhang@intel.com \
    --cc=srinivas.pandruvada@linux.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

all inboxes | Powered by JetHome®