From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC05FC001DE for ; Mon, 24 Jul 2023 07:40:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231231AbjGXHk2 (ORCPT ); Mon, 24 Jul 2023 03:40:28 -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 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