Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10439917ybi; Wed, 24 Jul 2019 23:15:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqw0YIHQ1PF30tHB5rLz3aAZxr4bFdOVpBR/xLNpXSdM45L1L3zxwH2L4l+EwEmgSRjXl9m1 X-Received: by 2002:a62:6:: with SMTP id 6mr14689735pfa.159.1564035306908; Wed, 24 Jul 2019 23:15:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564035306; cv=none; d=google.com; s=arc-20160816; b=Nygqsd7Tvtby34zHBf04gi3/oF0m0N3q0442TGz0UYGo6OFmndXpwaFmq6K3v3nj7X Jl0FVrBAAFjXLbjCDdwnBEr7LYh/qYfpP4JS8p/6jPii8NjK8yBpXHvWKdUqxGzqONpQ H0n8f28Ced3c31VxhIKtyk90R54epA6lG9MzsiKtBp76oN8wp/j4HzoGdpOCNcposQtR kWJJIbEtLNALHTqTW4NmgdI16NuclTXyN17K0xOWqDJRLdUQuMJ297Jab6qpkV7Wvnkw hwPRqCvC+lwFaDR0KkiUNpRmgHBl7LaZNxW48QJpKDRHX06QyjsFXvajpsnmsU2bDOQb BTGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uF5QN5/HRUJWc9GXnjRol7VDWW5C/L8oBsdBycl3s2o=; b=tt9uS9KItkNy7SeSfbYC+zHJ88RtocKSpZMFDZd5okK0VxB6Mmv/dp2Ig4CAj1X4N+ bRdhgxQCZ96vynvU3Gdu1APJFiYPO3AZodwD3Mc4+VwDbVLB7yf/CV9zdtonsSdCRn4X Cw13BdGU34Cqrd+NhQv/EOji1oR6cpj8iii/GfD+D9/i2RK/ulxFfSsmDlUCxR6yOZhc lKP+VDa2tm3s2Bt0VgSZzgZM7Xb0wqEQbEVwSc8OTwkihf5emfty88+6V7SVYegSrHER K9PkTOuJCWjYevhC1LiNVKN7qAf2pehYq5LAxRIYMpMSsw+J+5a8e2h5tLdJKuHiQFS6 S/vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=C3g+Yz9y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k33si18331288pgi.563.2019.07.24.23.14.51; Wed, 24 Jul 2019 23:15:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=C3g+Yz9y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404391AbfGYFkb (ORCPT + 99 others); Thu, 25 Jul 2019 01:40:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:54976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404369AbfGYFkZ (ORCPT ); Thu, 25 Jul 2019 01:40:25 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 674A522BF3; Thu, 25 Jul 2019 05:40:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033224; bh=fEa96WUvN7djOaWvWgooNf0cHcNNqWtnMFlsIyt2W1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C3g+Yz9yRWwqp/xZYps1Cd1nXT7tmW9TB78pCGB4q6tqOXtyFYtRFfMFtsm0R6mG7 A+4Hz/r9bDDPmO3MhlAqbN/LVlGEq256z9y9KJD669xw2ry4hlqsr9EeWdAHkQWS/+ QXqtakoogg6B70/bSc9cKlK0ueomX28H9ygu/cVE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andi Kleen , Jiri Olsa , Kan Liang , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.19 136/271] perf stat: Make metric event lookup more robust Date: Wed, 24 Jul 2019 21:20:05 +0200 Message-Id: <20190724191706.868455411@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 145c407c808352acd625be793396fd4f33c794f8 ] After setting up metric groups through the event parser, the metricgroup code looks them up again in the event list. Make sure we only look up events that haven't been used by some other metric. The data structures currently cannot handle more than one metric per event. This avoids problems with multiple events partially overlapping. Signed-off-by: Andi Kleen Acked-by: Jiri Olsa Cc: Kan Liang Link: http://lkml.kernel.org/r/20190624193711.35241-2-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/stat-shadow.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c index 99990f5f2512..bbb0e042d8e5 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c @@ -303,7 +303,7 @@ static struct perf_evsel *perf_stat__find_event(struct perf_evlist *evsel_list, struct perf_evsel *c2; evlist__for_each_entry (evsel_list, c2) { - if (!strcasecmp(c2->name, name)) + if (!strcasecmp(c2->name, name) && !c2->collect_stat) return c2; } return NULL; @@ -342,7 +342,8 @@ void perf_stat__collect_metric_expr(struct perf_evlist *evsel_list) if (leader) { /* Search in group */ for_each_group_member (oc, leader) { - if (!strcasecmp(oc->name, metric_names[i])) { + if (!strcasecmp(oc->name, metric_names[i]) && + !oc->collect_stat) { found = true; break; } -- 2.20.1