rt: printk: create bogus deferred print functions
Subsystems (3)
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 :)
Best, Luis
===
commit c14d0593588daa7d53f66bf1e787f982daf8cc98
Author: Luis Claudio R. Goncalves <[email protected]> Date: Tue May 23 19:17:23 2023 -0300
rt: printk: create bogus deferred print functions
Since v5.10-rc1-rt1 we carry this change:
commit 9153e3c5cb0c96242fa85ab151b9b29647634c9a
Author: John Ogness <[email protected]>
Date: Mon Oct 19 22:53:30 2020 +0206
printk: remove deferred printing
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 __printk_safe_enter() and __printk_safe_exit() pair of functions.
In order to work around that problem, while minimizing the code delta, make the two related functions, printk_deferred_enter() and printk_deferred_exit() into no-ops.
include/linux/printk.h +2 -2
@@ -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 ) { }
Re: rt: printk: create bogus deferred print functions (V2)
Quoted 7 lines · Luis Claudio R. Goncalves
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.
Quoted 7 lines
My question is whether I should use the workaround or something like what Clark did in v5.15-rt:
449f5e1c4ddefRevert "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.
---
include/linux/printk.h +2 -2
@@ -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 ) { }
mm/page_alloc.c +0 -2
@@ -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); }
Signature · 1 line
2.40.1
Re: rt: printk: create bogus deferred print functions (V2)
Quoted 11 lines · Luis Claudio R. Goncalves
Quoted 7 lines
My question is whether I should use the workaround or something like what Clark did in v5.15-rt:
449f5e1c4ddefRevert "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. :)
I missed that this got reverted in the v5.15 tree. Please see what I wrote to your release email. And this deferred thingy needs to go back into v5.15.
Sebastian