Skip to content

Commit

Permalink
Merge branch 'x86-boot-for-linus' of git://git.kernel.org/pub/scm/lin…
Browse files Browse the repository at this point in the history
…ux/kernel/git/tip/tip

Pull x86 boot changes from Ingo Molnar:
 "Two changes that prettify and compactify the SMP bootup output from:

     smpboot: Booting Node   0, Processors  #1 #2 #3 OK
     smpboot: Booting Node   1, Processors  #4 #5 #6 #7 OK
     smpboot: Booting Node   2, Processors  #8 #9 #10 #11 OK
     smpboot: Booting Node   3, Processors  #12 #13 #14 #15 OK
     Brought up 16 CPUs

  to something like:

     x86: Booting SMP configuration:
     .... node  #0, CPUs:        #1  #2  #3
     .... node  #1, CPUs:    #4  #5  #6  #7
     .... node  #2, CPUs:    #8  #9 #10 #11
     .... node  #3, CPUs:   #12 #13 #14 #15
     x86: Booted up 4 nodes, 16 CPUs"

* 'x86-boot-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/boot: Further compress CPUs bootup message
  x86: Improve the printout of the SMP bootup CPU table
  • Loading branch information
torvalds committed Nov 12, 2013
2 parents ae795fe + a17bce4 commit 014d595
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 9 deletions.
6 changes: 6 additions & 0 deletions arch/x86/include/asm/misc.h
@@ -0,0 +1,6 @@
#ifndef _ASM_X86_MISC_H
#define _ASM_X86_MISC_H

int num_digits(int val);

#endif /* _ASM_X86_MISC_H */
37 changes: 30 additions & 7 deletions arch/x86/kernel/smpboot.c
Expand Up @@ -73,11 +73,10 @@
#include <asm/setup.h>
#include <asm/uv/uv.h>
#include <linux/mc146818rtc.h>

#include <asm/smpboot_hooks.h>
#include <asm/i8259.h>

#include <asm/realmode.h>
#include <asm/misc.h>

/* State of each CPU */
DEFINE_PER_CPU(int, cpu_state) = { 0 };
Expand Down Expand Up @@ -648,22 +647,46 @@ wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip)
return (send_status | accept_status);
}

void smp_announce(void)
{
int num_nodes = num_online_nodes();

printk(KERN_INFO "x86: Booted up %d node%s, %d CPUs\n",
num_nodes, (num_nodes > 1 ? "s" : ""), num_online_cpus());
}

/* reduce the number of lines printed when booting a large cpu count system */
static void announce_cpu(int cpu, int apicid)
{
static int current_node = -1;
int node = early_cpu_to_node(cpu);
int max_cpu_present = find_last_bit(cpumask_bits(cpu_present_mask), NR_CPUS);
static int width, node_width;

if (!width)
width = num_digits(num_possible_cpus()) + 1; /* + '#' sign */

if (!node_width)
node_width = num_digits(num_possible_nodes()) + 1; /* + '#' */

if (cpu == 1)
printk(KERN_INFO "x86: Booting SMP configuration:\n");

if (system_state == SYSTEM_BOOTING) {
if (node != current_node) {
if (current_node > (-1))
pr_cont(" OK\n");
pr_cont("\n");
current_node = node;
pr_info("Booting Node %3d, Processors ", node);

printk(KERN_INFO ".... node %*s#%d, CPUs: ",
node_width - num_digits(node), " ", node);
}
pr_cont(" #%4d%s", cpu, cpu == max_cpu_present ? " OK\n" : "");
return;

/* Add padding for the BSP */
if (cpu == 1)
pr_cont("%*s", width + 1, " ");

pr_cont("%*s#%d", width - num_digits(cpu), " ", cpu);

} else
pr_info("Booting Node %d Processor %d APIC 0x%x\n",
node, cpu, apicid);
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/lib/Makefile
Expand Up @@ -16,7 +16,7 @@ clean-files := inat-tables.c

obj-$(CONFIG_SMP) += msr-smp.o cache-smp.o

lib-y := delay.o
lib-y := delay.o misc.o
lib-y += thunk_$(BITS).o
lib-y += usercopy_$(BITS).o usercopy.o getuser.o putuser.o
lib-y += memcpy_$(BITS).o
Expand Down
21 changes: 21 additions & 0 deletions arch/x86/lib/misc.c
@@ -0,0 +1,21 @@
/*
* Count the digits of @val including a possible sign.
*
* (Typed on and submitted from hpa's mobile phone.)
*/
int num_digits(int val)
{
int m = 10;
int d = 1;

if (val < 0) {
d++;
val = -val;
}

while (val >= m) {
m *= 10;
d++;
}
return d;
}
7 changes: 6 additions & 1 deletion kernel/smp.c
Expand Up @@ -524,6 +524,11 @@ void __init setup_nr_cpu_ids(void)
nr_cpu_ids = find_last_bit(cpumask_bits(cpu_possible_mask),NR_CPUS) + 1;
}

void __weak smp_announce(void)
{
printk(KERN_INFO "Brought up %d CPUs\n", num_online_cpus());
}

/* Called by boot processor to activate the rest. */
void __init smp_init(void)
{
Expand All @@ -540,7 +545,7 @@ void __init smp_init(void)
}

/* Any cleanup work */
printk(KERN_INFO "Brought up %ld CPUs\n", (long)num_online_cpus());
smp_announce();
smp_cpus_done(setup_max_cpus);
}

Expand Down

0 comments on commit 014d595

Please sign in to comment.