linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] smp: Add bootcpus parameter to boot subset of CPUs
@ 2020-10-22 22:04 Elliot Berman
  2020-10-23  7:45 ` Peter Zijlstra
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Elliot Berman @ 2020-10-22 22:04 UTC (permalink / raw)
  To: Thomas Gleixner, Peter Zijlstra, Paul E. McKenney, Jonathan Corbet
  Cc: Elliot Berman, Trilok Soni, Prasad Sodagudi, linux-kernel, linux-doc

In a heterogeneous multiprocessor system, specifying the 'maxcpus'
parameter on kernel command line does not provide sufficient control
over which CPUs are brought online at kernel boot time, since CPUs may
have nonuniform performance characteristics. Thus, add bootcpus kernel
parameter to control which CPUs should be brought online during kernel
boot. When both maxcpus and bootcpus is set, the more restrictive of the
two are booted.

Signed-off-by: Elliot Berman <eberman@codeaurora.org>
---
 Documentation/admin-guide/kernel-parameters.txt |  8 +++++++
 include/linux/cpu.h                             |  2 +-
 kernel/cpu.c                                    |  4 ++--
 kernel/smp.c                                    | 28 +++++++++++++++++++++++--
 4 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 65d047f..ea31af3 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -449,6 +449,14 @@
 
 			See Documentation/admin-guide/bootconfig.rst
 
+	bootcpus=	[SMP]  List of processors that an SMP kernel
+			will bring up during bootup. Similar to maxcpus, except
+			as a cpu list as described above. The more restrictive
+			of maxcpus and bootcpus applies. If bootcpus=1-3 and
+			maxcpus=2, only processors 1 and 2 are booted. As with
+			maxcpus, you can bring up other plugged cpu by executing
+			"echo 1 > /sys/devices/system/cpu/cpuX/online"
+
 	bert_disable	[ACPI]
 			Disable BERT OS support on buggy BIOSes.
 
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 8aa84c0..4146f71 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -95,7 +95,7 @@ void notify_cpu_starting(unsigned int cpu);
 extern void cpu_maps_update_begin(void);
 extern void cpu_maps_update_done(void);
 int bringup_hibernate_cpu(unsigned int sleep_cpu);
-void bringup_nonboot_cpus(unsigned int setup_max_cpus);
+void bringup_nonboot_cpus(unsigned int setup_max_cpus, cpumask_var_t boot_cpus);
 
 #else	/* CONFIG_SMP */
 #define cpuhp_tasks_frozen	0
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 6ff2578..71f626b 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1328,14 +1328,14 @@ int bringup_hibernate_cpu(unsigned int sleep_cpu)
 	return 0;
 }
 
-void bringup_nonboot_cpus(unsigned int setup_max_cpus)
+void bringup_nonboot_cpus(unsigned int setup_max_cpus, cpumask_var_t boot_cpus)
 {
 	unsigned int cpu;
 
 	for_each_present_cpu(cpu) {
 		if (num_online_cpus() >= setup_max_cpus)
 			break;
-		if (!cpu_online(cpu))
+		if (!cpu_online(cpu) && cpumask_test_cpu(cpu, boot_cpus))
 			cpu_up(cpu, CPUHP_ONLINE);
 	}
 }
diff --git a/kernel/smp.c b/kernel/smp.c
index 4d17501..727e003 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -738,7 +738,7 @@ EXPORT_SYMBOL(smp_call_function);
 /* Setup configured maximum number of CPUs to activate */
 unsigned int setup_max_cpus = NR_CPUS;
 EXPORT_SYMBOL(setup_max_cpus);
-
+static cpumask_var_t boot_cpus;
 
 /*
  * Setup routine for controlling SMP activation
@@ -787,6 +787,27 @@ static int __init maxcpus(char *str)
 
 early_param("maxcpus", maxcpus);
 
+static int __init bootcpus(char *str)
+{
+	alloc_bootmem_cpumask_var(&boot_cpus);
+	if (cpulist_parse(str, boot_cpus) < 0) {
+		pr_warn("incorrect bootcpus mask\n");
+		return -EINVAL;
+	}
+	cpumask_set_cpu(smp_processor_id(), boot_cpus);
+	return 0;
+}
+
+early_param("bootcpus", bootcpus);
+
+static void __init boot_cpus_init(void)
+{
+	if (!cpumask_available(boot_cpus))
+		zalloc_cpumask_var(&boot_cpus, GFP_NOWAIT);
+	if (cpumask_empty(boot_cpus))
+		cpumask_setall(boot_cpus);
+}
+
 /* Setup number of possible processor ids */
 unsigned int nr_cpu_ids __read_mostly = NR_CPUS;
 EXPORT_SYMBOL(nr_cpu_ids);
@@ -804,10 +825,13 @@ void __init smp_init(void)
 
 	idle_threads_init();
 	cpuhp_threads_init();
+	boot_cpus_init();
 
 	pr_info("Bringing up secondary CPUs ...\n");
 
-	bringup_nonboot_cpus(setup_max_cpus);
+	bringup_nonboot_cpus(setup_max_cpus, boot_cpus);
+
+	free_bootmem_cpumask_var(boot_cpus);
 
 	num_nodes = num_online_nodes();
 	num_cpus  = num_online_cpus();
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH] smp: Add bootcpus parameter to boot subset of CPUs
  2020-10-22 22:04 [PATCH] smp: Add bootcpus parameter to boot subset of CPUs Elliot Berman
@ 2020-10-23  7:45 ` Peter Zijlstra
  2020-10-23 21:59 ` Thomas Gleixner
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 14+ messages in thread
From: Peter Zijlstra @ 2020-10-23  7:45 UTC (permalink / raw)
  To: Elliot Berman
  Cc: Thomas Gleixner, Paul E. McKenney, Jonathan Corbet, Trilok Soni,
	Prasad Sodagudi, linux-kernel, linux-doc

On Thu, Oct 22, 2020 at 03:04:03PM -0700, Elliot Berman wrote:
> In a heterogeneous multiprocessor system, specifying the 'maxcpus'
> parameter on kernel command line does not provide sufficient control
> over which CPUs are brought online at kernel boot time, since CPUs may
> have nonuniform performance characteristics. Thus, add bootcpus kernel
> parameter to control which CPUs should be brought online during kernel
> boot. When both maxcpus and bootcpus is set, the more restrictive of the
> two are booted.

Why would one wish to do so? Having the ability for abilities sake is no
good.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] smp: Add bootcpus parameter to boot subset of CPUs
  2020-10-22 22:04 [PATCH] smp: Add bootcpus parameter to boot subset of CPUs Elliot Berman
  2020-10-23  7:45 ` Peter Zijlstra
