Re: [PATCH v3 10/11] perf tools report: Implement browsing of individual samples

From: Jiri Olsa
Date: Mon Mar 04 2019 - 10:27:38 EST


On Thu, Feb 28, 2019 at 10:35:49AM -0800, Andi Kleen wrote:

SNIP

> diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
> index 6040eb49ea23..ba8a58f2cdd0 100644
> --- a/tools/perf/util/hist.c
> +++ b/tools/perf/util/hist.c
> @@ -593,6 +593,40 @@ static struct hist_entry *hists__findnew_entry(struct hists *hists,
> return he;
> }
>
> +static unsigned random_max(unsigned high)
> +{
> + unsigned thresh = -high % high;
> + for (;;) {
> + unsigned r = random();
> + if (r >= thresh)
> + return r % high;
> + }
> +}
> +
> +static void hists__res_sample(struct hist_entry *he, struct perf_sample *sample)
> +{
> + struct res_sample *r;
> + int j;
> +
> + if (!he->res_samples) {
> + he->res_samples = calloc(sizeof(struct res_sample),
> + symbol_conf.res_sample);
> + if (!he->res_samples)
> + return;
> + }

please allocate this in hist_entry__init

thanks,
jirka