Re: [PATCH 1/3] libtracefs: New API for getting the raw format of a histogram

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon,  6 Dec 2021 17:08:53 +0200
"Yordan Karadzhov (VMware)" <y.karadz@xxxxxxxxx> wrote:

> +/*
> + * tracefs_hist_echo_fmt - show the raw format of the histogram
> + * @seq: A trace_seq to store the format string
> + * @hist: The histogram to read format from
> + *
> + * This show the raw format that describes the state of the histogram.
> + *
> + * Returns the size of the format string on succes -1 on error.
> + */
> +int tracefs_hist_echo_fmt(struct trace_seq *seq,
> +			  struct tracefs_instance *instance,
> +			  struct tracefs_hist *hist)
> +{
> +	const char *event = hist->event_name;
> +	const char *system = hist->system;
> +	int fmt_size;
> +	char *path;
> +	char *fmt;
> +
> +	path = tracefs_event_get_file(instance, system, event, "trigger");
> +	if (!path)
> +		return -1;
> +
> +	fmt = tracefs_event_file_read(instance, system, event, path,
> +				      &fmt_size);

First, path should just be "trigger" as tracefs_event_file_read() is a
short cut to get to the files for the event. I'm surprised that this even
worked.

> +	if (!fmt)
> +		return -1;
> +
> +	trace_seq_puts(seq, fmt);

Second, just reading the trigger file is not useful, as the trigger file
holds triggers, not just histograms. And you can have more than one
histogram in the trigger file. For instance, I could do:

 # cd /sys/kernel/debug/tracing/events/sched/sched_switch
 # echo stacktrace > trigger
 # echo 'hist:keys=prev_pid' >> trigger
 # echo 'hist:keys=next_pid' >> trigger
 # cat trigger
stacktrace:unlimited
hist:keys=prev_pid:vals=hitcount:sort=hitcount:size=2048 [active]
hist:keys=next_pid:vals=hitcount:sort=hitcount:size=2048 [active]

Is this really what you want?

-- Steve

> +	tracefs_put_tracing_file(path);
> +
> +	return fmt_size;
> +}
> +
>  /*
>   * tracefs_hist_command - Create, start, pause, destroy a histogram for an event
>   * @instance: The instance the histogram will be in (NULL for toplevel)




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux