On Tue, May 23, 2023 at 08:01:39PM -0300, Luis Claudio R. Goncalves wrote: > Hello, > > While working on v5.10.180-rt I stumbled over two commits from stable that > were related to deferred printing. That broke the kernel-rt builds for > v5.10-rt. I added the workaround below to the v5.10-rt-next[1] branch that > I pushed to kernelci. > > My question is whether I should use the workaround or something like > what Clark did in v5.15-rt: > > 449f5e1c4ddef Revert "printk: remove deferred printing" > > Which brings back all of deferred printing. I do hope, for my sanity, that > the answer is "workaround", but whatever you suggest is good for me :) The original patch failed on aarch64. So I expanded the patch a bit and changed description, making it an extension of the deferred printing removal already in tree. The question remains the same. :) ================ rt: printk: remove new references to deferred printing The support for deferred printing was removed in v5.10-rc1-rt1 by commit 9153e3c5cb0c9 ("printk: remove deferred printing") because: Since printing occurs either atomically or from the printing kthread, there is no need for any deferring or tracking possible recursion paths. Remove all printk context tracking. But with the recent v5.10.180 stable update these two commits were added: 32232bcd4e530 printk: declare printk_deferred_{enter,safe}() in include/linux/printk.h a992c387b4118 mm/page_alloc: fix potential deadlock on zonelist_update_seq seqlock And they break the kernel-rt builds because they depend on the nonexistent deferred printing __printk_safe_enter() and __printk_safe_exit() pair of functions and their higher level companions printk_deferred_enter() and printk_deferred_exit(). In order to work around this problem, remove the printk_deferred_* calls from mm/page_alloc.c and force the empty definitions of these functions if PREEMPT_RT is enabled. Fixes: 9153e3c5cb0c9 ("printk: remove deferred printing") Signed-off-by: Luis Claudio R. Goncalves <lgoncalv@xxxxxxxxxx> --- diff --git a/include/linux/printk.h b/include/linux/printk.h index 83c7734e98025..92e0656841128 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -609,7 +609,7 @@ static inline void print_hex_dump_debug(const char *prefix_str, int prefix_type, #define print_hex_dump_bytes(prefix_str, prefix_type, buf, len) \ print_hex_dump_debug(prefix_str, prefix_type, 16, 1, buf, len, true) -#ifdef CONFIG_PRINTK +#if defined(CONFIG_PRINTK) && !defined(CONFIG_PREEMPT_RT) extern void __printk_safe_enter(void); extern void __printk_safe_exit(void); /* @@ -619,7 +619,7 @@ extern void __printk_safe_exit(void); */ #define printk_deferred_enter __printk_safe_enter #define printk_deferred_exit __printk_safe_exit -#else +#else /* defined(CONFIG_PRINTK) && !defined(CONFIG_PREEMPT_RT) */ static inline void printk_deferred_enter(void) { } diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 5f1c50a6bebc5..7e65e3ef16e3a 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6057,7 +6057,6 @@ static void __build_all_zonelists(void *data) * tty_insert_flip_string_and_push_buffer() on other CPU might be * calling kmalloc(GFP_ATOMIC | __GFP_NOWARN) with port->lock held. */ - printk_deferred_enter(); write_seqlock(&zonelist_update_seq); #ifdef CONFIG_NUMA @@ -6092,7 +6091,6 @@ static void __build_all_zonelists(void *data) } write_sequnlock(&zonelist_update_seq); - printk_deferred_exit(); local_irq_restore(flags); } -- 2.40.1