Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761941AbbBJEII (ORCPT ); Mon, 9 Feb 2015 23:08:08 -0500 Received: from cdptpa-outbound-snat.email.rr.com ([107.14.166.227]:52008 "EHLO cdptpa-oedge-vip.email.rr.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754133AbbBJEIH (ORCPT ); Mon, 9 Feb 2015 23:08:07 -0500 Date: Mon, 9 Feb 2015 23:08:36 -0500 From: Steven Rostedt To: Alexei Starovoitov Cc: Ingo Molnar , Namhyung Kim , Arnaldo Carvalho de Melo , Jiri Olsa , Masami Hiramatsu , linux-api@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 linux-trace 4/8] samples: bpf: simple tracing example in C Message-ID: <20150209230836.7f913c60@grimm.local.home> In-Reply-To: <1423539961-21792-5-git-send-email-ast@plumgrid.com> References: <1423539961-21792-1-git-send-email-ast@plumgrid.com> <1423539961-21792-5-git-send-email-ast@plumgrid.com> 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 X-RR-Connecting-IP: 107.14.168.118:25 X-Cloudmark-Score: 0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1582 Lines: 40 On Mon, 9 Feb 2015 19:45:57 -0800 Alexei Starovoitov wrote: > +int perf_event_mmap(int fd); > +int perf_event_poll(int fd); > +typedef void (*print_fn)(void *data, int size); > +void perf_event_read(print_fn fn); > +struct trace_entry { > + unsigned short type; > + unsigned char flags; > + unsigned char preempt_count; > + int pid; > +}; > + Please do not hard code any structures. This is not a stable ABI, and it may not even match if you are running 32 bit userspace on top of a 64 bit kernel. Please parse the format files. libtraceevent does this for you. If need be, link to that. But if you look at the event format files you'll see the offsets and sizes in the binary code: 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; I don't want to get stuck with pinned kernel data structures again. We had 4 blank bytes of data for every event, because latency top hard coded the field. Luckily, the 64 bit / 32 bit interface caused latency top to have to use the event_parse code to work, and we were able to remove that field after it was converted. -- Steve -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/