mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] tools/bootconfig: Preserve filters when resetting and applying tracing
@ 2026-10-28 19:36 Eduardo Mucelli Rezende Oliveira
  2026-10-28 19:36 ` [PATCH 1/2] tools/bootconfig: Preserve filters when resetting histogram triggers Eduardo Mucelli Rezende Oliveira
  2026-10-28 19:36 ` [PATCH 2/2] tools/bootconfig: Quote command strings when applying ftrace settings Eduardo Mucelli Rezende Oliveira
  0 siblings, 2 replies; 3+ messages in thread
From: Eduardo Mucelli Rezende Oliveira @ 2026-10-28 19:36 UTC (permalink / raw)
  To: mhiramat; +Cc: rostedt, linux-trace-kernel, linux-kernel

Hi Masami,

Here are two more fixes for the bootconfig tracing scripts. They address
resetting existing histograms and applying saved filter strings. The
patches can be applied independently.

The first patch fixes histogram removal when a filter contains brackets
or repeated spaces. A failed removal can leave a variable provider
installed after reset, including a case where the helper returns success.
It uses separate sed expressions for [active] and [paused], following
your portability feedback.

The second patch keeps quoted strings intact when applying a bootconfig.
Currently, repeated spaces can be collapsed and literal wildcard
characters can expand to filenames, changing the filter being installed.

Both were tested in temporary tracefs instances on my Ubuntu machine,
running kernel 7.0.0-38-generic, with recording disabled. The individual
patch emails include the reproduction details.

Feedback is welcome.

Thanks,
Eduardo

Eduardo Mucelli Rezende Oliveira (2):
  tools/bootconfig: Preserve filters when resetting histogram triggers
  tools/bootconfig: Quote command strings when applying ftrace settings

 tools/bootconfig/scripts/bconf2ftrace.sh | 2 +-
 tools/bootconfig/scripts/ftrace.sh       | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)


base-commit: e28458ef30ad66ce7cd2299ec5ee8a8a016d67ff
-- 
2.53.0


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

* [PATCH 1/2] tools/bootconfig: Preserve filters when resetting histogram triggers
  2026-10-28 19:36 [PATCH 0/2] tools/bootconfig: Preserve filters when resetting and applying tracing Eduardo Mucelli Rezende Oliveira
@ 2026-10-28 19:36 ` Eduardo Mucelli Rezende Oliveira
  2026-10-28 19:36 ` [PATCH 2/2] tools/bootconfig: Quote command strings when applying ftrace settings Eduardo Mucelli Rezende Oliveira
  1 sibling, 0 replies; 3+ messages in thread
From: Eduardo Mucelli Rezende Oliveira @ 2026-10-28 19:36 UTC (permalink / raw)
  To: mhiramat; +Cc: rostedt, linux-trace-kernel, linux-kernel

reset_trigger_file() cuts a trigger line at its first '[' to discard the
histogram state suffix. A filter such as prev_comm ~ "[ab]" is truncated
inside its quoted string, producing an invalid removal command.

This also breaks the first pass that removes action histograms before
their variable providers. If an action histogram cannot be removed and
its provider is visited first in the second pass, the provider is busy
and remains installed after reset.

Remove only the trailing [active] or [paused] annotation. Quote the line
while extracting the command so that repeated spaces inside the filter
also survive, allowing the action histogram to match and be removed.

Fixes: 5675fd4ef51f ("tools/bootconfig: Add --init option for bconf2ftrace.sh")
Signed-off-by: Eduardo Mucelli Rezende Oliveira <edumucelli@gmail.com>
---
I tested reset_trigger_file in a temporary tracefs instance on my Ubuntu
machine, running kernel 7.0.0-38-generic, with recording disabled.
With an action histogram depending on a provider that comes first in
the event-directory order, the original helper left the provider behind.
This happened with a bracketed filter and with repeated spaces inside
a string. The spaced-string case even returned success.

With the fix, both histograms were removed. I also checked active and
paused histograms, onmax actions, and ordinary filter controls.

 tools/bootconfig/scripts/ftrace.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/bootconfig/scripts/ftrace.sh b/tools/bootconfig/scripts/ftrace.sh
