Re: [PATCH 01/12] perf tools: Keep group information

From: Arnaldo Carvalho de Melo
Date: Mon Nov 12 2012 - 12:08:30 EST


Em Sat, Nov 10, 2012 at 01:43:23AM +0900, Namhyung Kim escreveu:
> From: Namhyung Kim <namhyung.kim@xxxxxxx>
>
> Add a few of group-related field in struct perf_{evlist,evsel} so that
> the group information in a evlist can be known easily. It only counts
> groups which have more than 1 members since leader-only groups are
> treated as non-group events.

We don't need to add a group_idx, we can get it using evsel->idx -
evsel->leader->idx, interdiff of this patch to what I think is
equivalent:

diff -u b/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
--- b/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -111,18 +111,16 @@
void __perf_evlist__set_leader(struct list_head *list)
{
struct perf_evsel *evsel, *leader;
- int count = 0;

leader = list_entry(list->next, struct perf_evsel, node);
+ evsel = list_entry(list->prev, struct perf_evsel, node);
leader->leader = NULL;
+ leader->nr_members = evsel->idx - leader->idx + 1;

list_for_each_entry(evsel, list, node) {
- if (evsel != leader) {
+ if (evsel != leader)
evsel->leader = leader;
- evsel->group_idx = count++;
- }
}
- leader->nr_members = count;
}

void perf_evlist__set_leader(struct perf_evlist *evlist)
diff -u b/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
--- b/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -72,12 +72,9 @@
bool needs_swap;
/* parse modifier helper */
int exclude_GH;
+ int nr_members;
struct perf_evsel *leader;
char *group_name;
- union {
- int nr_members;
- int group_idx;
- };
};

struct cpu_map;
@@ -237,2 +234,11 @@
}
+
+static inline int perf_evsel__group_idx(struct perf_evsel *evsel)
+{
+ if (perf_evsel__is_group_leader(evsel)
+ return 0;
+
+ return evsel->idx - evsel->leader->idx;
+}
+
#endif /* __PERF_EVSEL_H */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/