From 3f6276d1f80d0ccef037e1e684f54d6b4db8c4c3 Mon Sep 17 00:00:00 2001 From: John Garry Date: Fri, 4 Dec 2020 19:10:11 +0800 Subject: [PATCH 159/201] perf evlist: Change evlist__splice_list_tail() ordering mainline inclusion from mainline-v5.11-rc1 commit 6d2783fe365fa5f571cf1416b5f5b1e352447a0e category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8C0CX Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6d2783fe365fa5f571cf1416b5f5b1e352447a0e ---------------------------------------------------------------------- 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 Acked-by: Kajol Jain Cc: Alexander Shishkin Cc: Andi Kleen Cc: Ian Rogers Cc: Jiri Olsa Cc: Joakim Zhang Cc: Kan Liang Cc: Kim Phillips Cc: Leo Yan Cc: Mark Rutland Cc: Mathieu Poirier Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Shaokun Zhang Cc: Will Deacon 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 Signed-off-by: hongrongxuan Conflicts: tools/perf/util/evlist.c --- tools/perf/util/evlist.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index bd791f9af49b..39b41d9d2a24 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -200,11 +200,22 @@ void perf_evlist__remove(struct perf_evlist *evlist, struct perf_evsel *evsel) void perf_evlist__splice_list_tail(struct perf_evlist *evlist, struct list_head *list) { - struct perf_evsel *evsel, *temp; + while (!list_empty(list)) { + struct perf_evsel *evsel, *temp, *leader = NULL; - __evlist__for_each_entry_safe(list, temp, evsel) { - list_del_init(&evsel->node); - perf_evlist__add(evlist, evsel); + __evlist__for_each_entry_safe(list, temp, evsel) { + list_del_init(&evsel->node); + perf_evlist__add(evlist, evsel); + leader = evsel; + break; + } + + __evlist__for_each_entry_safe(list, temp, evsel) { + if (evsel->leader == leader) { + list_del_init(&evsel->node); + perf_evlist__add(evlist, evsel); + } + } } } -- 2.27.0