Re: [PATCH] tools/bootconfig: Preserve structured histogram filter strings

From: Eduardo Mucelli

Date: Sat Nov 21 2026 - 16:14:49 EST


Thanks Masami!

On Fri, Nov 20, 2026 at 4:43 PM Masami Hiramatsu (Google)
<mhiramat@xxxxxxxxxx> wrote:
>
> On Thu, 19 Nov 2026 00:02:52 +0100, Eduardo Mucelli Rezende Oliveira <edumucelli@xxxxxxxxx> wrote:
> > print_one_histogram() expands the hist.filter value through an unquoted
> > command substitution. Field splitting collapses repeated whitespace in
> > quoted filter strings, and pathname expansion replaces literal wildcard
> > characters with filenames. The generated command is already incorrect
> > before run_cmd() evaluates it.
> >
> > Print the filter with printf and a quoted command substitution so that
> > structured histogram filters reach the generated command unchanged.
> >
> > Fixes: f134ebb28126 ("tools/bootconfig: Add histogram syntax support to bconf2ftrace.sh")
> > Signed-off-by: Eduardo Mucelli Rezende Oliveira <edumucelli@xxxxxxxxx>
>
> OK, looks good to me. Let me pick it.
>
> Thanks!
>
> > ---
> > Hi Masami,
> >
> > Thanks for picking up the run_cmd() quoting fix. I had this small
> > follow-up ready in case that patch went in.
> >
> > Here's the thread for that patch.
> > https://lore.kernel.org/all/97454eceb5d56bf956740b8998972767bcfe6c70.1793216183.git.edumucelli@xxxxxxxxx/
> >
> > This uses the structured hist.filter option documented here:
> > https://docs.kernel.org/trace/boottime-trace.html#ftrace-histogram-options
> >
> > I tested numbered and unnumbered histograms in a temporary tracefs
> > instance on my Ubuntu machine, running kernel 7.0.0-38-generic. Repeated
> > spaces and tabs were collapsed, and a wildcard expanded to filenames.
> > With the fix, the generated and installed filters matched the input.
> >
> > The run_cmd() quoting fix was present in both versions of this test.
> > This additional change fixes the string while the histogram command is
> > being generated, before it reaches run_cmd().
> >
> > Feedback is welcome.
> >
> > Thanks,
> > Eduardo
> >
> > tools/bootconfig/scripts/bconf2ftrace.sh | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> >
> > base-commit: 0ad31c3252d4c626a93ae6251340ef86b18342d0
> >
> > diff --git a/tools/bootconfig/scripts/bconf2ftrace.sh b/tools/bootconfig/scripts/bconf2ftrace.sh
> > index 6a3535a2c..0992e54c6 100755
> > --- a/tools/bootconfig/scripts/bconf2ftrace.sh
> > +++ b/tools/bootconfig/scripts/bconf2ftrace.sh
> > @@ -163,7 +163,7 @@ print_one_histogram() { # prefix
> > print_hist_actions ${1} "onmatch" "event"
> >
> > if xbc_has_key "${1}.filter"; then
> > - echo -n " if "`xbc_get_val ${1}.filter`
> > + printf ' if %s' "$(xbc_get_val ${1}.filter)"
> > fi
> > }
> >
> >
>
> --
> Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>



--
Eduardo Mucelli R. Oliveira -- http://eduar.do