diff options
author | Namhyung Kim <namhyung@kernel.org> | 2015-04-06 01:36:16 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-04-08 08:07:09 -0400 |
commit | 3201f0dc42f7fad9387afc4692cea3d0c730cba2 (patch) | |
tree | 571296cc0ee74dff4bf2b8dae460c9e27d4472f8 | |
parent | ba92732e9808df679ddf75c5ea1c0caae6d7dce2 (diff) |
tools lib traceevent: Honor operator priority
Currently it ignores operator priority and just sets processed args as a
right operand. But it could result in priority inversion in case that
the right operand is also a operator arg and its priority is lower.
For example, following print format is from new kmem events.
"page=%p", REC->pfn != -1UL ? (((struct page *)(0xffffea0000000000UL)) + (REC->pfn)) : ((void *)0)
But this was treated as below:
REC->pfn != ((null - 1UL) ? ((struct page *)0xffffea0000000000UL + REC->pfn) : (void *) 0)
In this case, the right arg was '?' operator which has lower priority.
But it just sets the whole arg so making the output confusing - page was
always 0 or 1 since that's the result of logical operation.
With this patch, it can handle it properly like following:
((REC->pfn != (null - 1UL)) ? ((struct page *)0xffffea0000000000UL + REC->pfn) : (void *) 0)
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Joonsoo Kim <js1304@gmail.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/1428298576-9785-10-git-send-email-namhyung@kernel.org
[ Replaced 'swap' with 'rotate' in a comment as requested by Steve and agreed by Namhyung ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/lib/traceevent/event-parse.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 6d31b6419d37..12a7e2a40c89 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c | |||
@@ -1939,7 +1939,22 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok) | |||
1939 | goto out_warn_free; | 1939 | goto out_warn_free; |
1940 | 1940 | ||
1941 | type = process_arg_token(event, right, tok, type); | 1941 | type = process_arg_token(event, right, tok, type); |
1942 | arg->op.right = right; | 1942 | |
1943 | if (right->type == PRINT_OP && | ||
1944 | get_op_prio(arg->op.op) < get_op_prio(right->op.op)) { | ||
1945 | struct print_arg tmp; | ||
1946 | |||
1947 | /* rotate ops according to the priority */ | ||
1948 | arg->op.right = right->op.left; | ||
1949 | |||
1950 | tmp = *arg; | ||
1951 | *arg = *right; | ||
1952 | *right = tmp; | ||
1953 | |||
1954 | arg->op.left = right; | ||
1955 | } else { | ||
1956 | arg->op.right = right; | ||
1957 | } | ||
1943 | 1958 | ||
1944 | } else if (strcmp(token, "[") == 0) { | 1959 | } else if (strcmp(token, "[") == 0) { |
1945 | 1960 | ||