In order to prepare supporting "isolcpus=" changes toward cpuset,
provide an API to modify the "isolcpus=" cpumask passed on boot.
TODO:
* Propagate the change to all interested subsystems (workqueue, net, pci)
* Make sure we can't concurrently change this cpumask (assert cpuset_rwsem
is held).
Signed-off-by: Frederic Weisbecker <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Juri Lelli <[email protected]>
Cc: Marcelo Tosatti <[email protected]>
Cc: Nitesh Lal <[email protected]>
Cc: Nicolas Saenz <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Christoph Lameter <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: Zefan Li <[email protected]>
Cc: Alex Belits <[email protected]>
---
include/linux/sched/isolation.h | 4 ++++
kernel/sched/isolation.c | 19 +++++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h
index cc9f393e2a70..a5960cb357d2 100644
--- a/include/linux/sched/isolation.h
+++ b/include/linux/sched/isolation.h
@@ -21,6 +21,7 @@ enum hk_flags {
DECLARE_STATIC_KEY_FALSE(housekeeping_overridden);
extern int housekeeping_any_cpu(enum hk_flags flags);
extern const struct cpumask *housekeeping_cpumask(enum hk_flags flags);
+extern void housekeeping_cpumask_set(struct cpumask *mask, enum hk_flags flags);
extern bool housekeeping_enabled(enum hk_flags flags);
extern void housekeeping_affine(struct task_struct *t, enum hk_flags flags);
extern bool housekeeping_test_cpu(int cpu, enum hk_flags flags);
@@ -38,6 +39,9 @@ static inline const struct cpumask *housekeeping_cpumask(enum hk_flags flags)
return cpu_possible_mask;
}
+static inline void housekeeping_cpumask_set(struct cpumask *mask,
+ enum hk_flags flags) { }
+
static inline bool housekeeping_enabled(enum hk_flags flags)
{
return false;
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index c2bdf7e6dc39..c071433059cf 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -68,7 +68,26 @@ bool housekeeping_test_cpu(int cpu, enum hk_flags flags)
}
EXPORT_SYMBOL_GPL(housekeeping_test_cpu);
+// Only support HK_FLAG_DOMAIN for now
+// TODO: propagate the changes through all interested subsystems:
+// workqueues, net, pci; ...
+void housekeeping_cpumask_set(struct cpumask *mask, enum hk_flags flags)
+{
+ /* Only HK_FLAG_DOMAIN change supported for now */
+ if (WARN_ON_ONCE(flags != HK_FLAG_DOMAIN))
+ return;
+ if (!static_key_enabled(&housekeeping_overridden.key)) {
+ if (cpumask_equal(mask, cpu_possible_mask))
+ return;
+ if (WARN_ON_ONCE(!alloc_cpumask_var(&hk_domain_mask, GFP_KERNEL)))
+ return;
+ cpumask_copy(hk_domain_mask, mask);
+ static_branch_enable(&housekeeping_overridden);
+ } else {
+ cpumask_copy(hk_domain_mask, mask);
+ }
+}
void __init housekeeping_init(void)
{
--
2.25.1
Hi Frederic,
[...]
>
> +// Only support HK_FLAG_DOMAIN for now
> +// TODO: propagate the changes through all interested subsystems:
> +// workqueues, net, pci; ...
> +void housekeeping_cpumask_set(struct cpumask *mask, enum hk_flags flags)
> +{
> + /* Only HK_FLAG_DOMAIN change supported for now */
> + if (WARN_ON_ONCE(flags != HK_FLAG_DOMAIN))
> + return;
>
> + if (!static_key_enabled(&housekeeping_overridden.key)) {
> + if (cpumask_equal(mask, cpu_possible_mask))
> + return;
> + if (WARN_ON_ONCE(!alloc_cpumask_var(&hk_domain_mask, GFP_KERNEL)))
> + return;
> + cpumask_copy(hk_domain_mask, mask);
> + static_branch_enable(&housekeeping_overridden);
I get a warning here. static_branch_enable() is trying to take cpus_read_lock().
But the same lock is already taken by cpuset_write_u64().
Also, shouldn't it set HK_FLAG_DOMAIN in housekeeping_flags to enable
housekeeping if the kernel started without isolcpus="" ?
--
Vincent