@ 2020-10-23 21:59 ` Thomas Gleixner
  2020-10-26 17:08   ` psodagud
  2020-10-25 13:06 ` Qais Yousef
  2020-10-28 15:55 ` Sudeep Holla
  3 siblings, 1 reply; 14+ messages in thread
From: Thomas Gleixner @ 2020-10-23 21:59 UTC (permalink / raw)
  To: Elliot Berman, Peter Zijlstra, Paul E. McKenney, Jonathan Corbet
  Cc: Elliot Berman, Trilok Soni, Prasad Sodagudi, linux-kernel, linux-doc

On Thu, Oct 22 2020 at 15:04, Elliot Berman wrote:
> In a heterogeneous multiprocessor system, specifying the 'maxcpus'
> parameter on kernel command line does not provide sufficient control
> over which CPUs are brought online at kernel boot time, since CPUs may
> have nonuniform performance characteristics. Thus, add bootcpus kernel
> parameter to control which CPUs should be brought online during kernel
> boot. When both maxcpus and bootcpus is set, the more restrictive of the
> two are booted.

What for? 'maxcpus' is a debug hack at best and outright dangerous on
certain architectures. Why do we need more of that? Just let the machine
boot and offline the CPUs from user space.

Thanks,

        tglx

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] smp: Add bootcpus parameter to boot subset of CPUs
  2020-10-22 22:04 [PATCH] smp: Add bootcpus parameter to boot subset of CPUs Elliot Berman
  2020-10-23  7:45 ` Peter Zijlstra
  2020-10-23 21:59 ` Thomas Gleixner
@ 2020-10-25 13:06 ` Qais Yousef
  2020-10-28 15:55 ` Sudeep Holla
  3 siblings, 0 replies; 14+ messages in thread
From: Qais Yousef @ 2020-10-25 13:06 UTC (permalink / raw)
  To: Elliot Berman
  Cc: Thomas Gleixner, Peter Zijlstra, Paul E. McKenney,
	Jonathan Corbet, Trilok Soni, Prasad Sodagudi, linux-kernel,
	linux-doc, Dietmar Eggemann, Lukasz Luba, Valentin Schneider

Hi Elliot

On 10/22/20 15:04, Elliot Berman wrote:
> In a heterogeneous multiprocessor system, specifying the 'maxcpus'
> parameter on kernel command line does not provide sufficient control
> over which CPUs are brought online at kernel boot time, since CPUs may
> have nonuniform performance characteristics. Thus, add bootcpus kernel

Are you seeing boot time issues on big.LITTLE systems that's why you need this
extra config? If so it'll be good to elaborate on the problem. Scheduler should
place the heavy tasks on bigs. It'll be good to understand what's failing in
here as this might not be addressing the root cause.

Thanks

--
Qais Yousef

> parameter to control which CPUs should be brought online during kernel
> boot. When both maxcpus and bootcpus is set, the more restrictive of the
> two are booted.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] smp: Add bootcpus parameter to boot subset of CPUs
  2020-10-23 21:59 ` Thomas Gleixner
@ 2020-10-26 17:08   ` psodagud
  2020-10-26 17:12     ` Peter Zijlstra
  2020-10-26 19:04     ` Thomas Gleixner
  0 siblings, 2 replies; 14+ messages in thread
From: psodagud @ 2020-10-26 17:08 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Elliot Berman, Peter Zijlstra, Paul E. McKenney, Jonathan Corbet,
	Trilok Soni, linux-kernel, linux-doc

