[PATCH v6 16/16] cpumask: Add enabled cpumask for present CPUs that can be brought online

Salil Mehta salil.mehta at huawei.com
Wed Apr 17 10:01:17 PDT 2024


>  From: Jonathan Cameron <jonathan.cameron at huawei.com>
>  Sent: Wednesday, April 17, 2024 2:19 PM
>  
>  From: James Morse <james.morse at arm.com>
>  
>  The 'offline' file in sysfs shows all offline CPUs, including those that aren't
>  present. User-space is expected to remove not-present CPUs from this list
>  to learn which CPUs could be brought online.
>  
>  CPUs can be present but not-enabled. These CPUs can't be brought online
>  until the firmware policy changes, which comes with an ACPI notification
>  that will register the CPUs.
>  
>  With only the offline and present files, user-space is unable to determine
>  which CPUs it can try to bring online. Add a new CPU mask that shows this
>  based on all the registered CPUs.
>  
>  Signed-off-by: James Morse <james.morse at arm.com>
>  Tested-by: Miguel Luis <miguel.luis at oracle.com>
>  Tested-by: Vishnu Pajjuri <vishnu at os.amperecomputing.com>
>  Tested-by: Jianyong Wu <jianyong.wu at arm.com>
>  Acked-by: Thomas Gleixner <tglx at linutronix.de>
>  Signed-off-by: Russell King (Oracle) <rmk+kernel at armlinux.org.uk>
>  Signed-off-by: Jonathan Cameron <Jonathan.Cameron at huawei.com>
>  
>  ---
>  v5: No change
>  ---
>   .../ABI/testing/sysfs-devices-system-cpu      |  6 +++++
>   drivers/base/cpu.c                            | 10 ++++++++
>   include/linux/cpumask.h                       | 25 +++++++++++++++++++
>   kernel/cpu.c                                  |  3 +++
>   4 files changed, 44 insertions(+)
>  

[...]


>  diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index
>  b9d0d14e5960..4713b86d20f2 100644
>  --- a/drivers/base/cpu.c
>  +++ b/drivers/base/cpu.c
>  @@ -95,6 +95,7 @@ void unregister_cpu(struct cpu *cpu)  {
>   	int logical_cpu = cpu->dev.id;
>  
>  +	set_cpu_enabled(logical_cpu, false);


sorry, It is being done here in context to (un)register)cpu().


>   	unregister_cpu_under_node(logical_cpu,
>  cpu_to_node(logical_cpu));
>  
>   	device_unregister(&cpu->dev);
>  @@ -273,6 +274,13 @@ static ssize_t print_cpus_offline(struct device *dev,
>  }  static DEVICE_ATTR(offline, 0444, print_cpus_offline, NULL);
>  
>  +static ssize_t print_cpus_enabled(struct device *dev,
>  +				  struct device_attribute *attr, char *buf) {
>  +	return sysfs_emit(buf, "%*pbl\n",
>  cpumask_pr_args(cpu_enabled_mask));
>  +}
>  +static DEVICE_ATTR(enabled, 0444, print_cpus_enabled, NULL);
>  +
>   static ssize_t print_cpus_isolated(struct device *dev,
>   				  struct device_attribute *attr, char *buf)  {
>  @@ -413,6 +421,7 @@ int register_cpu(struct cpu *cpu, int num)
>   	register_cpu_under_node(num, cpu_to_node(num));
>   	dev_pm_qos_expose_latency_limit(&cpu->dev,
>  
>  	PM_QOS_RESUME_LATENCY_NO_CONSTRAINT);
>  +	set_cpu_enabled(num, true);


and here.

Thanks
Salil.





More information about the linux-arm-kernel mailing list