Re: [PATCH 3/4] cpumask: use maxcpus=NUM to extend the cpu limit as well as restrict the limit

From: Rusty Russell
Date: Fri Dec 12 2008 - 06:41:52 EST


On Thursday 11 December 2008 21:58:09 Mike Travis wrote:
> Impact: allow adding additional cpus.
>
> Use maxcpus=NUM kernel parameter to extend the number of possible cpus as well
> as (currently) limit them. Any cpus >= number of present cpus will disabled.
...

These two bits of logic are very similar: can we merge them?

> - possible = num_processors + disabled_cpus;
> - if (possible > NR_CPUS)
> - possible = NR_CPUS;
> + if (setup_max_cpus == -1) /* not specified */
> + possible = num_processors + disabled_cpus;
> + else if (setup_max_cpus == 0) /* UP mode forced */
> + possible = 1;
> + else /* user specified */
> + possible = setup_max_cpus;
> +
> + if (possible > CONFIG_NR_CPUS) {
> + printk(KERN_WARNING
> + "%d Processors exceeds NR_CPUS limit of %d\n",
> + possible, CONFIG_NR_CPUS);
> + possible = CONFIG_NR_CPUS;
> + }
...
> -extern unsigned int setup_max_cpus;
> +extern int setup_max_cpus;
> +static inline int maxcpus(void)
> +{
> + int maxcpus = setup_max_cpus;
> +
> + if (maxcpus == -1 || maxcpus > CONFIG_NR_CPUS)
> + maxcpus = CONFIG_NR_CPUS;
> + else if (maxcpus == 0)
> + maxcpus = 1;
> +
> + return maxcpus;
> +}

If this didn't trunacte to CONFIG_NR_CPUS, it could still be used here:

> @@ -425,7 +423,7 @@ static void __init smp_init(void)
>
> /* FIXME: This should be done in userspace --RR */
> for_each_present_cpu(cpu) {
> - if (num_online_cpus() >= setup_max_cpus)
> + if (num_online_cpus() >= maxcpus())
> break;
> if (!cpu_online(cpu))
> cpu_up(cpu);

And it turns out noone actually uses the smp_cpus_done() arg, so
I don't know what the semantics are supposed to be.

> @@ -433,7 +431,7 @@ static void __init smp_init(void)
>
> /* Any cleanup work */
> printk(KERN_INFO "Brought up %ld CPUs\n", (long)num_online_cpus());
> - smp_cpus_done(setup_max_cpus);
> + smp_cpus_done(maxcpus());

Cheers,
Rusty.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/