diff mbox series

[v6,32/57] nouveau: adapt NV_DEBUG, NV_ATOMIC to use DRM.debug

Message ID 20220904214134.408619-33-jim.cromie@gmail.com (mailing list archive)
State New, archived
Headers show
Series DYNDBG: opt-in class'd debug for modules, use in drm. | expand

Commit Message

Jim Cromie Sept. 4, 2022, 9:41 p.m. UTC
These 2 macros used drm_debug_enabled() on DRM_UT_{DRIVER,ATOMIC}
respectively, replace those with drm_dbg_##cat invocations.

this results in new class'd prdbg callsites:

:#> grep nouveau /proc/dynamic_debug/control | grep class | wc
    116    1130   15584
:#> grep nouveau /proc/dynamic_debug/control | grep class | grep DRIVER | wc
     74     704    9709
:#> grep nouveau /proc/dynamic_debug/control | grep class | grep ATOMIC | wc
     31     307    4237
:#> grep nouveau /proc/dynamic_debug/control | grep class | grep KMS | wc
     11     119    1638

the KMS entries are due to existing uses of drm_dbg_kms().

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 drivers/gpu/drm/nouveau/nouveau_drv.h | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

Comments

Timur Tabi March 6, 2023, 6:49 p.m. UTC | #1
On Sun, Sep 4, 2022 at 4:48 PM Jim Cromie <jim.cromie@gmail.com> wrote:
>
> These 2 macros used drm_debug_enabled() on DRM_UT_{DRIVER,ATOMIC}
> respectively, replace those with drm_dbg_##cat invocations.
>
> this results in new class'd prdbg callsites:
>
> :#> grep nouveau /proc/dynamic_debug/control | grep class | wc
>     116    1130   15584
> :#> grep nouveau /proc/dynamic_debug/control | grep class | grep DRIVER | wc
>      74     704    9709
> :#> grep nouveau /proc/dynamic_debug/control | grep class | grep ATOMIC | wc
>      31     307    4237
> :#> grep nouveau /proc/dynamic_debug/control | grep class | grep KMS | wc
>      11     119    1638
>
> the KMS entries are due to existing uses of drm_dbg_kms().
>
> Signed-off-by: Jim Cromie <jim.cromie@gmail.com>

Has this patch set been forgotten?  It was posted six months ago and
there's no sign that it was picked up.

The changes to drm_debug_enabled have impacted NV_DEBUG and NV_ATOMIC
and something needs to be fixed.  I posted a simpler patch a few weeks
ago, but maybe Jim's is better.
Jim Cromie March 7, 2023, 5:10 a.m. UTC | #2
On Mon, Mar 6, 2023 at 11:50 AM Timur Tabi <timur@kernel.org> wrote:
>
> On Sun, Sep 4, 2022 at 4:48 PM Jim Cromie <jim.cromie@gmail.com> wrote:
> >
> > These 2 macros used drm_debug_enabled() on DRM_UT_{DRIVER,ATOMIC}
> > respectively, replace those with drm_dbg_##cat invocations.
> >
> > this results in new class'd prdbg callsites:
> >
> > :#> grep nouveau /proc/dynamic_debug/control | grep class | wc
> >     116    1130   15584
> > :#> grep nouveau /proc/dynamic_debug/control | grep class | grep DRIVER | wc
> >      74     704    9709
> > :#> grep nouveau /proc/dynamic_debug/control | grep class | grep ATOMIC | wc
> >      31     307    4237
> > :#> grep nouveau /proc/dynamic_debug/control | grep class | grep KMS | wc
> >      11     119    1638
> >
> > the KMS entries are due to existing uses of drm_dbg_kms().
> >
> > Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
>
> Has this patch set been forgotten?  It was posted six months ago and
> there's no sign that it was picked up.

Not forgotten, but chicken-egg problems with initializing prdbgs/drm-dbgs
in drm.ko & dependent drivers pushed it down in priority.
I have a fix for them, which needs Jasons "lets use notifier-chain" patches,
which is now in Luis' modules-next.

After that fix lands, I can revisit this one.

> The changes to drm_debug_enabled have impacted NV_DEBUG and NV_ATOMIC
> and something needs to be fixed.  I posted a simpler patch a few weeks
> ago, but maybe Jim's is better.

I couldnt find it on lore, can you post a link ?

But I do recall something about chatty logs, caused by

#define drm_debug_enabled_instrumented(category)                        \
        ({                                                              \
                pr_debug("todo: is this frequent enough to optimize ?\n"); \
                drm_debug_enabled_raw(category);                        \
        })

If thats the case, it does seem to be frequent enough to silence.

Before you do so, could you turn on the "mfl" flags,
and count occurrences of each callsite ?

echo module nouveau +mfl > /proc/dynamic_debug/control

the numbers and duration of enablement would inform any optimization,
including those available in the subject patchset.

thanks,
Jim
diff mbox series

Patch

diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 84df5ddae4d0..3b8a76004b57 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -39,6 +39,7 @@ 
  */
 
 #include <linux/notifier.h>
+#include <linux/dynamic_debug.h>
 
 #include <nvif/client.h>
 #include <nvif/device.h>
@@ -263,13 +264,16 @@  void nouveau_drm_device_remove(struct drm_device *dev);
 #define NV_WARN(drm,f,a...) NV_PRINTK(warn, &(drm)->client, f, ##a)
 #define NV_INFO(drm,f,a...) NV_PRINTK(info, &(drm)->client, f, ##a)
 
-#define NV_DEBUG(drm,f,a...) do {                                              \
-	if (drm_debug_enabled(DRM_UT_DRIVER))                                  \
-		NV_PRINTK(info, &(drm)->client, f, ##a);                       \
+#define NV_DRMDBG(cat,c,f,a...) do {				\
+	struct nouveau_cli *_cli = (c);				\
+	drm_dbg_##cat(_cli->drm->dev, "%s: "f, _cli->name, ##a); \
 } while(0)
-#define NV_ATOMIC(drm,f,a...) do {                                             \
-	if (drm_debug_enabled(DRM_UT_ATOMIC))                                  \
-		NV_PRINTK(info, &(drm)->client, f, ##a);                       \
+
+#define NV_DEBUG(drm,f,a...) do {					\
+	NV_DRMDBG(driver, &(drm)->client, f, ##a);			\
+} while(0)
+#define NV_ATOMIC(drm,f,a...) do {					\
+	NV_DRMDBG(atomic, &(drm)->client, f, ##a);			\
 } while(0)
 
 #define NV_PRINTK_ONCE(l,c,f,a...) NV_PRINTK(l##_once,c,f, ##a)