From nobody Sun Oct 5 16:14:09 2025 Received: from mail-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.54]) (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 5201228000B; Sun, 3 Aug 2025 03:58:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754193529; cv=none; b=tu8cv6MRpcGV3An+HC5Zl4mZ1i+px1MDRJ5osOsOYlyXVwS5duauQuh6wbTcnB1wLmu6BBMPsjjloe7d+Qk5XR/4QXN4ormogjcgHZkwTvyH8TqUxCCy4jKT8P/eT0/xW2MkazzGqI3reYzdALGOMUFD7hkJWlmR7aEMuJjoxcs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754193529; c=relaxed/simple; bh=bFptKY//Y7AeurprMAUL2pttbCSoLwQDJIXPiXNp2Bs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Oyi6l4d0KwODAtNe6CVOjT4DOnFcebQLnJD1YB71+DC5n5bRSrNX9U6lJK3qqoCCF3RbQyHz9Ws5nnrPKZxTQ9TcYuQkMtMggPhz8JyN41WaMtFk1a5LppGunfAxWb2+bk+p9nw4qt5P/1AoZVCBQD4i8dkNKOCUkPI7HNLlQVw= 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=fY0/R1Tw; arc=none smtp.client-ip=209.85.166.54 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="fY0/R1Tw" Received: by mail-io1-f54.google.com with SMTP id ca18e2360f4ac-87c6dfca35bso98238339f.1; Sat, 02 Aug 2025 20:58:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754193526; x=1754798326; 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=5v9qJvElB9xnBCx4c3TzoDVgCXyi+Hp+akyZh9KZwV0=; b=fY0/R1TwPoRp07l1YllROy9i0DlS/J54az9svRtfr+qZpsvbXP8gvjTDUMDncfBUG2 BtvxOPkuMjtoU3nPnWTvWsHGAPFDWIOV0lkiM/si5q62E1CJOCVQ6slJbfuikdOZsVht LjhqQtwrg4Ci6LInweO5u3nSyC13f6mCSjujjcNoKJNbtL09IPEN1eo7HcDyu6/vKmeO t0NbGcqtAAvr2G0JOiaDGMIwCJAS9OrrXhwoqHrz8N0xKzQRzZlCTMc+ZIZbWWGdW/lT 4JxFCmsCw/DfC0s2Mpb4lxXWZjy5J0dzM9aL2KMTUwuMhnmBxmsxcJpSKrSNgx/dj5Iy XVtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754193526; x=1754798326; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5v9qJvElB9xnBCx4c3TzoDVgCXyi+Hp+akyZh9KZwV0=; b=KWs+CNGv9pEvyOhg/wTJO2poZYGQZbNS1Dot+hhkDKxoM3GUzTPTKNv+JcgkNL5oWU oy4YJt/RZAN8+cWjZRNmm0EYZx0DIRJdIc2mct2UlVBBhx9r6BBdm7i4KpxYlB2iCCdG d9epW883OohQBMTXFG1V+rO6/NCnS2jxm6SiIrQuaMC9+fqs4Dgc1Uts0TUXxYO1Qj7O +DLsI8xVcbaOvSAa9rVMsx08ZpJDkS2cTYRBq3vQC9v1dvhaU+ihXMLXD7LCZHxR0Mgp fQQ3znVRbP1DbXh89fzBWed+sN4C5/yLr3D9jimQmzxQjFaZR+hDlHF8U2INjxcD7hPZ 4lAw== X-Forwarded-Encrypted: i=1; AJvYcCUgDW29jiZX0b8bX+fHoyAsSHwIXbr3wsymxJO/wMCpMbfsqMTIAd1D4IhhuFJxN3P8aIFySSM6K7PKier+@vger.kernel.org X-Gm-Message-State: AOJu0YxTD2nawIaJLxf7CoNi147mO92avS+22ypCaA12Cg54Jaq6qOMm mwzZ2o3cpjAx96yYNAT1GQ9WrttYFp8UfqzG3wNPSWjAooKF1mpykSbA1I1J5mUKM4U= X-Gm-Gg: ASbGnctst1cMirvQnoDwsCo3oEiZ3znaI4f/fvMAYUq0WizbAZ/fqgvl6C3UF2ViBVm xFcTxmqyrJn5wnU94UY+ahx1X6Zmqeyup8REloA/iHnwlnMcZ4+TXOWvOkOlCW4btC4US2KJDBv DQkt72xiwtmXQTMkld86IYyutL1NHgxXdOixmpIl9M2FRhzd0PhITCfFi022t7fxL8MY25gp8e3 7JebzRheGNPoZDgkXereAvZG+Gwr72I8ePDcUJXHnkGoMPfDzrmQ+ori/jIdvX7M6pF9AozTTH5 G/0chBjvs4eShVCCAcLGsYyItRm4Th+E+xIRopZp8ZXodmyw8wvZznU/0c16lgF171aTQPzQ2w6 TA4VFNDl/hST8e3c/0uo0YfQ09Ir1W+yrCX8u2x57pRp7+SGYIuz2oYgdSV6dtlNhSlX3kerIJ4 2bdg== X-Google-Smtp-Source: AGHT+IEfkx+mWG/5C96EB2sKffZquP2JNAMc+2Hxnxpx6JWp1mejb70acLW+yvRvYAwNDC6Jp/PAZg== X-Received: by 2002:a6b:ea09:0:b0:881:7c2d:20e9 with SMTP id ca18e2360f4ac-8817c2d23a7mr42429039f.2.1754193526185; Sat, 02 Aug 2025 20:58:46 -0700 (PDT) Received: from frodo.raven-morpho.ts.net (c-67-165-245-5.hsd1.co.comcast.net. [67.165.245.5]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-50a55df0940sm2268319173.106.2025.08.02.20.58.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Aug 2025 20:58:45 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com Cc: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, groeck@google.com, yanivt@google.com, bleung@google.com, 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 v4 09/58] dyndbg: refactor param_set_dyndbg_classes and below Date: Sat, 2 Aug 2025 21:57:27 -0600 Message-ID: <20250803035816.603405-10-jim.cromie@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250803035816.603405-1-jim.cromie@gmail.com> References: <20250803035816.603405-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. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- v3 s/modnm/mod_name/g --- 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 d9268d051a106..96cd31c457e2e 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -593,9 +593,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]; @@ -603,7 +604,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)) @@ -612,12 +615,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 @@ -672,7 +679,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]); @@ -682,7 +689,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); @@ -696,18 +703,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; @@ -744,8 +742,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: @@ -758,7 +756,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: @@ -767,16 +765,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.50.1