Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp299913lqo; Thu, 9 May 2024 23:17:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWzM7Ey3Ugqwdx4YlxVfJqBLcvKQ2ELQm6QAEw+PAkuSee+RvKpdhKTa25Snc7+TI1c8FFuHi1zDPUPlGD8/lR3tSX8ZVkt6060lhqBkA== X-Google-Smtp-Source: AGHT+IEqlvq+EEOuhN0Jt/V7Z0EN8RFNwYzPrN/XIFq3aWDeOBGvKMNMP0gu1fCRDk4S/JvCZttF X-Received: by 2002:a17:906:590f:b0:a59:9b52:cfc3 with SMTP id a640c23a62f3a-a5a2d57a35dmr92333766b.29.1715321824665; Thu, 09 May 2024 23:17:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715321824; cv=pass; d=google.com; s=arc-20160816; b=jWH4VC+yz/ZBidhxwyPb6tbnpoMvO+LCOpWQrIALxA2IyYGc/C88mp8vbmBZ4Ybcey CdQjowiyKUzH9imflA44q6uGAljANavV76ZIvfIpTu0ClBbSnVPyWcbJ/xiw/dyypBmw saNcun7FJNJ73tyxL1NSqjXxleOLNao/OYa+F5UQAWYWxcXbP2VknmWyANfYSnjyGRet sn3Hx7+kM+r1FIp86XUYHwlxfMjwc6Z0kGroYxCFLa4vJwXAN648CjNW7O6o9rhbhy+4 beccvAKdSzenvFUcO/nexjzCV+HRIzzEFjgpDJq8mZrGQsFbfAmEesCcl1811f5nU0Hq LDXA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=P013eBlgxlZ/UL/3+JN87mWVkNfsmaCM+AjZob2UWLs=; fh=iKXqT+fN6mNPnEgUhGU/cZrABnYL0lz9IatJqVRxZEs=; b=U6qC1B+ooRFrTC5ICpViU48XqL5cfDPMk0AYEm6Ch18cPG42Gs9wDhy0cmEWnN0cJi GJcHK13uGeFDVD2149UorQr+VUtpgYX76QU0J5Pf1qtd33cKSTiN9SYhzCzZp3fuUK38 bmjHt5OAD+cbhzlo0ePe6OUq9qcp/uqRYLCOWuf6a1f0jEV66RgWRElTOpGa68xb7giB svq49nbc3z467/QVVflPNTCNcTAH5EomypFl9SGzXHJmcIxceCcFyV8yFcCXBoEiszIA 4uJ9d+AzXSHy+Akhif2PfG/y0aZYOORo5wLMmBmwbM2Kapl2xiPM9yXurBymwsVaknDG kvxw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4ZQ91omp; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-175310-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175310-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17c04298si157867266b.897.2024.05.09.23.17.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 23:17:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175310-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4ZQ91omp; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-175310-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175310-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C13F51F21CBE for ; Fri, 10 May 2024 06:17:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D87E515E1E3; Fri, 10 May 2024 06:16:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="4ZQ91omp" Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 834771494DE for ; Fri, 10 May 2024 06:16:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715321815; cv=none; b=Rim6Gr3yKXzEfeOeSJAnO0dArATPYrS1QDpC3kqpfs48lrlzdEQiokghD5RB3kpqMSTJsr9j/hkcJsrsJ9351I8Xh27j+iaTmvg/4GR3W4uIaqipQXMT+oQsEclhob03QCCyHtlG9KJ/GYnn7LFZP0A3p4O1+/JpI11A7YNJ+mI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715321815; c=relaxed/simple; bh=6feafTWRKD/pFfv6a7aXeKx22UNSWKArlBNWuqJ7QgE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Bbb0V7bEEW1q+Qd8E1ddvbcB4BZsCerJe1t5nuqzUmeCskXSp0O1BQfCTgoTzCWIMQUeAfAKm53bhSoVQ4WjBCxo5ZSNbpb73xl547ECEY9NsJEekX6FqM02Gtao+RnnojTVIi/nPuG0gBwADTt3VcK2SOql3dDT3mfJjDwN1Bg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=4ZQ91omp; arc=none smtp.client-ip=209.85.160.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-43df9ac3ebcso193951cf.0 for ; Thu, 09 May 2024 23:16:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715321812; x=1715926612; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=P013eBlgxlZ/UL/3+JN87mWVkNfsmaCM+AjZob2UWLs=; b=4ZQ91ompuwz0icugSg63hINIrh511TEMRTYeqxW/IVdOhuLI7HrgVTs0QH+Egx23qS v8d8up62e+FgUEtqBR3Ex17p1Q53CnB9RE+mEbCrQegUfgMaeVxs/KRv4kiJALiyU6rT Ss2UqUwet5nmTSCDk2M2oz3ootlGgZcjRtULAlzo0XcAQqfwb1JcJc5iAmIh9IQBkRKi D/9YoIbs38SwyNEIE0vrdPyIXHt0NNfzw/t2hlbkAxQsKPSTbz100HY5FfcKRF3mwGI6 JbfudLTqFdroJ+QXdVbhDQeQxf+kFgGnL4MuTPrrdBQd33uI2N7iY3ain/kvnnl2BWbG RDOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715321812; x=1715926612; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P013eBlgxlZ/UL/3+JN87mWVkNfsmaCM+AjZob2UWLs=; b=EFyNbqAKJzG08EOTzerwU1PHnWbG+ifbxxf24RUFt5A2sLShi2wOkmaRWasUoE5xkZ rY9+u2kUkYzFtplKNNzvKMR4GU3ej/VqFCcRdvi6AXVmsQgS3/r4k/RmNUWRK+G9gfOz SmmWmTZ5kbK+iZEAodkl6yQf0a4opgHvZh4kGSejmyeTeze5jfyS340Vxbo3sTLX/Cyg dPxLMkEtZoIRPM/w8aUtePN9okHRK47K5snG/jQZ5PXJcHK6bpABXQU69MxonBGLDUMV rYPomFw+Zf98s70cWKqUFqs7UGJmF3BkhfNrqQ3weKXPlnFoaqpF51mOpNpDdjMTEKgo jjIA== X-Forwarded-Encrypted: i=1; AJvYcCV1FJUFtDB2vNnMiSPrvCmRtYWHV3u027x15aWuerIbtL54U2cEX32cDq/no0PetiRCYX9ScPTKT3ZXauYxNPYX/BEV1/hwIcGW9ci2 X-Gm-Message-State: AOJu0YwipNBm4NCXodv55AX5rKJ/0g4B9u654nu9cGuV5/jnXO9IZw+0 jKYRlN1wRabyBg9KWYu9sBUiufilwp1VUtBfse6hoHvt+wYTmCpXQKJxKe4ot3je4Z4uih4i78U FtO8yIViM/ChLSJ6EZ3fX4lDBURA6EYORNfOW X-Received: by 2002:a05:622a:5292:b0:43a:bcee:eaa2 with SMTP id d75a77b69052e-43dfdce7f5dmr1976371cf.20.1715321812281; Thu, 09 May 2024 23:16:52 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240510024729.1075732-1-justin.he@arm.com> <20240510024729.1075732-3-justin.he@arm.com> In-Reply-To: <20240510024729.1075732-3-justin.he@arm.com> From: Ian Rogers Date: Thu, 9 May 2024 23:16:40 -0700 Message-ID: Subject: Re: [PATCH 2/2] perf pmu: Fix num_events calculation To: Jia He Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 9, 2024 at 7:47=E2=80=AFPM Jia He wrote: > > When pe is NULL in the function perf_pmu__new_alias(), the total number > of events is added to loaded_json_aliases. However, if pmu->events_table > is NULL and cpu_aliases_added is false, the calculation for the events > number in perf_pmu__num_events() is incorrect. > > Then cause the error report after "perf list": > Unexpected event smmuv3_pmcg_3f062/smmuv3_pmcg_3f062/transaction// > > Fix it by adding loaded_json_aliases in the calculation under the > mentioned conditions. > > Test it also with "perf bench internals pmu-scan" and there is no > regression. > > Fixes: e6ff1eed3584 ("perf pmu: Lazily add JSON events") > Signed-off-by: Jia He > --- > tools/perf/util/pmu.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c > index a1eef7b2e389..a53224e2ce7e 100644 > --- a/tools/perf/util/pmu.c > +++ b/tools/perf/util/pmu.c > @@ -1639,6 +1639,8 @@ size_t perf_pmu__num_events(struct perf_pmu *pmu) > nr +=3D pmu->loaded_json_aliases; > else if (pmu->events_table) > nr +=3D pmu_events_table__num_events(pmu->events_table, p= mu) - pmu->loaded_json_aliases; > + else > + nr +=3D pmu->loaded_json_aliases; Thanks for working on this! The "struct pmu_event *pe" in new_alias is an entry from the json data, and "pmu->events_table" should NULL if there is no json data. I believe the code is assuming that these lines aren't necessary as it shouldn't be possible to load json data if the json events table doesn't exist for the PMU - if there is no json data then loaded_json_aliases should be 0 and no addition is necessary. I'm wondering why this case isn't true for you. Thanks, Ian > > return pmu->selectable ? nr + 1 : nr; > } > -- > 2.34.1 >