Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1717178

Re: [PATCH v2 01/19] perf, tools: Save max_x, max_y in xyarray

From Jiri Olsa <jolsa@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2 01/19] perf, tools: Save max_x, max_y in xyarray
Date 2017-08-22 10:30 +0200
Message-ID <uhcJs-8b9-3@gated-at.bofh.it> (permalink)
References <udrxo-1lO-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Aug 11, 2017 at 04:26:16PM -0700, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
> 
> Save the original array dimensions in xyarrays, so that users can retrieve them
> later. Add some inline functions to access these fields.
> 
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> ---
>  tools/perf/util/xyarray.c |  2 ++
>  tools/perf/util/xyarray.h | 12 ++++++++++++
>  2 files changed, 14 insertions(+)
> 
> diff --git a/tools/perf/util/xyarray.c b/tools/perf/util/xyarray.c
> index 7251fdbabced..c8f415d9877b 100644
> --- a/tools/perf/util/xyarray.c
> +++ b/tools/perf/util/xyarray.c
> @@ -12,6 +12,8 @@ struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size)
>  		xy->entry_size = entry_size;
>  		xy->row_size   = row_size;
>  		xy->entries    = xlen * ylen;
> +		xy->max_x      = xlen;
> +		xy->max_y      = ylen;
>  	}
>  
>  	return xy;
> diff --git a/tools/perf/util/xyarray.h b/tools/perf/util/xyarray.h
> index 7f30af371b7e..785884158137 100644
> --- a/tools/perf/util/xyarray.h
> +++ b/tools/perf/util/xyarray.h
> @@ -7,6 +7,8 @@ struct xyarray {
>  	size_t row_size;
>  	size_t entry_size;
>  	size_t entries;
> +	size_t max_x;
> +	size_t max_y;
>  	char contents[];
>  };
>  
> @@ -19,4 +21,14 @@ static inline void *xyarray__entry(struct xyarray *xy, int x, int y)
>  	return &xy->contents[x * xy->row_size + y * xy->entry_size];
>  }
>  
> +static inline int xy_max_y(struct xyarray *xy)
> +{
> +	return xy->max_x;
> +}
> +
> +static inline int xy_max_x(struct xyarray *xy)
> +{
> +	return xy->max_y;
> +}

I think you should follow the standard naming
and use xyarray__max_x and xyarray__max_y

jirka

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 01/19] perf, tools: Save max_x, max_y in xyarray Andi Kleen <andi@firstfloor.org> - 2017-08-12 01:40 +0200
  [PATCH v2 13/19] perf, tools: Print generic metric header even for failed expressions Andi Kleen <andi@firstfloor.org> - 2017-08-12 01:40 +0200
  [PATCH v2 02/19] perf, tools: Fix buffer overflow while freeing events Andi Kleen <andi@firstfloor.org> - 2017-08-12 01:40 +0200
    Re: [PATCH v2 02/19] perf, tools: Fix buffer overflow while freeing  events Jiri Olsa <jolsa@redhat.com> - 2017-08-22 10:30 +0200
    [tip:perf/core] perf evsel: Fix buffer overflow while freeing  events tip-bot for Andi Kleen <tipbot@zytor.com> - 2017-08-24 10:30 +0200
  Re: [PATCH v2 01/19] perf, tools: Save max_x, max_y in xyarray Jiri Olsa <jolsa@redhat.com> - 2017-08-14 22:20 +0200
    Re: [PATCH v2 01/19] perf, tools: Save max_x, max_y in xyarray Andi Kleen <ak@linux.intel.com> - 2017-08-14 22:40 +0200
      Re: [PATCH v2 01/19] perf, tools: Save max_x, max_y in xyarray Jiri Olsa <jolsa@redhat.com> - 2017-08-14 23:20 +0200
  Re: [PATCH v2 01/19] perf, tools: Save max_x, max_y in xyarray Jiri Olsa <jolsa@redhat.com> - 2017-08-22 10:30 +0200
    Re: [PATCH v2 01/19] perf, tools: Save max_x, max_y in xyarray Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-08-22 16:50 +0200
      Re: [PATCH v2 01/19] perf, tools: Save max_x, max_y in xyarray Jiri Olsa <jolsa@redhat.com> - 2017-08-22 16:50 +0200
        Re: [PATCH v2 01/19] perf, tools: Save max_x, max_y in xyarray Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-08-22 17:10 +0200
  [tip:perf/core] perf xyarray: Save max_x, max_y tip-bot for Andi Kleen <tipbot@zytor.com> - 2017-08-24 10:30 +0200

csiph-web