Re: [PATCH] x86: Limit the number of processor bootup messages

From: Xiaotian Feng
Date: Tue Jan 19 2010 - 00:07:34 EST


Could we consider such cases that system doesn't have a large number
of processors? This commit makes my system bootup message ugly ....

CPU0: Intel(R) Core(TM)2 Quad CPU Q9400 @ 2.66GHz stepping 0a
lockdep: fixing up alternatives.
Booting Node 0, Processors #1lockdep: fixing up alternatives.
#2lockdep: fixing up alternatives.
#3
Brought up 4 CPUs
Total of 4 processors activated (21278.36 BogoMIPS).

So if num_present_cpus < nr_cpu_ids, the output will never print OK.....
And the output is also twisted with lockdep prints...

On Fri, Dec 11, 2009 at 9:19 AM, Mike Travis <travis@xxxxxxx> wrote:
> x86: Limit the number of processor bootup messages
>
> When there are a large number of processors in a system, there
> is an excessive amount of messages sent to the system console.
> It's estimated that with 4096 processors in a system, and the
> console baudrate set to 56K, the startup messages will take
> about 84 minutes to clear the serial port.
>
> This set of patches limits the number of repetitious messages
> which contain no additional information. ÂMuch of this information
> is obtainable from the /proc and /sysfs. Â Some of the messages
> are also sent to the kernel log buffer as KERN_DEBUG messages so
> dmesg can be used to examine more closely any details specific to
> a problem.
>
> The new cpu bootup sequence for system_state == SYSTEM_BOOTING:
>
> Booting Node  0, Processors Â#1 #2 #3 #4 #5 #6 #7 Ok.
> Booting Node  1, Processors Â#8 #9 #10 #11 #12 #13 #14 #15 Ok.
> ...
> Booting Node  3, Processors Â#56 #57 #58 #59 #60 #61 #62 #63 Ok.
> Brought up 64 CPUs
>
> After the system is running, a single line boot message is displayed
> when CPU's are hotplugged on:
>
> Â Booting Node %d Processor %d APIC 0x%x
>
>
> Status of the following lines:
>
> Â CPU: Physical Processor ID: Â Â Â Â Âprinted once (for boot cpu)
> Â CPU: Processor Core ID: Â Â Â Â Â Â Âprinted once (for boot cpu)
>  CPU: Hyper-Threading is disabled   printed once (for boot cpu)
>  CPU: Thermal monitoring enabled   Âprinted once (for boot cpu)
> Â CPU %d/0x%x -> Node %d: Â Â Â Â Â Â Âremoved
> Â CPU %d is now offline: Â Â Â Â Â Â Â only if system_state == RUNNING
> Â Initializing CPU#%d: Â Â Â Â KERN_DEBUG
>
> Signed-off-by: Mike Travis <travis@xxxxxxx>
> ---
> arch/x86/kernel/cpu/addon_cpuid_features.c | Â 15 +++++----
> arch/x86/kernel/cpu/amd.c         Â|  Â2 -
> arch/x86/kernel/cpu/common.c        |  Â8 +++--
> arch/x86/kernel/cpu/intel.c        Â|  Â2 -
> arch/x86/kernel/cpu/mcheck/therm_throt.c  |  Â4 +-
> arch/x86/kernel/smpboot.c         Â|  45
> +++++++++++++++++++----------
> 6 files changed, 47 insertions(+), 29 deletions(-)
>
> --- linux.orig/arch/x86/kernel/cpu/addon_cpuid_features.c
> +++ linux/arch/x86/kernel/cpu/addon_cpuid_features.c
> @@ -74,6 +74,7 @@
> Â Â Â Âunsigned int eax, ebx, ecx, edx, sub_index;
> Â Â Â Âunsigned int ht_mask_width, core_plus_mask_width;
> Â Â Â Âunsigned int core_select_mask, core_level_siblings;
> + Â Â Â static bool printed;
>
> Â Â Â Âif (c->cpuid_level < 0xb)
> Â Â Â Â Â Â Â Âreturn;
> @@ -127,12 +128,14 @@
>
> Â Â Â Âc->x86_max_cores = (core_level_siblings / smp_num_siblings);
>
> -
> - Â Â Â printk(KERN_INFO Â"CPU: Physical Processor ID: %d\n",
> - Â Â Â Â Â Â Âc->phys_proc_id);
> - Â Â Â if (c->x86_max_cores > 1)
> - Â Â Â Â Â Â Â printk(KERN_INFO Â"CPU: Processor Core ID: %d\n",
> - Â Â Â Â Â Â Â Â Â Â Âc->cpu_core_id);
> + Â Â Â if (!printed) {
> + Â Â Â Â Â Â Â printk(KERN_INFO Â"CPU: Physical Processor ID: %d\n",
> + Â Â Â Â Â Â Â Â Â Â Âc->phys_proc_id);
> + Â Â Â Â Â Â Â if (c->x86_max_cores > 1)
> + Â Â Â Â Â Â Â Â Â Â Â printk(KERN_INFO Â"CPU: Processor Core ID: %d\n",
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âc->cpu_core_id);
> + Â Â Â Â Â Â Â printed = 1;
> + Â Â Â }
> Â Â Â Âreturn;
> #endif
> }
> --- linux.orig/arch/x86/kernel/cpu/amd.c
> +++ linux/arch/x86/kernel/cpu/amd.c
> @@ -375,8 +375,6 @@
> Â Â Â Â Â Â Â Â Â Â Â Ânode = nearby_node(apicid);
> Â Â Â Â}
> Â Â Â Ânuma_set_node(cpu, node);
> -
> - Â Â Â printk(KERN_INFO "CPU %d/0x%x -> Node %d\n", cpu, apicid, node);
> #endif
> }
>
> --- linux.orig/arch/x86/kernel/cpu/common.c
> +++ linux/arch/x86/kernel/cpu/common.c
> @@ -427,6 +427,7 @@
> #ifdef CONFIG_X86_HT
> Â Â Â Âu32 eax, ebx, ecx, edx;
> Â Â Â Âint index_msb, core_bits;
> + Â Â Â static bool printed;
>
> Â Â Â Âif (!cpu_has(c, X86_FEATURE_HT))
> Â Â Â Â Â Â Â Âreturn;
> @@ -442,7 +443,7 @@
> Â Â Â Âsmp_num_siblings = (ebx & 0xff0000) >> 16;
>
> Â Â Â Âif (smp_num_siblings == 1) {
> - Â Â Â Â Â Â Â printk(KERN_INFO Â"CPU: Hyper-Threading is disabled\n");
> + Â Â Â Â Â Â Â printk_once(KERN_INFO "CPU0: Hyper-Threading is
> disabled\n");
> Â Â Â Â Â Â Â Âgoto out;
> Â Â Â Â}
>
> @@ -469,11 +470,12 @@
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ((1 << core_bits) - 1);
>
> out:
> - Â Â Â if ((c->x86_max_cores * smp_num_siblings) > 1) {
> + Â Â Â if (!printed && (c->x86_max_cores * smp_num_siblings) > 1) {
> Â Â Â Â Â Â Â Âprintk(KERN_INFO Â"CPU: Physical Processor ID: %d\n",
> Â Â Â Â Â Â Â Â Â Â Â c->phys_proc_id);
> Â Â Â Â Â Â Â Âprintk(KERN_INFO Â"CPU: Processor Core ID: %d\n",
> Â Â Â Â Â Â Â Â Â Â Â c->cpu_core_id);
> + Â Â Â Â Â Â Â printed = 1;
> Â Â Â Â}
> #endif
> }
> @@ -1115,7 +1117,7 @@
> Â Â Â Âif (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask))
> Â Â Â Â Â Â Â Âpanic("CPU#%d already initialized!\n", cpu);
>
> - Â Â Â printk(KERN_INFO "Initializing CPU#%d\n", cpu);
> + Â Â Â pr_debug("Initializing CPU#%d\n", cpu);
>
> Â Â Â Âclear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE);
>
> --- linux.orig/arch/x86/kernel/cpu/intel.c
> +++ linux/arch/x86/kernel/cpu/intel.c
> @@ -266,8 +266,6 @@
> Â Â Â Âif (node == NUMA_NO_NODE || !node_online(node))
> Â Â Â Â Â Â Â Ânode = first_node(node_online_map);
> Â Â Â Ânuma_set_node(cpu, node);
> -
> - Â Â Â printk(KERN_INFO "CPU %d/0x%x -> Node %d\n", cpu, apicid, node);
> #endif
> }
>
> --- linux.orig/arch/x86/kernel/cpu/mcheck/therm_throt.c
> +++ linux/arch/x86/kernel/cpu/mcheck/therm_throt.c
> @@ -339,8 +339,8 @@
> Â Â Â Âl = apic_read(APIC_LVTTHMR);
> Â Â Â Âapic_write(APIC_LVTTHMR, l & ~APIC_LVT_MASKED);
>
> - Â Â Â printk(KERN_INFO "CPU%d: Thermal monitoring enabled (%s)\n",
> - Â Â Â Â Â Â Âcpu, tm2 ? "TM2" : "TM1");
> + Â Â Â printk_once(KERN_INFO "CPU0: Thermal monitoring enabled (%s)\n",
> + Â Â Â Â Â Â Â Â Â Â Âtm2 ? "TM2" : "TM1");
>
> Â Â Â Â/* enable thermal throttle processing */
> Â Â Â Âatomic_set(&therm_throt_en, 1);
> --- linux.orig/arch/x86/kernel/smpboot.c
> +++ linux/arch/x86/kernel/smpboot.c
> @@ -671,6 +671,26 @@
> Â Â Â Âcomplete(&c_idle->done);
> }
>
> +/* reduce the number of lines printed when booting a large cpu count system
> */
> +static void __cpuinit announce_cpu(int cpu, int apicid)
> +{
> + Â Â Â static int current_node = -1;
> + Â Â Â int node = cpu_to_node(cpu);
> +
> + Â Â Â if (system_state == SYSTEM_BOOTING) {
> + Â Â Â Â Â Â Â if (node != current_node) {
> + Â Â Â Â Â Â Â Â Â Â Â if (current_node > (-1))
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pr_cont(" Ok.\n");
> + Â Â Â Â Â Â Â Â Â Â Â current_node = node;
> + Â Â Â Â Â Â Â Â Â Â Â pr_info("Booting Node %3d, Processors ", node);
> + Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â pr_cont(" #%d%s", cpu, cpu == (nr_cpu_ids - 1) ? " Ok.\n" :
> "");
> + Â Â Â Â Â Â Â return;
> + Â Â Â } else
> + Â Â Â Â Â Â Â pr_info("Booting Node %d Processor %d APIC 0x%x\n",
> + Â Â Â Â Â Â Â Â Â Â Â node, cpu, apicid);
> +}
> +
> /*
> Â* NOTE - on most systems this is a PHYSICAL apic ID, but on multiquad
> Â* (ie clustered apic addressing mode), this is a LOGICAL apic ID.
> @@ -736,9 +756,8 @@
> Â Â Â Â/* start_ip had better be page-aligned! */
> Â Â Â Âstart_ip = setup_trampoline();
>
> -    /* So we see what's up  */
> - Â Â Â printk(KERN_INFO "Booting processor %d APIC 0x%x ip 0x%lx\n",
> - Â Â Â Â Â Â Â Â Â Â Â Â cpu, apicid, start_ip);
> + Â Â Â /* So we see what's up */
> + Â Â Â announce_cpu(cpu, apicid);
>
> Â Â Â Â/*
> Â Â Â Â * This grunge runs the startup process for
> @@ -787,21 +806,17 @@
> Â Â Â Â Â Â Â Â Â Â Â Âudelay(100);
> Â Â Â Â Â Â Â Â}
>
> - Â Â Â Â Â Â Â if (cpumask_test_cpu(cpu, cpu_callin_mask)) {
> - Â Â Â Â Â Â Â Â Â Â Â /* number CPUs logically, starting from 1 (BSP is 0)
> */
> - Â Â Â Â Â Â Â Â Â Â Â pr_debug("OK.\n");
> - Â Â Â Â Â Â Â Â Â Â Â printk(KERN_INFO "CPU%d: ", cpu);
> - Â Â Â Â Â Â Â Â Â Â Â print_cpu_info(&cpu_data(cpu));
> - Â Â Â Â Â Â Â Â Â Â Â pr_debug("CPU has booted.\n");
> - Â Â Â Â Â Â Â } else {
> + Â Â Â Â Â Â Â if (cpumask_test_cpu(cpu, cpu_callin_mask))
> + Â Â Â Â Â Â Â Â Â Â Â pr_debug("CPU%d: has booted.\n", cpu);
> + Â Â Â Â Â Â Â else {
> Â Â Â Â Â Â Â Â Â Â Â Âboot_error = 1;
> Â Â Â Â Â Â Â Â Â Â Â Âif (*((volatile unsigned char *)trampoline_base)
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â== 0xA5)
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â/* trampoline started but...? */
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printk(KERN_ERR "Stuck ??\n");
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pr_err("CPU%d: Stuck ??\n", cpu);
> Â Â Â Â Â Â Â Â Â Â Â Âelse
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â/* trampoline code not run */
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printk(KERN_ERR "Not responding.\n");
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pr_err("CPU%d: Not responding.\n", cpu);
> Â Â Â Â Â Â Â Â Â Â Â Âif (apic->inquire_remote_apic)
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âapic->inquire_remote_apic(apicid);
> Â Â Â Â Â Â Â Â}
> @@ -1291,14 +1306,16 @@
> Â Â Â Âfor (i = 0; i < 10; i++) {
> Â Â Â Â Â Â Â Â/* They ack this in play_dead by setting CPU_DEAD */
> Â Â Â Â Â Â Â Âif (per_cpu(cpu_state, cpu) == CPU_DEAD) {
> - Â Â Â Â Â Â Â Â Â Â Â printk(KERN_INFO "CPU %d is now offline\n", cpu);
> + Â Â Â Â Â Â Â Â Â Â Â if (system_state == SYSTEM_RUNNING)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pr_info("CPU %u is now offline\n", cpu);
> +
> Â Â Â Â Â Â Â Â Â Â Â Âif (1 == num_online_cpus())
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âalternatives_smp_switch(0);
> Â Â Â Â Â Â Â Â Â Â Â Âreturn;
> Â Â Â Â Â Â Â Â}
> Â Â Â Â Â Â Â Âmsleep(100);
> Â Â Â Â}
> - Â Â Â printk(KERN_ERR "CPU %u didn't die...\n", cpu);
> + Â Â Â pr_err("CPU %u didn't die...\n", cpu);
> }
>
> void play_dead_common(void)
>
> --
> 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/
>
N‹§²æìr¸›yúèšØb²X¬¶ÇvØ^–)Þ{.nÇ+‰·¥Š{±‘êçzX§¶›¡Ü}©ž²ÆzÚ&j:+v‰¨¾«‘êçzZ+€Ê+zf£¢·hšˆ§~†­†Ûiÿûàz¹®w¥¢¸?™¨è­Ú&¢)ßf”ù^jÇy§m…á@A«a¶Úÿ 0¶ìh®å’i