On 2020-10-23 14:59, Thomas Gleixner wrote:
> On Thu, Oct 22 2020 at 15:04, Elliot Berman wrote:
>> In a heterogeneous multiprocessor system, specifying the 'maxcpus'
>> parameter on kernel command line does not provide sufficient control
>> over which CPUs are brought online at kernel boot time, since CPUs may
>> have nonuniform performance characteristics. Thus, add bootcpus kernel
>> parameter to control which CPUs should be brought online during kernel
>> boot. When both maxcpus and bootcpus is set, the more restrictive of 
>> the
>> two are booted.
> 
> What for? 'maxcpus' is a debug hack at best and outright dangerous on
> certain architectures. Why do we need more of that? Just let the 
> machine
> boot and offline the CPUs from user space.

Hi Thomas and Peter,

Based on my understanding with maxcpus option provides, maximum no of 
CPUs are brough up during the device boot up. There is a different case, 
in which we want to restrict which CPUs to be brough up.
On a system with 8 cpus, if we set maxcpus as 3, cpu0, cpu1, and cpu2 
are brough up during the bootup.  For example, if we want to bring 
core0, core3 and core4 current maxcpu(as 3) setting would not help us.
On some platform we want the flexibility on which CPUs to bring up 
during the device bootup. bootcpus command line is helping to bring 
specific CPUs and these patches are working downstream.

> 
> Thanks,
> 
>         tglx

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] smp: Add bootcpus parameter to boot subset of CPUs
  2020-10-26 17:08   ` psodagud
@ 2020-10-26 17:12     ` Peter Zijlstra
  2020-10-27 17:06       ` Elliot Berman
  2020-10-26 19:04     ` Thomas Gleixner
  1 sibling, 1 reply; 14+ messages in thread
From: Peter Zijlstra @ 2020-10-26 17:12 UTC (permalink / raw)
  To: psodagud
  Cc: Thomas Gleixner, Elliot Berman, Paul E. McKenney,
	Jonathan Corbet, Trilok Soni, linux-kernel, linux-doc

On Mon, Oct 26, 2020 at 10:08:47AM -0700, psodagud@codeaurora.org wrote:
> On 2020-10-23 14:59, Thomas Gleixner wrote:
> > On Thu, Oct 22 2020 at 15:04, Elliot Berman wrote:
> > > In a heterogeneous multiprocessor system, specifying the 'maxcpus'
> > > parameter on kernel command line does not provide sufficient control
> > > over which CPUs are brought online at kernel boot time, since CPUs may
> > > have nonuniform performance characteristics. Thus, add bootcpus kernel
> > > parameter to control which CPUs should be brought online during kernel
> > > boot. When both maxcpus and bootcpus is set, the more restrictive of
> > > the
> > > two are booted.
> > 
> > What for? 'maxcpus' is a debug hack at best and outright dangerous on
> > certain architectures. Why do we need more of that? Just let the machine
> > boot and offline the CPUs from user space.
> 
> Hi Thomas and Peter,
> 
> Based on my understanding with maxcpus option provides, maximum no of CPUs
> are brough up during the device boot up. There is a different case, in which
> we want to restrict which CPUs to be brough up.
> On a system with 8 cpus, if we set maxcpus as 3, cpu0, cpu1, and cpu2 are
> brough up during the bootup.  For example, if we want to bring core0, core3
> and core4 current maxcpu(as 3) setting would not help us.
> On some platform we want the flexibility on which CPUs to bring up during
> the device bootup. bootcpus command line is helping to bring specific CPUs
> and these patches are working downstream.

That's a lot of words, but exactly 0 on _WHY_ you would want to do that.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] smp: Add bootcpus parameter to boot subset of CPUs
  2020-10-26 17:08   ` psodagud
  2020-10-26 17:12     ` Peter Zijlstra
@ 2020-10-26 19:04     ` Thomas Gleixner
  1 sibling, 0 replies; 14+ messages in thread
From: Thomas Gleixner @ 2020-10-26 19:04 UTC (permalink / raw)
  To: psodagud
  Cc: Elliot Berman, Peter Zijlstra, Paul E. McKenney, Jonathan Corbet,
	Trilok Soni, linux-kernel, linux-doc

On Mon, Oct 26 2020 at 10:08, psodagud wrote:
> Based on my understanding with maxcpus option provides, maximum no of 
> CPUs are brough up during the device boot up. There is a different case, 
> in which we want to restrict which CPUs to be brough up.

Again: What for? Why?

> On a system with 8 cpus, if we set maxcpus as 3, cpu0, cpu1, and cpu2 
> are brough up during the bootup.  For example, if we want to bring 
> core0, core3 and core4 current maxcpu(as 3) setting would not help us.
> On some platform we want the flexibility on which CPUs to bring up 
> during the device bootup. bootcpus command line is helping to bring 
> specific CPUs and these patches are working downstream.

A lot of patches work downstream by some definition of work. But that
does not make an argument to bring them upstream.

Thanks,

        tglx

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] smp: Add bootcpus parameter to boot subset of CPUs
  2020-10-26 17:12     ` Peter Zijlstra
@ 2020-10-27 17:06       ` Elliot Berman
  2020-10-28 14:55         ` Qais Yousef
  0 siblings, 1 reply; 14+ messages in thread
