perf metricgroup: Order event groups by size

When adding event groups to the group list, insert them in size order.
This performs an insertion sort on the group list. By placing the
largest groups at the front of the group list it is possible to see if a
larger group contains the same events as a later group. This can make
the later group redundant - it can reuse the events from the large
group.  A later patch will add this sharing.

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Andrii Nakryiko <andriin@fb.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Kim Phillips <kim.phillips@amd.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Clarke <pc@us.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: bpf@vger.kernel.org
Cc: netdev@vger.kernel.org
Link: http://lore.kernel.org/lkml/20200520182011.32236-5-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Ian Rogers 2020-05-20 11:20:08 -07:00 коммит произвёл Arnaldo Carvalho de Melo
Родитель 7f9eca51c1
Коммит 6bf2102bec
1 изменённых файлов: 15 добавлений и 1 удалений

Просмотреть файл

@ -511,7 +511,21 @@ static int __metricgroup__add_metric(struct list_head *group_list,
return -EINVAL;
}
list_add_tail(&eg->nd, group_list);
if (list_empty(group_list))
list_add(&eg->nd, group_list);
else {
struct list_head *pos;
/* Place the largest groups at the front. */
list_for_each_prev(pos, group_list) {
struct egroup *old = list_entry(pos, struct egroup, nd);
if (hashmap__size(&eg->pctx.ids) <=
hashmap__size(&old->pctx.ids))
break;
}
list_add(&eg->nd, pos);
}
return 0;
}