linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 01/24] dyndbg-docs: eschew file /full/path query in docs
       [not found] <20200613155738.2249399-1-jim.cromie@gmail.com>
@ 2020-06-13 15:57 ` Jim Cromie
  2020-06-14  6:04   ` Greg KH
  2020-06-13 15:57 ` [PATCH v2 02/24] dyndbg-docs: initialization is done early, not arch Jim Cromie
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Jim Cromie @ 2020-06-13 15:57 UTC (permalink / raw)
  To: jbaron, linux-kernel, akpm, gregkh
  Cc: linux, Jim Cromie, Jonathan Corbet, Will Deacon, Andrew Morton,
	Orson Zhai, Petr Mladek, linux-doc

Regarding:
commit 2b6783191da7 ("dynamic_debug: add trim_prefix() to provide source-root relative paths")
commit a73619a845d5 ("kbuild: use -fmacro-prefix-map to make __FILE__ a relative path")

2nd commit broke dynamic-debug's "file $fullpath" query form, but
nobody noticed because 1st commit had trimmed prefixes from
control-file output, so the click-copy-pasting of fullpaths into new
queries had ceased; that query form became unused.

Removing the function is cleanest, but it could be useful in
old-compiler corner cases, where __FILE__ still has /full/path,
and it safely does nothing otherwize.

So instead, quietly deprecate "file /full/path" query form, by
removing all /full/paths examples in the docs.  I skipped adding a
back-compat note.
---
 .../admin-guide/dynamic-debug-howto.rst       | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst
index 1012bd9305e9..57108f64afc8 100644
--- a/Documentation/admin-guide/dynamic-debug-howto.rst
+++ b/Documentation/admin-guide/dynamic-debug-howto.rst
@@ -70,10 +70,10 @@ statements via::
 
   nullarbor:~ # cat <debugfs>/dynamic_debug/control
   # filename:lineno [module]function flags format
-  /usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:323 [svcxprt_rdma]svc_rdma_cleanup =_ "SVCRDMA Module Removed, deregister RPC RDMA transport\012"
-  /usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:341 [svcxprt_rdma]svc_rdma_init =_ "\011max_inline       : %d\012"
-  /usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:340 [svcxprt_rdma]svc_rdma_init =_ "\011sq_depth         : %d\012"
-  /usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:338 [svcxprt_rdma]svc_rdma_init =_ "\011max_requests     : %d\012"
+  net/sunrpc/svc_rdma.c:323 [svcxprt_rdma]svc_rdma_cleanup =_ "SVCRDMA Module Removed, deregister RPC RDMA transport\012"
+  net/sunrpc/svc_rdma.c:341 [svcxprt_rdma]svc_rdma_init =_ "\011max_inline       : %d\012"
+  net/sunrpc/svc_rdma.c:340 [svcxprt_rdma]svc_rdma_init =_ "\011sq_depth         : %d\012"
+  net/sunrpc/svc_rdma.c:338 [svcxprt_rdma]svc_rdma_init =_ "\011max_requests     : %d\012"
   ...
 
 
@@ -93,7 +93,7 @@ the debug statement callsites with any non-default flags::
 
   nullarbor:~ # awk '$3 != "=_"' <debugfs>/dynamic_debug/control
   # filename:lineno [module]function flags format
-  /usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svcsock.c:1603 [sunrpc]svc_send p "svc_process: st_sendto returned %d\012"
+  net/sunrpc/svcsock.c:1603 [sunrpc]svc_send p "svc_process: st_sendto returned %d\012"
 
 Command Language Reference
 ==========================
@@ -166,13 +166,12 @@ func
 	func svc_tcp_accept
 
 file
-    The given string is compared against either the full pathname, the
-    src-root relative pathname, or the basename of the source file of
-    each callsite.  Examples::
+    The given string is compared against either the src-root relative
+    pathname, or the basename of the source file of each callsite.
+    Examples::
 
 	file svcsock.c
-	file kernel/freezer.c
-	file /usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svcsock.c
+	file kernel/freezer.c	# ie column 1 of control file
 
 module
     The given string is compared against the module name
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 02/24] dyndbg-docs: initialization is done early, not arch
       [not found] <20200613155738.2249399-1-jim.cromie@gmail.com>
  2020-06-13 15:57 ` [PATCH v2 01/24] dyndbg-docs: eschew file /full/path query in docs Jim Cromie
@ 2020-06-13 15:57 ` Jim Cromie
  2020-06-13 15:57 ` [PATCH v2 11/24] dyndbg: accept 'file foo.c:func1' and 'file foo.c:10-100' Jim Cromie
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Jim Cromie @ 2020-06-13 15:57 UTC (permalink / raw)
  To: jbaron, linux-kernel, akpm, gregkh
  Cc: linux, Jim Cromie, Jonathan Corbet, Petr Mladek, Will Deacon,
	Andrew Morton, Orson Zhai, linux-doc

since cf964976484 in 2012, initialization is done with early_initcall,
update the Docs, which still say arch_initcall.
---
 Documentation/admin-guide/dynamic-debug-howto.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst
