From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org, tglx@linutronix.de,
yury.norov@gmail.com, maddy@linux.ibm.com
Cc: sshegde@linux.ibm.com, vschneid@redhat.com,
dietmar.eggemann@arm.com, rostedt@goodmis.org,
jstultz@google.com, kprateek.nayak@amd.com,
huschle@linux.ibm.com, srikar@linux.ibm.com,
linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk
Subject: [DEBUG PATCH 5/5] powerpc: Use manual hint for cpu parking
Date: Fri, 23 May 2025 23:44:48 +0530 [thread overview]
Message-ID: <20250523181448.3777233-6-sshegde@linux.ibm.com> (raw)
In-Reply-To: <20250523181448.3777233-1-sshegde@linux.ibm.com>
Use sysfs to provide hint. Depending on the system configuration one
needs to decide the number. vp - virtual processor or vCPU.
For example, when 40 > vp_manual_hint means scheduler is supposed to use
only 0-39 vCPUs. By default, vp_manual_hint is set to all possible CPUs
and it has be at least 1.
This is for illustration only. Not meant to be merged. One can modify as
per their arch.
Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
---
arch/powerpc/kernel/smp.c | 45 +++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 5ac7084eebc0..37eb6aa71613 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -64,6 +64,7 @@
#include <asm/systemcfg.h>
#include <trace/events/ipi.h>
+#include <linux/debugfs.h>
#ifdef DEBUG
#include <asm/udbg.h>
@@ -82,6 +83,7 @@ bool has_big_cores __ro_after_init;
bool coregroup_enabled __ro_after_init;
bool thread_group_shares_l2 __ro_after_init;
bool thread_group_shares_l3 __ro_after_init;
+static int vp_manual_hint = NR_CPUS;
DEFINE_PER_CPU(cpumask_var_t, cpu_sibling_map);
DEFINE_PER_CPU(cpumask_var_t, cpu_smallcore_map);
@@ -1727,6 +1729,7 @@ static void __init build_sched_topology(void)
BUG_ON(i >= ARRAY_SIZE(powerpc_topology) - 1);
set_sched_topology(powerpc_topology);
+ vp_manual_hint = num_present_cpus();
}
void __init smp_cpus_done(unsigned int max_cpus)
@@ -1807,4 +1810,46 @@ void __noreturn arch_cpu_idle_dead(void)
start_secondary_resume();
}
+/*
+ * sysfs hint to mark CPUs as parked. This will help in restricting
+ * the workload to specified number of CPUs.
+ * For example 40 > vp_manual_hint means, workload will run on
+ * 0-39 CPUs.
+ */
+
+static int pv_vp_manual_hint_set(void *data, u64 val)
+{
+ int cpu;
+
+ if (val == 0 || vp_manual_hint > num_present_cpus())
+ vp_manual_hint = num_present_cpus();
+
+ if (val != vp_manual_hint)
+ vp_manual_hint = val;
+
+ for_each_present_cpu(cpu) {
+ if (cpu >= vp_manual_hint)
+ set_cpu_parked(cpu, true);
+ else
+ set_cpu_parked(cpu, false);
+ }
+ return 0;
+}
+
+static int pv_vp_manual_hint_get(void *data, u64 *val)
+{
+ *val = vp_manual_hint;
+ return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(fops_pv_vp_manual_hint, pv_vp_manual_hint_get, pv_vp_manual_hint_set, "%llu\n");
+
+static __init int paravirt_debugfs_init(void)
+{
+ if (is_shared_processor())
+ debugfs_create_file("vp_manual_hint", 0600, arch_debugfs_dir, NULL, &fops_pv_vp_manual_hint);
+ return 0;
+}
+
+device_initcall(paravirt_debugfs_init)
#endif
--
2.39.3
next prev parent reply other threads:[~2025-05-23 18:15 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-23 18:14 [RFC PATCH 0/5] sched: cpu parked and push current task mechanism Shrikanth Hegde
2025-05-23 18:14 ` [RFC PATCH 1/5] cpumask: Introduce cpu parked mask Shrikanth Hegde
2025-05-27 15:06 ` Yury Norov
2025-06-23 8:10 ` Shrikanth Hegde
2025-05-23 18:14 ` [RFC PATCH 2/5] sched/core: Don't use parked cpu for selection Shrikanth Hegde
2025-05-27 14:59 ` Yury Norov
2025-05-27 17:35 ` Shrikanth Hegde
2025-05-23 18:14 ` [RFC PATCH 3/5] sched/fair: Don't use parked cpu for load balancing Shrikanth Hegde
2025-05-23 18:14 ` [RFC PATCH 4/5] sched/core: Push current task when cpu is parked Shrikanth Hegde
2025-05-24 7:39 ` kernel test robot
2025-05-24 15:45 ` Shrikanth Hegde
2025-05-23 18:14 ` Shrikanth Hegde [this message]
2025-05-27 15:10 ` [RFC PATCH 0/5] sched: cpu parked and push current task mechanism Peter Zijlstra
2025-05-27 15:47 ` Yury Norov
2025-05-27 17:30 ` Shrikanth Hegde
2025-06-02 4:25 ` Shrikanth Hegde
2025-06-02 14:22 ` Tobias Huschle
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=20250523181448.3777233-6-sshegde@linux.ibm.com \
--to=sshegde@linux.ibm.com \
--cc=dietmar.eggemann@arm.com \
--cc=huschle@linux.ibm.com \
--cc=jstultz@google.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=maddy@linux.ibm.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=srikar@linux.ibm.com \
--cc=tglx@linutronix.de \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=yury.norov@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.