Jiri Olsa
9fafd98f1b
perf tools: Fix various casting issues for 32 bits
...
- util/parse-events.c(parse_events_add_breakpoint)
need to use unsigned long instead of u64, otherwise
we get following gcc error on 32 bits:
error: cast from pointer to integer of different size
- util/header.c(print_event_desc)
cannot retype to signed type, otherwise we get following
gcc error on 32 bits:
error: comparison between signed and unsigned integer expressions
Signed-off-by: Jiri Olsa <jolsa@redhat.com >
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com >
Cc: Frederic Weisbecker <fweisbec@gmail.com >
Cc: Ingo Molnar <mingo@elte.hu >
Cc: Paul Mackerras <paulus@samba.org >
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl >
Link: http://lkml.kernel.org/r/1332267341-26338-2-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2012-03-22 15:11:18 -03:00
Arnaldo Carvalho de Melo
0d09eb7a9a
Merge branch 'perf/urgent' into perf/core
...
Merge Reason: to pick the fix:
commit e7f01d1
perf tools: Use scnprintf where applicable
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2012-03-22 15:09:08 -03:00
Arnaldo Carvalho de Melo
e7f01d1e3d
perf tools: Use scnprintf where applicable
...
Several places were expecting that the value returned was the number of
characters printed, not what would be printed if there was space.
Fix it by using the scnprintf and vscnprintf variants we inherited from
the kernel sources.
Some corner cases where the number of printed characters were not
accounted were fixed too.
Reported-by: Anton Blanchard <anton@samba.org >
Cc: Anton Blanchard <anton@samba.org >
Cc: Eric B Munson <emunson@mgebm.net >
Cc: David Ahern <dsahern@gmail.com >
Cc: Frederic Weisbecker <fweisbec@gmail.com >
Cc: Mike Galbraith <efault@gmx.de >
Cc: Paul Mackerras <paulus@samba.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Stephane Eranian <eranian@google.com >
Cc: Yanmin Zhang <yanmin_zhang@linux.intel.com >
Cc: stable@kernel.org
Link: http://lkml.kernel.org/n/tip-kwxo2eh29cxmd8ilixi2005x@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2012-03-14 12:36:19 -03:00
Stephane Eranian
330aa675b4
perf record: Add HEADER_BRANCH_STACK tag
...
This patch adds a new feature bit, namely,
HEADER_BRANCH_STACK. When present, it indicates
that sample records may contain branch stack.
This could be useful to a viewer to switch to
branch mode without having to parse all the
samples or without a specific cmdline option.
This will be used in a subsequent patch to
enhance perf report with branch stacks.
Signed-off-by: Stephane Eranian <eranian@google.com >
Cc: peterz@infradead.org
Cc: acme@redhat.com
Cc: asharma@fb.com
Cc: ravitillo@lbl.gov
Cc: vweaver1@eecs.utk.edu
Cc: khandual@linux.vnet.ibm.com
Cc: dsahern@gmail.com
Link: http://lkml.kernel.org/r/1331246868-19905-3-git-send-email-eranian@google.com
Signed-off-by: Ingo Molnar <mingo@elte.hu >
2012-03-09 08:26:08 +01:00
Stephane Eranian
114382a0ae
perf tools: Make perf able to read files from older ABIs
...
This patches provides a way to handle legacy perf.data
files. Legacy files are those using the older PERFFILE
signature.
For those, it is still necessary to detect endianness but
without comparing their header->attr_size with the
tool's own version as it may be different. Instead, we use
a reference table for all known sizes from the legacy era.
We try all the combinations for sizes and endianness. If we find
a match, we proceed, otherwise we return: "incompatible file
format".
This is also done for the pipe-mode file format.
Signed-off-by: Stephane Eranian <eranian@google.com >
Cc: peterz@infradead.org
Cc: acme@redhat.com
Cc: robert.richter@amd.com
Cc: ming.m.lin@intel.com
Cc: andi@firstfloor.org
Cc: asharma@fb.com
Cc: ravitillo@lbl.gov
Cc: vweaver1@eecs.utk.edu
Cc: khandual@linux.vnet.ibm.com
Cc: dsahern@gmail.com
Link: http://lkml.kernel.org/r/1328826068-11713-19-git-send-email-eranian@google.com
Signed-off-by: Ingo Molnar <mingo@elte.hu >
2012-03-09 08:26:07 +01:00
Stephane Eranian
62db90681c
perf tools: Fix ABI compatibility bug in print_event_desc()
...
This patches cleans up local variable types for msz and ret.
They need to be size_t and ssize_t respectively.
It also fixes a bug whereby perf would not read attr struct
with a different size than what it knows about.
Signed-off-by: Stephane Eranian <eranian@google.com >
Cc: peterz@infradead.org
Cc: acme@redhat.com
Cc: robert.richter@amd.com
Cc: ming.m.lin@intel.com
Cc: andi@firstfloor.org
Cc: asharma@fb.com
Cc: ravitillo@lbl.gov
Cc: vweaver1@eecs.utk.edu
Cc: khandual@linux.vnet.ibm.com
Cc: dsahern@gmail.com
Link: http://lkml.kernel.org/r/1328826068-11713-18-git-send-email-eranian@google.com
Signed-off-by: Ingo Molnar <mingo@elte.hu >
2012-03-09 08:26:06 +01:00
Stephane Eranian
69996df486
perf tools: Enable reading of perf.data files from different ABI rev
...
This patch allows perf to process perf.data files generated
using an ABI that has a different perf_event_attr struct size,
i.e., a different ABI version.
The perf_event_attr can be extended, yet perf needs to cope with
older perf.data files. Similarly, perf must be able to cope with
a perf.data file which is using a newer version of the ABI than
what it knows about.
This patch adds read_attr(), a routine that reads a
perf_event_attr struct from a file incrementally based on its
advertised size. If the on-file struct is smaller than what perf
knows, then the extra fields are zeroed. If the on-file struct
is bigger, then perf only uses what it knows about, the rest is
skipped.
Signed-off-by: Stephane Eranian <eranian@google.com >
Cc: peterz@infradead.org
Cc: acme@redhat.com
Cc: robert.richter@amd.com
Cc: ming.m.lin@intel.com
Cc: andi@firstfloor.org
Cc: asharma@fb.com
Cc: ravitillo@lbl.gov
Cc: vweaver1@eecs.utk.edu
Cc: khandual@linux.vnet.ibm.com
Cc: dsahern@gmail.com
Link: http://lkml.kernel.org/r/1328826068-11713-17-git-send-email-eranian@google.com
Signed-off-by: Ingo Molnar <mingo@elte.hu >
2012-03-09 08:26:06 +01:00
Robert Richter
f1c67db7e3
perf tools: Factor out feature op to process header sections
...
There is individual code for each feature to process header sections.
Adding a function pointer .process to struct feature_ops for keeping the
implementation in separate functions. Code to process header sections is
now a generic function.
Cc: Ingo Molnar <mingo@elte.hu >
Link: http://lkml.kernel.org/r/1328884916-5901-2-git-send-email-robert.richter@amd.com
Signed-off-by: Robert Richter <robert.richter@amd.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2012-02-13 23:33:36 -02:00
Robert Richter
08d95bd256
perf tools: Moving code in header.c
...
Needed for later changes. No modified functionality.
Cc: Ingo Molnar <mingo@elte.hu >
Link: http://lkml.kernel.org/r/1328884916-5901-1-git-send-email-robert.richter@amd.com
Signed-off-by: Robert Richter <robert.richter@amd.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2012-02-13 23:32:32 -02:00
Stephane Eranian
73323f541f
perf tools: fix endianness detection in perf.data
...
The current version of perf detects whether or not the perf.data file is
written in a different endianness using the attr_size field in the
header of the file. This field represents sizeof(struct perf_event_attr)
as known to perf record. If the sizes do not match, then perf tries the
byte-swapped version. If they match, then the tool assumes a different
endianness.
The issue with the approach is that it assumes the size of
perf_event_attr always has to match between perf record and perf report.
However, the kernel perf_event ABI is extensible. New fields can be
added to struct perf_event_attr. Consequently, it is not possible to use
attr_size to detect endianness.
This patch takes another approach by using the magic number written at
the beginning of the perf.data file to detect endianness. The magic
number is an eight-byte signature. It's primary purpose is to identify
(signature) a perf.data file. But it could also be used to encode the
endianness.
The patch introduces a new value for this signature. The key difference
is that the signature is written differently in the file depending on
the endianness. Thus, by comparing the signature from the file with the
tool's own signature it is possible to detect endianness. The new
signature is "PERFILE2".
Backward compatiblity with existing perf.data file is ensured.
Tested-by: David Ahern <dsahern@gmail.com >
Acked-by: David Ahern <dsahern@gmail.com >
Cc: Andi Kleen <andi@firstfloor.org >
Cc: Anshuman Khandual <khandual@linux.vnet.ibm.com >
Cc: Arun Sharma <asharma@fb.com >
Cc: David Ahern <dsahern@gmail.com >
Cc: Ingo Molnar <mingo@elte.hu >
Cc: Lin Ming <ming.m.lin@intel.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Roberto Agostino Vitillo <ravitillo@lbl.gov >
Cc: Robert Richter <robert.richter@amd.com >
Cc: Vince Weaver <vweaver1@eecs.utk.edu >
Link: http://lkml.kernel.org/r/1328187288-24395-15-git-send-email-eranian@google.com
Signed-off-by: Stephane Eranian <eranian@google.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2012-02-09 12:28:10 -02:00
Stephane Eranian
d8d9c282a1
perf tools: Fix strlen() bug in perf_event__synthesize_event_type()
...
The event_type record has a max length for the event name.
It's called MAX_EVENT_NAME.
The name may be truncated to fit the max length. But the header.size still
reflects the original name length. If that length is > MAX_EVENT_NAME, then the
header.size field is bogus. Fix this by using the length of the name after the
potential truncation.
Cc: David Ahern <dsahern@gmail.com >
Cc: Ingo Molnar <mingo@elte.hu >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: http://lkml.kernel.org/r/20120120094912.GA4882@quad
Signed-off-by: Stephane Eranian <eranian@google.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2012-01-30 22:29:12 -02:00
Stephane Eranian
f8f4b28722
perf tools: Fix strlen() bug in perf_event__synthesize_event_type()
...
The event_type record has a max length for the event name.
It's called MAX_EVENT_NAME.
The name may be truncated to fit the max length. But the header.size still
reflects the original name length. If that length is > MAX_EVENT_NAME, then the
header.size field is bogus. Fix this by using the length of the name after the
potential truncation.
Cc: David Ahern <dsahern@gmail.com >
Cc: Ingo Molnar <mingo@elte.hu >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: http://lkml.kernel.org/r/20120120094912.GA4882@quad
Signed-off-by: Stephane Eranian <eranian@google.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2012-01-24 20:31:34 -02:00
Ingo Molnar
f232806272
perf tools: Fix feature-bits rework fallout, remove unused variable
...
Cc: Arnaldo Carvalho de Melo <acme@redhat.com >
Cc: Frederic Weisbecker <fweisbec@gmail.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Stephane Eranian <eranian@google.com >
Cc: Robert Richter <robert.richter@amd.com >
Link: http://lkml.kernel.org/n/tip-lfckuwbl8m1ykb7t9ydsxe4r@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@elte.hu >
2011-12-29 21:26:17 +01:00
Robert Richter
b1e5a9bee3
perf tools: Use for_each_set_bit() to iterate over feature flags
...
This patch introduces the for_each_set_bit() macro and modifies feature
implementation to use it.
Cc: Frederic Weisbecker <fweisbec@gmail.com >
Cc: Ingo Molnar <mingo@elte.hu >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Stephane Eranian <eranian@google.com >
Link: http://lkml.kernel.org/r/1323248577-11268-8-git-send-email-robert.richter@amd.com
Signed-off-by: Robert Richter <robert.richter@amd.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2011-12-23 17:03:36 -02:00
Robert Richter
e20960c027
perf tools: Unify handling of features when writing feature section
...
The features HEADER_TRACE_INFO and HEADER_BUILD_ID are handled
different when writing the feature section. All other features are
simply disabled on failure and writing the section goes on without
returning an error. There is no reason for these special cases. This
patch unifies handling of the features.
This should be ok since all features can be parsed independently.
Offset and size of a feature's block is stored in struct perf_file_
section right after the data block of perf.data (see perf_session__
write_header()). Thus, if a feature does not exist then other features
can be processed anyway.
Also moving special code for HEADER_BUILD_ID out to write_build_id().
v2:
* perf record throws an error now if buildids may not be generated,
which can be disabled with the --no-buildid option.
Cc: Frederic Weisbecker <fweisbec@gmail.com >
Cc: Ingo Molnar <mingo@elte.hu >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Stephane Eranian <eranian@google.com >
Link: http://lkml.kernel.org/r/1323248577-11268-6-git-send-email-robert.richter@amd.com
Signed-off-by: Robert Richter <robert.richter@amd.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2011-12-23 17:02:22 -02:00
Robert Richter
1b5495043d
perf tools: Moving code in some files
...
Needed for later changes. No modified functionality.
Cc: Frederic Weisbecker <fweisbec@gmail.com >
Cc: Ingo Molnar <mingo@elte.hu >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Stephane Eranian <eranian@google.com >
Link: http://lkml.kernel.org/r/1323248577-11268-4-git-send-email-robert.richter@amd.com
Signed-off-by: Robert Richter <robert.richter@amd.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2011-12-23 16:58:22 -02:00
Robert Richter
f7a8a13364
perf tools: Continue processing header on unknown features
...
A feature may be unknown if perf.data is created and parsed on different
perf tool versions. This should not stop the header to be processed,
instead continue processing it.
Cc: Frederic Weisbecker <fweisbec@gmail.com >
Cc: Ingo Molnar <mingo@elte.hu >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Stephane Eranian <eranian@google.com >
Link: http://lkml.kernel.org/r/1323248577-11268-2-git-send-email-robert.richter@amd.com
Signed-off-by: Robert Richter <robert.richter@amd.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2011-12-23 16:57:09 -02:00
Robert Richter
8cdfa78a88
perf tools: Improve macros for struct feature_ops
...
Reducing duplication and line size by extending function names for
print and write from a single name.
Cc: Frederic Weisbecker <fweisbec@gmail.com >
Cc: Ingo Molnar <mingo@elte.hu >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Stephane Eranian <eranian@google.com >
Link: http://lkml.kernel.org/r/1323248577-11268-7-git-send-email-robert.richter@amd.com
Signed-off-by: Robert Richter <robert.richter@amd.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2011-12-23 16:56:27 -02:00
Ingo Molnar
d87f69a16e
Merge commit 'v3.2-rc6' into perf/core
...
Merge reason: Update with the latest fixes.
Signed-off-by: Ingo Molnar <mingo@elte.hu >
2011-12-20 20:32:11 +01:00
Andrew Vagin
6340cfed48
perf header: Use event_name() to get an event name
...
perf_evsel.name may be not initialized
Cc: David Ahern <dsahern@gmail.com >
Cc: Ingo Molnar <mingo@elte.hu >
Cc: Paul Mackerras <paulus@samba.org >
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl >
Cc: Arun Sharma <asharma@fb.com >
Cc: devel@openvz.org
Link: http://lkml.kernel.org/r/1322471015-107825-2-git-send-email-avagin@openvz.org
Signed-off-by: Andrew Vagin <avagin@openvz.org >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2011-12-06 09:22:48 -02:00
Arnaldo Carvalho de Melo
45694aa770
perf tools: Rename perf_event_ops to perf_tool
...
To better reflect that it became the base class for all tools, that must
be in each tool struct and where common stuff will be put.
Cc: David Ahern <dsahern@gmail.com >
Cc: Frederic Weisbecker <fweisbec@gmail.com >
Cc: Mike Galbraith <efault@gmx.de >
Cc: Paul Mackerras <paulus@samba.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Stephane Eranian <eranian@google.com >
Link: http://lkml.kernel.org/n/tip-qgpc4msetqlwr8y2k7537cxe@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2011-11-28 10:39:28 -02:00
Arnaldo Carvalho de Melo
743eb86865
perf tools: Resolve machine earlier and pass it to perf_event_ops
...
Reducing the exposure of perf_session further, so that we can use the
classes in cases where no perf.data file is created.
Cc: David Ahern <dsahern@gmail.com >
Cc: Frederic Weisbecker <fweisbec@gmail.com >
Cc: Mike Galbraith <efault@gmx.de >
Cc: Paul Mackerras <paulus@samba.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Stephane Eranian <eranian@google.com >
Link: http://lkml.kernel.org/n/tip-stua66dcscsezzrcdugvbmvd@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2011-11-28 10:39:12 -02:00
Arnaldo Carvalho de Melo
d20deb64e0
perf tools: Pass tool context in the the perf_event_ops functions
...
So that we don't need to have that many globals.
Next steps will remove the 'session' pointer, that in most cases is
not needed.
Then we can rename perf_event_ops to 'perf_tool' that better describes
this class hierarchy.
Cc: David Ahern <dsahern@gmail.com >
Cc: Frederic Weisbecker <fweisbec@gmail.com >
Cc: Mike Galbraith <efault@gmx.de >
Cc: Paul Mackerras <paulus@samba.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Stephane Eranian <eranian@google.com >
Link: http://lkml.kernel.org/n/tip-wp4djox7x6w1i2bab1pt4xxp@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2011-11-28 10:38:56 -02:00
Arnaldo Carvalho de Melo
10d0f086df
perf event: perf_event_ops->attr() manipulates only an evlist
...
Removing another case where a perf_session is required when processing
events.
Cc: David Ahern <dsahern@gmail.com >
Cc: Frederic Weisbecker <fweisbec@gmail.com >
Cc: Mike Galbraith <efault@gmx.de >
Cc: Paul Mackerras <paulus@samba.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Stephane Eranian <eranian@google.com >
Link: http://lkml.kernel.org/n/tip-ug1wtjbnva4bxwknflkkrlrh@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2011-11-28 10:37:43 -02:00
Arnaldo Carvalho de Melo
d04b35f808
perf symbols: Add nr_events to symbol_conf
...
Since symbol__alloc_hists need it, to avoid passing it around in many
functions have it in the symbol_conf struct.
Cc: David Ahern <dsahern@gmail.com >
Cc: Frederic Weisbecker <fweisbec@gmail.com >
Cc: Mike Galbraith <efault@gmx.de >
Cc: Paul Mackerras <paulus@samba.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Stephane Eranian <eranian@google.com >
Link: http://lkml.kernel.org/n/tip-cwv8ysvpywzjq4v3xtbd4zwv@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2011-11-28 10:37:11 -02:00