index 57108f64afc8..1423af580bed 100644
--- a/Documentation/admin-guide/dynamic-debug-howto.rst
+++ b/Documentation/admin-guide/dynamic-debug-howto.rst
@@ -250,8 +250,8 @@ the syntax described above, but must not exceed 1023 characters.  Your
 bootloader may impose lower limits.
 
 These ``dyndbg`` params are processed just after the ddebug tables are
-processed, as part of the arch_initcall.  Thus you can enable debug
-messages in all code run after this arch_initcall via this boot
+processed, as part of the early_initcall.  Thus you can enable debug
+messages in all code run after this early_initcall via this boot
 parameter.
 
 On an x86 system for example ACPI enablement is a subsys_initcall and::
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 11/24] dyndbg: accept 'file foo.c:func1' and 'file foo.c:10-100'
       [not found] <20200613155738.2249399-1-jim.cromie@gmail.com>
  2020-06-13 15:57 ` [PATCH v2 01/24] dyndbg-docs: eschew file /full/path query in docs Jim Cromie
  2020-06-13 15:57 ` [PATCH v2 02/24] dyndbg-docs: initialization is done early, not arch Jim Cromie
@ 2020-06-13 15:57 ` Jim Cromie
  2020-06-15 14:46   ` Petr Mladek
  2020-06-13 15:57 ` [PATCH v2 15/24] dyndbg: extend ddebug_parse_flags to accept optional leading filter-flags Jim Cromie
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Jim Cromie @ 2020-06-13 15:57 UTC (permalink / raw)
  To: jbaron, linux-kernel, akpm, gregkh
  Cc: linux, Jim Cromie, Jonathan Corbet, Will Deacon, Andrew Morton,
	Petr Mladek, Orson Zhai, linux-doc

Accept these additional query forms:

   echo "file $filestr +_" > control

       path/to/file.c:100	# as from control, column 1
       path/to/file.c:1-100	# or any legal line-range
       path/to/file.c:func_A	# as from an editor/browser
       path/to/file.c:drm_\*	# wildcards still work
       path/to/file.c:*_foo	# lead wildcard too

1st 2 examples are treated as line-ranges, 3,4 are treated as func's

Doc these changes, and sprinkle in a few extra wild-card examples and
trailing # explanation texts.
---
 .../admin-guide/dynamic-debug-howto.rst       |  5 +++++
 lib/dynamic_debug.c                           | 20 ++++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst
index 1423af580bed..6c04aea8f4cd 100644
--- a/Documentation/admin-guide/dynamic-debug-howto.rst
+++ b/Documentation/admin-guide/dynamic-debug-howto.rst
@@ -164,6 +164,7 @@ func
     of each callsite.  Example::
 
 	func svc_tcp_accept
+	func *recv*		# in rfcomm, bluetooth, ping, tcp
 
 file
     The given string is compared against either the src-root relative
@@ -172,6 +173,9 @@ file
 
 	file svcsock.c
 	file kernel/freezer.c	# ie column 1 of control file
+	file drivers/usb/*	# all callsites under it
+	file inode.c:start_*	# parse :tail as a func (above)
+	file inode.c:1-100	# parse :tail as a line-range (above)
 
 module
     The given string is compared against the module name
@@ -181,6 +185,7 @@ module
 
 	module sunrpc
 	module nfsd
+	module drm*	# both drm, drm_kms_helper
 
 format
     The given string is searched for in the dynamic debug format
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index f87a7bef4204..784c075c7db9 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -322,6 +322,8 @@ static int parse_linerange(struct ddebug_query *query, const char *first)
 	} else {
 		query->last_lineno = query->first_lineno;
 	}
+	vpr_info("parsed line %d-%d\n", query->first_lineno,
+		 query->last_lineno);
 	return 0;
 }
 
@@ -358,6 +360,7 @@ static int ddebug_parse_query(char *words[], int nwords,
 {
 	unsigned int i;
 	int rc = 0;
+	char *fline;
 
 	/* check we have an even number of words */
 	if (nwords % 2 != 0) {
@@ -374,7 +377,22 @@ static int ddebug_parse_query(char *words[], int nwords,
 		if (!strcmp(words[i], "func")) {
 			rc = check_set(&query->function, words[i+1], "func");
 		} else if (!strcmp(words[i], "file")) {
-			rc = check_set(&query->filename, words[i+1], "file");
+			if (check_set(&query->filename, words[i+1], "file"))
+				return -EINVAL;
+
+			/* tail :$info is function or line-range */
+			fline = strchr(query->filename, ':');
+			if (!fline)
+				break;
+			*fline++ = '\0';
+			if (isalpha(*fline) || *fline == '*' || *fline == '?') {
+				/* take as function name */
+				if (check_set(&query->function, fline, "func"))
+					return -EINVAL;
+			} else {
+				if (parse_linerange(query, fline))
+					return -EINVAL;
+			}
 		} else if (!strcmp(words[i], "module")) {
 			rc = check_set(&query->module, words[i+1], "module");
 		} else if (!strcmp(words[i], "format")) {
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 15/24] dyndbg: extend ddebug_parse_flags to accept optional leading filter-flags
       [not found] <20200613155738.2249399-1-jim.cromie@gmail.com>
                   ` (2 preceding siblings ...)
  2020-06-13 15:57 ` [PATCH v2 11/24] dyndbg: accept 'file foo.c:func1' and 'file foo.c:10-100' Jim Cromie
@ 2020-06-13 15:57 ` Jim Cromie
  2020-06-15 15:37   ` Petr Mladek
  2020-06-13 15:57 ` [PATCH v2 17/24] dyndbg: add user-flag, negating-flags, and filtering on flags Jim Cromie
  2020-06-13 15:57 ` [PATCH v2 18/24] dyndbg: allow negating flag-chars in modflags Jim Cromie
  5 siblings, 1 reply; 12+ messages in thread
From: Jim Cromie @ 2020-06-13 15:57 UTC (permalink / raw)
  To: jbaron, linux-kernel, akpm, gregkh
  Cc: linux, Jim Cromie, Jonathan Corbet, Andrew Morton, Will Deacon,
	Petr Mladek, Orson Zhai, linux-doc

change ddebug_parse_flags to accept optional filterflags before OP.
this now sets the parameter added in ~1
---
 .../admin-guide/dynamic-debug-howto.rst       | 18 +++++++----
 lib/dynamic_debug.c                           | 30 ++++++++++---------
 2 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst
index 6c04aea8f4cd..4f343e6036f5 100644
--- a/Documentation/admin-guide/dynamic-debug-howto.rst
+++ b/Documentation/admin-guide/dynamic-debug-howto.rst
@@ -217,13 +217,19 @@ line
 	line -1605          // the 1605 lines from line 1 to line 1605
 	line 1600-          // all lines from line 1600 to the end of the file
 
-The flags specification comprises a change operation followed
-by one or more flag characters.  The change operation is one
-of the characters::
+Flags Specification::
 
-  -    remove the given flags
-  +    add the given flags
-  =    set the flags to the given flags
+  flagspec	::= filterflags? OP modflags
+  filterflags	::= flagset
+  modflags	::= flagset
+  flagset	::= ([pfmltu_] | [PFMLTU_])+	# also cant have pP etc
+  OP		::= [-+=]
+
+OP: modify callsites per following flagset::
+
+  -    remove the following flags
+  +    add the following flags
+  =    set the flags to the following flags
 
 The flags are::
 
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 0f393a930fdc..40436270d38a 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -441,34 +441,36 @@ static int ddebug_read_flags(const char *str, struct flagsettings *f)
 }
 
 /*
- * Parse `str' as a flags specification, format [-+=][p]+.
- * Sets up *maskp and *flagsp to be used when changing the
- * flags fields of matched _ddebug's.  Returns 0 on success
- * or <0 on error.
+ * Parse `str' as a flags-spec, ie: [pfmlt_]*[-+=][pfmlt_]+
+ * Fills flagsettings provided.  Returns 0 on success or <0 on error.
  */
-
 static int ddebug_parse_flags(const char *str,
 			      struct flagsettings *mods,
 			      struct flagsettings *filter)
 {
 	int op;
+	char *opp = strpbrk(str, "-+=");
 
-	switch (*str) {
-	case '+':
-	case '-':
-	case '=':
-		op = *str++;
-		break;
-	default:
-		pr_err("bad flag-op %c, at start of %s\n", *str, str);
+	if (!opp) {
+		pr_err("no OP given in %s\n", str);
 		return -EINVAL;
 	}
+	op = *opp;
 	vpr_info("op='%c'\n", op);
 
+	if (opp != str) {
+		/* filterflags precedes OP, grab it */
+		*opp++ = '\0';
+		if (ddebug_read_flags(str, filter))
+			return -EINVAL;
+		str = opp;
+	} else
+		str++;
+
 	if (ddebug_read_flags(str, mods))
 		return -EINVAL;
 
-	/* calculate final flags, mask based upon op */
+	/* calculate final mods: flags, mask based upon op */
 	switch (op) {
 	case '=':
 		mods->mask = 0;
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 17/24] dyndbg: add user-flag, negating-flags, and filtering on flags
       [not found] <20200613155738.2249399-1-jim.cromie@gmail.com>
                   ` (3 preceding siblings ...)
  2020-06-13 15:57 ` [PATCH v2 15/24] dyndbg: extend ddebug_parse_flags to accept optional leading filter-flags Jim Cromie
@ 2020-06-13 15:57 ` Jim Cromie
  2020-06-16 11:41   ` Petr Mladek
  2020-06-13 15:57 ` [PATCH v2 18/24] dyndbg: allow negating flag-chars in modflags Jim Cromie
  5 siblings, 1 reply; 12+ messages in thread
