Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp123081pxb; Wed, 20 Jan 2021 02:53:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJymtUp0v9l0Y0ACHH3P+vXepoIa9Z7CUe4K+UOcJvpDagQBvap4x6g909cLnYTzF67SxrYR X-Received: by 2002:a17:906:8046:: with SMTP id x6mr5897915ejw.351.1611140034887; Wed, 20 Jan 2021 02:53:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611140034; cv=none; d=google.com; s=arc-20160816; b=n0/9Ege1ADxjeb06mN32mM21JLreShCufK28bvWoq1id5TNqfHPUhxJh4oTY4YxD23 lQInfFl2Du03KByYjRcA9NXTzb0lKlelrdQbqPFBXL7QYBI+RCMl/9V9NU2sBCU1NWEL aNPL9sHQOoQeve+iVFUYTKWDZaKaZyuMZ7m81AiE61/wBhMyDO/xOGTqWLM/x7es3cp1 yP/ffsyQ5ffLc8Dojoesz5DC06Kxsukors8WV1zDAUAxxcFrCFn38JbeHJ5j+NmKcKnr WFoa1xk8Icfeh+CvoM+E6akThs26RPzG3bomtl/AZQDRYCThjgrSwQx32kJ4vd1/0Frf OQ0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=UTxhIhNLdiKNbWxAgt+AsVHW4dlEK8dlUUu+gp9gvmk=; b=J1g2yWtmV3F7kcT0siTDOPizM4bbNSBvBisOJiq0cC+3DuYOs74zwx3tuYYNImVaff KGgR32rjK81sZtc6QfjE5ORKdPT6FtN4XN85E+4qhYMBF/Fy6Ev4oxHFtiDpJLuWpRe4 9QRWCj2pfdrqljpKvGYNgid3t0uQwQNbdAcY3LIJBWwW3yo+MEsnybbK9KSV91tRP8Wm XAOsZ7dyVUjntvOCPTjykYG9z2TRLrbOd+EEZO6EcpSNaaPJbbpJ3nHRcHXaHON4w17l nFq9Ti6u+xBJVg31xKveixZRs/SFfhpZmnsMaEaDAtp1l4Twh+KPj+t9xWx+BNYfikXD HjJw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q12si547253ejs.148.2021.01.20.02.53.20; Wed, 20 Jan 2021 02:53:54 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730943AbhATKOE (ORCPT + 99 others); Wed, 20 Jan 2021 05:14:04 -0500 Received: from frasgout.his.huawei.com ([185.176.79.56]:2382 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730542AbhATJRx (ORCPT ); Wed, 20 Jan 2021 04:17:53 -0500 Received: from fraeml703-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4DLKZx4DQgz67f5r; Wed, 20 Jan 2021 17:14:01 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml703-chm.china.huawei.com (10.206.15.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2106.2; Wed, 20 Jan 2021 10:17:10 +0100 Received: from [10.47.7.185] (10.47.7.185) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Wed, 20 Jan 2021 09:17:09 +0000 Subject: Re: [PATCH] perf metricgroup: Fix system PMU metrics To: Joakim Zhang , "peterz@infradead.org" , "mingo@redhat.com" , "acme@kernel.org" , "mark.rutland@arm.com" , "alexander.shishkin@linux.intel.com" , "jolsa@redhat.com" , "namhyung@kernel.org" , "irogers@google.com" , "kjain@linux.ibm.com" CC: "linux-kernel@vger.kernel.org" , "linuxarm@openeuler.org" References: <1611050655-44020-1-git-send-email-john.garry@huawei.com> <4a876638-3c92-4a49-1925-0ff20c5d42b7@huawei.com> From: John Garry Message-ID: Date: Wed, 20 Jan 2021 09:15:54 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.47.7.185] X-ClientProxiedBy: lhreml741-chm.china.huawei.com (10.201.108.191) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20/01/2021 05:15, Joakim Zhang wrote: > >> -----Original Message----- >> From: John Garry >> Sent: 2021年1月20日 1:33 >> To: Joakim Zhang ; peterz@infradead.org; >> mingo@redhat.com; acme@kernel.org; mark.rutland@arm.com; >> alexander.shishkin@linux.intel.com; jolsa@redhat.com; >> namhyung@kernel.org; irogers@google.com; kjain@linux.ibm.com >> Cc: linux-kernel@vger.kernel.org; linuxarm@openeuler.org >> Subject: Re: [PATCH] perf metricgroup: Fix system PMU metrics >> >> On 19/01/2021 15:47, John Garry wrote: >>> On 19/01/2021 10:56, Joakim Zhang wrote: >>>> It seems have other issue compared to 5.10 kernel after switching to >>>> this framework, below metric can't work. >>>> "MetricExpr": "(( imx8_ddr0@read\\-cycles@ + >>>> imx8_ddr0@write\\-cycles@ >>>> ) * 4 * 4 / duration_time) / (750 * 1000000 * 4 * 4)" >>>> After change to: >>>> "MetricExpr": "(( imx8mm_ddr.read_cycles + imx8mm_ddr.write_cycles ) >>>> * >>>> 4 * 4 / duration_time) / (750 * 1000000 * 4 * 4)", >>> >>> It seems that any metric which includes "duration_time" is broken, >>> even on x86: >>> >>> john@localhost:~/acme/tools/perf> sudo ./perf stat -v -M >>> L1D_Cache_Fill_BW sleep 1 Using CPUID GenuineIntel-6-3D-4 metric expr >>> 64 * l1d.replacement / 1000000000 / duration_time for >>> L1D_Cache_Fill_BW found event duration_time found event >>> l1d.replacement adding {l1d.replacement}:W,duration_time >>> l1d.replacement -> cpu/umask=0x1,(null)=0x1e8483,event=0x51/ >>> Segmentation fault >>> >>> >>> Seems to be from my commit c2337d67199 ("perf metricgroup: Fix metrics >>> using aliases covering multiple PMUs") >>> >>> I'll look to fix it now. >>> >> >> Please try this: >> >> From 2380f1ef0250e6818b3dbc7bff4a868810875e2a Mon Sep 17 00:00:00 >> 2001 >> From: John Garry >> Date: Tue, 19 Jan 2021 17:29:54 +0000 >> Subject: [PATCH] perf metricgroup: Fix metric support for duration_time >> >> For a metric using duration_time, the strcmp() check when finding identical >> events in metric_events[] is broken, as it does not consider that the >> event pmu_name is NULL - it would be for duration_time. >> >> As such, add a NULL check here for event pmu_name. >> >> Signed-off-by: John Garry >> >> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c >> index ee94d3e8dd65..277adff8017f 100644 >> --- a/tools/perf/util/metricgroup.c >> +++ b/tools/perf/util/metricgroup.c >> @@ -280,6 +280,8 @@ static struct evsel *find_evsel_group(struct evlist >> *perf_evlist, >> */ >> if (!has_constraint && >> ev->leader != metric_events[i]->leader && >> + ev->leader->pmu_name && >> + metric_events[i]->leader->pmu_name && >> !strcmp(ev->leader->pmu_name, >> metric_events[i]->leader->pmu_name)) >> break; >> -- >> 2.26.2 >> >> > > For this patch: Tested-by: Joakim Zhang > > Hi John, Jolsa, > > Is there any way to avoid breaking exist metric expressions? If not, it will always happened after metricgroup changes. > They are not normally broken like that. Normally we test beforehand, but these cases were missed here by me. However if you were testing them previously, then it would be expected that you had tested them again for the final patchset which was merged. Anyway, we can look to add metric tests for these. @Arnaldo, I will send separate formal patch for this today. Thanks, John