Messages in this thread |  | | | Date | Fri, 16 Dec 2011 00:47:28 +0100 | | From | Robert Richter <> | | Subject | Re: [PATCH 4/4] perf script: Add script to collect and display IBS samples |
| |
On 15.12.11 12:19:03, David Ahern wrote:
> > +sub process_event > > +{ > > + my ($event, $attr, $sample, $raw_data) = @_; > > + > > + my ($type) = (unpack("LSS", $event))[0]; > > + my ($sample_type) = (unpack("LLQQQQQLLQQ", $attr))[4]; > > + my ($cpu, $raw_size) = (unpack("QLLQQQQQLL", $sample))[8, 9]; > > + my ($caps, @ibs_data) = unpack("LQ*", $raw_data); > > + > > + return if (!$raw_size); # no raw data > > + > > + if (scalar(@ibs_data) == 3) { > > + printf("IBS_FETCH sample on cpu%d\tIBS0: 0x%016x IBS1: 0x%016x IBS2:0x%016x\n", > > + $cpu, @ibs_data); > > + } else { > > + printf("IBS_OP sample on cpu%d\t" . > > + "\t IBS0: 0x%016x IBS1: 0x%016x IBS2: 0x%016x\n" . > > + "\tIBS3: 0x%016x IBS4: 0x%016x IBS5: 0x%016x IBS6: 0x%016x\n", > > + cpu, @ibs_data); > > + } > > +} > > Doesn't seem like you are verifying that the tracepoints fed to this > script are actually ibs related. For example, if a user points to the > wrong perf.data which has raw data in it this script would happily parse > and display numbers.
For 'perf script ibs' and 'perf script record ibs' this does not matter as the builtin perf record wrapper is used that always creates ibs data. For 'perf script report ibs' the perf.data file is not checked for valid ibs samples. In case you point to a wrong file your report will be wrong too. I don't think this is an issue for this initial version. The pmu mapping is already in the header so implementing a check is generally possible.
> Also, why a perl script versus the builtin dumping capability of > perf-script? e.g., add ibs to the fields and while processing the event > verify that the tracepoint is ibs related.
IBS samples are not tracepoints but some special kind of hardware event. It would be hard to reuse the tracing framework for this. Also, the parser above is intended to be a reference implementation of how to generate and decode ibs samples. It should be the basis for customized scripts to extract information from ibs data.
-Robert
-- Advanced Micro Devices, Inc. Operating System Research Center
|  |