From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161204AbcFQQRs (ORCPT ); Fri, 17 Jun 2016 12:17:48 -0400 Received: from smtprelay0126.hostedemail.com ([216.40.44.126]:58719 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932683AbcFQQRq (ORCPT ); Fri, 17 Jun 2016 12:17:46 -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:1543:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2553:2559:2562:2692:2693:3138:3139:3140:3141:3142:3355:3622:3865:3866:3867:3868:3870:3871:3872:3874:4250:4321:4385:4470:4605:5007:6119:6261:7875:10004:10400:10848:10967:11026:11232:11658:11914:12043:12291:12296:12438:12517:12519:12555:12663:12683:12740:13095:13439:14096:14097:14181:14659:14721:21080:21324:21433:30034:30054:30090:30091,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,LFtime:2,LUA_SUMMARY:none X-HE-Tag: sofa49_257446374b202 X-Filterd-Recvd-Size: 3939 Date: Fri, 17 Jun 2016 12:17:36 -0400 From: Steven Rostedt To: Jeremy Linton Cc: linux-kernel@vger.kernel.org, acme@redhat.com, namhyung@kernel.org, kapileshwar.singh@arm.com, scottwood@freescale.com, hekuang@huawei.com Subject: Re: [RFC/PATCH] perf: Add sizeof operator support Message-ID: <20160617121736.023f009f@gandalf.local.home> In-Reply-To: <1465922312-30064-1-git-send-email-jeremy.linton@arm.com> References: <1465922312-30064-1-git-send-email-jeremy.linton@arm.com> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; 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 Tue, 14 Jun 2016 11:38:32 -0500 Jeremy Linton wrote: > There are a fair number of tracepoints in the kernel making > use of the sizeof operator. Allow perf to understand some of > those cases, and report a more informative error message for > the ones it cannot understand. > > Signed-off-by: Jeremy Linton > --- > > So this is as much a RFC as a patch because the use of sizeof > seems to extend to structures, pointers, etc that aren't easy > to deduce from userspace. I'm not sure what the correct solution > should be in those cases. > > tools/lib/traceevent/event-parse.c | 46 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 46 insertions(+) > > diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c > index a8b6357..5813248 100644 > --- a/tools/lib/traceevent/event-parse.c > +++ b/tools/lib/traceevent/event-parse.c > @@ -31,6 +31,8 @@ > #include > #include > #include > +#include > +#include > > #include > #include "event-parse.h" > @@ -2868,6 +2870,46 @@ process_str(struct event_format *event __maybe_unused, struct print_arg *arg, > } > > static enum event_type > +process_sizeof(struct event_format *event __maybe_unused, struct print_arg *arg, > + char **tok) > +{ > + char *token; > + char *atom; > + > + if (process_paren(event, arg, &token) < 0) > + goto out_free; > + > + atom = arg->atom.atom; > + if (arg->type != PRINT_ATOM) { > + do_warning_event(event, "didn't understand %s for sizeof\n", > + token); > + goto out_free_atom; > + } > + > + if (strcmp(token, "__u64") == 0) { > + if (asprintf(&arg->atom.atom, "%zd", sizeof(__u64)) < 0) > + goto out_free_atom; > + } else if (strcmp(token, "__u32") == 0) { > + if (asprintf(&arg->atom.atom, "%zd", sizeof(__u32)) < 0) > + goto out_free_atom; What events are doing sizeof(__u64) and sizeof(__u32)? First, that's useless, as sizeof(__u64) will always be 8, and sizeof(__u32) will always be 4. What exactly is this fixing? -- Steve > + } else { > + do_warning_event(event, "unknown sizeof %s\n", token); > + goto out_free_atom; > + } > + > + free(atom); > + *tok = token; > + return EVENT_DELIM; > + > + out_free_atom: > + free_token(atom); > + out_free: > + free_token(token); > + *tok = NULL; > + return EVENT_ERROR; > +} > + > +static enum event_type > process_bitmask(struct event_format *event __maybe_unused, struct print_arg *arg, > char **tok) > { > @@ -3026,6 +3068,10 @@ process_function(struct event_format *event, struct print_arg *arg, > free_token(token); > return process_dynamic_array_len(event, arg, tok); > } > + if (strcmp(token, "sizeof") == 0) { > + free_token(token); > + return process_sizeof(event, arg, tok); > + } > > func = find_func_handler(event->pevent, token); > if (func) {