Re: [PATCH v2 1/4] libtracefs: Add new constructors for histograms

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

 



On Fri, Sep 24, 2021 at 12:59 PM Yordan Karadzhov (VMware)
<y.karadz@xxxxxxxxx> wrote:
>
> The current way to create an N-dimensional histogram is bit
> counterintuitive. We first have to call tracefs_hist_alloc()
> which is essentially a constructor of 1d histogram. Then we
> have to call tracefs_hist_add_key() N-1 times in order to
> increase the dimentions of the histogram. Here we transform
> tracefs_hist_alloc() into a constructor of N-dimensional
> histogram and we also add 2 helper constructors for 1d and
> 2d histograms.
>
> Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@xxxxxxxxx>
> ---
>  include/tracefs.h  | 19 +++++++++--
>  src/tracefs-hist.c | 84 ++++++++++++++++++++++++++++++++++++++--------
>  2 files changed, 87 insertions(+), 16 deletions(-)
>
> diff --git a/include/tracefs.h b/include/tracefs.h
> index 9d84777..5c4141e 100644
> --- a/include/tracefs.h
> +++ b/include/tracefs.h
> @@ -310,10 +310,25 @@ enum tracefs_compare {
>  };
>
>  void tracefs_hist_free(struct tracefs_hist *hist);
> +struct tracefs_hist *
> +tracefs_hist1d_alloc(struct tep_handle *tep,
> +                    const char *system, const char *event_name,
> +                    const char *key, enum tracefs_hist_key_type type);
> +struct tracefs_hist *
> +tracefs_hist2d_alloc(struct tep_handle *tep,
> +                    const char *system, const char *event_name,
> +                    const char *key1, enum tracefs_hist_key_type type1,
> +                    const char *key2, enum tracefs_hist_key_type type2);
> +
> +struct tracefs_hist_axis {
> +       const char *key;
> +       enum tracefs_hist_key_type type;
> +};
> +
>  struct tracefs_hist *
>  tracefs_hist_alloc(struct tep_handle *tep,

For consistency with the newly added "alloc" APIs, this should be
renamed. The dimensions of the histogram are part of the name, this
one is for N dimensions:
  tracefs_hist_alloc_1d()
  tracefs_hist_alloc_2d()
  tracefs_hist_alloc_nd()
or something like that.

> -                  const char *system, const char *event,
> -                  const char *key, enum tracefs_hist_key_type type);
> +                  const char *system, const char *event_name,
> +                  struct tracefs_hist_axis *axes);
>  int tracefs_hist_add_key(struct tracefs_hist *hist, const char *key,
>                          enum tracefs_hist_key_type type);
>  int tracefs_hist_add_value(struct tracefs_hist *hist, const char *value);
> diff --git a/src/tracefs-hist.c b/src/tracefs-hist.c
> index c112b68..ea12204 100644
> --- a/src/tracefs-hist.c
> +++ b/src/tracefs-hist.c
> @@ -189,7 +189,7 @@ void tracefs_hist_free(struct tracefs_hist *hist)
>  }

[...]

--
Tzvetomir (Ceco) Stoyanov
VMware Open Source Technology Center



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

  Powered by Linux