From: Gabriele Monaco <gmonaco@redhat.com>
To: linux-kernel@vger.kernel.org,
Frederic Weisbecker <frederic@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Waiman Long <longman@redhat.com>
Cc: Gabriele Monaco <gmonaco@redhat.com>
Subject: [PATCH v5 4/6] sched/isolation: Force housekeeping if isolcpus and nohz_full don't leave any
Date: Thu, 8 May 2025 16:53:24 +0200 [thread overview]
Message-ID: <20250508145319.97794-12-gmonaco@redhat.com> (raw)
In-Reply-To: <20250508145319.97794-8-gmonaco@redhat.com>
Currently the user can set up isolcpus and nohz_full in such a way that
leaves no housekeeping CPU (i.e. no CPU that is neither domain isolated
nor nohz full). This can be a problem for other subsystems (e.g. the
timer wheel imgration).
Prevent this configuration by setting the boot CPU as housekeeping if
the union of isolcpus and nohz_full covers all CPUs. In a similar
fashion as it already happens if either of them covers all CPUs.
Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
---
include/linux/tick.h | 2 ++
kernel/sched/isolation.c | 20 ++++++++++++++++++++
kernel/time/tick-sched.c | 7 +++++++
3 files changed, 29 insertions(+)
diff --git a/include/linux/tick.h b/include/linux/tick.h
index b8ddc8e631a3..0b32c0bd3512 100644
--- a/include/linux/tick.h
+++ b/include/linux/tick.h
@@ -278,6 +278,7 @@ static inline void tick_dep_clear_signal(struct signal_struct *signal,
extern void tick_nohz_full_kick_cpu(int cpu);
extern void __tick_nohz_task_switch(void);
extern void __init tick_nohz_full_setup(cpumask_var_t cpumask);
+extern void __init tick_nohz_full_clear_cpu(unsigned int cpu);
#else
static inline bool tick_nohz_full_enabled(void) { return false; }
static inline bool tick_nohz_full_cpu(int cpu) { return false; }
@@ -304,6 +305,7 @@ static inline void tick_dep_clear_signal(struct signal_struct *signal,
static inline void tick_nohz_full_kick_cpu(int cpu) { }
static inline void __tick_nohz_task_switch(void) { }
static inline void tick_nohz_full_setup(cpumask_var_t cpumask) { }
+static inline void tick_nohz_full_clear_cpu(unsigned int cpu) { }
#endif
static inline void tick_nohz_task_switch(void)
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index 81bc8b329ef1..27b65b401534 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -165,6 +165,26 @@ static int __init housekeeping_setup(char *str, unsigned long flags)
}
}
+ /* Check in combination with the previously set cpumask */
+ type = find_first_bit(&housekeeping.flags, HK_TYPE_MAX);
+ first_cpu = cpumask_first_and_and(cpu_present_mask,
+ housekeeping_staging,
+ housekeeping.cpumasks[type]);
+ if (first_cpu >= nr_cpu_ids || first_cpu >= setup_max_cpus) {
+ pr_warn("Housekeeping: must include one present CPU neither "
+ "in nohz_full= nor in isolcpus=, using boot CPU:%d\n",
+ smp_processor_id());
+ for_each_set_bit(type, &housekeeping.flags, HK_TYPE_MAX)
+ __cpumask_set_cpu(smp_processor_id(),
+ housekeeping.cpumasks[type]);
+ __cpumask_set_cpu(smp_processor_id(), housekeeping_staging);
+ __cpumask_clear_cpu(smp_processor_id(), non_housekeeping_mask);
+ tick_nohz_full_clear_cpu(smp_processor_id());
+
+ if (cpumask_empty(non_housekeeping_mask))
+ goto free_housekeeping_staging;
+ }
+
iter_flags = flags & ~housekeeping.flags;
for_each_set_bit(type, &iter_flags, HK_TYPE_MAX)
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index c527b421c865..2969ed13d1f4 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -604,6 +604,13 @@ void __init tick_nohz_full_setup(cpumask_var_t cpumask)
tick_nohz_full_running = true;
}
+/* Called if boot-time nohz CPU list changes during initialisation. */
+void __init tick_nohz_full_clear_cpu(unsigned int cpu)
+{
+ if (tick_nohz_full_running)
+ cpumask_clear_cpu(cpu, tick_nohz_full_mask);
+}
+
bool tick_nohz_cpu_hotpluggable(unsigned int cpu)
{
/*
--
2.49.0
next prev parent reply other threads:[~2025-05-08 14:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-08 14:53 [PATCH v5 0/6] timers: Exclude isolated cpus from timer migation Gabriele Monaco
2025-05-08 14:53 ` [PATCH v5 1/6] timers: Rename tmigr 'online' bit to 'available' Gabriele Monaco
2025-05-08 14:53 ` [PATCH v5 2/6] timers: Add the available mask in timer migration Gabriele Monaco
2025-05-08 14:53 ` [PATCH v5 3/6] cgroup/cpuset: Rename update_unbound_workqueue_cpumask() to update_exclusion_cpumasks() Gabriele Monaco
2025-05-08 14:53 ` Gabriele Monaco [this message]
2025-05-20 10:17 ` [PATCH v5 4/6] sched/isolation: Force housekeeping if isolcpus and nohz_full don't leave any Frederic Weisbecker
2025-05-20 11:17 ` Gabriele Monaco
2025-05-20 11:57 ` Frederic Weisbecker
2025-05-20 12:02 ` Frederic Weisbecker
2025-05-20 12:28 ` Gabriele Monaco
2025-05-08 14:53 ` [PATCH v5 5/6] cgroup/cpuset: Fail if isolated and nohz_full don't leave any housekeeping Gabriele Monaco
2025-05-20 13:39 ` Gabriele Monaco
2025-05-20 14:28 ` Frederic Weisbecker
2025-05-20 15:24 ` Gabriele Monaco
2025-05-23 11:15 ` Gabriele Monaco
2025-06-24 14:11 ` Frederic Weisbecker
2025-05-08 14:53 ` [PATCH v5 6/6] timers: Exclude isolated cpus from timer migation Gabriele Monaco
2025-05-20 14:43 ` Frederic Weisbecker
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=20250508145319.97794-12-gmonaco@redhat.com \
--to=gmonaco@redhat.com \
--cc=frederic@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=tglx@linutronix.de \
/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®