From nobody Tue Feb 10 03:44:58 2026 Received: from mail-io1-f49.google.com (mail-io1-f49.google.com [209.85.166.49]) (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 44A6F21504D for ; Sat, 25 Jan 2025 06:47:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737787641; cv=none; b=b3vFi/XqKIUmKcepqR+vEK4up9A1eP7hLFt4xyjfUt7QltN1I0Z6+UYubdxrTzJteb4Ofk+1fzOcfADorv2woh2DwpbmPsGi3X2wptB1cruMGEBDmu5BKdtmtOm5ZkiH2Hm1p5dwE4JxfjIzsW+4hIAuU7FKthhaSZ9LHTCFm0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737787641; c=relaxed/simple; bh=mhIYPHL/Ok4i9nfyLpKtTml5RWbBA6+tIXNMr9jjkBs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cPBBEQVUawnsxhsbCMqZhDHUaxxKvHhjGNhxWjXJk3h2uOZqcN3rlDtKubBoXcvzy832Y55vntUiB9oCFsU6MJsPcYxTWUFxvPjWpkQULvWFjN5mbLOYgIePsPAJhej3Key5zWQ2xeum8e8qAzXpVxda6UhLrGzIlXxk3e+WNcA= 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=dOKU8/MN; arc=none smtp.client-ip=209.85.166.49 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="dOKU8/MN" Received: by mail-io1-f49.google.com with SMTP id ca18e2360f4ac-844cd85f5ebso196408139f.3 for ; Fri, 24 Jan 2025 22:47:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737787638; x=1738392438; 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=4odqpWJj3urSpAKp7yVqXYnx87D5Dkk2hzn6/0RI0nQ=; b=dOKU8/MNOv5zVw0BSqdRHTB5F6L4Zf8/EpXLqiFgUZZYJtIwsZXIjdadQ3BhOIavsn zvdMt0sDyQCaQfwlEgFqRqYfdBV6SafzRpl9B+QNeBJLyGDe/ws1QWM7ka5uklUASDi5 EEM7/gUJrVINW7UguPu7M/FjWQJkiw4FUxaoF/xYpbMfSdbuSROXXd8V5lHniRRFm1LX aR5gK8rMsEmDJZyyQsco4aDrXBsn+MTGRB4G9rlHT8U80U3x46cj46CbmpUzcal5vG85 4eW4JqaWH3zvlMTlNXIjL7GJ5hzlgEZw8Tb03UKPkv2J1hdMc/9vFF7jUlqW38JmVOnB a9kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737787638; x=1738392438; 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=4odqpWJj3urSpAKp7yVqXYnx87D5Dkk2hzn6/0RI0nQ=; b=XJBQnsMwacYiqFHz6KfJvVJGedFItCP5vvgzsyCxzzWdAvSbb4GtdddxaedAYwYkjk qD4x2ZL2UQH5veMuQT2rsJzCvXIG9Lsb/LEcFn0COF1EP5CpTvZPsIs9DE17Zr0A7NZ0 r/9JPphOzE5y+RE5imGtjDsDKp+g6zMOlFG6YgIlNEL9JpvKuCUJR0E1e3gBPYiyh0ti 8l9E6G/QlqpYNDE0dZNOcmrcCctibLFVsFKp3ceVejjXB7DI1jkiHWLHen9GhheHkv0j ESgwXCNViWyvmjHskvUT0BHR75V0bZIcDpUbhCjAgKtDyXjIJd8uHD3u24OfqX+UUfqL GG9A== X-Gm-Message-State: AOJu0YwZLdfgikjQ40GT7mys9y5W3bbD5AO0oQGM2uaPyxZo2iBUOYeZ IzwWxlpAOWs4PXa1lExVRla8xjP7g89Yi9fei7nWsemdGbhNimpinC96KA== X-Gm-Gg: ASbGncvPawEYY3+2AAJDPoU3JjQ3n4hlEnobIkOOCt/Q3Gcv3xyfrjBiqsEv8ADN92J nvo2OYuE+r4oNACntWEOecu9/HSyXlNiO6Zn4LUN8sEU/lGvP5BpLR6y7o+qBJDmcMhuDw/Kex7 tAN4q1B214QR5XbWb7e62IumwhiORr/ko+Znn98OHCEuIvc3hRfy9f/gSQcG7/s6KSrAmOzeaHG 2F+Zc/kYCwUov4Lhk33iDgzOFqUT3uDtqa2nbY2Yqn3yIWeNkom6wZzPmNY8matBgajaW1Xl748 3qaa1EZ425izYBWq6em40gNLvh8YxcNdX5cOYg== X-Google-Smtp-Source: AGHT+IFIY03EaHMd/D6gQtTi8TOeZoophYBCZcpKsV2aOF16dKNLKKSpMulBpaJn1LdTAQ/2EmMthA== X-Received: by 2002:a05:6602:6c06:b0:849:a2bb:ffde with SMTP id ca18e2360f4ac-851b61f90fdmr3893348239f.4.1737787638040; Fri, 24 Jan 2025 22:47:18 -0800 (PST) Received: from gandalf.. (c-67-165-245-5.hsd1.co.comcast.net. [67.165.245.5]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-4ec1da476fesm1174144173.58.2025.01.24.22.47.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2025 22:47:17 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, ukaszb@chromium.org Cc: intel-gfx-trybot@lists.freedesktop.org, 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, Jim Cromie Subject: [PATCH 38/63] dyndbg: drop "protection" of class'd pr_debugs from legacy queries Date: Fri, 24 Jan 2025 23:45:52 -0700 Message-ID: <20250125064619.8305-39-jim.cromie@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250125064619.8305-1-jim.cromie@gmail.com> References: <20250125064619.8305-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" Current classmap code protects class'd pr_debugs from unintended changes by "legacy" unclassed queries: # this doesn't disable all of DRM_UT_* categories echo "-p" > /proc/dynamic_debug/control # name the class to change it - protective but tedious echo "class DRM_UT_CORE +p" > /proc/dynamic_debug/control # or do it the subsystem way echo 1 > /sys/module/drm/parameters/debug This "name the class to change it" behavior gave a modicum of protection to classmap users (ie DRM) so their debug settings aren't trivially and unintentionally altered underneath them. Afterall, __drm_debug is authoritative w/o dyndbg under it. But this made the class keyword special in some sense; the other keywords follow the rule: no "keyword value" given means no skipping on that criterion. Jason Baron didn't like this special case when I 1st proposed it; I argued 2 points: - "protection gives stable-debug, improving utility" - "class _DFLT" assumed in query is not that special I thought I'd convinced him back then, (and the patchset got merged), but he noted it again when he reviewed this series. So this commit undoes the special case, indirectly. The difference in behavior comes down to a choice on how to handle class-mismatches; ddebug_client_module_protects_classes() names this choice (and defines it false). On class-mismatches of this kind, it is "called" before skipping the legacy cmd on a class'd site. So this makes it a policy-choice, and reverts to original policy. Later, if any user/module wants to protect its classes, we could add a flag to ddebug_table, a means to set it from CLASSMAP_DEFINE, and check it when applying a classless query/cmd. Further, runtime mods to the protection are possible via an exported fn, or a grammar addition to >control. NOTES In ddebug_change(), the 2-part class code is mostly unchanged: 1. query->class_str is validated once per module, and maps good ones to valid_class, now renamed to slctd_class to convey non-boolean-ness. 2. in the inner per-site loop, site mismatches are now 2 sub-cases: a. a class_str given explicitly, and site doesn't match it. skip/continue. b. no class_str given, _CLASS_DFLT is inferred skip if ddebug_client_module_protects_classes() else fall thru to site-change CC: jbaron@akamai.com Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 68b5a77c2d79..9a278c7ca365 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -193,6 +193,17 @@ static int ddebug_find_valid_class(struct ddebug_table= const *dt, const char *cl return -ENOENT; } =20 +/* + * classmaps-v1 protected classes from changes by legacy commands + * (those selecting _DPRINTK_CLASS_DFLT by omission), v2 undoes that + * special treatment. State so explicitly. Later we could give + * modules the choice to protect their classes or to keep v2 behavior. + */ +static inline bool ddebug_client_module_protects_classes(const struct ddeb= ug_table *dt) +{ + return false; +} + /* * Search the tables for _ddebug's which match the given `query' and * apply the `flags' and `mask' to them. Returns number of matching @@ -206,7 +217,7 @@ static int ddebug_change(const struct ddebug_query *que= ry, struct flag_settings unsigned int newflags; unsigned int nfound =3D 0; struct flagsbuf fbuf, nbuf; - int valid_class; + int slctd_class; =20 /* search for matching ddebugs */ mutex_lock(&ddebug_lock); @@ -218,21 +229,26 @@ static int ddebug_change(const struct ddebug_query *q= uery, struct flag_settings continue; =20 if (query->class_string) { - valid_class =3D ddebug_find_valid_class(dt, query->class_string); - if (valid_class < 0) + slctd_class =3D ddebug_find_valid_class(dt, query->class_string); + if (slctd_class < 0) + /* skip/reject classes unknown by module */ continue; } else { - /* constrain query, do not touch class'd callsites */ - valid_class =3D _DPRINTK_CLASS_DFLT; + slctd_class =3D _DPRINTK_CLASS_DFLT; } =20 for (i =3D 0; i < dt->info.descs.len; i++) { struct _ddebug *dp =3D &dt->info.descs.start[i]; =20 - /* match site against query-class */ - if (dp->class_id !=3D valid_class) - continue; - + if (dp->class_id !=3D slctd_class) { + if (query->class_string) + /* site.class !=3D given class */ + continue; + /* legacy query, class'd site */ + else if (ddebug_client_module_protects_classes(dt)) + continue; + /* allow change on class'd pr_debug */ + } /* match against the source filename */ if (query->filename && !match_wildcard(query->filename, dp->filename) && --=20 2.48.1