Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp2805010rwo; Mon, 24 Jul 2023 01:14:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlHiqLtByJ8YWFag76WznHdVZwlPjydqr72m1ZZeKCY3QPMXtBTZTKraKpMmmjUicbrBdD7F X-Received: by 2002:a17:903:2581:b0:1bb:9e29:1468 with SMTP id jb1-20020a170903258100b001bb9e291468mr1592089plb.28.1690186455528; Mon, 24 Jul 2023 01:14:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690186455; cv=none; d=google.com; s=arc-20160816; b=ZHXTx7WVm6cloBgePiJVO44AU4bQoAU6gkyB8aIiRKOGOq2SrBvyuEQxt+/r1nDEnn r465/JLCl5SeVhbcMeDhEgTdlHUSgGDf5FwH+r0d3FVLY6WTY5UjLi1Soau2vV5ujmvN 8l7jfvHiLJqEVYUmVV7+eAmVWRPekzYNxEG0bHsB6geeS9xOGoZyAHA6ndGQdVukkyDP VJdAmUC/wQn5THajeZvotKtfEf5E2uwc/ohPZ10LwzSdPBlvI8yObKI73431bz5NE22i 32NlQDl+SiRNsxy6s2WE7uBW5ysTMUlMmvr+xsssPLOZYKXHpCLZXj0SFrUmxi32KDbb bVDA== 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=Mytif/b2IOlNp2gRBugpXXo7Q5fX18hRptGXcAEyNqg=; fh=oulqBZZ3hXaRnbTA+Ca4rMwbQATLOpwEed0ApAPG5wY=; b=WKQjraCJqZEW4yarLDcZIXMirZETHCN2sxXvcRQvSuTDWsW1CJxqhAKaRh4TgyeVVB SXWXX0vScjwPHRtVTPrCEtenbimXgGzetg2u52esvuaP4zdRDnZyRZrPGULn6/nwJ1// JWW5sOa8XWtjCYwOn8ITBmlMcBxOqR9+MwO8Xb9+jfyoFR3B32UTIDc7GgHnYeKuZhsy bi1q0Cr46sESI4jLlW470f98dWX1oGheaJ99Od87PBstau+tps6QofgOiNF9mh7oUOSW N/VoF8tCE3I48TQMOyJE4bn8q0aBWfDcFbhv5ze3TIYSgyt2hI0pLSZApbmQVjdPcZW3 bb9Q== 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:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j9-20020a170903024900b001b874c5f7a8si9052956plh.653.2023.07.24.01.13.57; Mon, 24 Jul 2023 01:14:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231185AbjGXHk0 (ORCPT + 99 others); Mon, 24 Jul 2023 03:40:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229499AbjGXHkX (ORCPT ); Mon, 24 Jul 2023 03:40:23 -0400 Received: from out30-112.freemail.mail.aliyun.com (out30-112.freemail.mail.aliyun.com [115.124.30.112]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 778F8195; Mon, 24 Jul 2023 00:40:21 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R151e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046049;MF=renyu.zj@linux.alibaba.com;NM=1;PH=DS;RN=18;SR=0;TI=SMTPD_---0Vo3N3oz_1690184414; Received: from 30.221.149.214(mailfrom:renyu.zj@linux.alibaba.com fp:SMTPD_---0Vo3N3oz_1690184414) by smtp.aliyun-inc.com; Mon, 24 Jul 2023 15:40:16 +0800 Message-ID: <2e392aa9-859a-75ef-eb3e-1870b1e78061@linux.alibaba.com> Date: Mon, 24 Jul 2023 15:40:12 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: [PATCH] perf arm64: Fix read PMU cpu slots To: Haixin Yu , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org References: From: Jing Zhang In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 在 2023/7/24 下午1:06, Haixin Yu 写道: > Commit f8ad6018ce3c ("perf pmu: Remove duplication around > EVENT_SOURCE_DEVICE_PATH") uses sysfs__read_ull to read a full > sysfs path, which will never success. Fix it by read file directly. > > Signed-off-by: Haixin Yu > --- > tools/perf/arch/arm64/util/pmu.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/tools/perf/arch/arm64/util/pmu.c b/tools/perf/arch/arm64/util/pmu.c > index 561de0cb6b95..512a8f13c4de 100644 > --- a/tools/perf/arch/arm64/util/pmu.c > +++ b/tools/perf/arch/arm64/util/pmu.c > @@ -54,10 +54,11 @@ double perf_pmu__cpu_slots_per_cycle(void) > perf_pmu__pathname_scnprintf(path, sizeof(path), > pmu->name, "caps/slots"); > /* > - * The value of slots is not greater than 32 bits, but sysfs__read_int > - * can't read value with 0x prefix, so use sysfs__read_ull instead. > + * The value of slots is not greater than 32 bits, but > + * filename__read_int can't read value with 0x prefix, > + * so use filename__read_ull instead. > */ > - sysfs__read_ull(path, &slots); > + filename__read_ull(path, &slots); > } > > return slots ? (double)slots : NAN; Yes, the function perf_pmu__pathname_scnprintf returns the complete slots file path "/sys/bus/xxxxx/caps/slots", and sysfs__read_ull will add the prefix "/sys" to the path, so the final file path becomes "/sys/sys/bus/xxxx/caps/slots" which does not exist, and the slots file cannot be successfully read, so sysfs__read_ull needs to be changed to the filename__read_ull. I tested it and it works well. Tested-by: Jing Zhang