[1/2] printk: Add new pr_*_deferred_once() variants
diff mbox series

Message ID 20210123233741.3614408-2-qais.yousef@arm.com
State New, archived
Headers show
Series
  • Fix BUG: Invalid wait context in hrtimer_interrupt()
Related show

Commit Message

Qais Yousef Jan. 23, 2021, 11:37 p.m. UTC
To allow users in code where printk is not allowed.

Signed-off-by: Qais Yousef <qais.yousef@arm.com>
---
 include/linux/printk.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Comments

Peter Zijlstra Jan. 25, 2021, 10:37 a.m. UTC | #1
On Sat, Jan 23, 2021 at 11:37:40PM +0000, Qais Yousef wrote:
> To allow users in code where printk is not allowed.
> 
> Signed-off-by: Qais Yousef <qais.yousef@arm.com>
> ---
>  include/linux/printk.h | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/include/linux/printk.h b/include/linux/printk.h
> index fe7eb2351610..92c0978c7b44 100644
> --- a/include/linux/printk.h
> +++ b/include/linux/printk.h
> @@ -480,21 +480,45 @@ extern int kptr_restrict;
>  	printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
>  /* no pr_cont_once, don't do that... */
>  
> +#define pr_emerg_deferred_once(fmt, ...)				\
> +	printk_deferred_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
> +#define pr_alert_deferred_once(fmt, ...)				\
> +	printk_deferred_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
> +#define pr_crit_deferred_once(fmt, ...)					\
> +	printk_deferred_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
> +#define pr_err_deferred_once(fmt, ...)					\
> +	printk_deferred_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
> +#define pr_warn_deferred_once(fmt, ...)					\
> +	printk_deferred_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
> +#define pr_notice_deferred_once(fmt, ...)				\
> +	printk_deferred_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
> +#define pr_info_deferred_once(fmt, ...)					\
> +	printk_deferred_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
> +/* no pr_cont_deferred_once, don't do that... */

I absolutely detest this.. the whole _deferred thing is an abomination.

We should be very close to printk not needing this anymore, printk
people?
John Ogness Jan. 25, 2021, 10:58 a.m. UTC | #2
On 2021-01-25, Peter Zijlstra <peterz@infradead.org> wrote:
> On Sat, Jan 23, 2021 at 11:37:40PM +0000, Qais Yousef wrote:
>> To allow users in code where printk is not allowed.
>> 
>> Signed-off-by: Qais Yousef <qais.yousef@arm.com>
>> ---
>>  include/linux/printk.h | 24 ++++++++++++++++++++++++
>>  1 file changed, 24 insertions(+)
>> 
>> diff --git a/include/linux/printk.h b/include/linux/printk.h
>> index fe7eb2351610..92c0978c7b44 100644
>> --- a/include/linux/printk.h
>> +++ b/include/linux/printk.h
>> @@ -480,21 +480,45 @@ extern int kptr_restrict;
>>  	printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
>>  /* no pr_cont_once, don't do that... */
>>  
>> +#define pr_emerg_deferred_once(fmt, ...)				\
>> +	printk_deferred_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
>> +#define pr_alert_deferred_once(fmt, ...)				\
>> +	printk_deferred_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
>> +#define pr_crit_deferred_once(fmt, ...)					\
>> +	printk_deferred_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
>> +#define pr_err_deferred_once(fmt, ...)					\
>> +	printk_deferred_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
>> +#define pr_warn_deferred_once(fmt, ...)					\
>> +	printk_deferred_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
>> +#define pr_notice_deferred_once(fmt, ...)				\
>> +	printk_deferred_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
>> +#define pr_info_deferred_once(fmt, ...)					\
>> +	printk_deferred_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
>> +/* no pr_cont_deferred_once, don't do that... */
>
> I absolutely detest this.. the whole _deferred thing is an
> abomination.

And it will disappear at some point.

> We should be very close to printk not needing this anymore, printk
> people?

It will disappear once console printing threads are introduced. We
probably still have a few kernel releases until we see that. First we
need to finish merging full lockless access, remove the safe buffers,
and merge the atomic consoles.

