diff for duplicates of <20100804152342.GC21004@linux-mips.org> diff --git a/a/1.txt b/N1/1.txt index 1630840..be42c1c 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -2,3 +2,114 @@ Santosh's patch was lacking akpm's cleanup patch. So I created the following from all contributions. Ralf + +>From 040f52ce2a3cab374bfed036ccd8ecf4b1fb7add Mon Sep 17 00:00:00 2001 +From: Kevin Cernekee <cernekee@gmail.com> +Date: Thu, 3 Jun 2010 22:11:25 -0700 +Subject: [PATCH] printk: fix delayed messages from CPU hotplug events + +When a secondary CPU is being brought up, it is not uncommon for +printk() to be invoked when cpu_online(smp_processor_id()) == 0. The +case that I witnessed personally was on MIPS: + +http://lkml.org/lkml/2010/5/30/4 + +If (can_use_console() == 0), printk() will spool its output to log_buf +and it will be visible in "dmesg", but that output will NOT be echoed to +the console until somebody calls release_console_sem() from a CPU that +is online. Therefore, the boot time messages from the new CPU can get +stuck in "limbo" for a long time, and might suddenly appear on the +screen when a completely unrelated event (e.g. "eth0: link is down") +occurs. + +This patch modifies the console code so that any pending messages are +automatically flushed out to the console whenever a CPU hotplug +operation completes successfully or aborts. + +The issue was seen on 2.6.34. + +Original patch by Kevin Cernekee with cleanups by akpm and additional fixes +by Santosh Shilimkar. This patch superseeds +https://patchwork.linux-mips.org/patch/1357/. + +Signed-off-by: Kevin Cernekee <cernekee@gmail.com> +To: <mingo@elte.hu> +To: <akpm@linux-foundation.org> +To: <simon.kagstrom@netinsight.net> +To: <David.Woodhouse@intel.com> +To: <lethal@linux-sh.org> +Cc: <linux-kernel@vger.kernel.org> +Cc: <linux-mips@linux-mips.org> +Reviewed-by: Paul Mundt <lethal@linux-sh.org> +Signed-off-by: Kevin Cernekee <cernekee@gmail.com> +Patchwork: https://patchwork.linux-mips.org/patch/1533/ +LKML-Reference: <ede63b5a20af951c755736f035d1e787772d7c28@localhost> +LKML-Reference: <EAF47CD23C76F840A9E7FCE10091EFAB02C5DB6D1F@dbde02.ent.ti.com> +Signed-off-by: Ralf Baechle <ralf@linux-mips.org> + +diff --git a/kernel/printk.c b/kernel/printk.c +index 444b770..4ab0164 100644 +--- a/kernel/printk.c ++++ b/kernel/printk.c +@@ -37,6 +37,8 @@ + #include <linux/ratelimit.h> + #include <linux/kmsg_dump.h> + #include <linux/syslog.h> ++#include <linux/cpu.h> ++#include <linux/notifier.h> + + #include <asm/uaccess.h> + +@@ -985,6 +987,32 @@ void resume_console(void) + } + + /** ++ * console_cpu_notify - print deferred console messages after CPU hotplug ++ * @self: notifier struct ++ * @action: CPU hotplug event ++ * @hcpu: unused ++ * ++ * If printk() is called from a CPU that is not online yet, the messages ++ * will be spooled but will not show up on the console. This function is ++ * called when a new CPU comes online (or fails to come up), and ensures ++ * that any such output gets printed. ++ */ ++static int __cpuinit console_cpu_notify(struct notifier_block *self, ++ unsigned long action, void *hcpu) ++{ ++ switch (action) { ++ case CPU_ONLINE: ++ case CPU_DEAD: ++ case CPU_DYING: ++ case CPU_DOWN_FAILED: ++ case CPU_UP_CANCELED: ++ acquire_console_sem(); ++ release_console_sem(); ++ } ++ return NOTIFY_OK; ++} ++ ++/** + * acquire_console_sem - lock the console system for exclusive use. + * + * Acquires a semaphore which guarantees that the caller has +@@ -1371,7 +1399,7 @@ int unregister_console(struct console *console) + } + EXPORT_SYMBOL(unregister_console); + +-static int __init disable_boot_consoles(void) ++static int __init printk_late_init(void) + { + struct console *con; + +@@ -1382,9 +1410,10 @@ static int __init disable_boot_consoles(void) + unregister_console(con); + } + } ++ hotcpu_notifier(console_cpu_notify, 0); + return 0; + } +-late_initcall(disable_boot_consoles); ++late_initcall(printk_late_init); + + #if defined CONFIG_PRINTK diff --git a/a/content_digest b/N1/content_digest index ee1da32..3f537ff 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -20,6 +20,117 @@ "Santosh's patch was lacking akpm's cleanup patch. So I created the\n" "following from all contributions.\n" "\n" - Ralf + " Ralf\n" + "\n" + ">From 040f52ce2a3cab374bfed036ccd8ecf4b1fb7add Mon Sep 17 00:00:00 2001\n" + "From: Kevin Cernekee <cernekee@gmail.com>\n" + "Date: Thu, 3 Jun 2010 22:11:25 -0700\n" + "Subject: [PATCH] printk: fix delayed messages from CPU hotplug events\n" + "\n" + "When a secondary CPU is being brought up, it is not uncommon for\n" + "printk() to be invoked when cpu_online(smp_processor_id()) == 0. The\n" + "case that I witnessed personally was on MIPS:\n" + "\n" + "http://lkml.org/lkml/2010/5/30/4\n" + "\n" + "If (can_use_console() == 0), printk() will spool its output to log_buf\n" + "and it will be visible in \"dmesg\", but that output will NOT be echoed to\n" + "the console until somebody calls release_console_sem() from a CPU that\n" + "is online. Therefore, the boot time messages from the new CPU can get\n" + "stuck in \"limbo\" for a long time, and might suddenly appear on the\n" + "screen when a completely unrelated event (e.g. \"eth0: link is down\")\n" + "occurs.\n" + "\n" + "This patch modifies the console code so that any pending messages are\n" + "automatically flushed out to the console whenever a CPU hotplug\n" + "operation completes successfully or aborts.\n" + "\n" + "The issue was seen on 2.6.34.\n" + "\n" + "Original patch by Kevin Cernekee with cleanups by akpm and additional fixes\n" + "by Santosh Shilimkar. This patch superseeds\n" + "https://patchwork.linux-mips.org/patch/1357/.\n" + "\n" + "Signed-off-by: Kevin Cernekee <cernekee@gmail.com>\n" + "To: <mingo@elte.hu>\n" + "To: <akpm@linux-foundation.org>\n" + "To: <simon.kagstrom@netinsight.net>\n" + "To: <David.Woodhouse@intel.com>\n" + "To: <lethal@linux-sh.org>\n" + "Cc: <linux-kernel@vger.kernel.org>\n" + "Cc: <linux-mips@linux-mips.org>\n" + "Reviewed-by: Paul Mundt <lethal@linux-sh.org>\n" + "Signed-off-by: Kevin Cernekee <cernekee@gmail.com>\n" + "Patchwork: https://patchwork.linux-mips.org/patch/1533/\n" + "LKML-Reference: <ede63b5a20af951c755736f035d1e787772d7c28@localhost>\n" + "LKML-Reference: <EAF47CD23C76F840A9E7FCE10091EFAB02C5DB6D1F@dbde02.ent.ti.com>\n" + "Signed-off-by: Ralf Baechle <ralf@linux-mips.org>\n" + "\n" + "diff --git a/kernel/printk.c b/kernel/printk.c\n" + "index 444b770..4ab0164 100644\n" + "--- a/kernel/printk.c\n" + "+++ b/kernel/printk.c\n" + "@@ -37,6 +37,8 @@\n" + " #include <linux/ratelimit.h>\n" + " #include <linux/kmsg_dump.h>\n" + " #include <linux/syslog.h>\n" + "+#include <linux/cpu.h>\n" + "+#include <linux/notifier.h>\n" + " \n" + " #include <asm/uaccess.h>\n" + " \n" + "@@ -985,6 +987,32 @@ void resume_console(void)\n" + " }\n" + " \n" + " /**\n" + "+ * console_cpu_notify - print deferred console messages after CPU hotplug\n" + "+ * @self: notifier struct\n" + "+ * @action: CPU hotplug event\n" + "+ * @hcpu: unused\n" + "+ *\n" + "+ * If printk() is called from a CPU that is not online yet, the messages\n" + "+ * will be spooled but will not show up on the console. This function is\n" + "+ * called when a new CPU comes online (or fails to come up), and ensures\n" + "+ * that any such output gets printed.\n" + "+ */\n" + "+static int __cpuinit console_cpu_notify(struct notifier_block *self,\n" + "+\tunsigned long action, void *hcpu)\n" + "+{\n" + "+\tswitch (action) {\n" + "+\tcase CPU_ONLINE:\n" + "+\tcase CPU_DEAD:\n" + "+\tcase CPU_DYING:\n" + "+\tcase CPU_DOWN_FAILED:\n" + "+\tcase CPU_UP_CANCELED:\n" + "+\t\tacquire_console_sem();\n" + "+\t\trelease_console_sem();\n" + "+\t}\n" + "+\treturn NOTIFY_OK;\n" + "+}\n" + "+\n" + "+/**\n" + " * acquire_console_sem - lock the console system for exclusive use.\n" + " *\n" + " * Acquires a semaphore which guarantees that the caller has\n" + "@@ -1371,7 +1399,7 @@ int unregister_console(struct console *console)\n" + " }\n" + " EXPORT_SYMBOL(unregister_console);\n" + " \n" + "-static int __init disable_boot_consoles(void)\n" + "+static int __init printk_late_init(void)\n" + " {\n" + " \tstruct console *con;\n" + " \n" + "@@ -1382,9 +1410,10 @@ static int __init disable_boot_consoles(void)\n" + " \t\t\tunregister_console(con);\n" + " \t\t}\n" + " \t}\n" + "+\thotcpu_notifier(console_cpu_notify, 0);\n" + " \treturn 0;\n" + " }\n" + "-late_initcall(disable_boot_consoles);\n" + "+late_initcall(printk_late_init);\n" + " \n" + #if defined CONFIG_PRINTK -0f07e5514ea11de138d35f505df1262404c9bc66e9cc8f2bcfc8e734256b8d29 +243bba086edc82f73ca1f54da72366d6bcefcda1c2a477b1add9307fa7004795
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.