From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753108AbbDFOpK (ORCPT ); Mon, 6 Apr 2015 10:45:10 -0400 Received: from smtprelay0095.hostedemail.com ([216.40.44.95]:48619 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752756AbbDFOpH (ORCPT ); Mon, 6 Apr 2015 10:45:07 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:966:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2553:2559:2562:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3872:3874:4321:4385:5007:6119:6261:7875:10004:10400:10848:10967:11026:11232:11658:11914:12043:12295:12296:12438:12517:12519:12555:12740:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: guide03_4993e684f1140 X-Filterd-Recvd-Size: 3425 Date: Mon, 6 Apr 2015 10:45:04 -0400 From: Steven Rostedt To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , David Ahern , Minchan Kim , Joonsoo Kim , linux-mm@kvack.org Subject: Re: [PATCH 9/9] tools lib traceevent: Honor operator priority Message-ID: <20150406104504.41e398d3@gandalf.local.home> In-Reply-To: <1428298576-9785-10-git-send-email-namhyung@kernel.org> References: <1428298576-9785-1-git-send-email-namhyung@kernel.org> <1428298576-9785-10-git-send-email-namhyung@kernel.org> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 6 Apr 2015 14:36:16 +0900 Namhyung Kim wrote: > 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) Nice catch. One nit. > > Cc: Steven Rostedt > Signed-off-by: Namhyung Kim > --- > 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 6d31b6419d37..604bea5c3fb0 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; > + > + /* swap ops according to the priority */ This isn't really a swap. Better term to use is "rotate". But other than that, Acked-by: Steven Rostedt -- Steve > + 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) { > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by kanga.kvack.org (Postfix) with ESMTP id 4D40B6B0038 for ; Mon, 6 Apr 2015 10:45:09 -0400 (EDT) Received: by iedfl3 with SMTP id fl3so25769236ied.1 for ; Mon, 06 Apr 2015 07:45:08 -0700 (PDT) Received: from smtprelay.hostedemail.com (smtprelay0054.hostedemail.com. [216.40.44.54]) by mx.google.com with ESMTP id i17si2623994ich.22.2015.04.06.07.45.07 for ; Mon, 06 Apr 2015 07:45:07 -0700 (PDT) Date: Mon, 6 Apr 2015 10:45:04 -0400 From: Steven Rostedt Subject: Re: [PATCH 9/9] tools lib traceevent: Honor operator priority Message-ID: <20150406104504.41e398d3@gandalf.local.home> In-Reply-To: <1428298576-9785-10-git-send-email-namhyung@kernel.org> References: <1428298576-9785-1-git-send-email-namhyung@kernel.org> <1428298576-9785-10-git-send-email-namhyung@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , David Ahern , Minchan Kim , Joonsoo Kim , linux-mm@kvack.org On Mon, 6 Apr 2015 14:36:16 +0900 Namhyung Kim wrote: > 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) Nice catch. One nit. > > Cc: Steven Rostedt > Signed-off-by: Namhyung Kim > --- > 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 6d31b6419d37..604bea5c3fb0 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; > + > + /* swap ops according to the priority */ This isn't really a swap. Better term to use is "rotate". But other than that, Acked-by: Steven Rostedt -- Steve > + 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) { > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org