John Ogness
Qais Yousef Jan. 25, 2021, 7:46 p.m. UTC | #3
On 01/25/21 12:04, John Ogness wrote:
> On 2021-01-25, Peter Zijlstra <peterz@infradead.org> wrote:
> > On Sat, Jan 23, 2021 at 11:37:40PM +0000, Qais Yousef wrote:
> >> To allow users in code where printk is not allowed.
> >> 
> >> Signed-off-by: Qais Yousef <qais.yousef@arm.com>
> >> ---
> >>  include/linux/printk.h | 24 ++++++++++++++++++++++++
> >>  1 file changed, 24 insertions(+)
> >> 
> >> diff --git a/include/linux/printk.h b/include/linux/printk.h
> >> index fe7eb2351610..92c0978c7b44 100644
> >> --- a/include/linux/printk.h
> >> +++ b/include/linux/printk.h
> >> @@ -480,21 +480,45 @@ extern int kptr_restrict;
> >>  	printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
> >>  /* no pr_cont_once, don't do that... */
> >>  
> >> +#define pr_emerg_deferred_once(fmt, ...)				\
> >> +	printk_deferred_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
> >> +#define pr_alert_deferred_once(fmt, ...)				\
> >> +	printk_deferred_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
> >> +#define pr_crit_deferred_once(fmt, ...)					\
> >> +	printk_deferred_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
> >> +#define pr_err_deferred_once(fmt, ...)					\
> >> +	printk_deferred_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
> >> +#define pr_warn_deferred_once(fmt, ...)					\
> >> +	printk_deferred_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
> >> +#define pr_notice_deferred_once(fmt, ...)				\
> >> +	printk_deferred_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
> >> +#define pr_info_deferred_once(fmt, ...)					\
> >> +	printk_deferred_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
> >> +/* no pr_cont_deferred_once, don't do that... */
> >
> > I absolutely detest this.. the whole _deferred thing is an
> > abomination.
> 
> And it will disappear at some point.
> 
> > We should be very close to printk not needing this anymore, printk
> > people?
> 
> It will disappear once console printing threads are introduced. We
> probably still have a few kernel releases until we see that. First we
> need to finish merging full lockless access, remove the safe buffers,
> and merge the atomic consoles.

Okay. As I said in the cover letter, I didn't think the addition of these new
macros looked like a win overall.

I will drop this patch and just open code the use of printk_deferred_once() in
hrtimer_interrupt(). Which should be easier to fix later when it should
disappear.

Thanks

--
Qais Yousef

Patch
diff mbox series

diff --git a/include/linux/printk.h b/include/linux/printk.h
index fe7eb2351610..92c0978c7b44 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -480,21 +480,45 @@  extern int kptr_restrict;
 	printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
 /* no pr_cont_once, don't do that... */
 
+#define pr_emerg_deferred_once(fmt, ...)				\
+	printk_deferred_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_alert_deferred_once(fmt, ...)				\
+	printk_deferred_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_crit_deferred_once(fmt, ...)					\
+	printk_deferred_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_err_deferred_once(fmt, ...)					\
+	printk_deferred_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_warn_deferred_once(fmt, ...)					\
+	printk_deferred_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_notice_deferred_once(fmt, ...)				\
+	printk_deferred_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_info_deferred_once(fmt, ...)					\
+	printk_deferred_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
+/* no pr_cont_deferred_once, don't do that... */
+
 #if defined(DEBUG)
 #define pr_devel_once(fmt, ...)					\
 	printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_devel_deferred_once(fmt, ...)			\
+	printk_deferred_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
 #else
 #define pr_devel_once(fmt, ...)					\
 	no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_devel_deferred_once(fmt, ...)			\
+	no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
 #endif
 
 /* If you are writing a driver, please use dev_dbg instead */
 #if defined(DEBUG)
 #define pr_debug_once(fmt, ...)					\
 	printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_debug_deferred_once(fmt, ...)			\
+	printk_deferred_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
 #else
 #define pr_debug_once(fmt, ...)					\
 	no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_debug_deferred_once(fmt, ...)			\
+	no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
 #endif
 
 /*