Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9933495ybi; Wed, 24 Jul 2019 12:35:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwtdxKdUuecBO0Be8gVxrhgNhWAgEJQvgJAfPKEwW2EPqRwSPrAuVEHR5MdP3qQrLd1dZe6 X-Received: by 2002:a17:90a:a407:: with SMTP id y7mr89256070pjp.97.1563996913249; Wed, 24 Jul 2019 12:35:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563996913; cv=none; d=google.com; s=arc-20160816; b=ghIQQmc30i0S8PLNXwa5OsBrs6M7mFcsNA4DNGPg/cdqIOE8CxuPs/I2LUWdqQMTlX AuKLfHm0qi/jWga/IrlJIUJ7lrFaq7B4958iqSzTkhWA9wn/MwFyt/q7UMQfjx66Pl4B NE1wjgxNQhcSt3rlxi+0FVJo7kciBJI0YHH8NizVvm5LyXMO0HLNZdwjKEXEH/xrldW3 WuJsVQHqIj+1ihGIaBmpCK9rXeZAOIU0n5dtSjlbhh9MCcptAV2g/TWx2sR+J1NVmduB FgZ7GRftgF4HJAhJxIqNyDuHkGVkzK1xFGkye99U+9/x5dp7MRJwmiNzVRHyH8b5Uk06 Gz1g== 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=DDoGMEZbiu/LnJPfsxJnfdSndlaGNC3y/n1dhI/3Fvw=; b=xTTinudoGrg0ihENCKfVV6JCnzniwTXtBwzcRoKPAAX9Eyws+bwgRUibstRFP+oqG3 vf/OYS0jgNIrz8Nsl0sRHcNZWmPvjGch8XPmvst0gA1LzRA8wfgEDIZFyyQD9Bnm4/uz lXhVPnTkhrjOq21DnarDkkyfRmVBlVmm7IZWY1xGDYxRQgQFlnaRpK0fxAWJjHbGcmTD jKDOBo/GwlDK9nzszcU+i0KSbZ9Hh9jGj85evHesZfKhr3/ORBMmRCci68hrlPEKg3pM kywHYvz0x5D/xEA4ktqLGJ4zRO9YdN5gpqemmNlbz6K1FsaL5ydROtLsuguTOC8HVy9C HCAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HsbHgn8N; 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 o4si14474228plb.274.2019.07.24.12.34.58; Wed, 24 Jul 2019 12:35:13 -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=HsbHgn8N; 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 S2388674AbfGXTeJ (ORCPT + 99 others); Wed, 24 Jul 2019 15:34:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:56346 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389054AbfGXTeI (ORCPT ); Wed, 24 Jul 2019 15:34:08 -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 9FA2A21951; Wed, 24 Jul 2019 19:34:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996847; bh=OeIkqK8Y0XklASlo+vRxyTqQThrrZsRCUX3HADXzfXQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HsbHgn8Ny2K4b/ETNJ9NZ5fEkQYZddupRiW/vxgD2zFd1YHLAGGAG6fo5Rv/xQtVp iEIPc7nSH/7NK28dNx1+bEyxDlD+eITXeWiJFYvMMleeaPkOPq2O44V34tp37oIyNa hvzxpxboWtgkwbeQrPP9QGtKPjdEwmyjf7IiXgHY= 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 5.2 210/413] perf stat: Make metric event lookup more robust Date: Wed, 24 Jul 2019 21:18:21 +0200 Message-Id: <20190724191749.531014367@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@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 83d8094be4fe..e545e2a8ae71 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