2019-07-31 05:41:21

by Fuqian Huang

[permalink] [raw]
Subject: [PATCH] drm: use trace_printk rather than printk in drm_dbg.

In drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c,
amdgpu_ih_process calls DRM_DEBUG which calls drm_dbg and
finally calls printk.
As amdgpu_ih_process is called from an interrupt handler,
and interrupt handler should be short as possible.

As printk may lead to bogging down the system or can even
create a live lock. printk should not be used in IRQ context.
Instead, trace_printk is recommended.
Link: https://lwn.net/Articles/365835

Signed-off-by: Fuqian Huang <[email protected]>
---
drivers/gpu/drm/drm_print.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c
index a17c8a14dba4..90cded140146 100644
--- a/drivers/gpu/drm/drm_print.c
+++ b/drivers/gpu/drm/drm_print.c
@@ -236,7 +236,7 @@ void drm_dbg(unsigned int category, const char *format, ...)
vaf.fmt = format;
vaf.va = &args;

- printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV",
+ trace_printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV",
__builtin_return_address(0), &vaf);

va_end(args);
--
2.11.0


2019-07-31 08:13:18

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] drm: use trace_printk rather than printk in drm_dbg.

On Wed, 2019-07-31 at 10:45 +0800, Fuqian Huang wrote:
> In drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c,
> amdgpu_ih_process calls DRM_DEBUG which calls drm_dbg and
> finally calls printk.
> As amdgpu_ih_process is called from an interrupt handler,
> and interrupt handler should be short as possible.
>
> As printk may lead to bogging down the system or can even
> create a live lock. printk should not be used in IRQ context.
> Instead, trace_printk is recommended.
> Link: https://lwn.net/Articles/365835
[]
> diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c
[]
> @@ -236,7 +236,7 @@ void drm_dbg(unsigned int category, const char *format, ...)
> vaf.fmt = format;
> vaf.va = &args;
>
> - printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV",
> + trace_printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV",
> __builtin_return_address(0), &vaf);
>
> va_end(args);

This makes all 4000+ drm_dbg/DRM_DEBUG uses emit
a trace_printk.

I suggest instead you make only the interrupt uses
use a different function and not drm_dbg.

Or maybe add an in_interrupt() check like

if (in_interrupt())
printk(KERN_DEBUG etc...)
else
trace_printk(etc...)



2019-07-31 08:26:11

by Fuqian Huang

[permalink] [raw]
Subject: Re: [PATCH] drm: use trace_printk rather than printk in drm_dbg.

Joe Perches <[email protected]> 於 2019年7月31日週三 下午2:06寫道:
>
> On Wed, 2019-07-31 at 10:45 +0800, Fuqian Huang wrote:
> > In drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c,
> > amdgpu_ih_process calls DRM_DEBUG which calls drm_dbg and
> > finally calls printk.
> > As amdgpu_ih_process is called from an interrupt handler,
> > and interrupt handler should be short as possible.
> >
> > As printk may lead to bogging down the system or can even
> > create a live lock. printk should not be used in IRQ context.
> > Instead, trace_printk is recommended.
> > Link: https://lwn.net/Articles/365835
> []
> > diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c
> []
> > @@ -236,7 +236,7 @@ void drm_dbg(unsigned int category, const char *format, ...)
> > vaf.fmt = format;
> > vaf.va = &args;
> >
> > - printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV",
> > + trace_printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV",
> > __builtin_return_address(0), &vaf);
> >
> > va_end(args);
>
> This makes all 4000+ drm_dbg/DRM_DEBUG uses emit
> a trace_printk.
>
> I suggest instead you make only the interrupt uses
> use a different function and not drm_dbg.
>
> Or maybe add an in_interrupt() check like
>
> if (in_interrupt())
> printk(KERN_DEBUG etc...)
> else
> trace_printk(etc...)

I will send a v2 patch to fix this.