perf cgroup: Maintain cgroup hierarchy

Each cgroup is kept in the perf_env's cgroup_tree sorted by the cgroup
id.  Hist entries have cgroup id can compare it directly and later it
can be used to find a group name using this tree.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20200325124536.2800725-5-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Namhyung Kim
2020-03-25 21:45:31 +09:00
committed by Arnaldo Carvalho de Melo
parent ba78c1c546
commit d1277aa36b
5 changed files with 109 additions and 5 deletions

View File

@@ -33,6 +33,7 @@
#include "asm/bug.h"
#include "bpf-event.h"
#include <internal/lib.h> // page_size
#include "cgroup.h"
#include <linux/ctype.h>
#include <symbol/kallsyms.h>
@@ -654,13 +655,19 @@ int machine__process_namespaces_event(struct machine *machine __maybe_unused,
return err;
}
int machine__process_cgroup_event(struct machine *machine __maybe_unused,
int machine__process_cgroup_event(struct machine *machine,
union perf_event *event,
struct perf_sample *sample __maybe_unused)
{
struct cgroup *cgrp;
if (dump_trace)
perf_event__fprintf_cgroup(event, stdout);
cgrp = cgroup__findnew(machine->env, event->cgroup.id, event->cgroup.path);
if (cgrp == NULL)
return -ENOMEM;
return 0;
}