perf evlist: Change evlist__splice_list_tail() ordering
authorJohn Garry <john.garry@huawei.com>
Fri, 4 Dec 2020 11:10:11 +0000 (19:10 +0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 17 Dec 2020 17:36:17 +0000 (14:36 -0300)
Function find_evsel_group() expects events to be ordered such that they
are grouped after their leader.

Modify evlist__splice_list_tail() to guarantee this (ordering).

[Should prob also change the function name]

Signed-off-by: John Garry <john.garry@huawei.com>
Acked-by: Kajol Jain <kjain@linux.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Kim Phillips <kim.phillips@amd.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
Cc: Will Deacon <will@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linuxarm@huawei.com
Link: http://lore.kernel.org/lkml/1607080216-36968-6-git-send-email-john.garry@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/evlist.c

index 4938191..89286f1 100644 (file)
@@ -179,11 +179,22 @@ void evlist__remove(struct evlist *evlist, struct evsel *evsel)
 
 void evlist__splice_list_tail(struct evlist *evlist, struct list_head *list)
 {
 
 void evlist__splice_list_tail(struct evlist *evlist, struct list_head *list)
 {
-       struct evsel *evsel, *temp;
+       while (!list_empty(list)) {
+               struct evsel *evsel, *temp, *leader = NULL;
 
 
-       __evlist__for_each_entry_safe(list, temp, evsel) {
-               list_del_init(&evsel->core.node);
-               evlist__add(evlist, evsel);
+               __evlist__for_each_entry_safe(list, temp, evsel) {
+                       list_del_init(&evsel->core.node);
+                       evlist__add(evlist, evsel);
+                       leader = evsel;
+                       break;
+               }
+
+               __evlist__for_each_entry_safe(list, temp, evsel) {
+                       if (evsel->leader == leader) {
+                               list_del_init(&evsel->core.node);
+                               evlist__add(evlist, evsel);
+                       }
+               }
        }
 }
 
        }
 }