From: Jim Cromie @ 2020-06-13 15:57 UTC (permalink / raw)
  To: jbaron, linux-kernel, akpm, gregkh
  Cc: linux, Jim Cromie, Jonathan Corbet, Andrew Morton, Petr Mladek,
	Will Deacon, Orson Zhai, linux-doc

1. Add a user-flag [u] which works like the [pfmlt] flags, but has no
effect on callsite behavior; it allows incremental marking of
arbitrary sets of callsites.

2. Add [PFMLTU] flags, which negate their counterparts; P===!p etc.
And in ddebug_read_flags():
   current code does:	[pfmltu_] -> flags
   copy it to:		[PFMLTU_] -> mask

also disallow both of a pair: ie no 'pP', no true & false.

3. Add filtering ops into ddebug_change(), right after all the
callsite-property selections are complete.  These filter on the
callsite's current flagstate before applying modflags.

Why ?

The 'u' flag lets the user assemble an arbitary set of callsites.
Then using filter flags, user can activate the 'u' set.

  #> echo 'file foo.c +u; file bar.c +u' > control   # and repeat
  #> echo 'u+p' > control

Using negating-flags in your filter-flags, you can completely specify
the matching flagstate; not just required flags, but also prohibited
flags.

The user flag isn't strictly needed, but with it you can avoid using
[fmlt] flags for marking, which would alter logging when enabled.
---
 .../admin-guide/dynamic-debug-howto.rst       | 31 ++++++++++++++++---
 include/linux/dynamic_debug.h                 |  1 +
 lib/dynamic_debug.c                           | 31 ++++++++++++++-----
 3 files changed, 51 insertions(+), 12 deletions(-)

diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst
index 4f343e6036f5..45d3adf889ba 100644
--- a/Documentation/admin-guide/dynamic-debug-howto.rst
+++ b/Documentation/admin-guide/dynamic-debug-howto.rst
@@ -238,16 +238,39 @@ The flags are::
   l    Include line number in the printed message
   m    Include module name in the printed message
   t    Include thread ID in messages not generated from interrupt context
+  u    user flag, to mark callsites into a group
   _    No flags are set. (Or'd with others on input)
 
-For ``print_hex_dump_debug()`` and ``print_hex_dump_bytes()``, only ``p`` flag
-have meaning, other flags ignored.
+Additionally, the flag-chars ``[pflmtu]`` have negating flag-chars
+``[PFMLTU]``, which invert the meanings above.  Their use follows.
+
+Using Filters::
+
+Filter-flags specify an optional additional selector on pr_debug
+callsites; with them you can compose an arbitrary set of callsites, by
+iteratively marking them with ``+u``, then enabling them all with
+``u+p``.  You can also use ``fmlt`` flags for this, unless the format
+changes are inconvenient.
+
+Filters can also contain the negating flags, like ``UF``, which select
+only callsites with ``u`` and ``f`` cleared.
+
+Flagsets cannot contain ``pP`` etc, a flag cannot be true and false.
+
+modflags containing upper-case flags is reserved/undefined for now.
+inverted-flags are currently ignored, usage gets trickier if given
+``-pXy``, it should leave x set.
+
+Notes::
+
+For ``print_hex_dump_debug()`` and ``print_hex_dump_bytes()``, only
+``p`` flag has meaning, other flags are ignored.
 
 For display, the flags are preceded by ``=``
 (mnemonic: what the flags are currently equal to).
 
-Note the regexp ``^[-+=][flmpt_]+$`` matches a flags specification.
-To clear all flags at once, use ``=_`` or ``-flmpt``.
+Note the regexp ``^[-+=][flmptu_]+$`` matches a flags specification.
+To clear all flags at once, use ``=_`` or ``-flmptu``.
 
 
 Debug messages during Boot Process
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index aa9ff9e1c0b3..59960a8dd9f9 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -32,6 +32,7 @@ struct _ddebug {
 #define _DPRINTK_FLAGS_INCL_FUNCNAME	(1<<2)
 #define _DPRINTK_FLAGS_INCL_LINENO	(1<<3)
 #define _DPRINTK_FLAGS_INCL_TID		(1<<4)
+#define _DPRINTK_FLAGS_USR		(1<<5)
 #if defined DEBUG
 #define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINT
 #else
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index b3c262c009d2..b02cde1cfc2f 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -83,13 +83,14 @@ static inline const char *trim_prefix(const char *path)
 	return path + skip;
 }
 
-static struct { unsigned flag:8; char opt_char; } opt_array[] = {
-	{ _DPRINTK_FLAGS_PRINT, 'p' },
-	{ _DPRINTK_FLAGS_INCL_MODNAME, 'm' },
-	{ _DPRINTK_FLAGS_INCL_FUNCNAME, 'f' },
-	{ _DPRINTK_FLAGS_INCL_LINENO, 'l' },
-	{ _DPRINTK_FLAGS_INCL_TID, 't' },
-	{ _DPRINTK_FLAGS_NONE, '_' },
+static struct { unsigned flag:8; char opt_char, not_char; } opt_array[] = {
+	{ _DPRINTK_FLAGS_PRINT,		'p', 'P' },
+	{ _DPRINTK_FLAGS_INCL_MODNAME,	'm', 'M' },
+	{ _DPRINTK_FLAGS_INCL_FUNCNAME,	'f', 'F' },
+	{ _DPRINTK_FLAGS_INCL_LINENO,	'l', 'L' },
+	{ _DPRINTK_FLAGS_INCL_TID,	't', 'T' },
+	{ _DPRINTK_FLAGS_NONE,		'_', '_' },
+	{ _DPRINTK_FLAGS_USR,		'u', 'U' },
 };
 
 struct flagsbuf { char buf[ARRAY_SIZE(opt_array)+1]; };
@@ -195,6 +196,13 @@ static int ddebug_change(const struct ddebug_query *query,
 			    dp->lineno > query->last_lineno)
 				continue;
 
+			/* filter for required flags */
+			if ((dp->flags & filter->flags) != filter->flags)
+				continue;
+			/* filter on prohibited bits */
+			if ((~dp->flags & filter->mask) != filter->mask)
+				continue;
+
 			nfound++;
 
 			newflags = (dp->flags & mods->mask) | mods->flags;
@@ -428,10 +436,17 @@ static int ddebug_read_flags(const char *str, struct flagsettings *f)
 			if (*str == opt_array[i].opt_char) {
 				f->flags |= opt_array[i].flag;
 				break;
+			} else if (*str == opt_array[i].not_char) {
+				f->mask |= opt_array[i].flag;
+				break;
 			}
 		}
 		if (i < 0) {
-			pr_err("unknown flag '%c' in \"%s\"\n", *str, str);
+			pr_err("unknown flag '%c'", *str);
+			return -EINVAL;
+		}
+		if (f->flags & f->mask) {
+			pr_err("flag '%c' conflicts with previous\n", *str);
 			return -EINVAL;
 		}
 	}
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 18/24] dyndbg: allow negating flag-chars in modflags
       [not found] <20200613155738.2249399-1-jim.cromie@gmail.com>
                   ` (4 preceding siblings ...)
  2020-06-13 15:57 ` [PATCH v2 17/24] dyndbg: add user-flag, negating-flags, and filtering on flags Jim Cromie
