Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp586122ybh; Wed, 11 Mar 2020 06:59:08 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtpPyngaQGNM4DgE+ahAkSMHwJQffyd2bmlzsgECid/+6mYR28NPFq+Qb71eafX5aHMgRwQ X-Received: by 2002:a05:6830:204c:: with SMTP id f12mr2444898otp.356.1583935147974; Wed, 11 Mar 2020 06:59:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583935147; cv=none; d=google.com; s=arc-20160816; b=ojJZzVX9/BT9Dc4L9B9GMPs+cy56BNWfI42zHpqZqOxyJPkBkpU+6cV4JIXj2nh1vg OYVZot9WbU2lAQ7uP0NA9rBjcl0GjKyO0aW7xix+6rJC+NFLg6TqYkfMJACnHQlsq/+0 ScRT/UhMSVBKmdNOwtquOekZBIp1dx2RVF90tsZFLjjqNYEhrNGNRICD4dXJKRBtok4h 4/BCGM8xkpnOI4Os7Lm7GDYuIAu2kocxFV0jV7i/sLMAvYV9Cw7XvKOcxsbpHl9q8uwx 8BXfFrpHVlvQNoZbupLDPr7t33BScAzmKnX2ImqgjtTGg0Jc+ok6Jvr9n43PmVENzC3+ zsWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:date:from :dkim-signature; bh=ZFbI6jxyOLmy5zFpBob+W3k/vHN4No+5Sal6e/neHIw=; b=xkexuDab2LoycRGc4rCpKKkalLZY0H+ZWZASS9LHtMu4isWi/cptT7wmDLR/Kolc08 LOFDED9ZWNz1sGVhj3ChkD/sLdzVEuAoHcaB2HfygKVIGv9OkOmOXYcGx11ffPSiJtYh RblOPEjJLmXzAIoS8eYdvI5QXWYlRh0yIvk5H9OiNCDlAdOP6LGqace26IBDnAQOzUfO qApoWdIiqoLmN1I0xtIBQbBAYUzIy0nXzBNEPuE8dXjs5Cxsp6H0zA4nJfBpaOa2tvkd APA34psiNE3+9URS1CqK20uO+5eX3KO7pA6Sz/KTLOBdIT+oQnF1kTlHRxDtFu0Ip/4C oR6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="MJ/vXcaL"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e25si1186097oth.38.2020.03.11.06.58.55; Wed, 11 Mar 2020 06:59:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="MJ/vXcaL"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729728AbgCKN6V (ORCPT + 99 others); Wed, 11 Mar 2020 09:58:21 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:39946 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729531AbgCKN6U (ORCPT ); Wed, 11 Mar 2020 09:58:20 -0400 Received: by mail-qt1-f195.google.com with SMTP id n5so1586328qtv.7; Wed, 11 Mar 2020 06:58:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ZFbI6jxyOLmy5zFpBob+W3k/vHN4No+5Sal6e/neHIw=; b=MJ/vXcaLbWq4pdseRy5Y62G9sjYVpjg6mNRVkJeAu8QWzOR1z8LvnWvY+pyohBpAZp Mx0/CNA6iA/9y2fnXz3/wM7jn6KicFUCrSi9KWVgduy71ebVe/HHHxu/SdvIdlIx+cx3 N2PKBwLdn1HsXgRdpk6FWIoLl5bbCkY+eT26ZssHKXyFWtUUlmdnQwF3/0htvEI8DbdY M+Z6gHKLEkQE9xRPLDM3nBdkFB7isdW3CtWvX/SzjA9aARYYaRcK8pzuF+LJiqPqLM6F 8mxgmsV6xV/mjeNR+sgOdnz0QkRVVaCnxhEttAmR8fgsNdLS333fCBoHq5LQfd565ZlE l/KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZFbI6jxyOLmy5zFpBob+W3k/vHN4No+5Sal6e/neHIw=; b=kwPWji8VwNxDko7JdqBwZGc1v9qNdS8Nx3xn97sjNCkXFBcJTosyTl+u8uHEZtN/GX d2JNslCBStCDfWr/a6GbiSsNw3Ex3/kazwtcFi3grwAbYKuEbhghOk/QCw++Sk4YIG+G XcZFICFJHXPRoOvjUbZff/8LOXb4XOp7cRqvgAXsWQGU8dOciJbN8eeRudQipvVc1NQV 3EQCz43u5Hsk+PErrabsGPx5mE1t5ZhomNK/MeNMndD9eNVWyL20gF+dKfHloohjU1/g JVBKN37N0RQBUNxd12zyFNoBmR07iaQOc2fRRxt/gZ7jcVei3LBP5n+4vZsjG6sHcumk MdNA== X-Gm-Message-State: ANhLgQ1rYQPC52CdFx33V/gj2I44gs+QVjLsWDYSZ/k17xHOty/AhXoY tE4qoXjzMOSKd92eatYYwOHJtwPgVaY= X-Received: by 2002:ac8:5642:: with SMTP id 2mr2813951qtt.348.1583935098914; Wed, 11 Mar 2020 06:58:18 -0700 (PDT) Received: from quaco.ghostprotocols.net ([179.97.37.151]) by smtp.gmail.com with ESMTPSA id 4sm21067754qky.106.2020.03.11.06.58.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2020 06:58:18 -0700 (PDT) From: Arnaldo Carvalho de Melo X-Google-Original-From: Arnaldo Carvalho de Melo Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id E72E040009; Wed, 11 Mar 2020 10:58:15 -0300 (-03) Date: Wed, 11 Mar 2020 10:58:15 -0300 To: Thomas Richter Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, gor@linux.ibm.com, sumanthk@linux.ibm.com, heiko.carstens@de.ibm.com Subject: Re: [PATCH] perf documentation: Add desription forHEADER_TRACING_DATA Message-ID: <20200311135815.GD19277@kernel.org> References: <20200303070846.18335-1-tmricht@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200303070846.18335-1-tmricht@linux.ibm.com> X-Url: http://acmel.wordpress.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Tue, Mar 03, 2020 at 08:08:46AM +0100, Thomas Richter escreveu: > Add description and layout in the perf.data file for > the header part describing trace data used in commands > perf record -e XXX > where XXX is a probe or tracepoint. Did you write this from scratch? I was going thru it and couldn't find what that "Note member 'ftrace_count' can be zero." refers to, couldn't find this ftrace_counter, is this outdated? [root@five ~]# find /sys/kernel/debug/tracing/events/ -type f | xargs grep ftrace_count [root@five ~]# find /sys/kernel/debug/tracing/events/ -name ftrace_count [root@five ~]# uname -a Linux five 5.5.5-200.fc31.x86_64 #1 SMP Wed Feb 19 23:28:07 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux [root@five ~]# The part about using a probe and then go on dissecting it is really nice, I'll try reproducing it soon, Thanks, - Arnaldo > Signed-off-by: Thomas Richter > --- > .../Documentation/perf.data-file-format.txt | 106 +++++++++++++++++- > 1 file changed, 105 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/Documentation/perf.data-file-format.txt b/tools/perf/Documentation/perf.data-file-format.txt > index b0152e1095c5..e3f78269e417 100644 > --- a/tools/perf/Documentation/perf.data-file-format.txt > +++ b/tools/perf/Documentation/perf.data-file-format.txt > @@ -67,9 +67,113 @@ flags. These define the valid bits: > > HEADER_RESERVED = 0, /* always cleared */ > HEADER_FIRST_FEATURE = 1, > + > HEADER_TRACING_DATA = 1, > > -Describe me. > +The header consists of several entries of variable length such as file > +contents of several trace files like 'header_page', 'header_event'. > +Also complete probe//format files are included. > +The numbers in parenthesis are structure members refered to later in > +the description and example. > + > +struct tracing_data { > + char birthday[3] = { 23, 8, 68 }; Eyecatcher > + char tracing[12] = "tracing0.6"; Type and version > + uint8_t bigendian; Big or little endian platform > + uint8_t sizelong; Size of long in bytes > + uint32_t pagesize: Pagesize in bytes > + char hdr_page[12] = "header_page" Name of file (1) > + uint64_t hdr_page_size; File size in bytes (1a) > + char hdr_page_contents[hdr_page_size]; Contents of file (1b) > + char hdr_event[13] = "header_event" Name of file (2) > + uint64_t hdr_event_size; File size in bytes > + char hdr_page_contents[hdr_event_size]; Contents of file > + uint32_t ftrace_count; Number of ftrace entries (3) > + struct { Size and content of file > + uint64_t file_size; > + char file_content[file_size] > + } ftrace[ftrace_count] ftrace_count array elements > + uint32_t event_types; Number of event types (4) > + struct { > + char name[]; Name, null terminatedg (5) > + uint32_t count; Number of probes (6) > + struct { > + uint64_t file_size; (7) > + char file_content[file_size]; (8) > + }[count]; Count always > 0 or omitted > + }[event_types]; > + uint32_t proc_kallsyms_size; Always zero > + uint64_t printk_file_size; File size in bytes (9) > + char printk_format[printk_file_size]; Contents of file > + uint64_t saved_cmdlines_size; File size in bytes (10) > + char saved_cmdlines[saved_cmdlines_size]; Contents of file > +}; > + > +The structure description is straight forward. It contains file name, size > +and contents from > +- /sys/kernel/debug/tracing/events/header_page (1, 1a, 1b) > +and > +- /sys/kernel/debug/tracing/events/header_event (2). > + > +This is followed by a variable length part of format files found in directory > +/sys/kernel/debug/tracing//events/ftrace/*/format for events selected > +by the perf record -e XXX commands. Note member 'ftrace_count' can be zero. > + > +Next are the number of probe types specified by the perf record -e XXXX > +command (4). Each type has stored its name (5), which is a null terminated > +string, and the number of probes (6) belonging to this type. For each > +active probe follows the file size (7) and file contents (8) of that probe. > + > +Finally the file size and contents of two more files is saved: > +- Size of /proc/kallsyms (always hard coded to zero and no file contents) > +- /sys/kernel/debug/tracing/printk_formats (9) > +- /sys/kernel/debug/tracing/saved_cmdlines (10) > + > +Example for the dynamic probes and trace points: > +Consider these probes have been set up: > + # ./perf probe -l > + probe:vfs_getname (on getname_flags:72@fs/namei.c with pathname) > + probe:xxx (on do_file_open_root:11@fs/namei.c) > + # > +and this command used for recording: > + # ./perf record -e probe:vfs_getname -e probe:xxx \ > + -e tcp:tcp_retransmit_skb -- touch /tmp/xxx > + > +This command line leads to two events in directory > + /sys/kernel/debug/tracing/events/probe/vfs_getname > + /sys/kernel/debug/tracing/events/probe/xxx > +and a tracepoint in directory > + /sys/kernel/debug/tracing/events/tcp/tcp_retransmit_skb. > + > +This results in this event_count (5) layout in the perf.data: > +using command: > + # od -Ax -t x4z -v perf.data > + > +0011a0 00000000 00000270 726f6265 00000000 >.......probe....< > + ^^ (4)^^^'' ''(5)''' ''--(6)- > + 4: # of types --> 2 > + 5: first one named 'probe' > + 6: 2 probes defined > +0011b0 02000000 00000001 766e616d 653a2078 >........vname: x< > + --###### (7)##### ## > + 7: first one 'named' xxx with format file size 0x176 > +0011c0 78780a49 443a2031 3138360a 666f726d >xx.ID: 1186.form< > +... > +001320 45432d3e 5f5f7072 6f62655f 69700a00 >EC->__probe_ip..< > + '' > +001330 00000000 0001e36e 616d653a 20766673 >.......name: vfs< > + ''(7)''' '''''' > + 7: second one named 'vfs_getname' with format file size 0x1e3 > +001340 5f676574 6e616d65 0a49443a 20313138 >_getname.ID: 118< > +... > +001510 70617468 6e616d65 290a7463 70000000 >pathname).tcp...< > + ''(5 )'--(6)- > +001520 00010000 00000000 05696e61 6d653a20 >.........iname: < > + ----#### (7)##### #### > + 5: second event type named 'tcp' > + 6: 1 probe defined > + 7: size of format file 0x568 > +001530 7463705f 72657472 616e736d 69745f73 >tcp_retransmit_s< > > HEADER_BUILD_ID = 2, > > -- > 2.23.0 > -- - Arnaldo