Received: by 2002:a05:7412:bc1a:b0:d7:7d3a:4fe2 with SMTP id ki26csp319916rdb; Sat, 19 Aug 2023 03:13:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjARoQR7OmfpC4NelLNWuC2JHeU27rKbgXbwf9wC0a85vvjWByVjohUwLyu/E9AlM5hlQD X-Received: by 2002:a17:90a:1348:b0:263:f36e:d610 with SMTP id y8-20020a17090a134800b00263f36ed610mr1574783pjf.0.1692439996674; Sat, 19 Aug 2023 03:13:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692439996; cv=none; d=google.com; s=arc-20160816; b=LRtn16I6VTGolinNcBnbKjjVO6mtKSK4o68GkuaaeQxDNWjiuP4xJJVm302IzWItOi O1C9GPDUzs4wzzPsDrFk6a2nzzO84n1fwImHwaX3D4XJl7lcteYKfdj6JJTNTAdAaUg/ R4Gt/P2eihCMywcyZ4E48DHqXfGXnB9f9iIQ5g5ZLE5iAFc+5bU3oturoGOexf1FofLE m3EufY8S+k/vwABhaYiWUXc1AqC4nt0r9kzkYYbsiV8aJO7QM6VbcXAcIipP91wdVBrd KxSRFP3xrNRlL4ZGWer1uksAcX8ZC6YkrbHRY3wxndtLw7zKqr6vh98TD5fT6ek2KONd IozQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:subject:user-agent:mime-version:date:message-id; bh=RYYi6Xv1vAVlWwj/S5V/Cug8f4czO5qThWYXq0kKuNE=; fh=ascNgOYvw+gduVjMtfONnDwjec9SEOuZNPUfTb9iyN0=; b=oBMVfqRHQsRFBDyV1RXXQmgYeLGidjoddflbN3X0aoKBlm/3Lwf29qy5V+t5NUio/e PzV7rQ8Hf0AhF4gO3ZisFq3KuQCU8ZkGVZVz7fe+6RWo+bahWX92kGCA5X97lembmnIT B2EY5J4tkrjiTa4ld6EKXvDBgrJ414I+fJ3ffBLR0HiRNJNCRdSpPkQfyi0LU8g1viFQ 0QydUhrhgsS0JMOCNzx1mhUNyFK0zwWY8in+VyGxIx0V3EtLnbnHIpSIq7IFnxe8WB7l CFDwNmjGqLIjQBwZjYv2Tl4SHFLlIrn4FxhLqFDeNNqhJKR+7NAvod+FF3cbyb95uW5z tj9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d5-20020a17090ac24500b002681289fee1si3175714pjx.107.2023.08.19.03.13.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 03:13:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AB6913F573; Sat, 19 Aug 2023 01:30:19 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233567AbjHSEQr (ORCPT + 99 others); Sat, 19 Aug 2023 00:16:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229532AbjHSEQS (ORCPT ); Sat, 19 Aug 2023 00:16:18 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3CCD1706; Fri, 18 Aug 2023 21:16:14 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RSQMV2ZnSzFqgl; Sat, 19 Aug 2023 12:13:10 +0800 (CST) Received: from [10.174.179.211] (10.174.179.211) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Sat, 19 Aug 2023 12:16:09 +0800 Message-ID: Date: Sat, 19 Aug 2023 12:16:09 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v1] perf header: Fix missing PMU caps To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Kan Liang , Sean Christopherson , K Prateek Nayak , , References: <20230818171952.3719251-1-irogers@google.com> From: "liwei (GF)" In-Reply-To: <20230818171952.3719251-1-irogers@google.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.211] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ian: On 2023/8/19 1:19, Ian Rogers wrote: > PMU caps are written as HEADER_PMU_CAPS or for the special case of the > PMU "cpu" as HEADER_CPU_PMU_CAPS. As the PMU "cpu" is special, and not > any "core" PMU, the logic had become broken and core PMUs not called > "cpu" were not having their caps written. This affects ARM and s390 > non-hybrid PMUs. > > Simplify the PMU caps writing logic to scan one fewer time and to be > more explicit in its behavior. > > Reported-by: Wei Li > Fixes: 178ddf3bad98 ("perf header: Avoid hybrid PMU list in write_pmu_caps") > Signed-off-by: Ian Rogers > --- > tools/perf/util/header.c | 31 ++++++++++++++++--------------- > 1 file changed, 16 insertions(+), 15 deletions(-) > > diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c > index 52fbf526fe74..13c71d28e0eb 100644 > --- a/tools/perf/util/header.c > +++ b/tools/perf/util/header.c > @@ -1605,8 +1605,15 @@ static int write_pmu_caps(struct feat_fd *ff, > int ret; > > while ((pmu = perf_pmus__scan(pmu))) { > - if (!pmu->name || !strcmp(pmu->name, "cpu") || > - perf_pmu__caps_parse(pmu) <= 0) > + if (!strcmp(pmu->name, "cpu")) { So you removed the check of 'pmu->name', does this check really redundant? since we can find such checks in many places in the perf code. If not, i think it is necessary for strcmp(). > + /* > + * The "cpu" PMU is special and covered by > + * HEADER_CPU_PMU_CAPS. Note, core PMUs are > + * counted/written here for ARM, s390 and Intel hybrid. > + */ > + continue; > + } > + if (perf_pmu__caps_parse(pmu) <= 0) > continue; > nr_pmu++; > } > @@ -1619,23 +1626,17 @@ static int write_pmu_caps(struct feat_fd *ff, > return 0; > > /* > - * Write hybrid pmu caps first to maintain compatibility with > - * older perf tool. > + * Note older perf tools assume core PMUs come first, this is a property > + * of perf_pmus__scan. > */ > - if (perf_pmus__num_core_pmus() > 1) { > - pmu = NULL; > - while ((pmu = perf_pmus__scan_core(pmu))) { > - ret = __write_pmu_caps(ff, pmu, true); > - if (ret < 0) > - return ret; > - } > - } > - > pmu = NULL; > while ((pmu = perf_pmus__scan(pmu))) { > - if (pmu->is_core || !pmu->nr_caps) > + if (!strcmp(pmu->name, "cpu")) { same here Thanks, Wei > + /* Skip as above. */ > + continue; > + } > + if (perf_pmu__caps_parse(pmu) <= 0) > continue; > - > ret = __write_pmu_caps(ff, pmu, true); > if (ret < 0) > return ret;