lkml.org 
[lkml]   [2018]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 5/9] perf utils: add support for arch standard events
On Wed, Feb 07, 2018 at 01:45:00AM +0800, John Garry wrote:

SNIP

> + char *perpkg;
> + char *unit;
> + char *metric_expr;
> + char *metric_name;
> + char *metric_group;
> + struct list_head list;
> + char strings[];
> +};
> +
> +static LIST_HEAD(arch_std_events);
> +
> +#define ADD_EVENT_STRING(string) do { if (string) { \
> + es->string = strings; \
> + strings += snprintf(strings, len, "%s", string) + 1; \
> +} } while (0)
> +
> +static int save_arch_std_events(void *data, char *name, char *event,
> + char *desc, char *long_desc, char *pmu,
> + char *unit, char *perpkg, char *metric_expr,
> + char *metric_name, char *metric_group)
> +{
> + struct event_struct *es;
> + struct stat *sb = data;
> + int len;
> + char *strings;
> +
> + /*
> + * Lazily allocate size of the json file to hold the
> + * strings, which would be more than large enough.
> + */
> + len = sb->st_size;
> +
> + es = malloc(sizeof(*es) + len);

hum, so for single event you allocate buffer of the size
of the entire file this event is defined in?

what do I miss? I assume there're more of those arch-defined
events defined in the single file..

jirka

\
 
 \ /
  Last update: 2018-02-08 14:57    [W:0.137 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site