index cc5250c64699..c2b993f8e366 100644
--- a/tools/bootconfig/scripts/ftrace.sh
+++ b/tools/bootconfig/scripts/ftrace.sh
@@ -21,13 +21,13 @@ reset_trigger_file() {
     # remove action triggers first
     grep -H ':on[^:]*(' $@ |
     while read line; do
-        cmd=`echo $line | cut -f2- -d: | cut -f1 -d"["`
+	cmd=`echo "$line" | cut -f2- -d: | sed -e 's/ \[active\]$//' -e 's/ \[paused\]$//'`
 	file=`echo $line | cut -f1 -d:`
 	echo "!$cmd" >> $file
     done
     grep -Hv ^# $@ |
     while read line; do
-        cmd=`echo $line | cut -f2- -d: | cut -f1 -d"["`
+	cmd=`echo "$line" | cut -f2- -d: | sed -e 's/ \[active\]$//' -e 's/ \[paused\]$//'`
 	file=`echo $line | cut -f1 -d:`
 	echo "!$cmd" > $file
     done
-- 
2.53.0


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

* [PATCH 2/2] tools/bootconfig: Quote command strings when applying ftrace settings
  2026-10-28 19:36 [PATCH 0/2] tools/bootconfig: Preserve filters when resetting and applying tracing Eduardo Mucelli Rezende Oliveira
  2026-10-28 19:36 ` [PATCH 1/2] tools/bootconfig: Preserve filters when resetting histogram triggers Eduardo Mucelli Rezende Oliveira
@ 2026-10-28 19:36 ` Eduardo Mucelli Rezende Oliveira
  1 sibling, 0 replies; 3+ messages in thread
From: Eduardo Mucelli Rezende Oliveira @ 2026-10-28 19:36 UTC (permalink / raw)
  To: mhiramat; +Cc: rostedt, linux-trace-kernel, linux-kernel

run_cmd() passes its command string to eval using an unquoted $*. The
shell performs field splitting and pathname expansion before eval can
parse the quotes in that string.

For example, an event filter prev_comm == "a  b" is applied as
prev_comm == "a b". A literal "*" surrounded by spaces inside a filter
can also expand to filenames in the current directory. The printed
command still contains the intended string, so --apply changes the
settings even though the preview looks correct.

Quote "$*" when passing it to eval to preserve the command string. This
fixes both per-event filters and histogram actions.

Fixes: 7e66ef0046cc ("tools/bootconfig: Add a script to generate ftrace shell-command from bootconfig")
Signed-off-by: Eduardo Mucelli Rezende Oliveira <edumucelli@gmail.com>
---
I tested this with hand-written configs in a temporary tracefs instance
on my Ubuntu machine, running kernel 7.0.0-38-generic, with recording
disabled. I checked both event filters and histogram action filters.
The original helper collapsed repeated spaces and expanded a literal *
into filenames. With the fix, the strings were preserved. Ordinary
string and numeric filters worked in both versions.

 tools/bootconfig/scripts/bconf2ftrace.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/bootconfig/scripts/bconf2ftrace.sh b/tools/bootconfig/scripts/bconf2ftrace.sh
index 7745c97e7abd..ea7b17d0d4d7 100755
--- a/tools/bootconfig/scripts/bconf2ftrace.sh
+++ b/tools/bootconfig/scripts/bconf2ftrace.sh
@@ -41,7 +41,7 @@ fi
 run_cmd() { # command
 	echo "$*"
 	if [ x"$APPLY" != x ]; then # apply command
-		eval $*
+		eval "$*"
 	fi
 }
 
-- 
2.53.0


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

end of thread, other threads:[~2026-10-28 19:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-28 19:36 [PATCH 0/2] tools/bootconfig: Preserve filters when resetting and applying tracing Eduardo Mucelli Rezende Oliveira
2026-10-28 19:36 ` [PATCH 1/2] tools/bootconfig: Preserve filters when resetting histogram triggers Eduardo Mucelli Rezende Oliveira
2026-10-28 19:36 ` [PATCH 2/2] tools/bootconfig: Quote command strings when applying ftrace settings Eduardo Mucelli Rezende Oliveira

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®