From: Elliot Berman @ 2020-10-27 17:06 UTC (permalink / raw)
  To: Peter Zijlstra, Thomas Gleixner
  Cc: Paul E. McKenney, Jonathan Corbet, Trilok Soni, linux-kernel,
	psodagud, linux-doc, Qais Yousef


On 10/26/2020 10:12 AM, Peter Zijlstra wrote:
> On Mon, Oct 26, 2020 at 10:08:47AM -0700, psodagud@codeaurora.org wrote:
>> On 2020-10-23 14:59, Thomas Gleixner wrote:
>>> On Thu, Oct 22 2020 at 15:04, Elliot Berman wrote:
>>>> In a heterogeneous multiprocessor system, specifying the 'maxcpus'
>>>> parameter on kernel command line does not provide sufficient control
>>>> over which CPUs are brought online at kernel boot time, since CPUs may
>>>> have nonuniform performance characteristics. Thus, add bootcpus kernel
>>>> parameter to control which CPUs should be brought online during kernel
>>>> boot. When both maxcpus and bootcpus is set, the more restrictive of
>>>> the
>>>> two are booted.
>>>
>>> What for? 'maxcpus' is a debug hack at best and outright dangerous on
>>> certain architectures. Why do we need more of that? Just let the machine
>>> boot and offline the CPUs from user space.
>>
>> Hi Thomas and Peter,
>>
>> Based on my understanding with maxcpus option provides, maximum no of CPUs
>> are brough up during the device boot up. There is a different case, in which
>> we want to restrict which CPUs to be brough up.
>> On a system with 8 cpus, if we set maxcpus as 3, cpu0, cpu1, and cpu2 are
>> brough up during the bootup.  For example, if we want to bring core0, core3
>> and core4 current maxcpu(as 3) setting would not help us.
>> On some platform we want the flexibility on which CPUs to bring up during
>> the device bootup. bootcpus command line is helping to bring specific CPUs
>> and these patches are working downstream.
> 
> That's a lot of words, but exactly 0 on _WHY_ you would want to do that.
> 

We find the ability to limit the number of cpus brought online at bootup 
useful, and to possibly later enable those cores. One use case is when 
device is undergoing initial testing is to use bootcpus to limit bootup 
to only a couple cores and later bring up the other cores for a 
controlled stress test. A core brought up during boot is also running 
device initialization. Besides being useful for SoC vendor bringup which 
typically occurs downstream, this particular use case could be exercised 
by developer of upstream support for a SoC when initial CPU settings are 
being determined.

Another use case is if user wishes to limit bootup only to the smaller 
or bigger cores. maxcpus= is not sufficient here to ensure that only 
those cores are booted since it limits only to the first N cores, which 
may not be the desired small or big cores. User may want to bring up 
only the smaller cores during bootup for thermal reasons. For instance, 
device may be later sufficiently charged such that boot up of the bigger 
cores is now permissible. Relying on thermal drivers to later take care 
of putting core into lower power idle may not occur until much later in 
boot (for instance, if the governor is a module).

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] smp: Add bootcpus parameter to boot subset of CPUs
  2020-10-27 17:06       ` Elliot Berman
@ 2020-10-28 14:55         ` Qais Yousef
  2020-10-28 15:15           ` Sudeep Holla
  0 siblings, 1 reply; 14+ messages in thread
From: Qais Yousef @ 2020-10-28 14:55 UTC (permalink / raw)
  To: Elliot Berman, Sudeep Holla
  Cc: Peter Zijlstra, Thomas Gleixner, Paul E. McKenney,
	Jonathan Corbet, Trilok Soni, linux-kernel, psodagud, linux-doc

Hi Elliot

+ Sudeep

On 10/27/20 10:06, Elliot Berman wrote:
> 
> On 10/26/2020 10:12 AM, Peter Zijlstra wrote:
> > On Mon, Oct 26, 2020 at 10:08:47AM -0700, psodagud@codeaurora.org wrote:
> > > On 2020-10-23 14:59, Thomas Gleixner wrote:
> > > > On Thu, Oct 22 2020 at 15:04, Elliot Berman wrote:
> > > > > In a heterogeneous multiprocessor system, specifying the 'maxcpus'
> > > > > parameter on kernel command line does not provide sufficient control
> > > > > over which CPUs are brought online at kernel boot time, since CPUs may
> > > > > have nonuniform performance characteristics. Thus, add bootcpus kernel
> > > > > parameter to control which CPUs should be brought online during kernel
> > > > > boot. When both maxcpus and bootcpus is set, the more restrictive of
> > > > > the
> > > > > two are booted.
> > > > 
> > > > What for? 'maxcpus' is a debug hack at best and outright dangerous on
> > > > certain architectures. Why do we need more of that? Just let the machine
> > > > boot and offline the CPUs from user space.
> > > 
> > > Hi Thomas and Peter,
> > > 
> > > Based on my understanding with maxcpus option provides, maximum no of CPUs
> > > are brough up during the device boot up. There is a different case, in which
> > > we want to restrict which CPUs to be brough up.
> > > On a system with 8 cpus, if we set maxcpus as 3, cpu0, cpu1, and cpu2 are
> > > brough up during the bootup.  For example, if we want to bring core0, core3
> > > and core4 current maxcpu(as 3) setting would not help us.
> > > On some platform we want the flexibility on which CPUs to bring up during
> > > the device bootup. bootcpus command line is helping to bring specific CPUs
> > > and these patches are working downstream.
> > 
> > That's a lot of words, but exactly 0 on _WHY_ you would want to do that.
> > 
> 
> We find the ability to limit the number of cpus brought online at bootup
> useful, and to possibly later enable those cores. One use case is when
> device is undergoing initial testing is to use bootcpus to limit bootup to
> only a couple cores and later bring up the other cores for a controlled
> stress test. A core brought up during boot is also running device
> initialization. Besides being useful for SoC vendor bringup which typically
> occurs downstream, this particular use case could be exercised by developer
> of upstream support for a SoC when initial CPU settings are being
> determined.
> 
> Another use case is if user wishes to limit bootup only to the smaller or
> bigger cores. maxcpus= is not sufficient here to ensure that only those
> cores are booted since it limits only to the first N cores, which may not be
> the desired small or big cores. User may want to bring up only the smaller
> cores during bootup for thermal reasons. For instance, device may be later
> sufficiently charged such that boot up of the bigger cores is now
> permissible. Relying on thermal drivers to later take care of putting core
> into lower power idle may not occur until much later in boot (for instance,
> if the governor is a module).

I would have thought that FW/SCP would have the power to block booting up the
CPUs if it deemed that to be unsafe.

Any thoughts Sudeep?

Thanks

--
Qais Yousef

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] smp: Add bootcpus parameter to boot subset of CPUs
  2020-10-28 14:55         ` Qais Yousef