@ 2020-06-13 15:57 ` Jim Cromie
  2020-06-16 11:47   ` Petr Mladek
  5 siblings, 1 reply; 12+ messages in thread
From: Jim Cromie @ 2020-06-13 15:57 UTC (permalink / raw)
  To: jbaron, linux-kernel, akpm, gregkh
  Cc: linux, Jim Cromie, Jonathan Corbet, Orson Zhai, Andrew Morton,
	Will Deacon, Petr Mladek, linux-doc

Extend flags modifications to allow [PFMLTU] negating flags.
This allows control-queries like:

  #> Q () { echo file inode.c $* > control } # to type less
  #> Q -P	# same as +p
  #> Q +U	# same as -u
  #> Q u-P	# same as u+p

This allows flags in a callsite to be simultaneously set and cleared,
while still starting with the current flagstate (with +- ops).

Using filter-flags with negating-flags, you can select exactly the
flagstates you want, both required and prohibited.

Then with negating-flags in modflags, you can set and clear every flag

  #> Q umfLT-Pmf  # select sites with u,m,f only. enable print, turn off m,f leave u

Its not an important feature, but it does fill out the logic.
and the patch is tiny, and feels more symmetrical.
---
 Documentation/admin-guide/dynamic-debug-howto.rst | 10 ++++++----
 lib/dynamic_debug.c                               |  6 ++++--
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst
index 45d3adf889ba..10e514237e83 100644
--- a/Documentation/admin-guide/dynamic-debug-howto.rst
+++ b/Documentation/admin-guide/dynamic-debug-howto.rst
@@ -257,9 +257,11 @@ only callsites with ``u`` and ``f`` cleared.
 
 Flagsets cannot contain ``pP`` etc, a flag cannot be true and false.
 
-modflags containing upper-case flags is reserved/undefined for now.
-inverted-flags are currently ignored, usage gets trickier if given
-``-pXy``, it should leave x set.
+modflags may contain upper-case flags also, using these lets you
+invert the flag setting implied by the OP; '-pU' means disable
+printing, and mark that callsite with the user-flag to create a group,
+for optional further manipulation.  Generally, '+p' and '-p' is your
+main choice, and use of negating flags in modflags is rare.
 
 Notes::
 
@@ -269,7 +271,7 @@ For ``print_hex_dump_debug()`` and ``print_hex_dump_bytes()``, only
 For display, the flags are preceded by ``=``
 (mnemonic: what the flags are currently equal to).
 
