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

Configure Feed

Select the types of activity you want to include in your feed.

Revert "printk: add functions to prefer direct printing"

This reverts commit 2bb2b7b57f81255c13f4395ea911d6bdc70c9fe2.

The testing of 5.19 release candidates revealed missing synchronization
between early and regular console functionality.

It would be possible to start the console kthreads later as a workaround.
But it is clear that console lock serialized console drivers between
each other. It opens a big area of possible problems that were not
considered by people involved in the development and review.

printk() is crucial for debugging kernel issues and console output is
very important part of it. The number of consoles is huge and a proper
review would take some time. As a result it need to be reverted for 5.19.

Link: https://lore.kernel.org/r/YrBdjVwBOVgLfHyb@alley
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20220623145157.21938-7-pmladek@suse.com

+2 -78
-2
drivers/tty/sysrq.c
··· 578 578 579 579 rcu_sysrq_start(); 580 580 rcu_read_lock(); 581 - printk_prefer_direct_enter(); 582 581 /* 583 582 * Raise the apparent loglevel to maximum so that the sysrq header 584 583 * is shown to provide the user with positive feedback. We do not ··· 619 620 pr_cont("\n"); 620 621 console_loglevel = orig_log_level; 621 622 } 622 - printk_prefer_direct_exit(); 623 623 rcu_read_unlock(); 624 624 rcu_sysrq_end(); 625 625
-11
include/linux/printk.h
··· 170 170 #define printk_deferred_enter __printk_safe_enter 171 171 #define printk_deferred_exit __printk_safe_exit 172 172 173 - extern void printk_prefer_direct_enter(void); 174 - extern void printk_prefer_direct_exit(void); 175 - 176 173 extern bool pr_flush(int timeout_ms, bool reset_on_progress); 177 174 178 175 /* ··· 219 222 } 220 223 221 224 static inline void printk_deferred_exit(void) 222 - { 223 - } 224 - 225 - static inline void printk_prefer_direct_enter(void) 226 - { 227 - } 228 - 229 - static inline void printk_prefer_direct_exit(void) 230 225 { 231 226 } 232 227
+1 -10
kernel/hung_task.c
··· 127 127 * complain: 128 128 */ 129 129 if (sysctl_hung_task_warnings) { 130 - printk_prefer_direct_enter(); 131 - 132 130 if (sysctl_hung_task_warnings > 0) 133 131 sysctl_hung_task_warnings--; 134 132 pr_err("INFO: task %s:%d blocked for more than %ld seconds.\n", ··· 142 144 143 145 if (sysctl_hung_task_all_cpu_backtrace) 144 146 hung_task_show_all_bt = true; 145 - 146 - printk_prefer_direct_exit(); 147 147 } 148 148 149 149 touch_nmi_watchdog(); ··· 204 208 } 205 209 unlock: 206 210 rcu_read_unlock(); 207 - if (hung_task_show_lock) { 208 - printk_prefer_direct_enter(); 211 + if (hung_task_show_lock) 209 212 debug_show_all_locks(); 210 - printk_prefer_direct_exit(); 211 - } 212 213 213 214 if (hung_task_show_all_bt) { 214 215 hung_task_show_all_bt = false; 215 - printk_prefer_direct_enter(); 216 216 trigger_all_cpu_backtrace(); 217 - printk_prefer_direct_exit(); 218 217 } 219 218 220 219 if (hung_task_call_panic)
-4
kernel/panic.c
··· 579 579 { 580 580 disable_trace_on_warning(); 581 581 582 - printk_prefer_direct_enter(); 583 - 584 582 if (file) 585 583 pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS\n", 586 584 raw_smp_processor_id(), current->pid, file, line, ··· 608 610 609 611 /* Just a warning, don't kill lockdep. */ 610 612 add_taint(taint, LOCKDEP_STILL_OK); 611 - 612 - printk_prefer_direct_exit(); 613 613 } 614 614 615 615 #ifndef __WARN_FLAGS
-28
kernel/printk/printk.c
··· 362 362 static DEFINE_MUTEX(syslog_lock); 363 363 364 364 #ifdef CONFIG_PRINTK 365 - static atomic_t printk_prefer_direct = ATOMIC_INIT(0); 366 - 367 - /** 368 - * printk_prefer_direct_enter - cause printk() calls to attempt direct 369 - * printing to all enabled consoles 370 - * 371 - * Since it is not possible to call into the console printing code from any 372 - * context, there is no guarantee that direct printing will occur. 373 - * 374 - * This globally effects all printk() callers. 375 - * 376 - * Context: Any context. 377 - */ 378 - void printk_prefer_direct_enter(void) 379 - { 380 - atomic_inc(&printk_prefer_direct); 381 - } 382 - 383 - /** 384 - * printk_prefer_direct_exit - restore printk() behavior 385 - * 386 - * Context: Any context. 387 - */ 388 - void printk_prefer_direct_exit(void) 389 - { 390 - WARN_ON(atomic_dec_if_positive(&printk_prefer_direct) < 0); 391 - } 392 - 393 365 DECLARE_WAIT_QUEUE_HEAD(log_wait); 394 366 /* All 3 protected by @syslog_lock. */ 395 367 /* the next printk record to read by syslog(READ) or /proc/kmsg */
-2
kernel/rcu/tree_stall.h
··· 647 647 * See Documentation/RCU/stallwarn.rst for info on how to debug 648 648 * RCU CPU stall warnings. 649 649 */ 650 - printk_prefer_direct_enter(); 651 650 trace_rcu_stall_warning(rcu_state.name, TPS("SelfDetected")); 652 651 pr_err("INFO: %s self-detected stall on CPU\n", rcu_state.name); 653 652 raw_spin_lock_irqsave_rcu_node(rdp->mynode, flags); ··· 684 685 */ 685 686 set_tsk_need_resched(current); 686 687 set_preempt_need_resched(); 687 - printk_prefer_direct_exit(); 688 688 } 689 689 690 690 static void check_cpu_stall(struct rcu_data *rdp)
+1 -13
kernel/reboot.c
··· 447 447 ret = run_cmd(reboot_cmd); 448 448 449 449 if (ret) { 450 - printk_prefer_direct_enter(); 451 450 pr_warn("Failed to start orderly reboot: forcing the issue\n"); 452 451 emergency_sync(); 453 452 kernel_restart(NULL); 454 - printk_prefer_direct_exit(); 455 453 } 456 454 457 455 return ret; ··· 462 464 ret = run_cmd(poweroff_cmd); 463 465 464 466 if (ret && force) { 465 - printk_prefer_direct_enter(); 466 467 pr_warn("Failed to start orderly shutdown: forcing the issue\n"); 467 468 468 469 /* ··· 471 474 */ 472 475 emergency_sync(); 473 476 kernel_power_off(); 474 - printk_prefer_direct_exit(); 475 477 } 476 478 477 479 return ret; ··· 528 532 */ 529 533 static void hw_failure_emergency_poweroff_func(struct work_struct *work) 530 534 { 531 - printk_prefer_direct_enter(); 532 - 533 535 /* 534 536 * We have reached here after the emergency shutdown waiting period has 535 537 * expired. This means orderly_poweroff has not been able to shut off ··· 544 550 */ 545 551 pr_emerg("Hardware protection shutdown failed. Trying emergency restart\n"); 546 552 emergency_restart(); 547 - 548 - printk_prefer_direct_exit(); 549 553 } 550 554 551 555 static DECLARE_DELAYED_WORK(hw_failure_emergency_poweroff_work, ··· 582 590 { 583 591 static atomic_t allow_proceed = ATOMIC_INIT(1); 584 592 585 - printk_prefer_direct_enter(); 586 - 587 593 pr_emerg("HARDWARE PROTECTION shutdown (%s)\n", reason); 588 594 589 595 /* Shutdown should be initiated only once. */ 590 596 if (!atomic_dec_and_test(&allow_proceed)) 591 - goto out; 597 + return; 592 598 593 599 /* 594 600 * Queue a backup emergency shutdown in the event of ··· 594 604 */ 595 605 hw_failure_emergency_poweroff(ms_until_forced); 596 606 orderly_poweroff(true); 597 - out: 598 - printk_prefer_direct_exit(); 599 607 } 600 608 EXPORT_SYMBOL_GPL(hw_protection_shutdown); 601 609
-4
kernel/watchdog.c
··· 424 424 /* Start period for the next softlockup warning. */ 425 425 update_report_ts(); 426 426 427 - printk_prefer_direct_enter(); 428 - 429 427 pr_emerg("BUG: soft lockup - CPU#%d stuck for %us! [%s:%d]\n", 430 428 smp_processor_id(), duration, 431 429 current->comm, task_pid_nr(current)); ··· 442 444 add_taint(TAINT_SOFTLOCKUP, LOCKDEP_STILL_OK); 443 445 if (softlockup_panic) 444 446 panic("softlockup: hung tasks"); 445 - 446 - printk_prefer_direct_exit(); 447 447 } 448 448 449 449 return HRTIMER_RESTART;
-4
kernel/watchdog_hld.c
··· 135 135 if (__this_cpu_read(hard_watchdog_warn) == true) 136 136 return; 137 137 138 - printk_prefer_direct_enter(); 139 - 140 138 pr_emerg("Watchdog detected hard LOCKUP on cpu %d\n", 141 139 this_cpu); 142 140 print_modules(); ··· 154 156 155 157 if (hardlockup_panic) 156 158 nmi_panic(regs, "Hard LOCKUP"); 157 - 158 - printk_prefer_direct_exit(); 159 159 160 160 __this_cpu_write(hard_watchdog_warn, true); 161 161 return;