From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752217AbbDTUqU (ORCPT ); Mon, 20 Apr 2015 16:46:20 -0400 Received: from smtprelay0223.hostedemail.com ([216.40.44.223]:39191 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750872AbbDTUqT (ORCPT ); Mon, 20 Apr 2015 16:46:19 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 30,2,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::,RULES_HIT:41:355:379:541:599:800:960:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1431:1437:1515:1516:1518:1534:1543:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2553:2559:2562:2892:2901:3138:3139:3140:3141:3142:3355:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:5007:6261:7875:7903:8603:9010:9163:10010:10400:10848:10967:11026:11232:11473:11658:11914:12043:12296:12438:12517:12519:12740:13138:13180:13229:13231:21060: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:1:0 X-HE-Tag: boy89_7116e2a378526 X-Filterd-Recvd-Size: 3882 Date: Mon, 20 Apr 2015 16:46:16 -0400 From: Steven Rostedt To: Arnaldo Carvalho de Melo Cc: David Ahern , Namhyung Kim , LKML Subject: Re: perf/tracepoints access to interpreted strings Message-ID: <20150420164616.4227fae9@gandalf.local.home> In-Reply-To: <20150415180927.GR16027@kernel.org> References: <552E8FB8.6010005@gmail.com> <20150415180927.GR16027@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 Wed, 15 Apr 2015 15:09:27 -0300 Arnaldo Carvalho de Melo wrote: > Em Wed, Apr 15, 2015 at 10:20:08AM -0600, David Ahern escreveu: > > I was hoping you could provide points on how to get access to an interpreted > > field in a tracepoint within perf. > > > This is an example of the tracepoint: > > > # cat /sys/kernel/debug/tracing/events/irq/softirq_exit/format > > name: softirq_exit > > ID: 99 > > format: > > field:unsigned short common_type; offset:0; size:2; signed:0; > > field:unsigned char common_flags; offset:2; size:1; signed:0; > > field:unsigned char common_preempt_count; offset:3; size:1; signed:0; > > field:int common_pid; offset:4; size:4; signed:1; > > field:int common_padding; offset:8; size:4; signed:1; > > > > field:unsigned int vec; offset:12; size:4; signed:0; > > > > print fmt: "vec=%u [action=%s]", REC->vec, __print_symbolic(REC->vec, { > > HI_SOFTIRQ, "HI" }, { TIMER_SOFTIRQ, "TIMER" }, { NET_TX_SOFTIRQ, "NET_TX" > > }, { NET_RX_SOFTIRQ, "NET_RX" }, { BLOCK_SOFTIRQ, "BLOCK" }, { > > BLOCK_IOPOLL_SOFTIRQ, "BLOCK_IOPOLL" }, { TASKLET_SOFTIRQ, "TASKLET" }, { > > SCHED_SOFTIRQ, "SCHED" }, { HRTIMER_SOFTIRQ, "HRTIMER" }, { RCU_SOFTIRQ, > > "RCU" }) > > > I would like to programmatically extract the action string. 'perf script' > > prints the samples fine which suggests libtraceevent extracts the > > information somehow. > > > Can you provide a suggestion -- something along the lines of > > perf_evsel__intval() or perf_evsel__rawptr()? > > We'll gonna have to parse the "print fmt" thing and look for entries > surrounded by [], then match it with the list of parameters, so that we > can end up with a: > > const char *perf_evsel__enum_entry(struct perf_evsel *evsel, > struct perf_sample *sample, > const char *enum_name, > int value); > > That would return one of "TIMER", "NET_TX", etc, that is, 0, > 1, N. > > If it is strictly an enum, i.e. no holes and just by looking at the > "format" file above I don't see how it could have holes, albeit enums > may have, we can as well have this: > > const char *perf_evsel__enum(struct perf_evsel *evsel, > struct perf_sample *sample, > const char *enum_name); > > That would return an array of strings that you could directly access, > indexing using some of the fields. > > I.e. internally we would see the tracepoint format file as: > > field:enum action vec; offset:12; size:4; signed:0; > > enum: action: TIMER, NET_TX, NET_RX, BLOCK, BLOCK_IOPOLL, TASKLET, SCHED, HRTIMER, RCU > Note, with the new TRACE_DEFINE_ENUM() that was already added to Linus's tree, that print_fmt now looks like: print fmt: "vec=%u [action=%s]", REC->vec, __print_symbolic(REC->vec, { 0, "HI" }, { 1, "TIMER" }, { 2, "NET_TX" }, { 3, "NET_RX" }, { 4, "BLOCK" }, { 5, "BLOCK_IOPOLL" }, { 6, "TASKLET" }, { 7, "SCHED" }, { 8, "HRTIMER" }, { 9, "RCU" }) -- Steve