From patchwork Wed Apr 2 17:41:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 14036286 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 D4988C28B20 for ; Wed, 2 Apr 2025 17:42:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1254F10E883; Wed, 2 Apr 2025 17:42:24 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ZwfP22DK"; dkim-atps=neutral Received: from mail-io1-f46.google.com (mail-io1-f46.google.com [209.85.166.46]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4FF4910E87A; Wed, 2 Apr 2025 17:42:23 +0000 (UTC) Received: by mail-io1-f46.google.com with SMTP id ca18e2360f4ac-85db7a3da71so1821039f.1; Wed, 02 Apr 2025 10:42:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743615742; x=1744220542; darn=lists.freedesktop.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=M14gZKfhH3KugOXUlz//RUWXY3n2mU5NyLnRML1fEas=; b=ZwfP22DK2HxAhraJPTKfg9vKc5nCmjIeF61eM3ae3bdLhQLf4tgOZ/cuBuIzgcMRky MUqJ+hpnrwNNshdsE9gEJ5CxwHWYr3jgY0lvnTT9ZjXzqR1FAVz08ExGz3uVafEy5681 3JmiR9DZrAv3cZt3owVbBs7Pq694tvCQ65sKFU/7iPHm9c3P3HcWzPPZewBzSHE1gXBh 0rf3qrZN9oq9/lu1p3TiuV5cVM1pam3WnZ8s3q51trOo+dTRF/yykAGMBYfMsMHv4JNR EqDAi4IlCkK2/B59pJlnhS9zZxwvxOireVKxae4U7BNI20sbebOfKvgFIH1cSUMQhJiS hm0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743615742; x=1744220542; 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=M14gZKfhH3KugOXUlz//RUWXY3n2mU5NyLnRML1fEas=; b=XgWLYZMB44XJx4cFgoyDyRnz3s3P9Ao7fj3rXewriSyQ6tzS6TKffIjiHentdt1Srs etU/lPs9G9GaB0cuNwVbBSROu5MxT3zwlYN+e7CHhldAyj0mIRLADWnJuQBsDWRXFrWh HHhRfmkMTO7W5tqHNrRQxyyBMBrjymx6wURfgUJyHu8eB+9esAIqF5qr9thl/RX960zS zu2/0Zd4FdXcppLr5ORzTI6SltqrrWCx2A9VZkAlao25Jwk6sdU2Oh9zyfIJWyrXXf5f iaFskkFkYGhoccKi/tWh2WQrGvB/tkjuc/ociUyHm93X8VYDUEDRKKWaExOnHuS1pwa2 L5rQ== X-Forwarded-Encrypted: i=1; AJvYcCUGUAP44rO0CSk6OwsQ61mDuVDXxl5gE2RVsd//fQMTPmVXbEvTbQS8uueuJioaBwN2PhSLtp9mZHi2@lists.freedesktop.org, AJvYcCWDtvvoeLv4ATu3bzlnN2fmfQKvGSBQez0NzNq/Pv+rVXfCVYGHo3+oR7u4p36/5Fj4YZEdcMNK@lists.freedesktop.org, AJvYcCWs5s5P/ECyJzW2bctWBnaHb1yh26G3u2ag4KgQMgL2Z1Iw9a6UAlpZnX5LYYspX2CT/1gdFKtYNUBG/6pmIQ==@lists.freedesktop.org X-Gm-Message-State: AOJu0YzEIsoCE4Eohz1HjhI4/zTlZZIRliEmhGqTIRDuG5B/xtSpXXky 5IJJKx6Hfk6N8IkB6N3AIqM/YG4fW4XNCRAk9xfzlCEcLHec81/k X-Gm-Gg: ASbGncvwZRbaVd9ZPMLBrvE1PDyBYOsVUD6QlEX3fCLHGhtFDwDWBqDIzhBITAzQc+Y meh5YonxE4YIpj+bW4QQMDPTfK+5wfrLL8UCE1V5M7sk9vwF5UsW5LuEhmeSU4HrIa8n0PMnzx7 TSQpV6eELFGoY9XYR4LEm5Kj+Edt50HYIkg5I57k5mxJZI3xigALXsnQ5Nwt9wxYil8TLI2pPOn nnRcQOdvQ/KdLm6KmIdG5R2voOEWKDBDZN1a9raKHpFN01rKaXAuSCyXREuw6L/tc9QRtiFh4/Y 2qrXa4bqEnorYmoMoL+fGYLUgtvPjJ1MwYygWiVCUvTh4GSuzauXYmZuetPINduAzeQERcqX99y HDw== X-Google-Smtp-Source: AGHT+IEHyX3rih30b1ivp2/YdoiUvkQ7tiETAKcxWC1uHIaX7eknjSc/IG5d+B4mXjukEeK8ZBu1iA== X-Received: by 2002:a05:6e02:98c:b0:3d6:d3f7:8827 with SMTP id e9e14a558f8ab-3d6d3f7c864mr38169645ab.22.1743615742512; Wed, 02 Apr 2025 10:42:22 -0700 (PDT) Received: from gandalf.. (c-67-165-245-5.hsd1.co.comcast.net. [67.165.245.5]) by smtp.googlemail.com with ESMTPSA id e9e14a558f8ab-3d5d5af8369sm33439725ab.71.2025.04.02.10.42.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Apr 2025 10:42:22 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com, linux-kernel@vger.kernel.org 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, Jim Cromie Subject: [PATCH v3 09/54] dyndbg: refactor param_set_dyndbg_classes and below Date: Wed, 2 Apr 2025 11:41:11 -0600 Message-ID: <20250402174156.1246171-10-jim.cromie@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402174156.1246171-1-jim.cromie@gmail.com> References: <20250402174156.1246171-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 c609ff873224..3ad2e38c9ae2 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; } -/* 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 ddebug_class_param *dcp, int matches = 0; int bi, ct; - v2pr_info("apply: 0x%lx to: 0x%lx\n", *new_bits, *old_bits); + if (*new_bits != *old_bits) + v2pr_info("apply bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, + *old_bits, query_modname ?: "'*'"); for (bi = 0; bi < map->length; bi++) { if (test_bit(bi, new_bits) == test_bit(bi, old_bits)) @@ -612,12 +615,16 @@ static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp, snprintf(query, QUERY_SIZE, "class %s %c%s", map->class_names[bi], test_bit(bi, new_bits) ? '+' : '-', dcp->flags); - ct = ddebug_exec_queries(query, NULL); + ct = ddebug_exec_queries(query, query_modname); matches += ct; v2pr_info("bit_%d: %d matches on class: %s -> 0x%lx\n", bi, ct, map->class_names[bi], *new_bits); } + if (*new_bits != *old_bits) + v2pr_info("applied bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, + *old_bits, query_modname ?: "'*'"); + return matches; } @@ -672,7 +679,7 @@ static int param_set_dyndbg_classnames(const char *instr, const struct kernel_pa continue; } curr_bits ^= BIT(cls_id); - totct += ddebug_apply_class_bitmap(dcp, &curr_bits, dcp->bits); + totct += ddebug_apply_class_bitmap(dcp, &curr_bits, dcp->bits, NULL); *dcp->bits = 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 *instr, const struct kernel_pa old_bits = CLASSMAP_BITMASK(*dcp->lvl); curr_bits = CLASSMAP_BITMASK(cls_id + (wanted ? 1 : 0 )); - totct += ddebug_apply_class_bitmap(dcp, &curr_bits, &old_bits); + totct += ddebug_apply_class_bitmap(dcp, &curr_bits, &old_bits, NULL); *dcp->lvl = (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 *instr, const struct kernel_pa return 0; } -/** - * 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 = kp->arg; const struct ddebug_class_map *map = dcp->map; @@ -744,8 +742,8 @@ int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp) KP_NAME(kp), inrep, CLASSMAP_BITMASK(map->length)); inrep &= CLASSMAP_BITMASK(map->length); } - v2pr_info("bits:%lx > %s\n", inrep, KP_NAME(kp)); - totct += ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits); + v2pr_info("bits:0x%lx > %s.%s\n", inrep, mod_name ?: "*", KP_NAME(kp)); + totct += ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits, mod_name); *dcp->bits = inrep; break; case DD_CLASS_TYPE_LEVEL_NUM: @@ -758,7 +756,7 @@ int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp) old_bits = CLASSMAP_BITMASK(*dcp->lvl); new_bits = CLASSMAP_BITMASK(inrep); v2pr_info("lvl:%ld bits:0x%lx > %s\n", inrep, new_bits, KP_NAME(kp)); - totct += ddebug_apply_class_bitmap(dcp, &new_bits, &old_bits); + totct += ddebug_apply_class_bitmap(dcp, &new_bits, &old_bits, mod_name); *dcp->lvl = 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); /** - * 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) {