Re: [PATCH 2/2] tools/bootconfig: Preserve all-f tracing CPU masks on export

From: Masami Hiramatsu (Google)

Date: Sun Nov 22 2026 - 04:36:54 EST


Hi,

On Sun, 22 Nov 2026 01:34:59 +0100, Eduardo Mucelli Rezende Oliveira <edumucelli@xxxxxxxxx> wrote:
> ftrace2bconf.sh skips tracing_cpumask values consisting only of f
> digits. For example, on a four-CPU system this drops the mask f. If the
> mask is subsequently narrowed to 3, replaying the export cannot restore
> tracing on all four CPUs because the configuration has no cpumask entry.
>
> Always emit the observed mask as one quoted bootconfig value so a replay

ftrace2bconf.sh intentionally omits default ftrace settings (such as
tracing_on=1, current_tracer=nop, trace_clock=local, max_graph_depth=0, and
default trace_options) because bootconfig is primarily meant for boot-time
tracing where ftrace starts in its default state. So I think the current
implementation is good enough.

For replaying an exported bootconfig onto a live system, bconf2ftrace.sh
provides --init (which calls initialize_ftrace() in
tools/bootconfig/scripts/ftrace.sh). Rather than emitting default values in
ftrace2bconf.sh, shouldn't initialize_ftrace() in
tools/bootconfig/scripts/ftrace.sh be updated to reset tracing_cpumask
back to all CPUs? Without --init, none of the other omitted defaults (e.g.
tracing_on=1, current_tracer=nop, trace_clock=local) are restored on replay
either.


> can restore it.
>
> Fixes: 2b86062a34a8 ("tools/bootconfig: Add a script to generates bootconfig from ftrace")
> Signed-off-by: Eduardo Mucelli Rezende Oliveira <edumucelli@xxxxxxxxx>
> ---
> tools/bootconfig/scripts/ftrace2bconf.sh | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)

> diff --git a/tools/bootconfig/scripts/ftrace2bconf.sh b/tools/bootconfig/scripts/ftrace2bconf.sh
> --- a/tools/bootconfig/scripts/ftrace2bconf.sh
> +++ b/tools/bootconfig/scripts/ftrace2bconf.sh
> @@ -278,9 +278,7 @@ instance_options() { # [instance-name]
> emit_kv $PREFIX.alloc_snapshot
> fi
> val=`cat $INSTANCE/tracing_cpumask`
> + emit_kv $PREFIX.cpumask = "\"$val\""

Unconditionally emitting `cpumask` here introduces a portability regression
for boot-time tracing: if a user exports a bootconfig on a 4-CPU system
with the default all-CPUs mask ("f"), this will now emit `ftrace.cpumask =
"f"`. When that bootconfig is used to boot a machine with more CPUs (e.g.,
8 or 16 CPUs), tracing will be silently restricted to CPUs 0-3 instead of
tracing all CPUs.

Skipping the default all-CPUs mask was intentional so exported bootconfigs
remain portable across machines with different CPU counts. If the replay
problem occurs with `bconf2ftrace.sh --init`, the right fix is to reset
`tracing_cpumask` in
`tools/bootconfig/scripts/ftrace.sh:initialize_ftrace()` rather than
unconditionally emitting the default mask here.

Thanks,

> - emit_kv $PREFIX.cpumask = "\"$val\""
> - fi
> val=`cat $INSTANCE/tracing_on`

--
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>