[PATCH v2 3/4] tools/bootconfig: Reset histogram variable tracking for each instance

From: Eduardo Mucelli Rezende Oliveira

Date: Sat Oct 31 2026 - 06:26:57 EST


Histogram variables are scoped to a trace instance, but ftrace2bconf.sh
keeps DEFINED_VARS across calls to event_options(). If an earlier instance
has defined ts0, a later instance can export a consumer of its own ts0
before exporting that instance's provider. Replaying the configuration
then fails because the local variable has not been defined yet.

Initialize the variable resolver state when starting each instance so
that its consumers are deferred until their local providers are exported.

Fixes: 2b86062a34a8 ("tools/bootconfig: Add a script to generates bootconfig from ftrace")
Signed-off-by: Eduardo Mucelli Rezende Oliveira <edumucelli@xxxxxxxxx>
---
I reproduced this with two temporary tracefs instances on my Ubuntu
machine, running kernel 7.0.0-38-generic, with recording disabled. Both
instances defined a histogram variable with the same name. In the second
instance, a consumer sorted before its local provider.

The original exporter put that consumer first and replay failed with an
undefined variable. With the fix, the local provider was exported first
and all three histograms were restored correctly.

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

diff --git a/tools/bootconfig/scripts/ftrace2bconf.sh b/tools/bootconfig/scripts/ftrace2bconf.sh
index 9100ebcd5af6..b63e04bf9400 100755
--- a/tools/bootconfig/scripts/ftrace2bconf.sh
+++ b/tools/bootconfig/scripts/ftrace2bconf.sh
@@ -84,8 +84,6 @@ synth_event_options() {
}

# Variables resolver
-DEFINED_VARS=
-UNRESOLVED_EVENTS=

defined_vars() { # event-dir
grep "^hist" $1/trigger | grep -o ':[a-zA-Z0-9_]*='
@@ -164,6 +162,8 @@ retry_unresolved() {

event_options() {
# PREFIX and INSTANCE must be set
+ DEFINED_VARS=
+ UNRESOLVED_EVENTS=
if [ $PREFIX = "ftrace" ]; then
# define the dynamic events
kprobe_event_options
--
2.53.0