-Note the regexp ``^[-+=][flmptu_]+$`` matches a flags specification.
+Note the regexp ``/^[-+=][flmptu_]+$/i`` matches a flags specification.
 To clear all flags at once, use ``=_`` or ``-flmptu``.
 
 
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index b02cde1cfc2f..d67fbbc5317f 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -486,15 +486,17 @@ static int ddebug_parse_flags(const char *str,
 
 	/* calculate final mods: flags, mask based upon op */
 	switch (op) {
+		unsigned int tmp;
 	case '=':
 		mods->mask = 0;
 		break;
 	case '+':
-		mods->mask = ~0U;
+		mods->mask = ~mods->mask;
 		break;
 	case '-':
+		tmp = mods->mask;
 		mods->mask = ~mods->flags;
-		mods->flags = 0;
+		mods->flags = tmp;
 		break;
 	}
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 01/24] dyndbg-docs: eschew file /full/path query in docs
  2020-06-13 15:57 ` [PATCH v2 01/24] dyndbg-docs: eschew file /full/path query in docs Jim Cromie
@ 2020-06-14  6:04   ` Greg KH
  2020-06-14 14:24     ` jim.cromie
  0 siblings, 1 reply; 12+ messages in thread
From: Greg KH @ 2020-06-14  6:04 UTC (permalink / raw)
  To: Jim Cromie
  Cc: jbaron, linux-kernel, akpm, linux, Jonathan Corbet, Will Deacon,
	Andrew Morton, Orson Zhai, Petr Mladek, linux-doc

On Sat, Jun 13, 2020 at 09:57:15AM -0600, Jim Cromie wrote:
> Regarding:
> commit 2b6783191da7 ("dynamic_debug: add trim_prefix() to provide source-root relative paths")
> commit a73619a845d5 ("kbuild: use -fmacro-prefix-map to make __FILE__ a relative path")
> 
> 2nd commit broke dynamic-debug's "file $fullpath" query form, but
> nobody noticed because 1st commit had trimmed prefixes from
> control-file output, so the click-copy-pasting of fullpaths into new
> queries had ceased; that query form became unused.
> 
> Removing the function is cleanest, but it could be useful in
> old-compiler corner cases, where __FILE__ still has /full/path,
> and it safely does nothing otherwize.
> 
> So instead, quietly deprecate "file /full/path" query form, by
> removing all /full/paths examples in the docs.  I skipped adding a
> back-compat note.
> ---
>  .../admin-guide/dynamic-debug-howto.rst       | 19 +++++++++----------
>  1 file changed, 9 insertions(+), 10 deletions(-)

None of your patches have a signed-off-by line so they can't be applied
anywhere :(

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 01/24] dyndbg-docs: eschew file /full/path query in docs
  2020-06-14  6:04   ` Greg KH
@ 2020-06-14 14:24     ` jim.cromie
  0 siblings, 0 replies; 12+ messages in thread
From: jim.cromie @ 2020-06-14 14:24 UTC (permalink / raw)
  To: Greg KH
  Cc: Jason Baron, LKML, akpm, Rasmus Villemoes, Jonathan Corbet,
	Will Deacon, Andrew Morton, Orson Zhai, Petr Mladek,
	Linux Documentation List

On Sun, Jun 14, 2020 at 12:04 AM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Sat, Jun 13, 2020 at 09:57:15AM -0600, Jim Cromie wrote:
> > Regarding:
> > ---
> >  .../admin-guide/dynamic-debug-howto.rst       | 19 +++++++++----------
> >  1 file changed, 9 insertions(+), 10 deletions(-)
>
> None of your patches have a signed-off-by line so they can't be applied
> anywhere :(

oof.  I missed the -s in format-patch
will resend soon, after some time for remaining feedback.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 11/24] dyndbg: accept 'file foo.c:func1' and 'file foo.c:10-100'
  2020-06-13 15:57 ` [PATCH v2 11/24] dyndbg: accept 'file foo.c:func1' and 'file foo.c:10-100' Jim Cromie
