Message ID | 5351f56289add68eee2aa5288f82a313c2b9f664.1701993656.git.jim.cromie@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5148899vqy; Thu, 7 Dec 2023 16:17:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IFOGJLAbLacZFWt8x4kTCOWpkq3tfpAbPvKvldUhgSxPeqMTOSuZE5Gf++vJgJ9hmxL942u X-Received: by 2002:a17:902:d2cb:b0:1d0:922:f65e with SMTP id n11-20020a170902d2cb00b001d00922f65emr61923plc.2.1701994634690; Thu, 07 Dec 2023 16:17:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701994634; cv=none; d=google.com; s=arc-20160816; b=cPTUcvGtYzRRgS0XDnmY6j+w7o0XZEQSqA8a2LsY7RANu2suIBbZtl8VaDvxIqzLrm iXi38/txYlMBK6husHAu0L0nXpXZqyi7BWhh39JDjI63YnzvLu9IeBfO5Ip0z8pS1O1n eRKBY4dOM3a60z4VnTLcx+wCn1mEfFrqXbM0J1FLCgRwQgymOIOnVNLY9McjwqNrY2Qy pmQHcypdnxPbB5t9qg4avtyiNX4jJtBkMD2xUaBxruHO4dcMmc1miZG1mrueEU0iK5Jj aA0t+C0x7m8jIRlxAhVicox+DPn9mjRp8fDGKNYiI/8gWh/VCnZWk6PPsNwvRFNWzBkR DDGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nzemyBWiktEMRpqERnIwUz6Pik0FVBTgB713Rxzb6zY=; fh=Zewmf3wThiipMhDjR96yol5QxF5bGjQ0muN6YDM9mM0=; b=p8eqeKtO6kr5PtnNFQ5RjheM4n1quUs0ovYAOk7DVqew1/N3Qab1gdA1RWdjt6YUEG J7VpwcEI2++6wWuDPR0osNFytXYAh1wElIIseCOMrvdOOCUqH83ir9iL6Mp6z/HNrpht VmhFr4MIS6w6dRw5PeQTK9hg88JbS/hoi7P9LAmQqU0kTpQGImqnDj7hiMUQKn8POQzw h0b3f34/qjSJvu/MngqCN6r3SV/7O2M3QjMU1PyNW1h6T301eHORVkgfSQr6Br0Ykz8L 8IqahaybhdeqDFfa+0lQPreP7SttOR1ynaK0eUw8YhxvhmbT2OL9SgSzO44D/QZAeayv G5oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="eYB2/Nv2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id y24-20020a634b18000000b005c215b317e9si493706pga.478.2023.12.07.16.17.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 16:17:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="eYB2/Nv2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 0882780775BF; Thu, 7 Dec 2023 16:15:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444220AbjLHAPm (ORCPT <rfc822;chrisfriedt@gmail.com> + 99 others); Thu, 7 Dec 2023 19:15:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444156AbjLHAP1 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 7 Dec 2023 19:15:27 -0500 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F4A71725 for <linux-kernel@vger.kernel.org>; Thu, 7 Dec 2023 16:15:33 -0800 (PST) Received: by mail-io1-xd30.google.com with SMTP id ca18e2360f4ac-7b3ec83a8d4so65778839f.1 for <linux-kernel@vger.kernel.org>; Thu, 07 Dec 2023 16:15:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701994532; x=1702599332; 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=nzemyBWiktEMRpqERnIwUz6Pik0FVBTgB713Rxzb6zY=; b=eYB2/Nv2F6Rz8yVggy3H5m3aBU+QdvcME2mv0cZEKardO8zz54KspNspZFHjVX1B7b xMMrbX3zTyw2pbsV66XNCUQF3z+OKm+O5ipsBsXBXCiQoGNbPAomG8bdKpK0xfnpKedl zZB7JqO8po9m8lythDVGulp3sujuQM26KjcNZwG02NV3UqFWzR13NwnHB41N2at+zCVY m/v6FJdWXYZv5q7ZxHhRzh2F3W3ATWJjFdg7kgwZAbPEMu50kjLXMPVtGuJ9jcpgGNsp SH5r1c+NVBUrad1G1Tcp8ACmwUROeuWhyX6vxdLNoe7RNmkIwfMSbVM/4v84Tkm5yV/i ZaQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701994532; x=1702599332; 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=nzemyBWiktEMRpqERnIwUz6Pik0FVBTgB713Rxzb6zY=; b=vtmayaK9Snl3Z6ZlD6mgW6TT7aVfPXwTH4x6RttxC4TMjPZh9rwH1QzKxnqeHV9uyq MrYaRn3dQdIOlCnDZyb28oaSHInNQ/gJ/BnVjKdMeQFkdZqn6hAS5EjZ0790pBzq4ZuV My77epjp20wcyR3OMuKnbYAyG6L2bGRYFjuiybY91mUCgVC/tr1dzWd76gQSHzWELfSf MjwxNWn9K4fxdzN82CAd3RJHcwsyy4fay4FD0USK4em6+U7awRXlwCJY8hfmcLsM0sCE 2S2qxVuUcZtm9roFFeb4OZUDYLStJPMosZ2o4sS1DPQbm7b36+aytwkEckOMiHKSBQra ZXRA== X-Gm-Message-State: AOJu0Yw2goeiS6dRBCvAOLcp10x95A2bB47N7e+0Bfq7PY7uhXQh85B3 +HoTaAm1oZqLOb1yS0a1Bsc= X-Received: by 2002:a6b:fe05:0:b0:7b7:22d:6ee3 with SMTP id x5-20020a6bfe05000000b007b7022d6ee3mr44376ioh.18.1701994532447; Thu, 07 Dec 2023 16:15:32 -0800 (PST) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z18-20020a056638241200b004664a0a7f2csm184652jat.177.2023.12.07.16.15.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 16:15:32 -0800 (PST) From: Jim Cromie <jim.cromie@gmail.com> To: lb@semihalf.com, linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, bleung@google.com, contact@emersion.fr, daniel@ffwll.ch, dianders@chromium.org, groeck@google.com, jbaron@akamai.com, jim.cromie@gmail.com, john.ogness@linutronix.de, keescook@chromium.org, pmladek@suse.com, ppaalanen@gmail.com, rostedt@goodmis.org, seanpaul@chromium.org, sergey.senozhatsky@gmail.com, upstream@semihalf.com, vincent.whitchurch@axis.com, yanivt@google.com, gregkh@linuxfoundation.org Subject: [re: PATCH v2 00/15 - 08/11] dyndbg: split multi-query strings with % Date: Thu, 7 Dec 2023 17:15:11 -0700 Message-ID: <5351f56289add68eee2aa5288f82a313c2b9f664.1701993656.git.jim.cromie@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <cover.1701993656.git.jim.cromie@gmail.com> References: <CAK8ByeK8dGcbxfXghw6=LrhSWLmO0a4XuB8C0nsUc812aoU0Pw@mail.gmail.com> <cover.1701993656.git.jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 07 Dec 2023 16:15:55 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784670726024055642 X-GMAIL-MSGID: 1784670726024055642 |
Commit Message
Jim Cromie
Dec. 8, 2023, 12:15 a.m. UTC
Multi-query strings have long allowed:
modprobe drm dyndbg="class DRM_UT_CORE +p; class DRM_UT_KMS +p"
modprobe drm dyndbg=<<EOX
class DRM_UT_CORE +pmf
class DRM_UT_KMS +pmf
EOX
More recently, the need for quoting was avoided by treating a comma
like a space/token-terminator:
modprobe drm dyndbg=class,DRM_UT_CORE,+p\;class,DRM_UT_KMS,+p
But that leaves unfinished business; that semi-colon needs escaping,
and thats not robust to further string interpolation. In particular,
it fails when passed to vng (virtme-ng).
So this patch adds '%' to the existing ';' and '\n' multi-cmd
separators, which is more shell-friendly, and avoids quoting and
escaping hassles.
modprobe drm dyndbg=class,DRM_UT_CORE,+p%class,DRM_UT_KMS,+p
NOTE: it does alter/break this (ill conceived) search:
[root@v6 lx]# ddcmd format %s +p
[ 38.170998] dyndbg: read 13 bytes from userspace
[ 38.171542] dyndbg: query 0: <format > on module: <*>
[ 38.172011] dyndbg: bad flag-op f, at start of format
[ 38.172487] dyndbg: flags parse failed
[ 38.172839] dyndbg: query 1: <s +p> on module: <*>
[ 38.173285] dyndbg: expecting pairs of match-spec <value>
[ 38.173791] dyndbg: query parse failed
[ 38.174141] dyndbg: processed 2 queries, with 0 matches, 2 errs
bash: echo: write error: Invalid argument
In trade for that minor format selection limitation, we get to do:
vng -v --user root -p 4 \
-a dynamic_debug.verbose=3 \
-a drm.debug=0x15 \
-a i915.dyndbg=class,DRM_UT_CORE,+pfmlt_%class,DRM_UT_KMS,+pfml
modprobe drm
modprobe i915
NOTES/TLDR:
In this example, using both drm.debug & drm.dyndbg is mostly for
testing. Using drm.debug is preferred, because the drivers all
explicitly depend on that input/control-point, so settings there are
propagated to drivers.
But more to the point, drm.dyndbg explicitly limits the query to drm.
In fact, you could pass a module wildcard in the above, and achieve
the same thing:
vng -v --user root -p 4 \
-a dynamic_debug.verbose=3 \
-a \*.dyndbg=class,DRM_UT_CORE,+pfmlt_%class,DRM_UT_KMS,+pfm%class,DRM_UT_ATOMIC,+pf
':' would be a more natural multi-cmd separator, but is reserved
for +T:<trace_buf> to designate separate tracebuf instances.
If '%' is distasteful, the backup plan is ",_,", since that would
never appear in a useful <format "$foo"> cmd.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
lib/dynamic_debug.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
pt., 8 gru 2023 o 01:15 Jim Cromie <jim.cromie@gmail.com> napisał(a): > > Multi-query strings have long allowed: > > modprobe drm dyndbg="class DRM_UT_CORE +p; class DRM_UT_KMS +p" > modprobe drm dyndbg=<<EOX > class DRM_UT_CORE +pmf > class DRM_UT_KMS +pmf > EOX > > More recently, the need for quoting was avoided by treating a comma > like a space/token-terminator: > > modprobe drm dyndbg=class,DRM_UT_CORE,+p\;class,DRM_UT_KMS,+p > > But that leaves unfinished business; that semi-colon needs escaping, > and thats not robust to further string interpolation. In particular, > it fails when passed to vng (virtme-ng). > > So this patch adds '%' to the existing ';' and '\n' multi-cmd > separators, which is more shell-friendly, and avoids quoting and > escaping hassles. > > modprobe drm dyndbg=class,DRM_UT_CORE,+p%class,DRM_UT_KMS,+p > > NOTE: it does alter/break this (ill conceived) search: > > [root@v6 lx]# ddcmd format %s +p > [ 38.170998] dyndbg: read 13 bytes from userspace > [ 38.171542] dyndbg: query 0: <format > on module: <*> > [ 38.172011] dyndbg: bad flag-op f, at start of format > [ 38.172487] dyndbg: flags parse failed > [ 38.172839] dyndbg: query 1: <s +p> on module: <*> > [ 38.173285] dyndbg: expecting pairs of match-spec <value> > [ 38.173791] dyndbg: query parse failed > [ 38.174141] dyndbg: processed 2 queries, with 0 matches, 2 errs > bash: echo: write error: Invalid argument > > In trade for that minor format selection limitation, we get to do: > > vng -v --user root -p 4 \ > -a dynamic_debug.verbose=3 \ > -a drm.debug=0x15 \ > -a i915.dyndbg=class,DRM_UT_CORE,+pfmlt_%class,DRM_UT_KMS,+pfml > modprobe drm > modprobe i915 > > NOTES/TLDR: > > In this example, using both drm.debug & drm.dyndbg is mostly for > testing. Using drm.debug is preferred, because the drivers all > explicitly depend on that input/control-point, so settings there are > propagated to drivers. > > But more to the point, drm.dyndbg explicitly limits the query to drm. > In fact, you could pass a module wildcard in the above, and achieve > the same thing: > > vng -v --user root -p 4 \ > -a dynamic_debug.verbose=3 \ > -a \*.dyndbg=class,DRM_UT_CORE,+pfmlt_%class,DRM_UT_KMS,+pfm%class,DRM_UT_ATOMIC,+pf > > ':' would be a more natural multi-cmd separator, but is reserved > for +T:<trace_buf> to designate separate tracebuf instances. > > If '%' is distasteful, the backup plan is ",_,", since that would > never appear in a useful <format "$foo"> cmd. > What if we use a different character for passing trace instance name to the T flag, for example "-", +T-trace_buf and then use ":" instead of "%" as a separator ? > Signed-off-by: Jim Cromie <jim.cromie@gmail.com> > --- > lib/dynamic_debug.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c > index c974f6e19ca1..0ca3ba9e2032 100644 > --- a/lib/dynamic_debug.c > +++ b/lib/dynamic_debug.c > @@ -963,7 +963,7 @@ static int ddebug_exec_queries(char *query, const char *modname) > int i, errs = 0, exitcode = 0, rc, nfound = 0; > > for (i = 0; query; query = split) { > - split = strpbrk(query, ";\n"); > + split = strpbrk(query, "%;\n"); > if (split) > *split++ = '\0'; > > -- > 2.43.0 >
On Fri, Dec 8, 2023 at 5:32 PM Łukasz Bartosik <lb@semihalf.com> wrote: > > pt., 8 gru 2023 o 01:15 Jim Cromie <jim.cromie@gmail.com> napisał(a): > > > > vng -v --user root -p 4 \ > > -a dynamic_debug.verbose=3 \ > > -a \*.dyndbg=class,DRM_UT_CORE,+pfmlt_%class,DRM_UT_KMS,+pfm%class,DRM_UT_ATOMIC,+pf > > > > ':' would be a more natural multi-cmd separator, but is reserved > > for +T:<trace_buf> to designate separate tracebuf instances. > > > > If '%' is distasteful, the backup plan is ",_,", since that would > > never appear in a useful <format "$foo"> cmd. > > > > What if we use a different character for passing trace instance name > to the T flag, for example "-", +T-trace_buf > and then use ":" instead of "%" as a separator ? > *** entering the Bikeshed *** One of the nice constraints of the flags-val is that it always starts with +/-/= the 1st char of flags is the only place they would appear unquoted. using '-' again dilutes that specialness. the whole +T:named_stream. syntax has a mnemonic value, it seems to explain itself (but I'm weird) WRT to ':' vs '%' as multi-cmd separator, what do we lose in each trade ? ultimately it invalidates a query containing those chars. IOW # impossible query when cmd-splitting on % echo format "search for %s because %d" +p > /proc/dynamic_debug/control # impossible when splitting on : echo format "my_label: " +p > /proc/dynamic_debug/control NB: only format would see an arg with either : or %, since theyre *never* in filenames, functions or module (or class) names. Of the 2, % is even more unlikely to wind up in a name, colon already appears in host:path and urls, and in some class-name systems (tho not planned for "class" keyword) the ability to search for colon-terminated labels seems more useful than searching for a particular set of printf format specifiers, which btw cant have colons between them.
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index c974f6e19ca1..0ca3ba9e2032 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -963,7 +963,7 @@ static int ddebug_exec_queries(char *query, const char *modname) int i, errs = 0, exitcode = 0, rc, nfound = 0; for (i = 0; query; query = split) { - split = strpbrk(query, ";\n"); + split = strpbrk(query, "%;\n"); if (split) *split++ = '\0';