From nobody Tue Apr 7 12:55:30 2026 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E97B399342 for ; Fri, 13 Mar 2026 13:23:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773408202; cv=none; b=dLV5xPtLNBfYN7gC+qI+mpKdg1sj8sBLHaHErx1+OPJFiANe9XQO2DLRRYYKSaF6XZjFeopfKUubByEHfDlascMRB0SapdaCBtgfikn9ttIHeXljmenhwCuBQH+Sf74IiniEROZEIkZVN4KIB/jJnqwuhstn5OchrvyEXWeZbO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773408202; c=relaxed/simple; bh=SoyzrIXTJl0zhkZLXioIJtb1P9eJp/0gNMCq5+HdwEM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bJXGa7FSBnGbQWOHC8Ct/V6n9SI8VXsZ7MnMFnXETR4N/YVnRAyDVXr7xPcGNGrCHRnVlZApx4MrUiiox/Vj13Rm4xGwEN+kJmxhI2eoDAV/ibxPB43ah9RANFjV46WMD6gfvUj2dX92kz3yGQL+v43NDmsgj512lhmrYHiIMvg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JR77j67J; arc=none smtp.client-ip=209.85.167.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JR77j67J" Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-4671cbce626so1072377b6e.1 for ; Fri, 13 Mar 2026 06:23:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773408200; x=1774013000; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pjtw7mSJYIyVbZmpiBkB/+QzGUfrkH1ZfSuml/KOt4o=; b=JR77j67Jc20mTsIi4UIb//KiRFx8VnYkAoC3Gcl9yAGNfTjkuTI86Tw+ueliCHZqfV J/0gcWbcwMUP6HohoOzE+PFmqoUwqr2Y9KCUZSA4HOwr9X7YAPDd6KMd9QFNS+djI4b7 sJTTP5FYhFAEfHYlDXwU8JpDSY69NVT/FdV13oTWiSoQ/6hodQBKWkEOMQkVzmnI33SC A5GeNs3xGONK2UD1dvp9Elu1tsvSRvNVCzPylqPNHTYbuCnApjGSWzoFtwWCzt9H/H9p HOrXxsGCjeIHweXewTynej9ZdArUmOln4MOZzHztvT5jGhascsjmaBzMCOwG33mj/yQS V88w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773408200; x=1774013000; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=pjtw7mSJYIyVbZmpiBkB/+QzGUfrkH1ZfSuml/KOt4o=; b=dVqaLLO+1D5UJjNDXgSj8mMVZkuipVAHEGU898a0cVLQyi8K1MsEYzVdwIaNfre5mW 7r7k9dfPcz86eF6baqPIQ/5+/iJucQtgrHrRro0clhQ0ajTyCXQ8nptptQQEWMn8ofbw jLQTpw2dL1vqLh0HrK4OmB00luZcmcBfQBTjuC/0Q9XjrN2a5rnEBXnXrf4DDKpRKo3X 1dEpnlt+1Ti9CHMRtjPr1SfSOYn351uZFUxhpuPuy2oZ2slrMXxIRVkTNFxgL7J3fC3L HibKG0Stk7+C+bBkKz/nIpt1yjhBOMyL+y6s7vlhXQebTSNzZ27uHLrxvNJmMnG/2yTI XYOg== X-Forwarded-Encrypted: i=1; AJvYcCXppwIiEHQ09/qcDH9+m1cp7uOs7aHGnX7lJc+4oSDxybBYbOx3zOm3VMhgMVokM10JQ9O8Em5OeBtEE1k=@vger.kernel.org X-Gm-Message-State: AOJu0Yx7zeAHvPCbSUXWebLFLZ4Dmkv0X1sYkfQaq6wK/+45Z4GikOB2 0sNGV7VUY4W5DOUNPwmOZnAqaFaM+OuKdnJFcihK8xTtYRFyxkM9r14+ X-Gm-Gg: ATEYQzyHQKMXTlQ5xgDGwJvuDn7Zc7ZkGqx2amAwxNYh/ftG458epDJhomBoVHeCYLx qcBbo2kBrbAg5nrINLaAnbSSb5OB6z8OahKVmULPlR4B067cFO+0oG9dBJPJir3cI+Bw8PO9yt5 UyTxGHcrRi3Lt8WFuFiSjb1cFI/kw3APVtQM6uYX9R/p9HjYbPVXu/jcDNFDVcjGDbxZyVJzJBd ++67IPymvfvthazYzl5vgPZ3RCiy3OwOVAjG4vY4zdT3SWiAn7QeaEriXI/M/Dbb80sGO+K4m+U vaRlwgUIO43oI81rI/hsSFNosv/6KTr6Tu5J6+dZHAoNCXaBmxLhWSjMx3wRBjSG8ZXF9EDnwaK JZSYLdBxJ0tTTiIpMDlyK4ymgT6rLDt1uwl028jEODQrzLaHM3FgGmjq5MZfveB5vr5sJ6nmirR ma9GedrmEDY3HbbQw6XWrd1+9M3MPHrnspl6a9UhVhbANQu8Z4 X-Received: by 2002:a05:6808:c2a4:b0:467:880:7441 with SMTP id 5614622812f47-46757088cc1mr1845607b6e.18.1773408200088; Fri, 13 Mar 2026 06:23:20 -0700 (PDT) Received: from frodo (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 5614622812f47-4673434a35csm4795987b6e.20.2026.03.13.06.23.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Mar 2026 06:23:19 -0700 (PDT) From: Jim Cromie To: airlied@gmail.com, simona@ffwll.ch, jbaron@akamai.com, gregkh@linuxfoundation.org, Jim Cromie , Andrew Morton , linux-kernel@vger.kernel.org Cc: mripard@kernel.org, tzimmermann@suse.de, maarten.lankhorst@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, christian.koenig@amd.com, matthew.auld@intel.com, arunpravin.paneerselvam@amd.com, louis.chauvet@bootlin.com, skhan@linuxfoundation.org, pmladek@suse.com, ukaszb@chromium.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH v11 12/65] dyndbg: refactor param_set_dyndbg_classes and below Date: Fri, 13 Mar 2026 07:19:37 -0600 Message-ID: <20260313132103.2529746-13-jim.cromie@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260313132103.2529746-1-jim.cromie@gmail.com> References: <20260313132103.2529746-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Refactor callchain below param_set_dyndbg_classes(1) to allow mod-name specific settings. Split (1) into upper/lower fns, adding modname param to lower, and passing NULL in from upper. Below that, add the same param to ddebug_apply_class_bitmap(), and pass it thru to _ddebug_queries(), replacing NULL with the param. This allows the callchain to update the classmap in just one module, vs just all as currently done. While the sysfs param is unlikely to ever update just one module, the callchain will be used for modprobe handling, which should update only that just-probed module. In ddebug_apply_class_bitmap(), also check for actual changes to the bits before announcing them, to declutter logs. No functional change. Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 65 ++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 3ae9ecabdad1..4313c8803007 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -605,9 +605,10 @@ static int ddebug_exec_queries(char *query, const char= *modname) return nfound; } =20 -/* apply a new bitmap to the sys-knob's current bit-state */ +/* apply a new class-param setting */ static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp, - unsigned long *new_bits, unsigned long *old_bits) + unsigned long *new_bits, unsigned long *old_bits, + const char *query_modname) { #define QUERY_SIZE 128 char query[QUERY_SIZE]; @@ -615,7 +616,9 @@ static int ddebug_apply_class_bitmap(const struct ddebu= g_class_param *dcp, int matches =3D 0; int bi, ct; =20 - v2pr_info("apply: 0x%lx to: 0x%lx\n", *new_bits, *old_bits); + if (*new_bits !=3D *old_bits) + v2pr_info("apply bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, + *old_bits, query_modname ?: "'*'"); =20 for (bi =3D 0; bi < map->length; bi++) { if (test_bit(bi, new_bits) =3D=3D test_bit(bi, old_bits)) @@ -624,12 +627,16 @@ static int ddebug_apply_class_bitmap(const struct dde= bug_class_param *dcp, snprintf(query, QUERY_SIZE, "class %s %c%s", map->class_names[bi], test_bit(bi, new_bits) ? '+' : '-', dcp->flags); =20 - ct =3D ddebug_exec_queries(query, NULL); + ct =3D ddebug_exec_queries(query, query_modname); matches +=3D ct; =20 v2pr_info("bit_%d: %d matches on class: %s -> 0x%lx\n", bi, ct, map->class_names[bi], *new_bits); } + if (*new_bits !=3D *old_bits) + v2pr_info("applied bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, + *old_bits, query_modname ?: "'*'"); + return matches; } =20 @@ -684,7 +691,7 @@ static int param_set_dyndbg_classnames(const char *inst= r, const struct kernel_pa continue; } curr_bits ^=3D BIT(cls_id); - totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, dcp->bits); + totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, dcp->bits, NULL); *dcp->bits =3D curr_bits; v2pr_info("%s: changed bit %d:%s\n", KP_NAME(kp), cls_id, map->class_names[cls_id]); @@ -694,7 +701,7 @@ static int param_set_dyndbg_classnames(const char *inst= r, const struct kernel_pa old_bits =3D CLASSMAP_BITMASK(*dcp->lvl); curr_bits =3D CLASSMAP_BITMASK(cls_id + (wanted ? 1 : 0 )); =20 - totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, &old_bits); + totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, &old_bits, NULL); *dcp->lvl =3D (cls_id + (wanted ? 1 : 0)); v2pr_info("%s: changed bit-%d: \"%s\" %lx->%lx\n", KP_NAME(kp), cls_id, map->class_names[cls_id], old_bits, curr_bits); @@ -708,18 +715,9 @@ static int param_set_dyndbg_classnames(const char *ins= tr, const struct kernel_pa return 0; } =20 -/** - * param_set_dyndbg_classes - class FOO >control - * @instr: string echo>d to sysfs, input depends on map_type - * @kp: kp->arg has state: bits/lvl, map, map_type - * - * Enable/disable prdbgs by their class, as given in the arguments to - * DECLARE_DYNDBG_CLASSMAP. For LEVEL map-types, enforce relative - * levels by bitpos. - * - * Returns: 0 or <0 if error. - */ -int param_set_dyndbg_classes(const char *instr, const struct kernel_param = *kp) +static int param_set_dyndbg_module_classes(const char *instr, + const struct kernel_param *kp, + const char *mod_name) { const struct ddebug_class_param *dcp =3D kp->arg; const struct ddebug_class_map *map =3D dcp->map; @@ -756,8 +754,8 @@ int param_set_dyndbg_classes(const char *instr, const s= truct kernel_param *kp) KP_NAME(kp), inrep, CLASSMAP_BITMASK(map->length)); inrep &=3D CLASSMAP_BITMASK(map->length); } - v2pr_info("bits:%lx > %s\n", inrep, KP_NAME(kp)); - totct +=3D ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits); + v2pr_info("bits:0x%lx > %s.%s\n", inrep, mod_name ?: "*", KP_NAME(kp)); + totct +=3D ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits, mod_name); *dcp->bits =3D inrep; break; case DD_CLASS_TYPE_LEVEL_NUM: @@ -770,7 +768,7 @@ int param_set_dyndbg_classes(const char *instr, const s= truct kernel_param *kp) old_bits =3D CLASSMAP_BITMASK(*dcp->lvl); new_bits =3D CLASSMAP_BITMASK(inrep); v2pr_info("lvl:%ld bits:0x%lx > %s\n", inrep, new_bits, KP_NAME(kp)); - totct +=3D ddebug_apply_class_bitmap(dcp, &new_bits, &old_bits); + totct +=3D ddebug_apply_class_bitmap(dcp, &new_bits, &old_bits, mod_name= ); *dcp->lvl =3D inrep; break; default: @@ -779,16 +777,33 @@ int param_set_dyndbg_classes(const char *instr, const= struct kernel_param *kp) vpr_info("%s: total matches: %d\n", KP_NAME(kp), totct); return 0; } + +/** + * param_set_dyndbg_classes - classmap kparam setter + * @instr: string echo>d to sysfs, input depends on map_type + * @kp: kp->arg has state: bits/lvl, map, map_type + * + * enable/disable all class'd pr_debugs in the classmap. For LEVEL + * map-types, enforce * relative levels by bitpos. + * + * Returns: 0 or <0 if error. + */ +int param_set_dyndbg_classes(const char *instr, const struct kernel_param = *kp) +{ + return param_set_dyndbg_module_classes(instr, kp, NULL); +} EXPORT_SYMBOL(param_set_dyndbg_classes); =20 /** - * param_get_dyndbg_classes - classes reader + * param_get_dyndbg_classes - classmap kparam getter * @buffer: string description of controlled bits -> classes * @kp: kp->arg has state: bits, map * - * Reads last written state, underlying prdbg state may have been - * altered by direct >control. Displays 0x for DISJOINT, 0-N for - * LEVEL Returns: #chars written or <0 on error + * Reads last written state, underlying pr_debug states may have been + * altered by direct >control. Displays 0x for DISJOINT classmap + * types, 0-N for LEVEL types. + * + * Returns: ct of chars written or <0 on error */ int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp) { --=20 2.53.0