Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4079794pxv; Mon, 28 Jun 2021 21:35:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyj9/dRJIf8RNbihlvzlU2DO7yssx8trvXELQQgoGAzgOnObNJC/1tFgg9OMrTcYtKto0Wr X-Received: by 2002:a17:907:3e0a:: with SMTP id hp10mr14260355ejc.110.1624941318642; Mon, 28 Jun 2021 21:35:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624941318; cv=none; d=google.com; s=arc-20160816; b=NPeOUYij1DdR4Y5Qq4k13xfhAhfZIMjDhZwuyq+gCeXTYrglUkKyoxKg07H+yQg4C7 m0TmZJjLzdEOqYOuIG7np7QelDQ30S2vPtXEb7LHXT3mJgwSYZFWGJxnbv6AgpQaDgsA sUh1jRegjSF4cckR/zmXaxq29Opx9qgkuC++nV/IA+mIFDL9w6WHpI7pM3lMpvo/uXbw VEl4hY0hwJotmOQA1ZwsJYOq7Oe5AjaIoH64MFSZu6bxPqYFIKfZvAOUEdgBe9Xg8loL uMMFPPuwKL59jrqwzGnyg67cAygTGkQT/BqDuIs41K5X7S/IBaqI9rDzPaLDFinth4Db pc3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=23i756DizbPe5Tq81adrM3z+cR5El93g/Fx0K2OMmhk=; b=mb7NlwYNzrvGlGQJM9z+HlvXUpkhzwl7JbzPSA/+eSO+jZHuxl/ZBS4pUhxpu24Z8V vTAuh/6+zGI+H5Sz6r8fy1Wsknz/9TIfLxSz6vByAh39MavglpfaUTpQ1ZGDvXPdSd+Y ZsxPmIJ4oavbQDV1MXvLk/p1M/lWkCVnuLg45BFDuJs4EEbIVO1lm3LI1T9ckSS7Mhwv 7KIpD1gfucgAqJgS5Lyh2J5DECeRPe3CVoSKNzFacU/VaG4vzpC+K37JXLXwPt3pV05x eHGF+LvjJwKSzxqRTs3vcGqZb3bikx1I6mehOE9sF762IUQh1izf5xQHOxhxNFOzSa+6 ouDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PpsGWIXY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s30si14766422ejs.736.2021.06.28.21.34.54; Mon, 28 Jun 2021 21:35:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PpsGWIXY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229824AbhF2EfQ (ORCPT + 99 others); Tue, 29 Jun 2021 00:35:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229517AbhF2EfP (ORCPT ); Tue, 29 Jun 2021 00:35:15 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63607C061766 for ; Mon, 28 Jun 2021 21:32:48 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id h4so17369398pgp.5 for ; Mon, 28 Jun 2021 21:32:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=23i756DizbPe5Tq81adrM3z+cR5El93g/Fx0K2OMmhk=; b=PpsGWIXYxBPhgafzsH2eFwhsDg5mCF0t90pleQ1+fS3Ft68xP+diqvfwpObEbh1oO+ bHhGDsR0mWE06IgwSiNr7YvCs/yxSGCUX3d/Hqck2bsbW4BnbtPhCORWwEqLjlGx2U1A O64aJYmbygBYdr8OZQho+wdTO2OYYMJqeVzGX4DvBpEUOd2H+LWBJU6FSWdiTFaxamPQ 7LVn+JDX2ueCHS4fOhKPxBL6LLJH4Gu8uGgXcio8KSLFpaCPH76fz4H8pNEVphJHgGF9 cRfeEkbJOBi44fHyi4y/QgB5JoynuYwfx1idGdew3FsvQM/3TWpX91ic8y8mrt7IZ+F/ oVpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=23i756DizbPe5Tq81adrM3z+cR5El93g/Fx0K2OMmhk=; b=DbhuatJIF35E6YVCBy30/l/nA2RkmOAfDql0luL3TW78jEm3TGdaDD37T4C/G/ObHh xjJWTLUlncDwvwF6BlwhoYUmCJVYoMHomN8AbKPX84x4pYl5ddrhJOebYWLMBtOzoGCT 4rjerb8Hu9H6HmhWndK8RJ8/nzrLar+8ApLsLBAfaJ/yw8h8uvMgjEnD0Hc8F10LspCi TqFdMmKno/kPc95xhPZzL5McS5vfenBd7wDJYFDxiylWmIkIH7zjCbltOLKvcijSn3jc VchdAplGbeRxs6g2rRYe58dgwYZ2fIkFopG8y6li4OKxSzyC0bHJNduGoB9LrezOqTLQ WmQg== X-Gm-Message-State: AOAM531Lf9dDjmWULtmXpm3NAbkScr7VUKezOgJkWs24uJ5urWOkVStC 5sT4eJh4gE95bLuJA3fAWt6Fqw== X-Received: by 2002:a05:6a00:1888:b029:303:ec88:66c with SMTP id x8-20020a056a001888b0290303ec88066cmr28398307pfh.7.1624941167473; Mon, 28 Jun 2021 21:32:47 -0700 (PDT) Received: from localhost ([136.185.134.182]) by smtp.gmail.com with ESMTPSA id 195sm16305577pfw.133.2021.06.28.21.32.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Jun 2021 21:32:46 -0700 (PDT) Date: Tue, 29 Jun 2021 10:02:44 +0530 From: Viresh Kumar To: Ionela Voinescu Cc: Rafael Wysocki , Sudeep Holla , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , linux-pm@vger.kernel.org, Qian Cai , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V3 4/4] cpufreq: CPPC: Add support for frequency invariance Message-ID: <20210629043244.xkjat5dqqjaixkii@vireshk-i7> References: <20210624094812.GA6095@arm.com> <20210624130418.poiy4ph66mbv3y67@vireshk-i7> <20210625085454.GA15540@arm.com> <20210625165418.shi3gkebumqllxma@vireshk-i7> <20210628104929.GA29595@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210628104929.GA29595@arm.com> User-Agent: NeoMutt/20180716-391-311a52 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28-06-21, 11:49, Ionela Voinescu wrote: > To be honest I would like to have more time on this before you merge the > set, to better understand Qian's results and some observations I have > for Thunder X2 (I will share in a bit). Ideally, this code was already merged in 5.13 and would have required us to fix any problems as we encounter them. I did revert it because it caused a kernel crash and I wasn't sure if there was a sane/easy way of fixing that so late in the release cycle. That was the right thing to do then. All those issues are gone now, we may have an issue around rounding of counters or some hardware specific issues, it isn't clear yet. But the stuff works fine otherwise, doesn't make the kernel crash and it is controlled with a CONFIG_ option, so those who don't want to use it can still disable it. The merge window is here now, if we don't merge it now, it gets delayed by a full cycle (roughly two months) and if we merge it now and are able to narrow down the rounding issues, if there are any, we will have full two months to make a fix for that and still push it in 5.14 itself. And so I would like to get it merged in this merge window itself, it also makes sure more people would get to test it, like Qian was able to figure out a problem here for us. > For the code, I think it's fine. I have a single observation regarding > the following code: > > > +static void cppc_cpufreq_cpu_fie_init(struct cpufreq_policy *policy) > > +{ > > + struct cppc_freq_invariance *cppc_fi; > > + int cpu, ret; > > + > > + if (cppc_cpufreq_driver.get == hisi_cppc_cpufreq_get_rate) > > + return; > > + > > + for_each_cpu(cpu, policy->cpus) { > > + cppc_fi = &per_cpu(cppc_freq_inv, cpu); > > + cppc_fi->cpu = cpu; > > + cppc_fi->cpu_data = policy->driver_data; > > + kthread_init_work(&cppc_fi->work, cppc_scale_freq_workfn); > > + init_irq_work(&cppc_fi->irq_work, cppc_irq_work); > > + > > + ret = cppc_get_perf_ctrs(cpu, &cppc_fi->prev_perf_fb_ctrs); > > + if (ret) { > > + pr_warn("%s: failed to read perf counters for cpu:%d: %d\n", > > + __func__, cpu, ret); > > + return; > > + } > > For this condition above, think about a scenario where reading counters > for offline CPUs returns an error. I'm not sure if that can happen, to > be honest. That would mean here that you will never initialise the freq > source unless all CPUs in the policy are online at policy creation. > > My recommendation is to warn about the failed read of perf counters but > only return from this function if the target CPU is online as well when > reading counters fails. > > This is probably a nit, so I'll let you decide if you want to do something > about this. That is a very good observation actually. Thanks for that. This is how I fixed it. diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index d688877e8fbe..f6540068d0fe 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -171,7 +171,13 @@ static void cppc_cpufreq_cpu_fie_init(struct cpufreq_policy *policy) if (ret) { pr_warn("%s: failed to read perf counters for cpu:%d: %d\n", __func__, cpu, ret); - return; + + /* + * Don't abort if the CPU was offline while the driver + * was getting registered. + */ + if (cpu_online(cpu)) + return; } } -- viresh