From eebd097b300dab67c86b1de1bd79235f101d6303 Mon Sep 17 00:00:00 2001 From: Hao Chen Date: Fri, 19 May 2023 15:29:38 +0800 Subject: [PATCH] perf: hns3: default use hardware event 0 as group leader event. driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7BY7T CVE: NA ---------------------------------------------------------------------- For hns3 pmu events, we use command as below before: perf stat -g -e hns3_pmu_sicl_0/config=0x00105,global=1/ -e hns3_pmu_sicl_0/config=0x10105,global=1/ -I 1000 We want 0x00105 event and 0x10105 event share a hardware event, but for kernel 6.2 'commit 5f8f95673f68 ("perf evlist: Remove group option.")' remove -g parameter. So add this patch to set default related event idx as 0 to share the first hardware event. Fixes: 66637ab137b4 ("drivers/perf: hisi: add driver for HNS3 PMU") Signed-off-by: Hao Chen --- drivers/perf/hisilicon/hns3_pmu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/perf/hisilicon/hns3_pmu.c b/drivers/perf/hisilicon/hns3_pmu.c index 76c2babed4d0..92b2f535094b 100644 --- a/drivers/perf/hisilicon/hns3_pmu.c +++ b/drivers/perf/hisilicon/hns3_pmu.c @@ -804,9 +804,11 @@ static int hns3_pmu_find_related_event_idx(struct hns3_pmu *hns3_pmu, if (!hns3_pmu_cmp_event(sibling, event)) continue; - /* Related events is used in group */ + /* Related events is used in group, else we use index 0 event as related event */ if (sibling->group_leader == event->group_leader) return idx; + else + return 0; } /* No related event and all hardware events are used up */ -- GitLab