Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp287849rdh; Thu, 26 Oct 2023 02:06:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFgfMNabDQnACeZlj5WiYlHQPwBUBGkbubGHk1M12ZvhgYVkUKDm5MLwIX5ohuG0BFp0WKf X-Received: by 2002:a67:ef51:0:b0:457:dbe3:ef45 with SMTP id k17-20020a67ef51000000b00457dbe3ef45mr17720297vsr.19.1698311189072; Thu, 26 Oct 2023 02:06:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698311189; cv=none; d=google.com; s=arc-20160816; b=LoHesZVdg0Nr3uEqAntsQSlFYRc2aaV0xcUSBxmoX9tMv5RzK5OaWZNeXXTyIw+mIX ICJ4F48wWFXIoG97dx7sIPlurMOtB1cRlC4PK/jOclIBzRygK0tlbpiWMYqCFM8Nk4TW WuAV4r8AQFyy5hHoPKMHVZ6XXaaXxhTG0qdK9nl1S32tmmh5ZSY0cDm21Mlcfsuh84XC uzclcJNPl7De/vpi2GznNe8fKfgdkwbRw4AGn6hV5EysdEov6WDbvZ58/fZz/tz3oHQJ BU7J/9murKDgm7xJHb3UW6g9vIKB2QagUCG/zed626iwy0yusNUZLh0rkwtSZTUvcixN h1VA== 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:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=qd9qGZ6NW+R1BPutZB0A9droCYF3efWSgPUBG/DjJwc=; fh=5q9Rmrk9AcbmH4bfOnHLTAWx6bDeviIcKBymXqES2PM=; b=u5nrPHeSItyLiAWWHafP4eRbYF8phhZ1xMq0xDYrabnOnTSfN8qrRn6duzlCT2utSs yLu2KzutxLwHf0YMhNoq3470GsZZkdpnD7rPo7b3OxzVR3ZxYXPsdSNqDiAnEnBuL4Wh 05EAuwcm0IGtKI8pGW0zimNeUiWEngxvoZvNEcvhHV6ssMJT9XjKEDhtPoRQhS+YgHlU BS4iHAOFyE2Y9SN0LnEyQE5KFG1uWXkBnv/WJtigF7icJencD9FkjsNvHZNboJzT/loC 0w3x6gzPU6AVUHYAewEnJlzXZZxCko+oD8feX/2gpMCEVvXjBIewzqcVVg/F51atcUxz tXNw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id u88-20020a25ab61000000b00da0622b5547si5901760ybi.569.2023.10.26.02.06.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 02:06:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 5C07080E0B45; Thu, 26 Oct 2023 02:05:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344465AbjJZJFl (ORCPT + 99 others); Thu, 26 Oct 2023 05:05:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229823AbjJZJFk (ORCPT ); Thu, 26 Oct 2023 05:05:40 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C99310E; Thu, 26 Oct 2023 02:05:35 -0700 (PDT) Received: from kwepemi500024.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SGKZ81Y6Gz1L8xr; Thu, 26 Oct 2023 17:02:40 +0800 (CST) Received: from [10.174.179.163] (10.174.179.163) by kwepemi500024.china.huawei.com (7.221.188.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 26 Oct 2023 17:05:32 +0800 Message-ID: <438e230d-5169-32b3-3992-9fef5ba71f05@huawei.com> Date: Thu, 26 Oct 2023 17:05:31 +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 2/3] cpufreq: CPPC: Keep the target core awake when reading its cpufreq rate Content-Language: en-US To: Sudeep Holla CC: , , , , , , , , , , , , , , , , References: <20231025093847.3740104-1-zengheng4@huawei.com> <20231025093847.3740104-3-zengheng4@huawei.com> <20231025111301.ng5eaeaixfs3jjpg@bogus> From: Zeng Heng In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.163] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500024.china.huawei.com (7.221.188.100) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.1 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 26 Oct 2023 02:05:56 -0700 (PDT) 在 2023/10/26 16:53, Sudeep Holla 写道: > On Thu, Oct 26, 2023 at 10:24:54AM +0800, Zeng Heng wrote: >> 在 2023/10/25 19:13, Sudeep Holla 写道: >>> On Wed, Oct 25, 2023 at 05:38:46PM +0800, Zeng Heng wrote: >>>> As ARM AMU's document says, all counters are subject to any changes >>>> in clock frequency, including clock stopping caused by the WFI and WFE >>>> instructions. >>>> >>>> Therefore, using smp_call_on_cpu() to trigger target CPU to >>>> read self's AMU counters, which ensures the counters are working >>>> properly while cstate feature is enabled. >>>> >>>> Reported-by: Sumit Gupta >>>> Link: https://lore.kernel.org/all/20230418113459.12860-7-sumitg@nvidia.com/ >>>> Signed-off-by: Zeng Heng >>>> --- >>>> drivers/cpufreq/cppc_cpufreq.c | 39 ++++++++++++++++++++++++++-------- >>>> 1 file changed, 30 insertions(+), 9 deletions(-) >>>> >>>> diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c >>>> index fe08ca419b3d..321a9dc9484d 100644 >>>> --- a/drivers/cpufreq/cppc_cpufreq.c >>>> +++ b/drivers/cpufreq/cppc_cpufreq.c >>> [...] >>> >>>> @@ -850,18 +871,18 @@ static unsigned int cppc_cpufreq_get_rate(unsigned int cpu) >>>> cpufreq_cpu_put(policy); >>>> - ret = cppc_get_perf_ctrs(cpu, &fb_ctrs_t0); >>>> - if (ret) >>>> - return 0; >>>> - >>>> - udelay(2); /* 2usec delay between sampling */ >>>> + if (cpu_has_amu_feat(cpu)) >>> Have you compiled this on x86 ? Even if you have somehow managed to, >>> this is not the right place to check the presence of AMU feature on >>> the CPU. >>> If AMU registers are used in CPPC, they must be using FFH GAS, in which >>> case the interpretation of FFH is architecture dependent code. >> According to drivers/cpufreq/Makefile, cppc_cpufreq.c is only compiled with >> ARM architecture. >> > Well that's true but this change doesn't belong to cppc_cpufreq.c, it must > be part of drivers/acpi/cppc_acpi.c IMO and sorry I assumed that without > explicitly mentioning that here. > >> But here, I would change cpu_has_amu_feat() with cpc_ffh_supported(), which >> belongs to FFH APIs. >> > It is not like that. cppc_acpi.c will know the GAS is FFH based so no need to > check anything there. I see counters_read_on_cpu() called from cpc_ffh_read() > already takes care of reading the AMUs on the right CPU. What exactly is > the issue you are seeing ? I don't if this change is needed at all. > > -- > Regards, > Sudeep In this scenario, both topology.c and cppc_acpi.c do not provide an API to keep the AMU online during the whole sampling period. Just using cpc_read_ffh() at the start and end of the sampling period is not enough. Zeng Heng