@ 2020-10-28 15:15           ` Sudeep Holla
  2020-10-29 21:37             ` Elliot Berman
  0 siblings, 1 reply; 14+ messages in thread
From: Sudeep Holla @ 2020-10-28 15:15 UTC (permalink / raw)
  To: Qais Yousef
  Cc: Elliot Berman, Peter Zijlstra, Thomas Gleixner, Paul E. McKenney,
	Jonathan Corbet, Sudeep Holla, Trilok Soni, linux-kernel,
	psodagud, linux-doc

On Wed, Oct 28, 2020 at 02:55:16PM +0000, Qais Yousef wrote:
> Hi Elliot
> 
> + Sudeep
> 
> On 10/27/20 10:06, Elliot Berman wrote:
> > 
> > On 10/26/2020 10:12 AM, Peter Zijlstra wrote:
> > > On Mon, Oct 26, 2020 at 10:08:47AM -0700, psodagud@codeaurora.org wrote:
> > > > On 2020-10-23 14:59, Thomas Gleixner wrote:
> > > > > On Thu, Oct 22 2020 at 15:04, Elliot Berman wrote:
> > > > > > In a heterogeneous multiprocessor system, specifying the 'maxcpus'
> > > > > > parameter on kernel command line does not provide sufficient control
> > > > > > over which CPUs are brought online at kernel boot time, since CPUs may
> > > > > > have nonuniform performance characteristics. Thus, add bootcpus kernel
> > > > > > parameter to control which CPUs should be brought online during kernel
> > > > > > boot. When both maxcpus and bootcpus is set, the more restrictive of
> > > > > > the
> > > > > > two are booted.
> > > > > 
> > > > > What for? 'maxcpus' is a debug hack at best and outright dangerous on
> > > > > certain architectures. Why do we need more of that? Just let the machine
> > > > > boot and offline the CPUs from user space.

Completely agreed, this is what I have suggested people in the past.

> > > >
> > > > Hi Thomas and Peter,
> > > >
> > > > Based on my understanding with maxcpus option provides, maximum no of CPUs
> > > > are brough up during the device boot up. There is a different case, in which
> > > > we want to restrict which CPUs to be brough up.
> > > > On a system with 8 cpus, if we set maxcpus as 3, cpu0, cpu1, and cpu2 are
> > > > brough up during the bootup.  For example, if we want to bring core0, core3
> > > > and core4 current maxcpu(as 3) setting would not help us.
> > > > On some platform we want the flexibility on which CPUs to bring up during
> > > > the device bootup. bootcpus command line is helping to bring specific CPUs
> > > > and these patches are working downstream.
> > >

Either offline "unwanted" CPUs from user space. If that is not possible
for whatever thermal reasons, we need to check if we can disable them in
the DT like ACPI does. IIUC, it is not supported for some reasons I need
to recall/check, can't remember that now. If that is not possible, make
those nodes disappear in the bootloader ?

> > > That's a lot of words, but exactly 0 on _WHY_ you would want to do that.
> > >
> >
> > We find the ability to limit the number of cpus brought online at bootup
> > useful, and to possibly later enable those cores. One use case is when
> > device is undergoing initial testing is to use bootcpus to limit bootup to
> > only a couple cores and later bring up the other cores for a controlled
> > stress test. A core brought up during boot is also running device
> > initialization. Besides being useful for SoC vendor bringup which typically
> > occurs downstream, this particular use case could be exercised by developer
> > of upstream support for a SoC when initial CPU settings are being
> > determined.
> >

Why not try single core instead of couple of core and add the needed ones
for the user-space ?

