From patchwork Wed Nov 1 00:25:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 13442361 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B218CC4167D for ; Wed, 1 Nov 2023 00:26:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231603AbjKAA0V (ORCPT ); Tue, 31 Oct 2023 20:26:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232206AbjKAA0U (ORCPT ); Tue, 31 Oct 2023 20:26:20 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64400F4; Tue, 31 Oct 2023 17:26:18 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-7a6774da682so237910639f.3; Tue, 31 Oct 2023 17:26:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698798377; x=1699403177; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Crihteq14mq1SNgvZmjOWL5sINKEUJsXZXrqKikBaFA=; b=S7hZDo5x5QiwstdqXNGe7Ho9HLxYe9ocSofq0BgFxYqyIQZ8Mp2HLFlbdX9Yxi6f2M m9hpg4D1g82//Xf1egGSgJIwjSbf2iXd75ErU469vGvIoq0FdgTHIOWnAREkRA1sB0qt FNLWJ7F0X8+5T5OUCdHNSPE/bG9vI+nIUthYCaSvq01ACv/gfXIC+WFBI9xZkSFf2IGC QRmxx1gKSwywo94HrxKOiv7jW/xZTKZfewcCXT8MyP3sk17WpuWeZzoDtKlffpN2AUoV jcTIntEiglXX/yG9yU3QgWJY0qbn2pbHNCbWSpFgO597n8QxDnaMtueCx+nRfzZuQejZ 0tdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698798377; x=1699403177; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Crihteq14mq1SNgvZmjOWL5sINKEUJsXZXrqKikBaFA=; b=RQwRDgMFUY3fSGUPnZPcIlkc+68Xv3xz8NyqMHygygiqnYBRZPHQt/h/M2dzszoDHj VEYz6RKcgRzg3Mn087ayh/yuFqhq+QyBhI02Be0ruLw5GzILjD7rogyVMPrej/AJ6AYo aSrOPA1P8gabsin0PiEgZlv6aVwiVW40FbDP2EmwCG5v+dSUvZ9MLhJ4nCqgNsEHr57L kjZYCd/UVJlwURlUBhKDk8ynFUf2Lxk8CMsQfTMGoSUT+LmukUByKlyESk+LyU30lIKC x379uKXFLslShf3zoIJKbF123vqV7ishBYcqgHYT6mN1hd9+tL/UQeE9MWEQedZYpgyq pANg== X-Gm-Message-State: AOJu0YxhoA4qk16um/ZpImbtdn9bzIIU+8sNTmmUpUM/2J0+iUGd317H /Qoww9c8BDz2vytHlr2X6yx294sFnWVAXg== X-Google-Smtp-Source: AGHT+IEvAaoR06BIVnuyKsQIdXDCjeoXMJTD3Hx+wBd5i6t6IGdzUzFxe+C0CccvWJTiQOS040zF+A== X-Received: by 2002:a05:6e02:3893:b0:359:9c0:de73 with SMTP id cn19-20020a056e02389300b0035909c0de73mr14028636ilb.26.1698798377422; Tue, 31 Oct 2023 17:26:17 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id t1-20020a92c901000000b00357cc8df1d5sm141701ilp.68.2023.10.31.17.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 17:26:16 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: lb@semihalf.com, linux@rasmusvillemoes.dk, joe@perches.com, mcgrof@kernel.org, daniel.vetter@ffwll.ch, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, groeck@google.com, yanivt@google.com, bleung@google.com, linux-doc@vger.kernel.org, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v7d 00/23] fix DRM_USE_DYNAMIC_DEBUG=y regression Date: Tue, 31 Oct 2023 18:25:46 -0600 Message-ID: <20231101002609.3533731-1-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org hi Jason, DRM-folk (v7d - refreshed onto v6.6, patch-21 squashed into 14) This patchest fixes the chicken-egg initialization problem in the 1st version of ddebug-class-maps, that DRM-CI uncovered. The root-problem was DECLARE_DYNDBG_CLASSMAP, which broke the K&R rule: "define once, refer many". In patch 14 it is replaced by: DYNDBG_CLASSMAP_DEFINE - define and export a struct ddebug_class_map DYNDBG_CLASSMAP_USE - ref the exported struct test-dynamic-debug is also extended with a -submod.ko, in order to recapitulate the drm & drivers initialization scenario. The final blocking bug was a missing __align(8) on the ddebug_class_user record inserted by DYNDBG_CLASSMAP_USE. This caused DRM=y (builtin only) to have a corrupt record for drm_kms_helper (a builtin dependent). Curiously, a clang build did not exhibit this problem. Heres a part of dmesg, for a DRM=y kernel, booted with dynamic_debug.verbose=3 drm.debug=0x10 [ 0.466747] dyndbg: add-module: drm 406 sites [ 0.467569] dyndbg: classes[0]: module:drm base:0 len:10 type:DISJOINT_BITS [ 0.467743] dyndbg: module:drm attached 1 classes [ 0.468557] dyndbg: builtin class: module:drm base:0 len:10 type:DISJOINT_BITS [ 0.468742] dyndbg: found kp:drm.debug =0x10 [ 0.468743] dyndbg: mapped to: module:drm base:0 len:10 type:DISJOINT_BITS [ 0.469742] dyndbg: drm.debug: classbits: 0x10 [ 0.470573] dyndbg: apply bitmap: 0x10 to: 0x0 for drm [ 0.470743] dyndbg: query 0: "class DRM_UT_ATOMIC +p" mod:drm [ 0.471743] dyndbg: split into words: "class" "DRM_UT_ATOMIC" "+p" [ 0.472743] dyndbg: op='+' flags=0x1 maskp=0xffffffff [ 0.473679] dyndbg: parsed: func="" file="" module="drm" format="" lineno=0-0 class=DRM_UT_ATOMIC [ 0.473749] dyndbg: processed 1 queries, with 0 matches, 0 errs [ 0.474742] dyndbg: bit_4: 0 matches on class: DRM_UT_ATOMIC -> 0x10 [ 0.475742] dyndbg: applied bitmap: 0x10 to: 0x0 for drm [ 0.476686] dyndbg: 406 debug prints in module drm [ 0.476743] dyndbg: add-module: drm_kms_helper 93 sites [ 0.477727] dyndbg: class_ref[0] drm_kms_helper -> drm module:drm base:0 len:10 type:DISJOINT_BITS [ 0.477743] dyndbg: builtin class: module:drm base:0 len:10 type:DISJOINT_BITS [ 0.478742] dyndbg: found kp:drm.debug =0x10 [ 0.478743] dyndbg: mapped to: module:drm base:0 len:10 type:DISJOINT_BITS [ 0.479743] dyndbg: drm.debug: classbits: 0x10 [ 0.480592] dyndbg: apply bitmap: 0x10 to: 0x0 for drm_kms_helper [ 0.480743] dyndbg: query 0: "class DRM_UT_ATOMIC +p" mod:drm_kms_helper [ 0.481743] dyndbg: split into words: "class" "DRM_UT_ATOMIC" "+p" [ 0.482743] dyndbg: op='+' flags=0x1 maskp=0xffffffff [ 0.483743] dyndbg: parsed: func="" file="" module="drm_kms_helper" format="" lineno=0-0 class=DRM_UT_ATOMIC [ 0.484750] dyndbg: class-ref: drm_kms_helper.DRM_UT_ATOMIC module:drm_kms_helper nd:93 nc:0 nu:1 [ 0.485809] dyndbg: processed 1 queries, with 44 matches, 0 errs [ 0.486742] dyndbg: bit_4: 44 matches on class: DRM_UT_ATOMIC -> 0x10 [ 0.487742] dyndbg: applied bitmap: 0x10 to: 0x0 for drm_kms_helper [ 0.488743] dyndbg: attach-client-module: module:drm_kms_helper nd:93 nc:0 nu:1 [ 0.489742] dyndbg: 93 debug prints in module drm_kms_helper Id like to get this into linux-next, so widespread testing is appreciated. lkp-robot reported BUILD SUCCESS on it, Im running it on my amdgpu desktop. I have scripts to operate the test-module if anyone wants them. Patches are also at https://github.com/jimc/linux/tree/dd-fix-7d Jim Cromie (23): test-dyndbg: fixup CLASSMAP usage error dyndbg: reword "class unknown," to "class:_UNKNOWN_" dyndbg: make ddebug_class_param union members same size dyndbg: replace classmap list with a vector dyndbg: ddebug_apply_class_bitmap - add module arg, select on it dyndbg: split param_set_dyndbg_classes to module/wrapper fns dyndbg: drop NUM_TYPE_ARRAY dyndbg: reduce verbose/debug clutter dyndbg: silence debugs with no-change updates dyndbg: tighten ddebug_class_name() 1st arg type dyndbg: tighten fn-sig of ddebug_apply_class_bitmap dyndbg: reduce verbose=3 messages in ddebug_add_module dyndbg-API: remove DD_CLASS_TYPE_(DISJOINT|LEVEL)_NAMES and code dyndbg-API: fix CONFIG_DRM_USE_DYNAMIC_DEBUG regression dyndbg: refactor ddebug_classparam_clamp_input dyndbg-API: promote DYNDBG_CLASSMAP_PARAM to API dyndbg-doc: add classmap info to howto dyndbg: reserve flag bit _DPRINTK_FLAGS_PREFIX_CACHED dyndbg: add _DPRINTK_FLAGS_INCL_LOOKUP dyndbg: refactor *dynamic_emit_prefix drm: use correct ccflags-y spelling drm-drivers: DRM_CLASSMAP_USE in 2nd batch of drivers, helpers drm: restore CONFIG_DRM_USE_DYNAMIC_DEBUG un-BROKEN .../admin-guide/dynamic-debug-howto.rst | 60 ++- MAINTAINERS | 2 +- drivers/gpu/drm/Kconfig | 3 +- drivers/gpu/drm/Makefile | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 12 +- drivers/gpu/drm/display/drm_dp_helper.c | 12 +- drivers/gpu/drm/drm_crtc_helper.c | 12 +- drivers/gpu/drm/drm_gem_shmem_helper.c | 2 + drivers/gpu/drm/drm_print.c | 35 +- drivers/gpu/drm/gud/gud_drv.c | 2 + drivers/gpu/drm/i915/i915_params.c | 12 +- drivers/gpu/drm/mgag200/mgag200_drv.c | 2 + drivers/gpu/drm/nouveau/nouveau_drm.c | 12 +- drivers/gpu/drm/qxl/qxl_drv.c | 2 + drivers/gpu/drm/radeon/radeon_drv.c | 2 + drivers/gpu/drm/udl/udl_main.c | 2 + drivers/gpu/drm/vkms/vkms_drv.c | 2 + drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 + include/asm-generic/vmlinux.lds.h | 1 + include/drm/drm_print.h | 12 +- include/linux/dynamic_debug.h | 121 +++-- kernel/module/main.c | 3 + lib/Kconfig.debug | 24 +- lib/Makefile | 3 + lib/dynamic_debug.c | 458 +++++++++++------- lib/test_dynamic_debug.c | 131 ++--- lib/test_dynamic_debug_submod.c | 17 + 27 files changed, 584 insertions(+), 365 deletions(-) create mode 100644 lib/test_dynamic_debug_submod.c