aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-04-05 17:01:10 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-04-08 10:34:26 -0400
commite9e94e3bd862d31777335722e747e97d9821bc1d (patch)
tree950e87eb9870450f94e10c598eb320f450ff16ca /tools/perf/util
parent854c5548dfad017920a36201d40449fdbad90bfb (diff)
perf trace: Ignore "overwrite" field if present in /events/header_page
That is not used in perf where we have the LOST events. Without this patch we get: [root@doppio ~]# perf lock report | head -3 Warning: Error: expected 'data' but read 'overwrite' So, to make the same perf command work with kernels with and without this field, introduce variants for the parsing routines to not warn the user in such case. Discussed-with: Steven Rostedt <rostedt@goodmis.org> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/trace-event-parse.c49
1 files changed, 34 insertions, 15 deletions
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index 9b3c20f42f98..3b81250ffedb 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -37,6 +37,8 @@ int header_page_ts_offset;
37int header_page_ts_size; 37int header_page_ts_size;
38int header_page_size_offset; 38int header_page_size_offset;
39int header_page_size_size; 39int header_page_size_size;
40int header_page_overwrite_offset;
41int header_page_overwrite_size;
40int header_page_data_offset; 42int header_page_data_offset;
41int header_page_data_size; 43int header_page_data_size;
42 44
@@ -628,23 +630,32 @@ static int test_type(enum event_type type, enum event_type expect)
628 return 0; 630 return 0;
629} 631}
630 632
631static int test_type_token(enum event_type type, char *token, 633static int __test_type_token(enum event_type type, char *token,
632 enum event_type expect, const char *expect_tok) 634 enum event_type expect, const char *expect_tok,
635 bool warn)
633{ 636{
634 if (type != expect) { 637 if (type != expect) {
635 warning("Error: expected type %d but read %d", 638 if (warn)
636 expect, type); 639 warning("Error: expected type %d but read %d",
640 expect, type);
637 return -1; 641 return -1;
638 } 642 }
639 643
640 if (strcmp(token, expect_tok) != 0) { 644 if (strcmp(token, expect_tok) != 0) {
641 warning("Error: expected '%s' but read '%s'", 645 if (warn)
642 expect_tok, token); 646 warning("Error: expected '%s' but read '%s'",
647 expect_tok, token);
643 return -1; 648 return -1;
644 } 649 }
645 return 0; 650 return 0;
646} 651}
647 652
653static int test_type_token(enum event_type type, char *token,
654 enum event_type expect, const char *expect_tok)
655{
656 return __test_type_token(type, token, expect, expect_tok, true);
657}
658
648static int __read_expect_type(enum event_type expect, char **tok, int newline_ok) 659static int __read_expect_type(enum event_type expect, char **tok, int newline_ok)
649{ 660{
650 enum event_type type; 661 enum event_type type;
@@ -661,7 +672,8 @@ static int read_expect_type(enum event_type expect, char **tok)
661 return __read_expect_type(expect, tok, 1); 672 return __read_expect_type(expect, tok, 1);
662} 673}
663 674
664static int __read_expected(enum event_type expect, const char *str, int newline_ok) 675static int __read_expected(enum event_type expect, const char *str,
676 int newline_ok, bool warn)
665{ 677{
666 enum event_type type; 678 enum event_type type;
667 char *token; 679 char *token;
@@ -672,21 +684,26 @@ static int __read_expected(enum event_type expect, const char *str, int newline_
672 else 684 else
673 type = read_token_item(&token); 685 type = read_token_item(&token);
674 686
675 ret = test_type_token(type, token, expect, str); 687 ret = __test_type_token(type, token, expect, str, warn);
676 688
677 free_token(token); 689 free_token(token);
678 690
679 return ret; 691 return ret;
680} 692}
681 693
694static int read_expected_warn(enum event_type expect, const char *str, bool warn)
695{
696 return __read_expected(expect, str, 1, warn);
697}
698
682static int read_expected(enum event_type expect, const char *str) 699static int read_expected(enum event_type expect, const char *str)
683{ 700{
684 return __read_expected(expect, str, 1); 701 return __read_expected(expect, str, 1, true);
685} 702}
686 703
687static int read_expected_item(enum event_type expect, const char *str) 704static int read_expected_item(enum event_type expect, const char *str)
688{ 705{
689 return __read_expected(expect, str, 0); 706 return __read_expected(expect, str, 0, true);
690} 707}
691 708
692static char *event_read_name(void) 709static char *event_read_name(void)
@@ -3088,7 +3105,7 @@ static void print_args(struct print_arg *args)
3088} 3105}
3089 3106
3090static void parse_header_field(const char *field, 3107static void parse_header_field(const char *field,
3091 int *offset, int *size) 3108 int *offset, int *size, bool warn)
3092{ 3109{
3093 char *token; 3110 char *token;
3094 int type; 3111 int type;
@@ -3103,7 +3120,7 @@ static void parse_header_field(const char *field,
3103 goto fail; 3120 goto fail;
3104 free_token(token); 3121 free_token(token);
3105 3122
3106 if (read_expected(EVENT_ITEM, field) < 0) 3123 if (read_expected_warn(EVENT_ITEM, field, warn) < 0)
3107 return; 3124 return;
3108 if (read_expected(EVENT_OP, ";") < 0) 3125 if (read_expected(EVENT_OP, ";") < 0)
3109 return; 3126 return;
@@ -3160,11 +3177,13 @@ int parse_header_page(char *buf, unsigned long size)
3160 init_input_buf(buf, size); 3177 init_input_buf(buf, size);
3161 3178
3162 parse_header_field("timestamp", &header_page_ts_offset, 3179 parse_header_field("timestamp", &header_page_ts_offset,
3163 &header_page_ts_size); 3180 &header_page_ts_size, true);
3164 parse_header_field("commit", &header_page_size_offset, 3181 parse_header_field("commit", &header_page_size_offset,
3165 &header_page_size_size); 3182 &header_page_size_size, true);
3183 parse_header_field("overwrite", &header_page_overwrite_offset,
3184 &header_page_overwrite_size, false);
3166 parse_header_field("data", &header_page_data_offset, 3185 parse_header_field("data", &header_page_data_offset,
3167 &header_page_data_size); 3186 &header_page_data_size, true);
3168 3187
3169 return 0; 3188 return 0;
3170} 3189}