> > Another use case is if user wishes to limit bootup only to the smaller or
> > bigger cores. maxcpus= is not sufficient here to ensure that only those
> > cores are booted since it limits only to the first N cores, which may not be
> > the desired small or big cores. User may want to bring up only the smaller
> > cores during bootup for thermal reasons. For instance, device may be later
> > sufficiently charged such that boot up of the bigger cores is now
> > permissible. Relying on thermal drivers to later take care of putting core
> > into lower power idle may not occur until much later in boot (for instance,
> > if the governor is a module).
>
> I would have thought that FW/SCP would have the power to block booting up the
> CPUs if it deemed that to be unsafe.
>

I think it is more like *desire* to run with whatever battery life is left
rather than *unsafe* to bring up the core.

Also not sure if we can put such battery life related policies in the
firmware. If there is a thermal constraint, I am sure f/w will and must
refuse to boot the core. I doubt if we are talking about that here. It is
more a policy to extract max out of the battery life left, at-least the way
I see this issue. I may not have full context here, sorry.

-- 
Regards,
Sudeep

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] smp: Add bootcpus parameter to boot subset of CPUs
  2020-10-22 22:04 [PATCH] smp: Add bootcpus parameter to boot subset of CPUs Elliot Berman
                   ` (2 preceding siblings ...)
  2020-10-25 13:06 ` Qais Yousef
@ 2020-10-28 15:55 ` Sudeep Holla
  3 siblings, 0 replies; 14+ messages in thread
From: Sudeep Holla @ 2020-10-28 15:55 UTC (permalink / raw)
  To: Elliot Berman
  Cc: Thomas Gleixner, Peter Zijlstra, Paul E. McKenney,
	Jonathan Corbet, Trilok Soni, Prasad Sodagudi, open list,
	linux-doc, Sudeep Holla

On Fri, Oct 23, 2020 at 7:24 AM Elliot Berman <eberman@codeaurora.org> wrote:
>
> In a heterogeneous multiprocessor system, specifying the 'maxcpus'
> parameter on kernel command line does not provide sufficient control
> over which CPUs are brought online at kernel boot time, since CPUs may
> have nonuniform performance characteristics. Thus, add bootcpus kernel
> parameter to control which CPUs should be brought online during kernel
> boot. When both maxcpus and bootcpus is set, the more restrictive of the
> two are booted.
>
> Signed-off-by: Elliot Berman <eberman@codeaurora.org>
> ---
>  Documentation/admin-guide/kernel-parameters.txt |  8 +++++++
>  include/linux/cpu.h                             |  2 +-
>  kernel/cpu.c                                    |  4 ++--
>  kernel/smp.c                                    | 28 +++++++++++++++++++++++--
>  4 files changed, 37 insertions(+), 5 deletions(-)
>
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index 65d047f..ea31af3 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -449,6 +449,14 @@
>
>                         See Documentation/admin-guide/bootconfig.rst
>
> +       bootcpus=       [SMP]  List of processors that an SMP kernel
> +                       will bring up during bootup. Similar to maxcpus, except
> +                       as a cpu list as described above. The more restrictive
> +                       of maxcpus and bootcpus applies. If bootcpus=1-3 and
> +                       maxcpus=2, only processors 1 and 2 are booted. As with
> +                       maxcpus, you can bring up other plugged cpu by executing
> +                       "echo 1 > /sys/devices/system/cpu/cpuX/online"
> +

There is a fundamental assumption here that the user of this cmdline
understands how
the logical cpu numbers are allocated for the physical cpus. Based on
the discussion
I understand that you want to boot specific physical cpus for whatever
reasons and
here you want to specify the logical cpu numbers for them. So NACK for
that concept
alone irrespective of whether this concept as a whole is acceptable or not.

-- 
Regards,
Sudeep

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] smp: Add bootcpus parameter to boot subset of CPUs
  2020-10-28 15:15           ` Sudeep Holla
@ 2020-10-29 21:37             ` Elliot Berman
  2020-10-30 17:45               ` Sudeep Holla
  0 siblings, 1 reply; 14+ messages in thread
From: Elliot Berman @ 2020-10-29 21:37 UTC (permalink / raw)
  To: Sudeep Holla, Qais Yousef
  Cc: Peter Zijlstra, Thomas Gleixner, Paul E. McKenney,
	Jonathan Corbet, Trilok Soni, linux-kernel, psodagud, linux-doc

On 10/28/2020 8:15 AM, Sudeep Holla wrote:
>>>>> Hi Thomas and Peter,
>>>>>
>>>>> Based on my understanding with maxcpus option provides, maximum no of CPUs
>>>>> are brough up during the device boot up. There is a different case, in which
>>>>> we want to restrict which CPUs to be brough up.
>>>>> On a system with 8 cpus, if we set maxcpus as 3, cpu0, cpu1, and cpu2 are
>>>>> brough up during the bootup.  For example, if we want to bring core0, core3
>>>>> and core4 current maxcpu(as 3) setting would not help us.
>>>>> On some platform we want the flexibility on which CPUs to bring up during
>>>>> the device bootup. bootcpus command line is helping to bring specific CPUs
>>>>> and these patches are working downstream.
>>>>
> 
> Either offline "unwanted" CPUs from user space. If that is not possible
> for whatever thermal reasons, we need to check if we can disable them in
> the DT like ACPI does. IIUC, it is not supported for some reasons I need
> to recall/check, can't remember that now. If that is not possible, make
> those nodes disappear in the bootloader ?
> 

