lkml.org 
[lkml]   [2016]   [Oct]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH 20/57] perf c2c report: Add dcacheline dimension key
Em Wed, Oct 05, 2016 at 07:45:17AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Wed, Oct 05, 2016 at 12:46:12AM +0200, Jiri Olsa escreveu:
> > On Tue, Oct 04, 2016 at 01:50:12PM -0300, Arnaldo Carvalho de Melo wrote:
> > > Em Thu, Sep 22, 2016 at 05:36:48PM +0200, Jiri Olsa escreveu:
> > > > Adding dcacheline dimension key support. It
> > > > displays cacheline address as hex number.
> > > >
> > > > Using c2c wrapper to standard 'dcacheline' object
> > > > to defined own header and simple (just address)
> > > > cacheline output.
> > >
> > > So, at this point I move from:
> > >
> > > # perf c2c report
> > > Error: Invalid --fields key: `dcacheline'
> > > #
> > >
> > > To:
> > >
> > > [root@jouet ~]# perf c2c report
> > > Error: Unknown --fields key: `offset'
> > > Segmentation fault (core dumped)
> > > [root@jouet ~]#
> >
> > oops, attached patch should fix that, but I needed to change
> > following patches:

Now we're at:

[root@jouet ~]# perf c2c report
Error: Unknown --fields key: `offset'
0x50cbc0 [0x8]: failed to process type: 68
failed to process sample
[root@jouet ~]#

> >
> > perf c2c report: Add cacheline hists processing
> > perf c2c report: Decode c2c_stats for hist entries
> >
> > I updated perf/c2c_v4 branch with the fix and rebased
> > to your current perf/core.. let me know if I need to
> > repost
> >
> > thanks,
> > jirka
>
> ok, I'm trying to fix it myself, starting with this:
>
> + ret = c2c_hists__init(hists, sort);
> + if (ret)
> + free(hists);
> +
> + return &hists->hists;
>
> That is on "perf c2c report: Add cacheline hists processing"

That became:

commit f485e33c4543ac31f2eb77293b49bfe821271bbb
Author: Jiri Olsa <jolsa@kernel.org>
Date: Thu Sep 22 17:36:45 2016 +0200

perf c2c report: Add cacheline hists processing

Store cacheline related entries in nested hist object for each cacheline
data. Nested entries are sorted by 'offset' within related cacheline.

We will allow specific sort keys to be configured for nested cacheline
data entries in following patches.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1474558645-19956-18-git-send-email-jolsa@kernel.org
[ he__get_hists() should return NULL when c2c_hists__init() fails ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index 29fb9573e292..df413b564361 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -61,6 +61,34 @@ static struct hist_entry_ops c2c_entry_ops = {
.free = c2c_he_free,
};

+static int c2c_hists__init(struct c2c_hists *hists,
+ const char *sort);
+
+static struct hists*
+he__get_hists(struct hist_entry *he,
+ const char *sort)
+{
+ struct c2c_hist_entry *c2c_he;
+ struct c2c_hists *hists;
+ int ret;
+
+ c2c_he = container_of(he, struct c2c_hist_entry, he);
+ if (c2c_he->hists)
+ return &c2c_he->hists->hists;
+
+ hists = c2c_he->hists = zalloc(sizeof(*hists));
+ if (!hists)
+ return NULL;
+
+ ret = c2c_hists__init(hists, sort);
+ if (ret) {
+ free(hists);
+ return NULL;
+ }
+
+ return &hists->hists;
+}
+
static int process_sample_event(struct perf_tool *tool __maybe_unused,
union perf_event *event,
struct perf_sample *sample,
@@ -70,7 +98,7 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
struct hists *hists = &c2c.hists.hists;
struct hist_entry *he;
struct addr_location al;
- struct mem_info *mi;
+ struct mem_info *mi, *mi_dup;
int ret;

if (machine__resolve(machine, &al, sample) < 0) {
@@ -83,19 +111,50 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
if (mi == NULL)
return -ENOMEM;

+ mi_dup = memdup(mi, sizeof(*mi));
+ if (!mi_dup)
+ goto free_mi;
+
he = hists__add_entry_ops(hists, &c2c_entry_ops,
&al, NULL, NULL, mi,
sample, true);
- if (he == NULL) {
- free(mi);
- return -ENOMEM;
- }
+ if (he == NULL)
+ goto free_mi_dup;

hists__inc_nr_samples(hists, he->filtered);
ret = hist_entry__append_callchain(he, sample);

+ if (!ret) {
+ mi = mi_dup;
+
+ mi_dup = memdup(mi, sizeof(*mi));
+ if (!mi_dup)
+ goto free_mi;
+
+ hists = he__get_hists(he, "offset");
+ if (!hists)
+ goto free_mi_dup;
+
+ he = hists__add_entry_ops(hists, &c2c_entry_ops,
+ &al, NULL, NULL, mi,
+ sample, true);
+ if (he == NULL)
+ goto free_mi_dup;
+
+ hists__inc_nr_samples(hists, he->filtered);
+ ret = hist_entry__append_callchain(he, sample);
+ }
+
+out:
addr_location__put(&al);
return ret;
+
+free_mi_dup:
+ free(mi_dup);
+free_mi:
+ free(mi);
+ ret = -ENOMEM;
+ goto out;
}

static struct perf_c2c c2c = {
@@ -400,6 +459,27 @@ static int c2c_hists__reinit(struct c2c_hists *c2c_hists,
return hpp_list__parse(&c2c_hists->list, output, sort);
}

+static int filter_cb(struct hist_entry *he __maybe_unused)
+{
+ return 0;
+}
+
+static int resort_cl_cb(struct hist_entry *he)
+{
+ struct c2c_hist_entry *c2c_he;
+ struct c2c_hists *c2c_hists;
+
+ c2c_he = container_of(he, struct c2c_hist_entry, he);
+ c2c_hists = c2c_he->hists;
+
+ if (c2c_hists) {
+ hists__collapse_resort(&c2c_hists->hists, NULL);
+ hists__output_resort_cb(&c2c_hists->hists, NULL, filter_cb);
+ }
+
+ return 0;
+}
+
static int perf_c2c__report(int argc, const char **argv)
{
struct perf_session *session;
@@ -458,7 +538,7 @@ static int perf_c2c__report(int argc, const char **argv)
ui_progress__init(&prog, c2c.hists.hists.nr_entries, "Sorting...");

hists__collapse_resort(&c2c.hists.hists, NULL);
- hists__output_resort(&c2c.hists.hists, &prog);
+ hists__output_resort_cb(&c2c.hists.hists, &prog, resort_cl_cb);

ui_progress__finish();

> >
> > ---
> > diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
> > index 335c0fd30757..74c7822460e1 100644
> > --- a/tools/perf/builtin-c2c.c
> > +++ b/tools/perf/builtin-c2c.c
> > @@ -86,7 +86,7 @@ he__get_c2c_hists(struct hist_entry *he,
> >
> > ret = c2c_hists__init(hists, sort);
> > if (ret)
> > - free(hists);
> > + zfree(&hists);
> >
> > return hists;
> > }

\
 
 \ /
  Last update: 2016-10-05 12:50    [W:0.222 / U:0.504 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site