From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932183AbbDHPLe (ORCPT ); Wed, 8 Apr 2015 11:11:34 -0400 Received: from terminus.zytor.com ([198.137.202.10]:40225 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753447AbbDHPLb (ORCPT ); Wed, 8 Apr 2015 11:11:31 -0400 Date: Wed, 8 Apr 2015 08:11:04 -0700 From: tip-bot for Namhyung Kim Message-ID: Cc: a.p.zijlstra@chello.nl, rostedt@goodmis.org, mingo@kernel.org, namhyung@kernel.org, dsahern@gmail.com, acme@redhat.com, js1304@gmail.com, hpa@zytor.com, jolsa@redhat.com, linux-kernel@vger.kernel.org, minchan@kernel.org, tglx@linutronix.de Reply-To: linux-kernel@vger.kernel.org, jolsa@redhat.com, hpa@zytor.com, minchan@kernel.org, tglx@linutronix.de, acme@redhat.com, dsahern@gmail.com, namhyung@kernel.org, js1304@gmail.com, mingo@kernel.org, a.p.zijlstra@chello.nl, rostedt@goodmis.org In-Reply-To: <1428298576-9785-10-git-send-email-namhyung@kernel.org> References: <1428298576-9785-10-git-send-email-namhyung@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] tools lib traceevent: Honor operator priority Git-Commit-ID: 3201f0dc42f7fad9387afc4692cea3d0c730cba2 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 3201f0dc42f7fad9387afc4692cea3d0c730cba2 Gitweb: http://git.kernel.org/tip/3201f0dc42f7fad9387afc4692cea3d0c730cba2 Author: Namhyung Kim AuthorDate: Mon, 6 Apr 2015 14:36:16 +0900 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 8 Apr 2015 09:07:09 -0300 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 Acked-by: Steven Rostedt Cc: David Ahern Cc: Jiri Olsa Cc: Joonsoo Kim Cc: Minchan Kim Cc: Peter Zijlstra 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 --- tools/lib/traceevent/event-parse.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 6d31b64..12a7e2a 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) goto out_warn_free; type = process_arg_token(event, right, tok, type); - arg->op.right = right; + + if (right->type == PRINT_OP && + get_op_prio(arg->op.op) < get_op_prio(right->op.op)) { + struct print_arg tmp; + + /* rotate ops according to the priority */ + arg->op.right = right->op.left; + + tmp = *arg; + *arg = *right; + *right = tmp; + + arg->op.left = right; + } else { + arg->op.right = right; + } } else if (strcmp(token, "[") == 0) {