Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Revert "perf tools: Default to cpu// for events v5"

This reverts commit 50e200f07948 ("perf tools: Default to cpu// for
events v5")

The fixup cannot handle the case that
new style format(which without //) mixed with
other different formats.

For example,
group events with new style format: {mem-stores,mem-loads}
some hardware event + new style event: cycles,mem-loads
Cache event + new style event: LLC-loads,mem-loads
Raw event + new style event:
cpu/event=0xc8,umask=0x08/,mem-loads
old style event and new stytle mixture: mem-stores,cpu/mem-loads/

Signed-off-by: Kan Liang <kan.liang@intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1412694532-23391-2-git-send-email-kan.liang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Kan Liang and committed by
Arnaldo Carvalho de Melo
42f60c2d b56d5bef

+1 -54
-1
tools/perf/util/include/linux/string.h
··· 1 1 #include <string.h> 2 2 3 3 void *memdup(const void *src, size_t len); 4 - int str_append(char **s, int *len, const char *a);
+1 -29
tools/perf/util/parse-events.c
··· 6 6 #include "parse-options.h" 7 7 #include "parse-events.h" 8 8 #include "exec_cmd.h" 9 - #include "linux/string.h" 9 + #include "string.h" 10 10 #include "symbol.h" 11 11 #include "cache.h" 12 12 #include "header.h" ··· 863 863 return 0; 864 864 } 865 865 866 - static int parse_events__scanner(const char *str, void *data, int start_token); 867 - 868 - static int parse_events_fixup(int ret, const char *str, void *data, 869 - int start_token) 870 - { 871 - char *o = strdup(str); 872 - char *s = NULL; 873 - char *t = o; 874 - char *p; 875 - int len = 0; 876 - 877 - if (!o) 878 - return ret; 879 - while ((p = strsep(&t, ",")) != NULL) { 880 - if (s) 881 - str_append(&s, &len, ","); 882 - str_append(&s, &len, "cpu/"); 883 - str_append(&s, &len, p); 884 - str_append(&s, &len, "/"); 885 - } 886 - free(o); 887 - if (!s) 888 - return -ENOMEM; 889 - return parse_events__scanner(s, data, start_token); 890 - } 891 - 892 866 static int parse_events__scanner(const char *str, void *data, int start_token) 893 867 { 894 868 YY_BUFFER_STATE buffer; ··· 883 909 parse_events__flush_buffer(buffer, scanner); 884 910 parse_events__delete_buffer(buffer, scanner); 885 911 parse_events_lex_destroy(scanner); 886 - if (ret && !strchr(str, '/')) 887 - ret = parse_events_fixup(ret, str, data, start_token); 888 912 return ret; 889 913 } 890 914
-24
tools/perf/util/string.c
··· 357 357 358 358 return p; 359 359 } 360 - 361 - /** 362 - * str_append - reallocate string and append another 363 - * @s: pointer to string pointer 364 - * @len: pointer to len (initialized) 365 - * @a: string to append. 366 - */ 367 - int str_append(char **s, int *len, const char *a) 368 - { 369 - int olen = *s ? strlen(*s) : 0; 370 - int nlen = olen + strlen(a) + 1; 371 - if (*len < nlen) { 372 - *len = *len * 2; 373 - if (*len < nlen) 374 - *len = nlen; 375 - *s = realloc(*s, *len); 376 - if (!*s) 377 - return -ENOMEM; 378 - if (olen == 0) 379 - **s = 0; 380 - } 381 - strcat(*s, a); 382 - return 0; 383 - }