• Jin Yao's avatar
    perf parse-events: Use strcmp() to compare the PMU name · 31c5c447
    Jin Yao authored
    [ Upstream commit 8510895b ]
    
    A big uncore event group is split into multiple small groups which only
    include the uncore events from the same PMU. This has been supported in
    the commit 3cdc5c2c ("perf parse-events: Handle uncore event
    aliases in small groups properly").
    
    If the event's PMU name starts to repeat, it must be a new event.
    That can be used to distinguish the leader from other members.
    But now it only compares the pointer of pmu_name
    (leader->pmu_name == evsel->pmu_name).
    
    If we use "perf stat -M LLC_MISSES.PCIE_WRITE -a" on cascadelakex,
    the event list is:
    
      evsel->name					evsel->pmu_name
      ---------------------------------------------------------------
      unc_iio_data_req_of_cpu.mem_write.part0		uncore_iio_4 (as leader)
      unc_iio_data_req_of_cpu.mem_write.part0		uncore_iio_2
      unc_iio_data_req_of_cpu.mem_write.part0		uncore_iio_0
      unc_iio_data_req_of_cpu.mem_write.part0		uncore_iio_5
      unc_iio_data_req_of_cpu.mem_write.part0		uncore_iio_3
      unc_iio_data_req_of_cpu.mem_write.part0		uncore_iio_1
      unc_iio_data_req_of_cpu.mem_write.part1		uncore_iio_4
      ......
    
    For the event "unc_iio_data_req_of_cpu.mem_write.part1" with
    "uncore_iio_4", it should be the event from PMU "uncore_iio_4".
    It's not a new leader for this PMU.
    
    But if we use "(leader->pmu_name == evsel->pmu_name)", the check
    would be failed and the event is stored to leaders[] as a new
    PMU leader.
    
    So this patch uses strcmp to compare the PMU name between events.
    
    Fixes: d4953f7e ("perf parse-events: Fix 3 use after frees found with clang ASAN")
    Signed-off-by: default avatarJin Yao <yao.jin@linux.intel.com>
    Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Andi Kleen <ak@linux.intel.com>
    Cc: Jin Yao <yao.jin@intel.com>
    Cc: Kan Liang <kan.liang@linux.intel.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Link: http://lore.kernel.org/lkml/20200430003618.17002-1-yao.jin@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
    31c5c447
parse-events.c 64.7 KB