Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4341861ybi; Tue, 30 Jul 2019 00:16:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwIrD1Zc1LlTkWQSNbFDHb9bJ/lo6rHaqmQtrP2BT52MkyA4iJkHkLq/oKNjNhznsSZfwki X-Received: by 2002:a63:2b0c:: with SMTP id r12mr107666568pgr.206.1564470976550; Tue, 30 Jul 2019 00:16:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564470976; cv=none; d=google.com; s=arc-20160816; b=xS9wQtJ8AHPoVUH36anniGc3hjs/KKAXomVx6nfx4Lw+gKlqZuBUzEZ5u/HYrAVUto 3nuvc7DiJBxTdsaNsPD98sRQ9MX3AZZ0krDe3BysMPONKPywcza57RcJjbXJHCydrQZx heu6K5RQQXMXdp28XwNE19XGUT8Y/xI21FhOVmeiKWVL/+zhT1z/EyKEytQuQ5tXzq42 TE11fTRep3WqQAy6qzPbSsNGvEYlvSrgO0ANcwoJy3a7y5imyxAQ0l+HTCpt68pImYIq M0DdAWObosSNWAHd0gh2DyQrU8PA84PCxIObs0VeyIqp9iSXut6WgEcij7s5G7ZP1ytC 9H1Q== 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=1po0e8qkmHCguCCUMkgfGR0pthbLy9MEAzNBQc9H4lQ=; b=C2r8ngRrCcUIzqQMcobGDlQa6qkSWJJDD+8GpA1wNBUGhTgqN3Ms+ZkftHcseQxbNP nBm4EoGMllI+iLgp5OHJrtB3/BQdID8Vlc1Ff6YFkmqxSAxy59+ByoOhbJ+86JR8GFzV 7nqkPBeT7rpSkxVmx8jslsqs2Ibu9ju20/tVuup4oXDitEbfya1OiW215G098bzGYmnr w5eQHnJzlM5DfMZnV9DHrtpvAnUBaUXBDkUNP/Ss4Pa7VaamgsPx3UjZGFwNlR9ugMc9 7yO/sAARg4g6yukD7zXzxuqH9e5N7CM5gfW6467dwp8/tXTEFZKD21Y4zVAco0rHIDVl +0eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=X4SQrCao; 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 j1si1514836pgk.187.2019.07.30.00.16.01; Tue, 30 Jul 2019 00:16:16 -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=X4SQrCao; 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 S1730469AbfG2UOV (ORCPT + 99 others); Mon, 29 Jul 2019 16:14:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:40934 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728280AbfG2T2P (ORCPT ); Mon, 29 Jul 2019 15:28:15 -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 DF3F421655; Mon, 29 Jul 2019 19:28:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428494; bh=2o22tR3EhmUoGO81eu0w4DIxcCBKxG35WXyGeRSq6xM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X4SQrCaogZ9ulT/8AjByxn4+Tdm0NYr+h6wi8mB95BZPoqx17FNiGkA+Ny3iClXgd UnTZBpovxK+8178tT6+R8QiT67/Vv7r4RspUXRJRnJ27bsOisv/HaNEpdebrlFXvGl dIf6VhSi3DQ7rMnnfGtc7vT19fbxL8Y/kQDtW2rk= 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.14 093/293] perf stat: Make metric event lookup more robust Date: Mon, 29 Jul 2019 21:19:44 +0200 Message-Id: <20190729190831.731409775@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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 37363869c9a1..eadc9a2aef16 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c @@ -271,7 +271,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; @@ -310,7 +310,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