On Mon, 21 Sep 2026 19:30:46 +0800
Xiang Gao <[email protected]> wrote:

> +static struct trace_mem_stats trace_buffers_memory_cpu(int cpu)
> +{
> +     struct trace_mem_stats stats = {};
> +     struct trace_array *tr;
> +
> +     guard(mutex)(&trace_types_lock);
> +
> +     list_for_each_entry(tr, &ftrace_trace_arrays, list)
> +             trace_array_buffer_memory(tr, cpu, &stats.buffers,
> +                                       &stats.snapshot);
> +
> +     /* Account for the bootstrapping temp_buffer as well. */
> +     if (temp_buffer)
> +             stats.buffers += ring_buffer_memory_size(temp_buffer, cpu);
> +
> +     return stats;
> +}
> +
> +static int trace_mem_per_cpu_show(struct seq_file *m, void *v)
> +{
> +     struct trace_mem_stats stats = 
> trace_buffers_memory_cpu((long)m->private);
> +
> +     seq_printf(m, "buffers: %lu\n", stats.buffers >> 10);
> +     seq_printf(m, "snapshot_buffers: %lu\n", stats.snapshot >> 10);
> +
> +     return 0;
> +}
> +
> +static int trace_mem_per_cpu_open(struct inode *inode, struct file *file)
> +{
> +     int ret;
> +
> +     ret = tracing_check_open_get_tr(NULL);
> +     if (ret)
> +             return ret;
> +
> +     return single_open(file, trace_mem_per_cpu_show, inode->i_private);
> +}
> +
> +static const struct file_operations trace_mem_per_cpu_fops = {
> +     .open           = trace_mem_per_cpu_open,
> +     .read           = seq_read,
> +     .llseek         = seq_lseek,
> +     .release        = single_release,
> +};
> +

These functions seems like a dead copy of non-per-cpu version. Can you
reuse the same code?

Thank you,

-- 
Masami Hiramatsu (Google) <[email protected]>

Reply via email to