If I disappear the cpu nodes in bootloader, then I can't later online 
these cpus back up when policy permits. In our experience, there is a 
performance hit of ~100ms to modify any devicetree node in bootloader, 
which is significant on a commercial device wanting to disable bootup of 
certain cores for thermal.

>>>> That's a lot of words, but exactly 0 on _WHY_ you would want to do that.
>>>>
>>>
>>> We find the ability to limit the number of cpus brought online at bootup
>>> useful, and to possibly later enable those cores. One use case is when
>>> device is undergoing initial testing is to use bootcpus to limit bootup to
>>> only a couple cores and later bring up the other cores for a controlled
>>> stress test. A core brought up during boot is also running device
>>> initialization. Besides being useful for SoC vendor bringup which typically
>>> occurs downstream, this particular use case could be exercised by developer
>>> of upstream support for a SoC when initial CPU settings are being
>>> determined.
>>>
> 
> Why not try single core instead of couple of core and add the needed ones
> for the user-space ?

In some instances, we have seen that further debugging is needed from 
firmware or hardware teams. In these instances, we wanted device to 
still be able to do SMP boot, but with a few cores disabled.

In the case where commercial device is using feature for thermal, device 
should boot multiple small cores. Booting only one core means we would 
not be able to use all possible cores to maximum extent possible in this 
thermal case.

>>> Another use case is if user wishes to limit bootup only to the smaller or
>>> bigger cores. maxcpus= is not sufficient here to ensure that only those
>>> cores are booted since it limits only to the first N cores, which may not be
>>> the desired small or big cores. User may want to bring up only the smaller
>>> cores during bootup for thermal reasons. For instance, device may be later
>>> sufficiently charged such that boot up of the bigger cores is now
>>> permissible. Relying on thermal drivers to later take care of putting core
>>> into lower power idle may not occur until much later in boot (for instance,
>>> if the governor is a module).
>>
>> I would have thought that FW/SCP would have the power to block booting up the
>> CPUs if it deemed that to be unsafe.
>>
> 
> I think it is more like *desire* to run with whatever battery life is left
> rather than *unsafe* to bring up the core.
> 
> Also not sure if we can put such battery life related policies in the
> firmware. If there is a thermal constraint, I am sure f/w will and must
> refuse to boot the core. I doubt if we are talking about that here. It is
> more a policy to extract max out of the battery life left, at-least the way
> I see this issue. I may not have full context here, sorry.