@ 2020-06-15 14:46   ` Petr Mladek
  0 siblings, 0 replies; 12+ messages in thread
From: Petr Mladek @ 2020-06-15 14:46 UTC (permalink / raw)
  To: Jim Cromie
  Cc: jbaron, linux-kernel, akpm, gregkh, linux, Jonathan Corbet,
	Will Deacon, Andrew Morton, Orson Zhai, linux-doc

On Sat 2020-06-13 09:57:25, Jim Cromie wrote:
> Accept these additional query forms:
> 
>    echo "file $filestr +_" > control
> 
>        path/to/file.c:100	# as from control, column 1
>        path/to/file.c:1-100	# or any legal line-range
>        path/to/file.c:func_A	# as from an editor/browser
>        path/to/file.c:drm_\*	# wildcards still work
                            ^

Should the backslash be there?

>        path/to/file.c:*_foo	# lead wildcard too
> 
> 1st 2 examples are treated as line-ranges, 3,4 are treated as func's

There is also 5th example.

> Doc these changes, and sprinkle in a few extra wild-card examples and
> trailing # explanation texts.
> ---
>  .../admin-guide/dynamic-debug-howto.rst       |  5 +++++
>  lib/dynamic_debug.c                           | 20 ++++++++++++++++++-
>  2 files changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst
> index 1423af580bed..6c04aea8f4cd 100644
> --- a/Documentation/admin-guide/dynamic-debug-howto.rst
> +++ b/Documentation/admin-guide/dynamic-debug-howto.rst
> @@ -164,6 +164,7 @@ func
>      of each callsite.  Example::
>  
>  	func svc_tcp_accept
> +	func *recv*		# in rfcomm, bluetooth, ping, tcp
>  
>  file
>      The given string is compared against either the src-root relative
> @@ -172,6 +173,9 @@ file
>  
>  	file svcsock.c
>  	file kernel/freezer.c	# ie column 1 of control file
> +	file drivers/usb/*	# all callsites under it
> +	file inode.c:start_*	# parse :tail as a func (above)
> +	file inode.c:1-100	# parse :tail as a line-range (above)
>  
>  module
>      The given string is compared against the module name
> @@ -181,6 +185,7 @@ module
>  
>  	module sunrpc
>  	module nfsd
> +	module drm*	# both drm, drm_kms_helper
>  
>  format
>      The given string is searched for in the dynamic debug format
> diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
> index f87a7bef4204..784c075c7db9 100644
> --- a/lib/dynamic_debug.c
> +++ b/lib/dynamic_debug.c
> @@ -322,6 +322,8 @@ static int parse_linerange(struct ddebug_query *query, const char *first)
>  	} else {
>  		query->last_lineno = query->first_lineno;
>  	}
> +	vpr_info("parsed line %d-%d\n", query->first_lineno,
> +		 query->last_lineno);

Is this supposed to be in the final code?
I do not see such messages printed for other parsed variants.

>  	return 0;
>  }
>  
> @@ -358,6 +360,7 @@ static int ddebug_parse_query(char *words[], int nwords,
>  {
>  	unsigned int i;
>  	int rc = 0;
> +	char *fline;
>  
>  	/* check we have an even number of words */
>  	if (nwords % 2 != 0) {
> @@ -374,7 +377,22 @@ static int ddebug_parse_query(char *words[], int nwords,
>  		if (!strcmp(words[i], "func")) {
>  			rc = check_set(&query->function, words[i+1], "func");
>  		} else if (!strcmp(words[i], "file")) {
> -			rc = check_set(&query->filename, words[i+1], "file");
> +			if (check_set(&query->filename, words[i+1], "file"))
> +				return -EINVAL;

There is no reason to hard code the error code. It should look like:

			rc = check_set(&query->filename, words[i+1], "file");
			if (rc)
				return rc;
> +
> +			/* tail :$info is function or line-range */
> +			fline = strchr(query->filename, ':');
> +			if (!fline)
> +				break;
> +			*fline++ = '\0';
> +			if (isalpha(*fline) || *fline == '*' || *fline == '?') {

I would do the oposite and check whether is starts with number.

> +				/* take as function name */
> +				if (check_set(&query->function, fline, "func"))
> +					return -EINVAL;
> +			} else {
> +				if (parse_linerange(query, fline))
> +					return -EINVAL;
> +			}

Also I would hide this into another function:

			rc = parse_filenane(...);


>  		} else if (!strcmp(words[i], "module")) {
>  			rc = check_set(&query->module, words[i+1], "module");
>  		} else if (!strcmp(words[i], "format")) {
> -- 
> 2.26.2

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 15/24] dyndbg: extend ddebug_parse_flags to accept optional leading filter-flags
  2020-06-13 15:57 ` [PATCH v2 15/24] dyndbg: extend ddebug_parse_flags to accept optional leading filter-flags Jim Cromie
@ 2020-06-15 15:37   ` Petr Mladek
  0 siblings, 0 replies; 12+ messages in thread
From: Petr Mladek @ 2020-06-15 15:37 UTC (permalink / raw)
  To: Jim Cromie
  Cc: jbaron, linux-kernel, akpm, gregkh, linux, Jonathan Corbet,
	Andrew Morton, Will Deacon, Orson Zhai, linux-doc

On Sat 2020-06-13 09:57:29, Jim Cromie wrote:
> change ddebug_parse_flags to accept optional filterflags before OP.
> this now sets the parameter added in ~1

What is "~1", please?

> ---
>  .../admin-guide/dynamic-debug-howto.rst       | 18 +++++++----
>  lib/dynamic_debug.c                           | 30 ++++++++++---------
>  2 files changed, 28 insertions(+), 20 deletions(-)
> 
> diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst
> index 6c04aea8f4cd..4f343e6036f5 100644
> --- a/Documentation/admin-guide/dynamic-debug-howto.rst
> +++ b/Documentation/admin-guide/dynamic-debug-howto.rst
> @@ -217,13 +217,19 @@ line
>  	line -1605          // the 1605 lines from line 1 to line 1605
>  	line 1600-          // all lines from line 1600 to the end of the file
>  
> -The flags specification comprises a change operation followed
> -by one or more flag characters.  The change operation is one
> -of the characters::

This removes rather useful information and there is no replacement.

> +Flags Specification::
>  
> -  -    remove the given flags
> -  +    add the given flags
> -  =    set the flags to the given flags
> +  flagspec	::= filterflags? OP modflags
> +  filterflags	::= flagset
> +  modflags	::= flagset
> +  flagset	::= ([pfmltu_] | [PFMLTU_])+	# also cant have pP etc
> +  OP		::= [-+=]

I have to say that dynamic debug interface always looked pretty
complicated to me. But I have no idea what the above means.

It explans some syntax. But it does not explain what filterfalgs
and modflags mean and how they would affect the operation.

Also some examples would be very useful.

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 17/24] dyndbg: add user-flag, negating-flags, and filtering on flags
  2020-06-13 15:57 ` [PATCH v2 17/24] dyndbg: add user-flag, negating-flags, and filtering on flags Jim Cromie
