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: 13442433 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CC56AC00142 for ; Wed, 1 Nov 2023 00:27:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ViB3/Pk39CmZC/MNo/bLO2iD+7bSl7zYoZWvu1vdInU=; b=lZ+Rvff7YUHuIe VRPyjYXnqKWWHsS3hSUQu3aIlZUWF4gM4mF/jAFIbfhSqXxtHQ80LBc1jX6z3ztoY0aZWdg2Ob8JC DVAWmb135t+HnbFBCZTOAsrsHo6BDk/7+rH5fx7vYFKJIAzxEmz9oHpmCG+33gsJrEmYZSFN38x+g DK9pTBVvABDJCfbeodCveP7VPMYucUro4LmJ5QvjaYo2XHFfPcMfpVmP16dgkcaQw+SCnzsJDzsO3 eUXc2Og6GeOThG15hqinJylp7h0mo+3A3mlFMp5vu9pAC7VgSazbEuZbIauPTgPOFFv+NmRZ0QYUL 1aDppQ+s2fgpgiHNcz6Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxz4K-006Ogp-1x; Wed, 01 Nov 2023 00:26:48 +0000 Received: from mail-il1-x132.google.com ([2607:f8b0:4864:20::132]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxz3v-006OFB-38 for linux-arm-kernel@lists.infradead.org; Wed, 01 Nov 2023 00:26:27 +0000 Received: by mail-il1-x132.google.com with SMTP id e9e14a558f8ab-35749078a59so20958975ab.3 for ; 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=lists.infradead.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=bOCWWX8tdmtw7WqX7SDVuL08DmG6YQRFHfJhCpGCwECySNNierkVYbi4FgZy7RXmL5 +oHdZUOWBy30wj7Ht70fbhXl4OnQU1402JY4/EnPZx3l5fppL21/Vf+s7eZZRInLGS7D kSBp5xSLmlmdqH6rnAxZzx4btYoszvH5LbCEtGypbJSiREvIL5NKwV9gbIDHPbj0Mofl 8glg2DkqZrdbUOO7ET3mETISEwbfMmVdw4tG8IGQk7kdg4gF4TRlNBULUYjsakHocIGh NQsAfyTsfN0ZV/XArw3R7ekSRz7igocMRJ1H8UfnuoEBY33Hbx2+Lv6QL67ImnzsB0Do 4awA== 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=HrbGSHwHLQNWv2Eblq1eq8NSOANW7PpKWI0nWHPbwZIAIXEtdGL9eHPOEiSncNP5ll guDLxF2cwL4jz3gm0OMY8YV793Mmsf0s+TjsOZz79iTf5c5CJhf7d+dKiqiYDx8VQWEp noK9ycM1tEkg8ksA9xjRO2JM8CXkJ9UQQ/AVTnyW8AuGzyxBFwFTxUZS4NE4fZ8ILbPz HOWlD2utpoqcoYw430SCl1YgMIb6BFv6lIY3PCD/mPqYvG29eE5SVc2cmqp2giDu22Wq s3mh6gYTDb7xHdV8lRaFcwAo+TQ6NMZtMUrds8LbKvQnQWxoqcZjgDCMcZApfFMnUSXd gonw== X-Gm-Message-State: AOJu0Yw2PtO4d3BlOSL/8S3cbPAJ4vPNwKt6Tji25vIUFVhh69uadQsd Rm28AcmRH7HbSeiuUyN4xIo= 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231031_172624_024264_65E26871 X-CRM114-Status: GOOD ( 13.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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