From mboxrd@z Thu Jan 1 00:00:00 1970 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 E4D7AE674B1 for ; Mon, 22 Dec 2025 14:00:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7469510E6A4; Mon, 22 Dec 2025 14:00:34 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="h6wMR2JX"; dkim-atps=neutral Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1D18D10E5E7 for ; Mon, 22 Dec 2025 08:26:19 +0000 (UTC) Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-7b8bbf16b71so3692553b3a.2 for ; Mon, 22 Dec 2025 00:26:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766391978; x=1766996778; 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=WDCSt59K+10ZOKnakaeCilFtSVyquWS+P/cFe/a6uAg=; b=h6wMR2JXsyG8c+MRujqu35kpGxkyTnO+Hm5weFPtgSrZHxM+dgrTa13EmuJTSrlVhA YYLZ+sl9ONxJP41Nw6ya03hX4c2eELt+oStF0CRz45qkZ210mxRR9B1qTmOn8iAGT/L+ pO7+4DQIIfJ6pjXQAeTA0cTZVx7uql+cdgMfQE+Aa2j/Hf7FUnzkLEwmVUUk6DYFPGyB vhVczkTAbg0xP9wXR2agXmBb4EQKW2c1IXz5LdbIK1tbWNZtCAb5VRnTSgt/Egjk6sYf k0BgSPQc0QPuj+xYFwFH90fXLQRxSZw2bqs8xvbqtx/d+1itFDmKBtR0ZqcueJ2KzC/Q qMOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766391978; x=1766996778; 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=WDCSt59K+10ZOKnakaeCilFtSVyquWS+P/cFe/a6uAg=; b=uzuvsoGZKwU2oXlT68shIMV3irYImI8XUAkQlgu3vhHWRJ0phU8td7Y26G9FCUkmqi X9R8G7//1WwKzj1Qh2qlkK2K1k9BQrj7VbH5V+swHZNVQdddlYkrMfdvtmdRN0kETdDL 6b34QyaxksnqjfdaILD0LiSLWn4fkthvBIzsJL/IUC2HVVGaYXsV5GNgA6PqnDTs8FUV bP3BoHziuEUua/xhhqIViAkx+vENkrHMTMXSfDf9LPpKvu1Dl77rZARL5YlPfcR3EihJ iV7V5yobWSmP6QPTRBK1263epVf7oMCzTnL+ru09D5xG0f4/dAX2JnLNLZfrzFbicRI/ uLDQ== X-Forwarded-Encrypted: i=1; AJvYcCXclWYmsdUoLFLTP67WvX+2UpOEn0KOV7PuksPeBUsbUvcxxWasii5YRKyEPTUuoT3KDIQ0Reej2v0=@lists.freedesktop.org X-Gm-Message-State: AOJu0Yx8NtRu5Y/3PGJxLFS0NfIGOKdobRJs8tFW2i84FXrzXQOApcsk 0ryUpP2XTsN6I8RELIO6E/G4N6+cXokMvokuL5fgquY6hBYsdoyxYh4A X-Gm-Gg: AY/fxX4UlWX1j7FqX3tlStgKKiCq9vU4unYluA09Zwg7+OG/zmDvifIcTNjxUxCFDCM Lb/U7STrn+4joKLB8cdpDk7JZozizX8ROlNmqvsXBdsoNgGxV9vb6HQElsAjmgZq5wOtCQhwyjo 2hq44Aiuyh6hZnApLpAFv5jCAnq20jECTH1Bj133fSXW8Bq/EimQnEYpJSBWt9PtZz4SOFNimPZ 2UIBvZayYOQnrR/yMz5qU90lerYLsXM6905xniZGND1pbC0kw+5jhDhSDg0cBql2Kcg8FGpBIJT ij64m+ppWCLowtxJ7vzm/0wYDQwVCd2bviC3f3mgllzc03yWJKQpxf0w8KKq7wi6ndfGjVZrPub ZbHTLCLcCwaega/cpVcxinr3VON+YkOtqJ2NuEjQmR4Kn0Z9JidZvjMb+jG60q4WwrEPk4dgGyH o+JNQoSfYs X-Google-Smtp-Source: AGHT+IEOgeXzV1hCWIimzrWiIka32wsRRn8gKqyhb6JthROJ0e2B6pTNBqm7iB1jb1DoK/0bL+KWAg== X-Received: by 2002:a05:6a00:ac85:b0:7e8:450c:61c0 with SMTP id d2e1a72fcca58-7ff66674fb2mr10796719b3a.48.1766391978564; Mon, 22 Dec 2025 00:26:18 -0800 (PST) Received: from frodo ([2404:4400:417e:3d00:8b90:7f55:1261:772f]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-7ff7e493123sm9540699b3a.50.2025.12.22.00.26.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Dec 2025 00:26:18 -0800 (PST) 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 v7 26/31] dyndbg: treat comma as a token separator Date: Mon, 22 Dec 2025 21:20:43 +1300 Message-ID: <20251222082049.1782440-27-jim.cromie@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251222082049.1782440-3-jim.cromie@gmail.com> References: <20251222082049.1782440-3-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Mon, 22 Dec 2025 14:00:06 +0000 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Treat comma as a token terminator, just like a space. This allows a user to avoid quoting hassles when spaces are otherwise needed: :#> modprobe drm dyndbg=class,DRM_UT_CORE,+p\;class,DRM_UT_KMS,+p or as a boot arg: drm.dyndbg=class,DRM_UT_CORE,+p # todo: support multi-query here Given the many ways a boot-line +args can be assembled and then passed in/down/around shell based tools, this may allow side-stepping all sorts of quoting hassles thru those layers. existing query format: modprobe test_dynamic_debug dyndbg="class D2_CORE +p" new format: modprobe test_dynamic_debug dyndbg=class,D2_CORE,+p ALSO selftests-dyndbg: add comma_terminator_tests New fn validates parsing and effect of queries using combinations of commas and spaces to delimit the tokens. It manipulates pr-debugs in builtin module/params, so might have deps I havent foreseen on odd configurations. Co-developed-by: Łukasz Bartosik Signed-off-by: Łukasz Bartosik Signed-off-by: Jim Cromie --- .../admin-guide/dynamic-debug-howto.rst | 9 +++++--- lib/dynamic_debug.c | 17 +++++++++++---- .../dynamic_debug/dyndbg_selftest.sh | 21 ++++++++++++++++++- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst index e76ccd987704..350d93834e19 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -78,11 +78,12 @@ Command Language Reference ========================== At the basic lexical level, a command is a sequence of words separated -by spaces or tabs. So these are all equivalent:: +by spaces, tabs, or commas. So these are all equivalent:: :#> ddcmd file svcsock.c line 1603 +p :#> ddcmd "file svcsock.c line 1603 +p" :#> ddcmd ' file svcsock.c line 1603 +p ' + :#> ddcmd file,svcsock.c,line,1603,+p Command submissions are bounded by a write() system call. Multiple commands can be written together, separated by ``;`` or ``\n``:: @@ -167,9 +168,11 @@ module The given string is compared against the module name of each callsite. The module name is the string as seen in ``lsmod``, i.e. without the directory or the ``.ko`` - suffix and with ``-`` changed to ``_``. Examples:: + suffix and with ``-`` changed to ``_``. - module sunrpc + Examples:: + + module,sunrpc # with ',' as token separator module nfsd module drm* # both drm, drm_kms_helper diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 1da2de7b1769..5ac7248d51bb 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -320,6 +320,14 @@ static int ddebug_change(const struct ddebug_query *query, struct flag_settings return nfound; } +static char *skip_spaces_and_commas(const char *str) +{ + str = skip_spaces(str); + while (*str == ',') + str = skip_spaces(++str); + return (char *)str; +} + /* * Split the buffer `buf' into space-separated words. * Handles simple " and ' quoting, i.e. without nested, @@ -333,8 +341,8 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords) while (*buf) { char *end; - /* Skip leading whitespace */ - buf = skip_spaces(buf); + /* Skip leading whitespace and comma */ + buf = skip_spaces_and_commas(buf); if (!*buf) break; /* oh, it was trailing whitespace */ if (*buf == '#') @@ -350,7 +358,7 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords) return -EINVAL; /* unclosed quote */ } } else { - for (end = buf; *end && !isspace(*end); end++) + for (end = buf; *end && !isspace(*end) && *end != ','; end++) ; if (end == buf) { pr_err("parse err after word:%d=%s\n", nwords, @@ -622,7 +630,8 @@ static int ddebug_exec_queries(char *query, const char *modname) if (split) *split++ = '\0'; - query = skip_spaces(query); + query = skip_spaces_and_commas(query); + if (!query || !*query || *query == '#') continue; diff --git a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh index 465fad3f392c..c7bf521f36ee 100755 --- a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh +++ b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh @@ -216,7 +216,7 @@ function check_err_msg() { function basic_tests { echo -e "${GREEN}# BASIC_TESTS ${NC}" if [ $LACK_DD_BUILTIN -eq 1 ]; then - echo "SKIP" + echo "SKIP - test requires params, which is a builtin module" return fi ddcmd =_ # zero everything @@ -238,8 +238,27 @@ EOF ddcmd =_ } +function comma_terminator_tests { + echo -e "${GREEN}# COMMA_TERMINATOR_TESTS ${NC}" + if [ $LACK_DD_BUILTIN -eq 1 ]; then + echo "SKIP - test requires params, which is a builtin module" + return + fi + # try combos of spaces & commas + check_match_ct '\[params\]' 4 -r + ddcmd module,params,=_ # commas as spaces + ddcmd module,params,+mpf # turn on module's pr-debugs + check_match_ct =pmf 4 + ddcmd ,module ,, , params, -p + check_match_ct =mf 4 + ddcmd " , module ,,, , params, -m" # + check_match_ct =f 4 + ddcmd =_ +} + tests_list=( basic_tests + comma_terminator_tests ) # Run tests -- 2.52.0