Re: [RFC][PATCHv2 2/4] printk: move printk_safe macros to printk header

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 16, 2018 at 02:04:26PM +0900, Sergey Senozhatsky wrote:
> Make printk_safe_enter_irqsave()/etc macros available to the
> rest of the kernel.
> 
> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@xxxxxxxxx>
> ---
>  include/linux/printk.h      | 40 +++++++++++++++++++++++++++++++++++++
>  kernel/printk/internal.h    | 37 ----------------------------------
>  kernel/printk/printk_safe.c |  6 ++++--
>  3 files changed, 44 insertions(+), 39 deletions(-)
> 
> diff --git a/include/linux/printk.h b/include/linux/printk.h
> index cf3eccfe1543..75f99441fd54 100644
> --- a/include/linux/printk.h
> +++ b/include/linux/printk.h
> @@ -157,6 +157,46 @@ static inline void printk_nmi_direct_enter(void) { }
>  static inline void printk_nmi_direct_exit(void) { }
>  #endif /* PRINTK_NMI */
>  
> +#ifdef CONFIG_PRINTK
> +extern void printk_safe_enter(void);
> +extern void printk_safe_exit(void);
> +
> +#define printk_safe_enter_irqsave(flags)	\
> +	do {					\
> +		local_irq_save(flags);		\
> +		printk_safe_enter();		\
> +	} while (0)
> +
> +#define printk_safe_exit_irqrestore(flags)	\
> +	do {					\
> +		printk_safe_exit();		\
> +		local_irq_restore(flags);	\
> +	} while (0)
> +
> +#define printk_safe_enter_irq()		\
> +	do {					\
> +		local_irq_disable();		\
> +		printk_safe_enter();		\
> +	} while (0)
> +
> +#define printk_safe_exit_irq()			\
> +	do {					\
> +		printk_safe_exit();		\
> +		local_irq_enable();		\
> +	} while (0)

So I really _really_ hate all this. Utterly detest it.

That whole magic 'safe' printk buffer crap is just that crap.

Instead of this tinkering around the edges, why don't you make the main
logbuf a lockless ringbuffer and then delegate the actual printing of
that buffer to a kthread, except for earlycon, which can do synchronous
output.



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux