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.

Merge branch 'rework/suspend-fixes' into for-linus

+79 -21
+5 -3
kernel/printk/internal.h
··· 185 185 bool legacy_offload; 186 186 }; 187 187 188 + extern bool console_irqwork_blocked; 189 + 188 190 /* 189 191 * Identify which console flushing methods should be used in the context of 190 192 * the caller. ··· 198 196 switch (nbcon_get_default_prio()) { 199 197 case NBCON_PRIO_NORMAL: 200 198 if (have_nbcon_console && !have_boot_console) { 201 - if (printk_kthreads_running) 199 + if (printk_kthreads_running && !console_irqwork_blocked) 202 200 ft->nbcon_offload = true; 203 201 else 204 202 ft->nbcon_atomic = true; ··· 208 206 if (have_legacy_console || have_boot_console) { 209 207 if (!is_printk_legacy_deferred()) 210 208 ft->legacy_direct = true; 211 - else 209 + else if (!console_irqwork_blocked) 212 210 ft->legacy_offload = true; 213 211 } 214 212 break; ··· 221 219 if (have_legacy_console || have_boot_console) { 222 220 if (!is_printk_legacy_deferred()) 223 221 ft->legacy_direct = true; 224 - else 222 + else if (!console_irqwork_blocked) 225 223 ft->legacy_offload = true; 226 224 } 227 225 break;
+8 -1
kernel/printk/nbcon.c
··· 1302 1302 if (!printk_kthreads_running) 1303 1303 return; 1304 1304 1305 + /* 1306 + * It is not allowed to call this function when console irq_work 1307 + * is blocked. 1308 + */ 1309 + if (WARN_ON_ONCE(console_irqwork_blocked)) 1310 + return; 1311 + 1305 1312 cookie = console_srcu_read_lock(); 1306 1313 for_each_console_srcu(con) { 1307 1314 if (!(console_srcu_read_flags(con) & CON_NBCON)) ··· 1899 1892 if (console_trylock()) 1900 1893 console_unlock(); 1901 1894 } else if (ft.legacy_offload) { 1902 - printk_trigger_flush(); 1895 + defer_console_output(); 1903 1896 } 1904 1897 } 1905 1898 console_srcu_read_unlock(cookie);
+66 -17
kernel/printk/printk.c
··· 462 462 /* See printk_legacy_allow_panic_sync() for details. */ 463 463 bool legacy_allow_panic_sync; 464 464 465 + /* Avoid using irq_work when suspending. */ 466 + bool console_irqwork_blocked; 467 + 465 468 #ifdef CONFIG_PRINTK 466 469 DECLARE_WAIT_QUEUE_HEAD(log_wait); 467 470 static DECLARE_WAIT_QUEUE_HEAD(legacy_wait); ··· 2393 2390 /* If called from the scheduler, we can not call up(). */ 2394 2391 if (level == LOGLEVEL_SCHED) { 2395 2392 level = LOGLEVEL_DEFAULT; 2396 - ft.legacy_offload |= ft.legacy_direct; 2393 + ft.legacy_offload |= ft.legacy_direct && !console_irqwork_blocked; 2397 2394 ft.legacy_direct = false; 2398 2395 } 2399 2396 ··· 2429 2426 2430 2427 if (ft.legacy_offload) 2431 2428 defer_console_output(); 2432 - else 2429 + else if (!console_irqwork_blocked) 2433 2430 wake_up_klogd(); 2434 2431 2435 2432 return printed_len; ··· 2733 2730 { 2734 2731 struct console *con; 2735 2732 2733 + if (console_suspend_enabled) 2734 + pr_info("Suspending console(s) (use no_console_suspend to debug)\n"); 2735 + 2736 + /* 2737 + * Flush any console backlog and then avoid queueing irq_work until 2738 + * console_resume_all(). Until then deferred printing is no longer 2739 + * triggered, NBCON consoles transition to atomic flushing, and 2740 + * any klogd waiters are not triggered. 2741 + */ 2742 + pr_flush(1000, true); 2743 + console_irqwork_blocked = true; 2744 + 2736 2745 if (!console_suspend_enabled) 2737 2746 return; 2738 - pr_info("Suspending console(s) (use no_console_suspend to debug)\n"); 2739 - pr_flush(1000, true); 2740 2747 2741 2748 console_list_lock(); 2742 2749 for_each_console(con) ··· 2767 2754 struct console_flush_type ft; 2768 2755 struct console *con; 2769 2756 2770 - if (!console_suspend_enabled) 2771 - return; 2772 - 2773 - console_list_lock(); 2774 - for_each_console(con) 2775 - console_srcu_write_flags(con, con->flags & ~CON_SUSPENDED); 2776 - console_list_unlock(); 2777 - 2778 2757 /* 2779 - * Ensure that all SRCU list walks have completed. All printing 2780 - * contexts must be able to see they are no longer suspended so 2781 - * that they are guaranteed to wake up and resume printing. 2758 + * Allow queueing irq_work. After restoring console state, deferred 2759 + * printing and any klogd waiters need to be triggered in case there 2760 + * is now a console backlog. 2782 2761 */ 2783 - synchronize_srcu(&console_srcu); 2762 + console_irqwork_blocked = false; 2763 + 2764 + if (console_suspend_enabled) { 2765 + console_list_lock(); 2766 + for_each_console(con) 2767 + console_srcu_write_flags(con, con->flags & ~CON_SUSPENDED); 2768 + console_list_unlock(); 2769 + 2770 + /* 2771 + * Ensure that all SRCU list walks have completed. All printing 2772 + * contexts must be able to see they are no longer suspended so 2773 + * that they are guaranteed to wake up and resume printing. 2774 + */ 2775 + synchronize_srcu(&console_srcu); 2776 + } 2784 2777 2785 2778 printk_get_console_flush_type(&ft); 2786 2779 if (ft.nbcon_offload) 2787 2780 nbcon_kthreads_wake(); 2788 2781 if (ft.legacy_offload) 2789 2782 defer_console_output(); 2783 + else 2784 + wake_up_klogd(); 2790 2785 2791 2786 pr_flush(1000, true); 2792 2787 } ··· 4580 4559 if (!printk_percpu_data_ready()) 4581 4560 return; 4582 4561 4562 + /* 4563 + * It is not allowed to call this function when console irq_work 4564 + * is blocked. 4565 + */ 4566 + if (WARN_ON_ONCE(console_irqwork_blocked)) 4567 + return; 4568 + 4583 4569 preempt_disable(); 4584 4570 /* 4585 4571 * Guarantee any new records can be seen by tasks preparing to wait ··· 4643 4615 __wake_up_klogd(PRINTK_PENDING_WAKEUP | PRINTK_PENDING_OUTPUT); 4644 4616 } 4645 4617 4618 + /** 4619 + * printk_trigger_flush - Attempt to flush printk buffer to consoles. 4620 + * 4621 + * If possible, flush the printk buffer to all consoles in the caller's 4622 + * context. If offloading is available, trigger deferred printing. 4623 + * 4624 + * This is best effort. Depending on the system state, console states, 4625 + * and caller context, no actual flushing may result from this call. 4626 + */ 4646 4627 void printk_trigger_flush(void) 4647 4628 { 4648 - defer_console_output(); 4629 + struct console_flush_type ft; 4630 + 4631 + printk_get_console_flush_type(&ft); 4632 + if (ft.nbcon_atomic) 4633 + nbcon_atomic_flush_pending(); 4634 + if (ft.nbcon_offload) 4635 + nbcon_kthreads_wake(); 4636 + if (ft.legacy_direct) { 4637 + if (console_trylock()) 4638 + console_unlock(); 4639 + } 4640 + if (ft.legacy_offload) 4641 + defer_console_output(); 4649 4642 } 4650 4643 4651 4644 int vprintk_deferred(const char *fmt, va_list args)