Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp235603lqo; Thu, 9 May 2024 19:48:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUiH+l/J35WSoHm1y4wFRSggiPCodLFpBWDcuCbTW1nRuKFtUgMtG+Ru6+wtZ7HnF5yD8rKwvQDePlbjCRUz/CgwicDpMZZlb3uwXM36w== X-Google-Smtp-Source: AGHT+IHs1lZR6k8Ycvw7B3H89FTmYAcySVme+yEnFoQxKpNe0DoYhUSeKhPirOOpVd0xkCUCzhJ/ X-Received: by 2002:a05:620a:269a:b0:792:a77f:fe71 with SMTP id af79cd13be357-792c757440amr183406985a.2.1715309302162; Thu, 09 May 2024 19:48:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715309302; cv=pass; d=google.com; s=arc-20160816; b=DrBhyaH3b58mjgORnoOGvsb9w3457L5Gyb0NIpdkUBeNBD+/8a8EHFnd7ahzo2i/iV C6HZ2FmobiDzMNq+PdC3Q36zvw9iEhophQwmFuUr4bSf22h/yHwh5tdNht7jLtRSQd3D rWFwxoFQjAU90Q5wG0LuiVJh6Sw7/yOoG9M2qouTkwyTMYZBOS089onkkUiv/kgvbryS DdtTh7O7XO+koSI901gX+z25SYZa99eB99IGc6XYezBAInTrcjDK2eQrMQHgmNIZG20E lLE1Y+JLyUavbr9aAJPUPK5Txhupk3FhVC+qbvHhuU/+rcA/pYg3fqa57ofBb7K57Niu j4fA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=0CLe6DFpjFg7vEsVb2wN8DLi6XxQSudAZQdRDWtaSfM=; fh=19wKBpXXPdFwNE6P3L3YSoEFLRVhCF5WqDG+by0JvXo=; b=olVXFM6dmkkiEqurUQucgKX9/uZZO1u5HVsQYoqBz3r3XHFXu2VKaEdqoCBFh6VvNW 2dkx2T90RJAN6cxq74rA27lkpv33RydGBClXJE4Wj8vtNp+qNWgWGZ+Om3YtI84hgH8E non2gyclDRdihAO6n/0sOY9mPxL//O9UIZhJOPikCsgvVkCKPgarcnc3L++3wBh1RKLw d1cIqD/8dEVkRPYDwf8/VdZCogLekeOQux8XoW+r3lek7wFkL0Y/mHAmBmBJ4yHrI2YG O3YGz9lktoRICdG2dv7ydoeEgJEeiWUA4KPtBU4urJGBGJu0jLA+CPZA2TzknocpHxB7 7mvQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-175224-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175224-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-792bf278967si259761185a.82.2024.05.09.19.48.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 19:48:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175224-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-175224-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175224-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C58C41C2112F for ; Fri, 10 May 2024 02:48:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AAC08149DF3; Fri, 10 May 2024 02:47:54 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 91D02148859; Fri, 10 May 2024 02:47:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715309274; cv=none; b=fGEBhbD+lic734zRQSURND3o2VHWQ1K+VFDJ16OSOnbwG1PV0rLX+O71eBDpbtOnA6h1xGtFdsBT48H6mHeG7gEo4DpKbGox80WXKh4SBfiwi/zt4t+xQQPZhXE8JzedjXSNZHaUrkowVDSxp8Fh4d5sCiDF0rhiW5TSHD9u1Ho= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715309274; c=relaxed/simple; bh=6C2HEBWVQBGHjUQwLwVFPEGO4xWWxUD2vEMMiGXlKm4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bVcjKq/NaN7ljBdncOugmNVBKyIEAeNF1N2nUbs3e7XgdrI0CRTRIJbogH1ukTqokxwqNxp2dYQZ8tk4hUk1nhlGoToT7kzXveBTClcOkt9M+lJzNGkD47U1TrNrclM7cqx8lJZVh5ZmEQOaoXXA9aow0y5K5Y8UQuOjhArW2c8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3C02D143D; Thu, 9 May 2024 19:48:17 -0700 (PDT) Received: from entos-yitian-01.shanghai.arm.com (entos-yitian-01.shanghai.arm.com [10.169.206.117]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 179813F762; Thu, 9 May 2024 19:47:47 -0700 (PDT) From: Jia He To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim Cc: Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Jia He Subject: [PATCH 2/2] perf pmu: Fix num_events calculation Date: Fri, 10 May 2024 02:47:29 +0000 Message-Id: <20240510024729.1075732-3-justin.he@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240510024729.1075732-1-justin.he@arm.com> References: <20240510024729.1075732-1-justin.he@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 += pmu->loaded_json_aliases; else if (pmu->events_table) nr += pmu_events_table__num_events(pmu->events_table, pmu) - pmu->loaded_json_aliases; + else + nr += pmu->loaded_json_aliases; return pmu->selectable ? nr + 1 : nr; } -- 2.34.1