Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp854384pxk; Thu, 17 Sep 2020 19:10:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5WOTvbzm+qNj+Bg3PW56bz8lqym1cLoCN7eHGcXHeVAbpuFZiupl96AeMUBzCJ+1cp6lE X-Received: by 2002:a17:906:1d08:: with SMTP id n8mr35019078ejh.236.1600395040873; Thu, 17 Sep 2020 19:10:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600395040; cv=none; d=google.com; s=arc-20160816; b=jPTbEIlvcd1lVv1FRDJhcSh2RMBcTl2cWAzmpcdyFygkB4PN8OicEZNs0A0mC+3v01 H5tyDn9DnO3wdKr4OmWQvOJgFEPFZdw4w4XOqAlNcMG3/aYFRJYlctnM55+yrjmofhOc BDsSO3Gi4Obtij3zvyZq1CcKCpENbcNRlH2HvdC4OFiTtVld9ATh/xUJ/GNqzwZUXZzB dgdvSs9PmEWbkAdqrcU1wAN7gHfR6f2E9RUSKYn1T8j0TrWyTmSoNlfQdEJt5v6q6HQC qZFhMDZrZhS2U9ETZMsPpBusSyoA+YBS19j0QrWQgpW+3nbK359zgg1VWOBVuBuwyh6v 7F1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+gY4e9AlKunuBvVqL8uJChmwZfejb+ngXScHbhYm7lg=; b=X+qotRRoRWw13kJ56iKYUfBVLtQX7XMcV7hSdjqO8PMSQei7ACqDsmFgkhjwvaLuFY MJDAOry4M3vr4hOj3j6FoU8ZvEWYl2YSNcWEey9v9sYKqqseGYp//AS3fqH0k3lRXKpn ENTeHIjtAox3PDbwI6ZvOdwwQjWS2rVx3DNU3j3bE2st7sPGBWFP6W07mPo2JzyDlwGR x4g0lliXRqRzqfsYUI26GisdyVcwQpi8eEAOS06mq9RIla/FrytVDLcI7qEKJxKgqLKP L693V0iHeGxfnORuoN7H551eIP3PLehlMDuL1laay5MZN17aSfJiSv/jPOCsrUoiiV0B PSCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=n0OCyrMr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e22si990113edv.198.2020.09.17.19.10.16; Thu, 17 Sep 2020 19:10:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=n0OCyrMr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727040AbgIRCIY (ORCPT + 99 others); Thu, 17 Sep 2020 22:08:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:58712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728015AbgIRCH4 (ORCPT ); Thu, 17 Sep 2020 22:07:56 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 86405238A1; Fri, 18 Sep 2020 02:07:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394875; bh=F54G469FFZBl8VA47b1OkQvsJsjS5tT4Y+JSvZv5ZAk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n0OCyrMrh09SQvaam+6EIS0TEH1cFBCIcWtaZWyyIxkYyixnh4W8jF1s4KWxlX1Pe cL5ap2IWIfLj76LpR55t2eC+sFb63mTFS8zhJ/RN/WvOGahK9yyQW83Na2Uazn8VY7 lgRK+CDz+MPahNjr8h6hP6yfmec6uB4bmSc7rWQ0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jin Yao , Jiri Olsa , Alexander Shishkin , Andi Kleen , Jin Yao , Kan Liang , Peter Zijlstra , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH AUTOSEL 5.4 326/330] perf parse-events: Use strcmp() to compare the PMU name Date: Thu, 17 Sep 2020 22:01:06 -0400 Message-Id: <20200918020110.2063155-326-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jin Yao [ Upstream commit 8510895bafdbf7c4dd24c22946d925691135c2b2 ] 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 3cdc5c2cb924a ("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: d4953f7ef1a2 ("perf parse-events: Fix 3 use after frees found with clang ASAN") Signed-off-by: Jin Yao Acked-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jin Yao Cc: Kan Liang Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/20200430003618.17002-1-yao.jin@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/parse-events.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index f16748cfcb262..3fb9d53666d15 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1507,12 +1507,11 @@ parse_events__set_leader_for_uncore_aliase(char *name, struct list_head *list, * event. That can be used to distinguish the leader from * other members, even they have the same event name. */ - if ((leader != evsel) && (leader->pmu_name == evsel->pmu_name)) { + if ((leader != evsel) && + !strcmp(leader->pmu_name, evsel->pmu_name)) { is_leader = false; continue; } - /* The name is always alias name */ - WARN_ON(strcmp(leader->name, evsel->name)); /* Store the leader event for each PMU */ leaders[nr_pmu++] = (uintptr_t) evsel; -- 2.25.1