@ 2020-06-16 11:41   ` Petr Mladek
  0 siblings, 0 replies; 12+ messages in thread
From: Petr Mladek @ 2020-06-16 11:41 UTC (permalink / raw)
  To: Jim Cromie
  Cc: jbaron, linux-kernel, akpm, gregkh, linux, Jonathan Corbet,
	Andrew Morton, Will Deacon, Orson Zhai, linux-doc

On Sat 2020-06-13 09:57:31, Jim Cromie wrote:
> 1. Add a user-flag [u] which works like the [pfmlt] flags, but has no
> effect on callsite behavior; it allows incremental marking of
> arbitrary sets of callsites.
> 
> 2. Add [PFMLTU] flags, which negate their counterparts; P===!p etc.
> And in ddebug_read_flags():
>    current code does:	[pfmltu_] -> flags
>    copy it to:		[PFMLTU_] -> mask
> 
> also disallow both of a pair: ie no 'pP', no true & false.
> 
> 3. Add filtering ops into ddebug_change(), right after all the
> callsite-property selections are complete.  These filter on the
> callsite's current flagstate before applying modflags.
> 
> Why ?
> 
> The 'u' flag lets the user assemble an arbitary set of callsites.
> Then using filter flags, user can activate the 'u' set.
> 
>   #> echo 'file foo.c +u; file bar.c +u' > control   # and repeat
>   #> echo 'u+p' > control

What was the motivation for this please?
Is it common to manipulate the same set of callsites again and again?
Do you have any usecase, please?

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 18/24] dyndbg: allow negating flag-chars in modflags
  2020-06-13 15:57 ` [PATCH v2 18/24] dyndbg: allow negating flag-chars in modflags Jim Cromie
@ 2020-06-16 11:47   ` Petr Mladek
  0 siblings, 0 replies; 12+ messages in thread
From: Petr Mladek @ 2020-06-16 11:47 UTC (permalink / raw)
  To: Jim Cromie
  Cc: jbaron, linux-kernel, akpm, gregkh, linux, Jonathan Corbet,
	Orson Zhai, Andrew Morton, Will Deacon, linux-doc

On Sat 2020-06-13 09:57:32, Jim Cromie wrote:
> Extend flags modifications to allow [PFMLTU] negating flags.
> This allows control-queries like:
> 
>   #> Q () { echo file inode.c $* > control } # to type less
>   #> Q -P	# same as +p
>   #> Q +U	# same as -u
>   #> Q u-P	# same as u+p
> 
> This allows flags in a callsite to be simultaneously set and cleared,
> while still starting with the current flagstate (with +- ops).
> 
> Using filter-flags with negating-flags, you can select exactly the
> flagstates you want, both required and prohibited.
> 
> Then with negating-flags in modflags, you can set and clear every flag
> 
>   #> Q umfLT-Pmf  # select sites with u,m,f only. enable print, turn off m,f leave u
> 
> Its not an important feature, but it does fill out the logic.
> and the patch is tiny, and feels more symmetrical.

I do not think that it is a good idea.

Many people do not like perl because it allows to do the same thing
many ways. The result is that the code is hard to read. There are too
many coding styles and tricks to understand.

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-06-16 11:47 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20200613155738.2249399-1-jim.cromie@gmail.com>
2020-06-13 15:57 ` [PATCH v2 01/24] dyndbg-docs: eschew file /full/path query in docs Jim Cromie
2020-06-14  6:04   ` Greg KH
2020-06-14 14:24     ` jim.cromie
2020-06-13 15:57 ` [PATCH v2 02/24] dyndbg-docs: initialization is done early, not arch Jim Cromie
2020-06-13 15:57 ` [PATCH v2 11/24] dyndbg: accept 'file foo.c:func1' and 'file foo.c:10-100' Jim Cromie
2020-06-15 14:46   ` Petr Mladek
2020-06-13 15:57 ` [PATCH v2 15/24] dyndbg: extend ddebug_parse_flags to accept optional leading filter-flags Jim Cromie
2020-06-15 15:37   ` Petr Mladek
2020-06-13 15:57 ` [PATCH v2 17/24] dyndbg: add user-flag, negating-flags, and filtering on flags Jim Cromie
2020-06-16 11:41   ` Petr Mladek
2020-06-13 15:57 ` [PATCH v2 18/24] dyndbg: allow negating flag-chars in modflags Jim Cromie
2020-06-16 11:47   ` Petr Mladek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).