Linux Trace Kernel
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kyuwon Cho" <kyuwon.cho@skku.edu>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH] tracing: check field variable references before removing histograms
Date: Fri, 04 Dec 2026 05:34:11 +0000	[thread overview]
Message-ID: <sashiko-outbox-249148@kernel.org> (raw)
In-Reply-To: <179634936693.931432.2335780990204797817@skku.edu>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] tracing: check_field_var_refs() fails to exclude sibling
  auxiliary hists
--

commit 341ded2e2cce86f2db2302bd7321ebea20e6b91e
Author: Kyuwon Cho <kyuwon.cho@skku.edu>

tracing: check field variable references before removing histograms

This commit stores each auxiliary field-variable histogram pointer in
struct field_var_hist and checks its variables for external references,
excluding the owning target histogram, before removing a histogram trigger
or truncating a trigger file.

> diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
> index d4702ad4e0036..a711bc2bf0bba 100644
> --- a/kernel/trace/trace_events_hist.c
> +++ b/kernel/trace/trace_events_hist.c

[ ... ]

> @@ -977,14 +979,16 @@ static struct hist_field *find_any_var_ref(struct hist_trigger_data *hist_data,
>   * Return: The VAR_REF field referencing the variable if so, NULL if not
>   */
>  static struct hist_field *find_any_var_ref(struct hist_trigger_data *hist_data,
> -					   unsigned int var_idx)
> +					   unsigned int var_idx,
> +					   struct hist_trigger_data *exclude)
>  {
>  	struct trace_array *tr = hist_data->event_file->tr;
>  	struct hist_field *found = NULL;
>  	struct hist_var_data *var_data;
>  
>  	list_for_each_entry(var_data, &tr->hist_vars, list) {
> -		if (var_data->hist_data == hist_data)
> +		if (var_data->hist_data == hist_data ||
> +		    var_data->hist_data == exclude)
>  			continue;
>  		found = find_var_ref(var_data->hist_data, hist_data, var_idx);
>  		if (found)

[ ... ]

> @@ -1026,6 +1032,21 @@ static bool check_var_refs(struct hist_trigger_data *hist_data)
>  	return found;
>  }
>  
> +static bool check_field_var_refs(struct hist_trigger_data *hist_data)
> +{
> +	unsigned int i;
> +
> +	for (i = 0; i < hist_data->n_field_var_hists; i++) {
> +		if (!hist_data->field_var_hists[i]->hist_data)
> +			continue;
> +		if (check_var_refs(hist_data->field_var_hists[i]->hist_data,
> +				   hist_data))
> +			return true;
> +	}
> +
> +	return false;
> +}

[Severity: Medium]
Can check_field_var_refs() permanently block removal of a target histogram
when one of its auxiliary field-variable histograms references a sibling
auxiliary histogram?

In a multi-parameter action such as mysynth(prio, prio+$synthetic_prio),
create_field_var_hist() creates a first auxiliary histogram defining
synthetic_prio and then a second auxiliary histogram whose expression
resolves $synthetic_prio against the first.

Because find_any_var_ref() skips only hist_data and the single exclude
pointer, the sibling reference makes removal return -EBUSY.  Neither
auxiliary histogram can be removed directly while the target references
both, leaving the triggers and synthetic event stuck until reboot.

Excluding sibling entries in hist_data->field_var_hists[] and tearing them
down in reverse order in unregister_field_var_hists() would avoid this
deadlock.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/179634936693.931432.2335780990204797817@skku.edu?part=1

      reply	other threads:[~2026-12-04  5:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  5:12 [PATCH] tracing: check field variable references before removing histograms Kyuwon Cho
2026-12-04  5:34 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-249148@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kyuwon.cho@skku.edu \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox