lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed,  3 Apr 2024 17:05:33 +0200
From: Pierre Gondois <pierre.gondois@....com>
To: linux-kernel@...r.kernel.org
Cc: Aaron Lu <aaron.lu@...el.com>,
	Rui Zhang <rui.zhang@...el.com>,
	Pierre Gondois <pierre.gondois@....com>,
	Anna-Maria Behnsen <anna-maria@...utronix.de>,
	Frederic Weisbecker <frederic@...nel.org>,
	Ingo Molnar <mingo@...nel.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Peter Zijlstra <peterz@...radead.org>,
	Juri Lelli <juri.lelli@...hat.com>,
	Vincent Guittot <vincent.guittot@...aro.org>,
	Dietmar Eggemann <dietmar.eggemann@....com>,
	Steven Rostedt <rostedt@...dmis.org>,
	Ben Segall <bsegall@...gle.com>,
	Mel Gorman <mgorman@...e.de>,
	Daniel Bristot de Oliveira <bristot@...hat.com>,
	Valentin Schneider <vschneid@...hat.com>,
	Tejun Heo <tj@...nel.org>,
	Michal Hocko <mhocko@...e.com>,
	Waiman Long <longman@...hat.com>,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: [PATCH 1/7] sched/isolation: Introduce housekeeping_runtime isolation

CONFIG_CPU_ISOLATION allows to setup various cpu masks to
exclude CPUs from some activities. Masks that are not modified
default to cpu_online_mask.
Masks are set at boot time. If no mask is modified, the static key
'housekeeping_overridden' is left to false, allowing to minimize the
cost of calls to housekeeping_*() functions.

Create a new housekeeping runtime type, whose isolation masks
can be modified at runtime. Also add a set of functions
around this new type. This type is independent from the
'housekeeping_overridden' static key.

Signed-off-by: Pierre Gondois <pierre.gondois@....com>
---
 include/linux/sched/isolation.h | 28 +++++++++++++++++++++
 kernel/sched/isolation.c        | 43 +++++++++++++++++++++++++++++++++
 2 files changed, 71 insertions(+)

diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h
index 2b461129d1fa..5d2f40c6f04c 100644
--- a/include/linux/sched/isolation.h
+++ b/include/linux/sched/isolation.h
@@ -6,6 +6,10 @@
 #include <linux/init.h>
 #include <linux/tick.h>
 
+enum hkr_type {
+	HKR_TYPE_MAX
+};
+
 enum hk_type {
 	HK_TYPE_TIMER,
 	HK_TYPE_RCU,
@@ -26,6 +30,12 @@ extern const struct cpumask *housekeeping_cpumask(enum hk_type type);
 extern bool housekeeping_enabled(enum hk_type type);
 extern void housekeeping_affine(struct task_struct *t, enum hk_type type);
 extern bool housekeeping_test_cpu(int cpu, enum hk_type type);
+
+extern const struct cpumask *housekeeping_runtime_cpumask(enum hkr_type type);
+extern bool housekeeping_runtime_test_cpu(int cpu, enum hkr_type type);
+extern void housekeeping_runtime_set_cpu(int cpu, enum hkr_type type);
+extern void housekeeping_runtime_clear_cpu(int cpu, enum hkr_type type);
+
 extern void __init housekeeping_init(void);
 
 #else
@@ -53,6 +63,24 @@ static inline bool housekeeping_test_cpu(int cpu, enum hk_type type)
 	return true;
 }
 
+static inline const struct cpumask *housekeeping_runtime_cpumask(enum hkr_type type)
+{
+	return cpu_possible_mask;
+}
+
+static inline bool housekeeping_runtime_test_cpu(int cpu, enum hkr_type type)
+{
+	return true;
+}
+
+static inline void housekeeping_runtime_set_cpu(int cpu, enum hkr_type type)
+{
+}
+
+static inline void housekeeping_runtime_clear_cpu(int cpu, enum hkr_type type)
+{
+}
+
 static inline void housekeeping_init(void) { }
 #endif /* CONFIG_CPU_ISOLATION */
 
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index 373d42c707bc..5acbed870c28 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -23,6 +23,13 @@ enum hk_flags {
 DEFINE_STATIC_KEY_FALSE(housekeeping_overridden);
 EXPORT_SYMBOL_GPL(housekeeping_overridden);
 
+struct housekeeping_runtime {
+	cpumask_var_t cpumasks[HKR_TYPE_MAX];
+	unsigned long flags;
+};
+
+static struct housekeeping_runtime housekeeping_runtime;
+
 struct housekeeping {
 	cpumask_var_t cpumasks[HK_TYPE_MAX];
 	unsigned long flags;
@@ -79,10 +86,46 @@ bool housekeeping_test_cpu(int cpu, enum hk_type type)
 }
 EXPORT_SYMBOL_GPL(housekeeping_test_cpu);
 
+const struct cpumask *housekeeping_runtime_cpumask(enum hkr_type type)
+{
+	if (housekeeping_runtime.cpumasks[type])
+		return housekeeping_runtime.cpumasks[type];
+	return cpu_possible_mask;
+}
+
+bool housekeeping_runtime_test_cpu(int cpu, enum hkr_type type)
+{
+	if (housekeeping_runtime.cpumasks[type])
+		return cpumask_test_cpu(cpu, housekeeping_runtime.cpumasks[type]);
+	return true;
+}
+
+void housekeeping_runtime_set_cpu(int cpu, enum hkr_type type)
+{
+	if (housekeeping_runtime.cpumasks[type])
+		cpumask_set_cpu(cpu, housekeeping_runtime.cpumasks[type]);
+}
+
+void housekeeping_runtime_clear_cpu(int cpu, enum hkr_type type)
+{
+	if (housekeeping_runtime.cpumasks[type])
+		cpumask_clear_cpu(cpu, housekeeping_runtime.cpumasks[type]);
+}
+
+static void __init housekeeping_runtime_init(void)
+{
+	enum hkr_type type;
+
+	for (type = 0; type < HKR_TYPE_MAX; type++)
+		alloc_cpumask_var(&housekeeping_runtime.cpumasks[type], GFP_KERNEL);
+}
+
 void __init housekeeping_init(void)
 {
 	enum hk_type type;
 
+	housekeeping_runtime_init();
+
 	if (!housekeeping.flags)
 		return;
 
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