Re: [PATCH] tracing: Move histogram trigger variables from stack to per CPU structure

From: Steven Rostedt
Date: Fri Apr 04 2025 - 09:58:45 EST


On Thu, 3 Apr 2025 20:42:51 -0400
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> +static struct hist_pad *get_hist_pad(void)
> +{
> + struct hist_pad *hist_pad;
> + int cnt;
> +
> + preempt_disable();
> + hist_pad = per_cpu_ptr(hist_pads, smp_processor_id());
> + if (!hist_pad)
> + goto out_fail;

Hmm, this is incorrect. hist_pads can be NULL or allocated, so the check
should be:

if (!hist_pads)
goto fail;
hist_pad = per_cpu_ptr(hist_pads, smp_processor_id());

Will send v2.

-- Steve


> +
> + if (this_cpu_read(hist_pad_cnt) == MAX_HIST_CNT)
> + goto out_fail;
> +
> + cnt = this_cpu_inc_return(hist_pad_cnt) - 1;
> +
> + return &hist_pad[cnt];
> +