Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1045989rwl; Wed, 29 Mar 2023 11:50:11 -0700 (PDT) X-Google-Smtp-Source: AKy350b99loSS98Aoq8+6YQ4hUazETGXyVqYdg1Y+2Hw/Vn7I+3ewoXsOLPCtGzmqrG6wBNQ8lYT X-Received: by 2002:a17:907:3fa3:b0:93d:425a:b935 with SMTP id hr35-20020a1709073fa300b0093d425ab935mr24921685ejc.25.1680115810779; Wed, 29 Mar 2023 11:50:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680115810; cv=none; d=google.com; s=arc-20160816; b=YLaciqhH1qcxAArIKK9k1OR7ULEPuAVn7Cha2tK4z7dVTW4WqoXjtHpifzHcNfiEze H8AobahM8aS7m8wfMPRVjr4HCViDALdlx/AJJZI8+65mhA9OnHGdXivL8VYFUm0Hr9e3 j+MclkjX+qHflllkFSSZ8Prprj6cpzZ0DNBE+lxfXpnCZVJQm6U61fQmy2EyiZ4NGVnO kqmEeFabvsnQpwQi0CGz9xf5Ud0ERP+lTjKnyb63hIIF9Nj6AJDG1Y7Ofvx9y5s4hT5q Dmk35WWWDDharsoPpmYUrZefEJq8LRxi+k/bSjeKP9sjcEIEjWyOLdCv8YlTBTq8glF9 5/0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=AdmqgvApQEgPn3DDSAur/NhGHnlQrjcLittQtzR3YYw=; b=ezXC4ByLqW0Tk1wxL2/UA5823tEsNk6i0v/Hz/RANtUgRCBQp4K55VKFGN/adpddKZ fbvQctD5Df52zXqjbnnpnInD592WF6HWEOttOMypHPuPbalOqEP9oKPI3zzfqaME3rzY k1+t0O3ZlEiQqyGMVT1CjAaSM6dOqQA/SVjPyQu/sDmqKb4DjC8Pk4n0uHYA9ir0b88e RjiusAohD+PBiQAi0gQogp5EDguP4slIzi149aohQdK/Vy9NkHbi5JNhCLMPjq2VUmw+ MTYGxWxgS8GbUfm96IAgAJ/gu+WgnbZ9/i+//MeEdIf0oKcyKk+e6yutfybN2T7HdhDd 2w+A== 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id vq8-20020a170907a4c800b00933489ce7a6si26999339ejc.444.2023.03.29.11.49.42; Wed, 29 Mar 2023 11:50:10 -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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229618AbjC2Snt convert rfc822-to-8bit (ORCPT + 99 others); Wed, 29 Mar 2023 14:43:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbjC2Sns (ORCPT ); Wed, 29 Mar 2023 14:43:48 -0400 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32F0510D3; Wed, 29 Mar 2023 11:43:47 -0700 (PDT) Received: by mail-ed1-f47.google.com with SMTP id i5so67374841eda.0; Wed, 29 Mar 2023 11:43:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680115425; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4IiUWBvQSZiUOLFDdU4Pxf+fx5anScSeaRxeHGvAu+o=; b=sgIciGKb00dstgq4Lqx0OIr6vrYxm6l2Tv3HHpdAGOi2GfC2oSkeT4wSOVSxTY+ccn UqBQoe9XNqWeCla8+2Kz3ojkXSmTmLrv3/DOhKHkQ6qq3DBLX7rnXe4O2lBvp0/4uLv+ dY2cckbDxbbvwqWS7z9WhHWY7HhPOYeXvW64zBS1AqsNSozV2PHK3KwqMrPnLDoWqUel bMI/15UysAAB97RuEDljZPyoFVJ/oTzKpZUf25AA4xQ+aUKFBDXbEhN3aXMj0j+02eHJ 2w4c8LXIa8kA7RlYYH1SRLvH+rmuV3HklmqRM67s7janZUrbbVEXgTxYEy+aLhmJELFy 98ew== X-Gm-Message-State: AAQBX9csDBB/l5ZUXYUtMiJu9J5sEasVvlCyB4fN3zksqIxOTx2eHZrd un2/NLLAD/J8oiOYl7T9urPRW3AFf/isUWQ5k+g= X-Received: by 2002:a50:d49e:0:b0:502:148d:9e1e with SMTP id s30-20020a50d49e000000b00502148d9e1emr10219719edi.3.1680115425745; Wed, 29 Mar 2023 11:43:45 -0700 (PDT) MIME-Version: 1.0 References: <20230328193846.8757-1-yang@os.amperecomputing.com> In-Reply-To: <20230328193846.8757-1-yang@os.amperecomputing.com> From: "Rafael J. Wysocki" Date: Wed, 29 Mar 2023 20:43:34 +0200 Message-ID: Subject: Re: [PATCH] cpufreq: CPPC: use 10ms delay instead of 2us to avoid high error To: Yang Shi Cc: rafael@kernel.org, viresh.kumar@linaro.org, scott@os.amperecomputing.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=0.5 required=5.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no 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 On Tue, Mar 28, 2023 at 9:39 PM Yang Shi wrote: > > When testing CPPC cpufreq on our platform, we noticed the error may be quite > high and the high error may happen quite often. For example, on a platform > with a maximum frequency of 2.8GHz when the CPUs were fully loaded (100% load), > we saw cpuinfo_cur_freq may show 4GHz, it means the error is > 40%. And the > high error (> 1%) happened 256 times out of 2127 samples (sampled every 3 > seconds) in an approximate 2hrs test. The description above is a bit cryptic IMV. For example, it is not particularly clear what "high error" means. > We tried to enlarge the delay, and tested with 100us, 1ms and 10ms. The > below is the results. > > 100us: > The highest error is 4GHz, 22 times out of 3623 samples > > 1ms: > The highest error is 3.3GHz, 3 times out of 2814 samples > > 10ms: > No high error anymore > > Increase the measurement delay in cppc_cpufreq_get_rate to 10ms to avoid > high measurement errors. > > Signed-off-by: Yang Shi > --- > drivers/cpufreq/cppc_cpufreq.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c > index 022e3555407c..c2bf65448d3d 100644 > --- a/drivers/cpufreq/cppc_cpufreq.c > +++ b/drivers/cpufreq/cppc_cpufreq.c > @@ -851,7 +851,7 @@ static unsigned int cppc_cpufreq_get_rate(unsigned int cpu) > if (ret) > return ret; > > - udelay(2); /* 2usec delay between sampling */ > + mdelay(10); /* 10msec delay between sampling */ This function can be called with interrupts off, so it cannot spin for 10 ms. > ret = cppc_get_perf_ctrs(cpu, &fb_ctrs_t1); > if (ret) > --