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

Merge tag 'printk-for-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux

Pull printk updates from Petr Mladek:

- New option "printk.debug_non_panic_cpus" allows to store printk
messages from non-panic CPUs during panic. It might be useful when
panic() fails. It is disabled by default because it increases the
chance to see the messages printed before panic() and on the
panic-CPU.

- New build option "CONFIG_NULL_TTY_DEFAULT_CONSOLE" allows to build
kernel without the virtual terminal support which prefers ttynull
over serial console.

- Do not unblank suspended consoles.

- Some code clean up.

* tag 'printk-for-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux:
printk/panic: Add option to allow non-panic CPUs to write to the ring buffer.
printk: Add an option to allow ttynull to be a default console device
printk: Check CON_SUSPEND when unblanking a console
printk: Rename console_start to console_resume
printk: Rename console_stop to console_suspend
printk: Rename resume_console to console_resume_all
printk: Rename suspend_console to console_suspend_all

+110 -46
+8
Documentation/admin-guide/kernel-parameters.txt
··· 5020 5020 Format: <bool> 5021 5021 default: 0 (auto_verbose is enabled) 5022 5022 5023 + printk.debug_non_panic_cpus= 5024 + Allows storing messages from non-panic CPUs into 5025 + the printk log buffer during panic(). They are 5026 + flushed to consoles by the panic-CPU on 5027 + a best-effort basis. 5028 + Format: <bool> (1/Y/y=enable, 0/N/n=disable) 5029 + Default: disabled 5030 + 5023 5031 printk.devkmsg={on,off,ratelimit} 5024 5032 Control writing to /dev/kmsg. 5025 5033 on - unlimited logging to /dev/kmsg from userspace
+3 -1
Documentation/admin-guide/serial-console.rst
··· 78 78 acting as a system console will be used. At this time, the system 79 79 first looks for a VGA card and then for a serial port. So if you don't 80 80 have a VGA card in your system the first serial port will automatically 81 - become the console. 81 + become the console, unless the kernel is configured with the 82 + CONFIG_NULL_TTY_DEFAULT_CONSOLE option, then it will default to using the 83 + ttynull device. 82 84 83 85 You will need to create a new device to use ``/dev/console``. The official 84 86 ``/dev/console`` is now character device 5,1.
+2 -2
drivers/gpu/drm/clients/drm_log.c
··· 323 323 { 324 324 struct drm_log *dlog = client_to_drm_log(client); 325 325 326 - console_stop(&dlog->con); 326 + console_suspend(&dlog->con); 327 327 328 328 return 0; 329 329 } ··· 332 332 { 333 333 struct drm_log *dlog = client_to_drm_log(client); 334 334 335 - console_start(&dlog->con); 335 + console_resume(&dlog->con); 336 336 337 337 return 0; 338 338 }
+18 -1
drivers/tty/Kconfig
··· 383 383 available or desired. 384 384 385 385 In order to use this driver, you should redirect the console to this 386 - TTY, or boot the kernel with console=ttynull. 386 + TTY, boot the kernel with console=ttynull, or enable 387 + NULL_TTY_DEFAULT_CONSOLE. 388 + 389 + If unsure, say N. 390 + 391 + config NULL_TTY_DEFAULT_CONSOLE 392 + bool "Support for console on ttynull" 393 + depends on NULL_TTY=y && !VT_CONSOLE 394 + help 395 + Say Y here if you want the NULL TTY to be used as a /dev/console 396 + device by default. 397 + 398 + For example, it might be useful to prevent a VT-less kernel from 399 + writing the system log to a random device connected to the serial 400 + port. 401 + 402 + Another console driver still might get preferred via the command 403 + line, SPCR, or the device tree. 387 404 388 405 If unsure, say N. 389 406
+3 -3
drivers/tty/serial/serial_core.c
··· 2426 2426 } 2427 2427 2428 2428 /* 2429 - * Disable the console device before suspending. 2429 + * Suspend the console device before suspending the port. 2430 2430 */ 2431 2431 if (uart_console(uport)) 2432 - console_stop(uport->cons); 2432 + console_suspend(uport->cons); 2433 2433 2434 2434 uart_change_pm(state, UART_PM_STATE_OFF); 2435 2435 ··· 2484 2484 uart_port_unlock_irq(uport); 2485 2485 } 2486 2486 if (console_suspend_enabled) 2487 - console_start(uport->cons); 2487 + console_resume(uport->cons); 2488 2488 } 2489 2489 2490 2490 if (tty_port_suspended(port)) {
+4 -4
include/linux/console.h
··· 633 633 extern void console_unblank(void); 634 634 extern void console_flush_on_panic(enum con_flush_mode mode); 635 635 extern struct tty_driver *console_device(int *); 636 - extern void console_stop(struct console *); 637 - extern void console_start(struct console *); 636 + extern void console_suspend(struct console *); 637 + extern void console_resume(struct console *); 638 638 extern int is_console_locked(void); 639 639 extern int braille_register_console(struct console *, int index, 640 640 char *console_options, char *braille_options); ··· 648 648 extern bool console_suspend_enabled; 649 649 650 650 /* Suspend and resume console messages over PM events */ 651 - extern void suspend_console(void); 652 - extern void resume_console(void); 651 + extern void console_suspend_all(void); 652 + extern void console_resume_all(void); 653 653 654 654 int mda_console_init(void); 655 655
+2 -2
kernel/kexec_core.c
··· 1013 1013 error = -EBUSY; 1014 1014 goto Restore_console; 1015 1015 } 1016 - suspend_console(); 1016 + console_suspend_all(); 1017 1017 error = dpm_suspend_start(PMSG_FREEZE); 1018 1018 if (error) 1019 1019 goto Resume_console; ··· 1072 1072 Resume_devices: 1073 1073 dpm_resume_end(PMSG_RESTORE); 1074 1074 Resume_console: 1075 - resume_console(); 1075 + console_resume_all(); 1076 1076 thaw_processes(); 1077 1077 Restore_console: 1078 1078 pm_restore_console();
+8 -8
kernel/power/hibernate.c
··· 411 411 goto Thaw; 412 412 } 413 413 414 - suspend_console(); 414 + console_suspend_all(); 415 415 pm_restrict_gfp_mask(); 416 416 417 417 error = dpm_suspend(PMSG_FREEZE); ··· 437 437 if (error || !in_suspend) 438 438 pm_restore_gfp_mask(); 439 439 440 - resume_console(); 440 + console_resume_all(); 441 441 dpm_complete(msg); 442 442 443 443 Close: ··· 547 547 int error; 548 548 549 549 pm_prepare_console(); 550 - suspend_console(); 550 + console_suspend_all(); 551 551 pm_restrict_gfp_mask(); 552 552 error = dpm_suspend_start(PMSG_QUIESCE); 553 553 if (!error) { ··· 561 561 } 562 562 dpm_resume_end(PMSG_RECOVER); 563 563 pm_restore_gfp_mask(); 564 - resume_console(); 564 + console_resume_all(); 565 565 pm_restore_console(); 566 566 return error; 567 567 } ··· 586 586 goto Close; 587 587 588 588 entering_platform_hibernation = true; 589 - suspend_console(); 589 + console_suspend_all(); 590 590 error = dpm_suspend_start(PMSG_HIBERNATE); 591 591 if (error) { 592 592 if (hibernation_ops->recover) ··· 639 639 Resume_devices: 640 640 entering_platform_hibernation = false; 641 641 dpm_resume_end(PMSG_RESTORE); 642 - resume_console(); 642 + console_resume_all(); 643 643 644 644 Close: 645 645 hibernation_ops->end(); ··· 901 901 if (error) 902 902 goto dpm_complete; 903 903 904 - suspend_console(); 904 + console_suspend_all(); 905 905 906 906 error = dpm_suspend(PMSG_FREEZE); 907 907 if (error) ··· 925 925 dpm_resume: 926 926 dpm_resume(PMSG_THAW); 927 927 928 - resume_console(); 928 + console_resume_all(); 929 929 930 930 dpm_complete: 931 931 dpm_complete(PMSG_THAW);
+4 -4
kernel/power/suspend.c
··· 508 508 if (error) 509 509 goto Close; 510 510 511 - suspend_console(); 511 + console_suspend_all(); 512 512 suspend_test_start(); 513 513 error = dpm_suspend_start(PMSG_SUSPEND); 514 514 if (error) { ··· 527 527 suspend_test_start(); 528 528 dpm_resume_end(PMSG_RESUME); 529 529 suspend_test_finish("resume devices"); 530 - trace_suspend_resume(TPS("resume_console"), state, true); 531 - resume_console(); 532 - trace_suspend_resume(TPS("resume_console"), state, false); 530 + trace_suspend_resume(TPS("console_resume_all"), state, true); 531 + console_resume_all(); 532 + trace_suspend_resume(TPS("console_resume_all"), state, false); 533 533 534 534 Close: 535 535 platform_resume_end(state);
+1
kernel/printk/internal.h
··· 64 64 65 65 extern struct printk_ringbuffer *prb; 66 66 extern bool printk_kthreads_running; 67 + extern bool debug_non_panic_cpus; 67 68 68 69 __printf(4, 0) 69 70 int vprintk_store(int facility, int level,
+44 -11
kernel/printk/printk.c
··· 2375 2375 } 2376 2376 } 2377 2377 2378 + bool __read_mostly debug_non_panic_cpus; 2379 + 2380 + #ifdef CONFIG_PRINTK_CALLER 2381 + static int __init debug_non_panic_cpus_setup(char *str) 2382 + { 2383 + debug_non_panic_cpus = true; 2384 + pr_info("allow messages from non-panic CPUs in panic()\n"); 2385 + 2386 + return 0; 2387 + } 2388 + early_param("debug_non_panic_cpus", debug_non_panic_cpus_setup); 2389 + module_param(debug_non_panic_cpus, bool, 0644); 2390 + MODULE_PARM_DESC(debug_non_panic_cpus, 2391 + "allow messages from non-panic CPUs in panic()"); 2392 + #endif 2393 + 2378 2394 asmlinkage int vprintk_emit(int facility, int level, 2379 2395 const struct dev_printk_info *dev_info, 2380 2396 const char *fmt, va_list args) ··· 2407 2391 * non-panic CPUs are generating any messages, they will be 2408 2392 * silently dropped. 2409 2393 */ 2410 - if (other_cpu_in_panic() && !panic_triggering_all_cpu_backtrace) 2394 + if (other_cpu_in_panic() && 2395 + !debug_non_panic_cpus && 2396 + !panic_triggering_all_cpu_backtrace) 2411 2397 return 0; 2412 2398 2413 2399 printk_get_console_flush_type(&ft); ··· 2749 2731 MODULE_PARM_DESC(console_no_auto_verbose, "Disable console loglevel raise to highest on oops/panic/etc"); 2750 2732 2751 2733 /** 2752 - * suspend_console - suspend the console subsystem 2734 + * console_suspend_all - suspend the console subsystem 2753 2735 * 2754 2736 * This disables printk() while we go into suspend states 2755 2737 */ 2756 - void suspend_console(void) 2738 + void console_suspend_all(void) 2757 2739 { 2758 2740 struct console *con; 2759 2741 ··· 2776 2758 synchronize_srcu(&console_srcu); 2777 2759 } 2778 2760 2779 - void resume_console(void) 2761 + void console_resume_all(void) 2780 2762 { 2781 2763 struct console_flush_type ft; 2782 2764 struct console *con; ··· 3358 3340 */ 3359 3341 cookie = console_srcu_read_lock(); 3360 3342 for_each_console_srcu(c) { 3361 - if ((console_srcu_read_flags(c) & CON_ENABLED) && c->unblank) { 3343 + short flags = console_srcu_read_flags(c); 3344 + 3345 + if (flags & CON_SUSPENDED) 3346 + continue; 3347 + 3348 + if ((flags & CON_ENABLED) && c->unblank) { 3362 3349 found_unblank = true; 3363 3350 break; 3364 3351 } ··· 3400 3377 3401 3378 cookie = console_srcu_read_lock(); 3402 3379 for_each_console_srcu(c) { 3403 - if ((console_srcu_read_flags(c) & CON_ENABLED) && c->unblank) 3380 + short flags = console_srcu_read_flags(c); 3381 + 3382 + if (flags & CON_SUSPENDED) 3383 + continue; 3384 + 3385 + if ((flags & CON_ENABLED) && c->unblank) 3404 3386 c->unblank(); 3405 3387 } 3406 3388 console_srcu_read_unlock(cookie); ··· 3523 3495 3524 3496 /* 3525 3497 * Prevent further output on the passed console device so that (for example) 3526 - * serial drivers can disable console output before suspending a port, and can 3498 + * serial drivers can suspend console output before suspending a port, and can 3527 3499 * re-enable output afterwards. 3528 3500 */ 3529 - void console_stop(struct console *console) 3501 + void console_suspend(struct console *console) 3530 3502 { 3531 3503 __pr_flush(console, 1000, true); 3532 3504 console_list_lock(); ··· 3541 3513 */ 3542 3514 synchronize_srcu(&console_srcu); 3543 3515 } 3544 - EXPORT_SYMBOL(console_stop); 3516 + EXPORT_SYMBOL(console_suspend); 3545 3517 3546 - void console_start(struct console *console) 3518 + void console_resume(struct console *console) 3547 3519 { 3548 3520 struct console_flush_type ft; 3549 3521 bool is_nbcon; ··· 3568 3540 3569 3541 __pr_flush(console, 1000, true); 3570 3542 } 3571 - EXPORT_SYMBOL(console_start); 3543 + EXPORT_SYMBOL(console_resume); 3572 3544 3573 3545 #ifdef CONFIG_PRINTK 3574 3546 static int unregister_console_locked(struct console *console); ··· 4302 4274 int ret; 4303 4275 initcall_t call; 4304 4276 initcall_entry_t *ce; 4277 + 4278 + #ifdef CONFIG_NULL_TTY_DEFAULT_CONSOLE 4279 + if (!console_set_on_cmdline) 4280 + add_preferred_console("ttynull", 0, NULL); 4281 + #endif 4305 4282 4306 4283 /* Setup the default TTY line discipline. */ 4307 4284 n_tty_init();
+8 -5
kernel/printk/printk_ringbuffer.c
··· 2133 2133 * there may be other finalized records beyond that 2134 2134 * need to be printed for a panic situation. If this 2135 2135 * is the panic CPU, skip this 2136 - * non-existent/non-finalized record unless it is 2137 - * at or beyond the head, in which case it is not 2138 - * possible to continue. 2136 + * non-existent/non-finalized record unless non-panic 2137 + * CPUs are still running and their debugging is 2138 + * explicitly enabled. 2139 2139 * 2140 2140 * Note that new messages printed on panic CPU are 2141 2141 * finalized when we are here. The only exception ··· 2143 2143 * But it would have the sequence number returned 2144 2144 * by "prb_next_reserve_seq() - 1". 2145 2145 */ 2146 - if (this_cpu_in_panic() && ((*seq + 1) < prb_next_reserve_seq(rb))) 2146 + if (this_cpu_in_panic() && 2147 + (!debug_non_panic_cpus || legacy_allow_panic_sync) && 2148 + ((*seq + 1) < prb_next_reserve_seq(rb))) { 2147 2149 (*seq)++; 2148 - else 2150 + } else { 2149 2151 return false; 2152 + } 2150 2153 } 2151 2154 } 2152 2155
+2 -2
tools/power/pm-graph/config/custom-timeline-functions.cfg
··· 122 122 freeze_kernel_threads: 123 123 pm_restrict_gfp_mask: 124 124 acpi_suspend_begin: 125 - suspend_console: 125 + console_suspend_all: 126 126 acpi_pm_prepare: 127 127 syscore_suspend: 128 128 arch_enable_nonboot_cpus_end: 129 129 syscore_resume: 130 130 acpi_pm_finish: 131 - resume_console: 131 + console_resume_all: 132 132 acpi_pm_end: 133 133 pm_restore_gfp_mask: 134 134 thaw_processes:
+3 -3
tools/power/pm-graph/sleepgraph.py
··· 210 210 'hibernate_preallocate_memory': {}, 211 211 'create_basic_memory_bitmaps': {}, 212 212 'swsusp_write': {}, 213 - 'suspend_console': {}, 213 + 'console_suspend_all': {}, 214 214 'acpi_pm_prepare': {}, 215 215 'syscore_suspend': {}, 216 216 'arch_enable_nonboot_cpus_end': {}, 217 217 'syscore_resume': {}, 218 218 'acpi_pm_finish': {}, 219 - 'resume_console': {}, 219 + 'console_resume_all': {}, 220 220 'acpi_pm_end': {}, 221 221 'pm_restore_gfp_mask': {}, 222 222 'thaw_processes': {}, ··· 3459 3459 tracewatch = ['irq_wakeup'] 3460 3460 if sysvals.usekprobes: 3461 3461 tracewatch += ['sync_filesystems', 'freeze_processes', 'syscore_suspend', 3462 - 'syscore_resume', 'resume_console', 'thaw_processes', 'CPU_ON', 3462 + 'syscore_resume', 'console_resume_all', 'thaw_processes', 'CPU_ON', 3463 3463 'CPU_OFF', 'acpi_suspend'] 3464 3464 3465 3465 # extract the callgraph and traceevent data