public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthew Dobson <colpatch@us.ibm.com>
To: Ashok Raj <ashok.raj@intel.com>
Cc: Nathan Lynch <nathanl@austin.ibm.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Greg Kroah-Hartman <greg@kroah.com>,
	rusty@rustcorp.com.au, Patrick Mochel <mochel@digitalimplant.org>,
	Anton Blanchard <anton@samba.org>
Subject: Re: [RFC/PATCH 3/4] introduce cpu_add and cpu_remove
Date: Fri, 05 Nov 2004 15:14:18 -0800	[thread overview]
Message-ID: <1099696458.16558.14.camel@arrakis> (raw)
In-Reply-To: <20041104175755.B9271@unix-os.sc.intel.com>

On Thu, 2004-11-04 at 17:57, Ashok Raj wrote:
> On Sun, Oct 24, 2004 at 05:42:31AM -0400, Nathan Lynch wrote:
> > 
> > These functions safely update cpu_present_map (i.e. with the
> > cpucontrol semaphore held) and register or unregister the cpu device
> > as needed.  These are needed by systems which can add or remove cpus
> > from the system after boot (e.g. ppc64 and ia64), and are intended to
> > be called from the platform-specific code such as the ACPI or Open
> > Firmware layers.
> > 
> > Signed-off-by: Nathan Lynch <nathanl@austin.ibm.com>
> > 
> > 
> > ---
> > 
> > 
> > +
> > +/*
> > + * Add a cpu to the system.  Return the number of the cpu added,
> > + * or NR_CPUS if no more slots available.
> > + */
> > +unsigned int cpu_add(void)
> > +{
> > +	unsigned int cpu = NR_CPUS;
> > +
> > +	lock_cpu_hotplug();
> > +
> > +	if (num_present_cpus() == num_possible_cpus())
> > +goto out;
> > +
> > +	for_each_cpu(cpu)
> > +		if (!cpu_present(cpu))
> > +			break;
> 
>      could we simplify this by
> 
>    cpus_compliment(cpu_compliment_map, cpu_present_map);
>    cpu = first_cpu(cpu_compliment_map);

Well, since for_each_cpu() is defined like this:
#define for_each_cpu(cpu)         for_each_cpu_mask((cpu), cpu_possible_map)

We could do:
cpus_andnot(new_cpu_map, cpu_possible_map, cpu_present_map);
cpu = first_cpu(new_cpu_map);

Or maybe even:
unsigned int cpu_add(void)
{
	unsigned int cpu = NR_CPUS;

	lock_cpu_hotplug();

	if (num_present_cpus() == num_possible_cpus())
		goto out;

	cpus_andnot(new_cpu_map, cpu_possible_map, cpu_present_map);
	for_each_cpu_mask(new_cpu_map)
		if (!register_cpu(cpu)) {
			cpu_set(cpu, cpu_present_map);
			goto out;
		}

	cpu = NR_CPUS;
out:
	unlock_cpu_hotplug();
	return cpu;
}

since we want to try all possible but !present CPUs until we exhaust
them all or find one to bring online.

Simply complimenting the cpu_present_map could easily return CPUs which
aren't 'present' and aren't even 'possible' since cpu_possible_map
doesn't necessarily equal 0xFFFFFFFF (or however many FF's for your
particular platform! ;)

And FWIW, I like where you're going with this, Nathan.  I wrote a lot of
the original system topology code for sysfs, most of which is thankfully
gone now! ;)  I had hoped to clean up some of the ickier stuff, but
haven't gotten around to it.

-Matt


  reply	other threads:[~2004-11-05 23:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-24  9:42 [RFC/PATCH 0/4] cpus, nodes, and the device model: dynamic cpu registration Nathan Lynch
2004-10-24  9:42 ` [RFC/PATCH 1/4] dynamic cpu registration - core changes Nathan Lynch
2004-11-05  1:51   ` Ashok Raj
2004-11-09  3:45     ` Nathan Lynch
2004-10-24  9:42 ` [RFC/PATCH 2/4] drivers/base/node.c changes for dynamic cpu registration Nathan Lynch
2004-10-24  9:42 ` [RFC/PATCH 3/4] introduce cpu_add and cpu_remove Nathan Lynch
2004-11-05  1:57   ` Ashok Raj
2004-11-05 23:14     ` Matthew Dobson [this message]
2004-10-24  9:42 ` [RFC/PATCH 4/4] ppc64: convert to sysdev_driver Nathan Lynch
2004-10-25  6:12 ` [RFC/PATCH 0/4] cpus, nodes, and the device model: dynamic cpu registration Rusty Russell
2004-10-25 11:20   ` Nathan Lynch
2004-11-05  1:09 ` Ashok Raj
2004-11-09  3:45   ` Nathan Lynch
2004-11-05  1:54 ` Keshavamurthy Anil S

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=1099696458.16558.14.camel@arrakis \
    --to=colpatch@us.ibm.com \
    --cc=anton@samba.org \
    --cc=ashok.raj@intel.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mochel@digitalimplant.org \
    --cc=nathanl@austin.ibm.com \
    --cc=rusty@rustcorp.com.au \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox