Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/boot: Further compress CPUs bootup message

Turn it into (for example):

[ 0.073380] x86: Booting SMP configuration:
[ 0.074005] .... node #0, CPUs: #1 #2 #3 #4 #5 #6 #7
[ 0.603005] .... node #1, CPUs: #8 #9 #10 #11 #12 #13 #14 #15
[ 1.200005] .... node #2, CPUs: #16 #17 #18 #19 #20 #21 #22 #23
[ 1.796005] .... node #3, CPUs: #24 #25 #26 #27 #28 #29 #30 #31
[ 2.393005] .... node #4, CPUs: #32 #33 #34 #35 #36 #37 #38 #39
[ 2.996005] .... node #5, CPUs: #40 #41 #42 #43 #44 #45 #46 #47
[ 3.600005] .... node #6, CPUs: #48 #49 #50 #51 #52 #53 #54 #55
[ 4.202005] .... node #7, CPUs: #56 #57 #58 #59 #60 #61 #62 #63
[ 4.811005] .... node #8, CPUs: #64 #65 #66 #67 #68 #69 #70 #71
[ 5.421006] .... node #9, CPUs: #72 #73 #74 #75 #76 #77 #78 #79
[ 6.032005] .... node #10, CPUs: #80 #81 #82 #83 #84 #85 #86 #87
[ 6.648006] .... node #11, CPUs: #88 #89 #90 #91 #92 #93 #94 #95
[ 7.262005] .... node #12, CPUs: #96 #97 #98 #99 #100 #101 #102 #103
[ 7.865005] .... node #13, CPUs: #104 #105 #106 #107 #108 #109 #110 #111
[ 8.466005] .... node #14, CPUs: #112 #113 #114 #115 #116 #117 #118 #119
[ 9.073006] .... node #15, CPUs: #120 #121 #122 #123 #124 #125 #126 #127
[ 9.679901] x86: Booted up 16 nodes, 128 CPUs

and drop useless elements.

Change num_digits() to hpa's division-avoiding, cell-phone-typed
version which he went at great lengths and pains to submit on a
Saturday evening.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: huawei.libin@huawei.com
Cc: wangyijing@huawei.com
Cc: fenghua.yu@intel.com
Cc: guohanjun@huawei.com
Cc: paul.gortmaker@windriver.com
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20130930095624.GB16383@pd.tnic
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Borislav Petkov and committed by
Ingo Molnar
a17bce4d 646e29a1

+40 -11
+19 -5
arch/x86/kernel/smpboot.c
··· 647 647 return (send_status | accept_status); 648 648 } 649 649 650 + void smp_announce(void) 651 + { 652 + int num_nodes = num_online_nodes(); 653 + 654 + printk(KERN_INFO "x86: Booted up %d node%s, %d CPUs\n", 655 + num_nodes, (num_nodes > 1 ? "s" : ""), num_online_cpus()); 656 + } 657 + 650 658 /* reduce the number of lines printed when booting a large cpu count system */ 651 659 static void announce_cpu(int cpu, int apicid) 652 660 { 653 661 static int current_node = -1; 654 662 int node = early_cpu_to_node(cpu); 655 - static int width; 663 + static int width, node_width; 656 664 657 665 if (!width) 658 666 width = num_digits(num_possible_cpus()) + 1; /* + '#' sign */ 659 667 668 + if (!node_width) 669 + node_width = num_digits(num_possible_nodes()) + 1; /* + '#' */ 670 + 671 + if (cpu == 1) 672 + printk(KERN_INFO "x86: Booting SMP configuration:\n"); 673 + 660 674 if (system_state == SYSTEM_BOOTING) { 661 675 if (node != current_node) { 662 676 if (current_node > (-1)) 663 - pr_cont(" OK\n"); 677 + pr_cont("\n"); 664 678 current_node = node; 665 - pr_info("Booting Node %3d, Processors:", node); 679 + 680 + printk(KERN_INFO ".... node %*s#%d, CPUs: ", 681 + node_width - num_digits(node), " ", node); 666 682 } 667 683 668 684 /* Add padding for the BSP */ ··· 687 671 688 672 pr_cont("%*s#%d", width - num_digits(cpu), " ", cpu); 689 673 690 - if (cpu == num_present_cpus() - 1) 691 - pr_cont(" OK\n"); 692 674 } else 693 675 pr_info("Booting Node %d Processor %d APIC 0x%x\n", 694 676 node, cpu, apicid);
+15 -5
arch/x86/lib/misc.c
··· 1 + /* 2 + * Count the digits of @val including a possible sign. 3 + * 4 + * (Typed on and submitted from hpa's mobile phone.) 5 + */ 1 6 int num_digits(int val) 2 7 { 3 - int digits = 0; 8 + int m = 10; 9 + int d = 1; 4 10 5 - while (val) { 6 - val /= 10; 7 - digits++; 11 + if (val < 0) { 12 + d++; 13 + val = -val; 8 14 } 9 15 10 - return digits; 16 + while (val >= m) { 17 + m *= 10; 18 + d++; 19 + } 20 + return d; 11 21 }
+6 -1
kernel/smp.c
··· 524 524 nr_cpu_ids = find_last_bit(cpumask_bits(cpu_possible_mask),NR_CPUS) + 1; 525 525 } 526 526 527 + void __weak smp_announce(void) 528 + { 529 + printk(KERN_INFO "Brought up %d CPUs\n", num_online_cpus()); 530 + } 531 + 527 532 /* Called by boot processor to activate the rest. */ 528 533 void __init smp_init(void) 529 534 { ··· 545 540 } 546 541 547 542 /* Any cleanup work */ 548 - printk(KERN_INFO "Brought up %ld CPUs\n", (long)num_online_cpus()); 543 + smp_announce(); 549 544 smp_cpus_done(setup_max_cpus); 550 545 } 551 546