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

Russell King (Oracle) linux at armlinux.org.uk
Tue Oct 24 09:05:40 PDT 2023


On Tue, Oct 24, 2023 at 06:02:30PM +0200, Greg Kroah-Hartman wrote:
> On Tue, Oct 24, 2023 at 04:19:24PM +0100, Russell King wrote:
> > 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>
> > ---
> >  drivers/base/cpu.c      | 10 ++++++++++
> >  include/linux/cpumask.h | 25 +++++++++++++++++++++++++
> >  kernel/cpu.c            |  3 +++
> >  3 files changed, 38 insertions(+)
> > 
> > diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
> > index 2b9cb2667654..f8bf1d4c7d71 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);
> >  	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);
> 
> This needs to be documented somewhere in Documentation/ABI/ did I miss
> that patch?

Thanks for pointing that out, no you missed the patch as nothing
touches Documentation/ABI/ in this patch series. I'll add some blurb
for it for the next iteration.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!



More information about the linux-riscv mailing list