home | list info | list archive | date index | thread index

[OCLUG-Tech] trying to document linux startup related to multiple processors (x86)

  • Subject: [OCLUG-Tech] trying to document linux startup related to multiple processors (x86)
  • From: "Robert P. J. Day" <rpjday [ at ] crashcourse [ dot ] ca>
  • Date: Fri, 3 May 2013 06:30:22 -0400 (EDT)
  as part of an ongoing set of online docs, i want to document how
linux boots and manages multiple processors/CPUs and, holy crap, i'm
getting lost in the details -- it looked so simple early on. :-)

  i've got an old page here:

http://www.crashcourse.ca/wiki/index.php/CPUs_and_SMP

and i'm rewriting it here:

http://www.crashcourse.ca/wiki/index.php/CPUs_and_multiprocessors

but there's an increasing number of files i'm digging through just to
figure out the flow of control, so here's a simple question. during
boot, i can see this line in my "dmesg" output:

 setup_percpu: NR_CPUS:256 nr_cpumask_bits:256 nr_cpu_ids:16 nr_node_ids:1

i know that NR_CPUS is configurable and it's set to 256 in my .config
so that's not a mystery. that obviously dictates what nr_cpumask_bits
is set to, but i'm still trying to figure out where nr_cpu_ids is
being set to 16.

  way down in arch/x86/kernel/smpboot.c, i can see this code snippet
in prefill_possible_map():

... snip ...
#ifdef CONFIG_HOTPLUG_CPU
        if (!setup_max_cpus)
#endif
        if (possible > i) {
                pr_warn("%d Processors exceeds max_cpus limit of %u\n",
                        possible, setup_max_cpus);
                possible = i;
        }

        pr_info("Allowing %d CPUs, %d hotplug CPUs\n",
                possible, max_t(int, possible - num_processors, 0));

        for (i = 0; i < possible; i++)
                set_cpu_possible(i, true);
        for (; i < NR_CPUS; i++)
                set_cpu_possible(i, false);

        nr_cpu_ids = possible;
... snip ...

and in my kern.log file, i can see the line:

  smpboot: Allowing 16 CPUs, 8 hotplug CPUs

which suggests i'm being allowed 8 live CPUs (on my quad-core ASUS,
that would be correct), plus another 8 "hotplug" CPUs. but i still
don't see where the boot process decides i get 8 extras, as opposed to
any other number.

  anyone know of a decent writeup on the above? the more i dig into
this, the longer this tutorial gets. :-)

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================