This is correct, FW here does not actually prevent core from starting 
since it is not a significant enough thermal issue.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] smp: Add bootcpus parameter to boot subset of CPUs
  2020-10-29 21:37             ` Elliot Berman
@ 2020-10-30 17:45               ` Sudeep Holla
  2020-11-03 22:10                 ` Thomas Gleixner
  0 siblings, 1 reply; 14+ messages in thread
From: Sudeep Holla @ 2020-10-30 17:45 UTC (permalink / raw)
  To: Elliot Berman
  Cc: Qais Yousef, Peter Zijlstra, Thomas Gleixner, Paul E. McKenney,
	Jonathan Corbet, Sudeep Holla, Trilok Soni, linux-kernel,
	psodagud, linux-doc

On Thu, Oct 29, 2020 at 02:37:06PM -0700, Elliot Berman wrote:
> On 10/28/2020 8:15 AM, Sudeep Holla wrote:
> > > > > > Hi Thomas and Peter,
> > > > > >
> > > > > > Based on my understanding with maxcpus option provides, maximum no of CPUs
> > > > > > are brough up during the device boot up. There is a different case, in which
> > > > > > we want to restrict which CPUs to be brough up.
> > > > > > On a system with 8 cpus, if we set maxcpus as 3, cpu0, cpu1, and cpu2 are
> > > > > > brough up during the bootup.  For example, if we want to bring core0, core3
> > > > > > and core4 current maxcpu(as 3) setting would not help us.
> > > > > > On some platform we want the flexibility on which CPUs to bring up during
> > > > > > the device bootup. bootcpus command line is helping to bring specific CPUs
> > > > > > and these patches are working downstream.
> > > > >
> >
> > Either offline "unwanted" CPUs from user space. If that is not possible
> > for whatever thermal reasons, we need to check if we can disable them in
> > the DT like ACPI does. IIUC, it is not supported for some reasons I need
> > to recall/check, can't remember that now. If that is not possible, make
> > those nodes disappear in the bootloader ?
> >
>
> If I disappear the cpu nodes in bootloader, then I can't later online these
> cpus back up when policy permits.

No I meant, to have policy in bootloader and manage device nodes based on
what you need in that boot.

> In our experience, there is a performance hit of ~100ms to modify any
> devicetree node in bootloader, which is significant on a commercial
> device wanting to disable bootup of certain cores for thermal.
>

I bet that performance hit is nowhere close to what you may have when you
offline a bunch of big cores, so I dismiss that, sorry.

> > > > > That's a lot of words, but exactly 0 on _WHY_ you would want to do that.
> > > > >
> > > >
> > > > We find the ability to limit the number of cpus brought online at bootup
> > > > useful, and to possibly later enable those cores. One use case is when
> > > > device is undergoing initial testing is to use bootcpus to limit bootup to
> > > > only a couple cores and later bring up the other cores for a controlled
> > > > stress test. A core brought up during boot is also running device
> > > > initialization. Besides being useful for SoC vendor bringup which typically
> > > > occurs downstream, this particular use case could be exercised by developer
> > > > of upstream support for a SoC when initial CPU settings are being
> > > > determined.
> > > >
> >
> > Why not try single core instead of couple of core and add the needed ones
> > for the user-space ?
>
> In some instances, we have seen that further debugging is needed from
> firmware or hardware teams. In these instances, we wanted device to still be
> able to do SMP boot, but with a few cores disabled.
>

Still manageable with different configuration in the bootloader.

> In the case where commercial device is using feature for thermal, device
> should boot multiple small cores. Booting only one core means we would not
> be able to use all possible cores to maximum extent possible in this thermal
> case.
>


I understood that point. But you haven't responded on my logical vs physical
number argument. I am clearly NACKing this patch as is for just usage of
logical CPU IDs in the command line while your intention is to control
the physical CPUs. So once again, NACK for that reason.

> > > > Another use case is if user wishes to limit bootup only to the smaller or
> > > > bigger cores. maxcpus= is not sufficient here to ensure that only those
> > > > cores are booted since it limits only to the first N cores, which may not be
> > > > the desired small or big cores. User may want to bring up only the smaller
> > > > cores during bootup for thermal reasons. For instance, device may be later
> > > > sufficiently charged such that boot up of the bigger cores is now
> > > > permissible. Relying on thermal drivers to later take care of putting core
> > > > into lower power idle may not occur until much later in boot (for instance,
> > > > if the governor is a module).
> > >
> > > I would have thought that FW/SCP would have the power to block booting up the
> > > CPUs if it deemed that to be unsafe.
> > >
> >
> > I think it is more like *desire* to run with whatever battery life is left
> > rather than *unsafe* to bring up the core.
> >
> > Also not sure if we can put such battery life related policies in the
> > firmware. If there is a thermal constraint, I am sure f/w will and must
> > refuse to boot the core. I doubt if we are talking about that here. It is
> > more a policy to extract max out of the battery life left, at-least the way
> > I see this issue. I may not have full context here, sorry.
>
> This is correct, FW here does not actually prevent core from starting since
> it is not a significant enough thermal issue.

Thanks for confirming.

--
Regards,
Sudeep

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] smp: Add bootcpus parameter to boot subset of CPUs
  2020-10-30 17:45               ` Sudeep Holla
@ 2020-11-03 22:10                 ` Thomas Gleixner
  0 siblings, 0 replies; 14+ messages in thread
From: Thomas Gleixner @ 2020-11-03 22:10 UTC (permalink / raw)
  To: Sudeep Holla, Elliot Berman
  Cc: Qais Yousef, Peter Zijlstra, Paul E. McKenney, Jonathan Corbet,
	Sudeep Holla, Trilok Soni, linux-kernel, psodagud, linux-doc

On Fri, Oct 30 2020 at 17:45, Sudeep Holla wrote:
> On Thu, Oct 29, 2020 at 02:37:06PM -0700, Elliot Berman wrote:
>> In the case where commercial device is using feature for thermal, device
>> should boot multiple small cores. Booting only one core means we would not
>> be able to use all possible cores to maximum extent possible in this thermal
>> case.
>
> I understood that point. But you haven't responded on my logical vs physical
> number argument. I am clearly NACKing this patch as is for just usage of
> logical CPU IDs in the command line while your intention is to control
> the physical CPUs. So once again, NACK for that reason.

Correct. And no, we are not going to add a command line option to select
physical CPU ids.

There are two ways to solve that:

  1) The firmware can tell the kernel whether a CPU should be brought up
     or not, e.g. by failing the bootup request.

  2) The kernel has a way to figure out the current thermal and/or power
     budget early in the boot process and sorts out which and how many
     CPUs fit into that limit.

Thanks,

        tglx


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-11-03 22:10 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-22 22:04 [PATCH] smp: Add bootcpus parameter to boot subset of CPUs Elliot Berman
2020-10-23  7:45 ` Peter Zijlstra
2020-10-23 21:59 ` Thomas Gleixner
2020-10-26 17:08   ` psodagud
2020-10-26 17:12     ` Peter Zijlstra
2020-10-27 17:06       ` Elliot Berman
2020-10-28 14:55         ` Qais Yousef
2020-10-28 15:15           ` Sudeep Holla
2020-10-29 21:37             ` Elliot Berman
2020-10-30 17:45               ` Sudeep Holla
2020-11-03 22:10                 ` Thomas Gleixner
2020-10-26 19:04     ` Thomas Gleixner
2020-10-25 13:06 ` Qais Yousef
2020-10-28 15:55 ` Sudeep Holla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).