Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1174695ybg; Wed, 29 Jul 2020 07:39:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1wMPFMBmIE4W7TLBWI8Ck4I7AZ7KIl8XaNZjkQ/cLg+35fp+e9a3W1ZRmefSOLmjiAUAc X-Received: by 2002:a17:906:a284:: with SMTP id i4mr7539164ejz.490.1596033583187; Wed, 29 Jul 2020 07:39:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596033583; cv=none; d=google.com; s=arc-20160816; b=FiE0v9t9as2CgytOOGmQJ1YcJAseL1js4gCwa+0yz5tqLIjDnJkzU98yM4E309zIKG k6P5Ks2zDO9yKDMxhJrkIqgDP+gkYZixecyi2lT7achZ9XqwTWIdKgiLEzKBK1jwgkoN 5uhDU7BK7MNlVKu7i2m2laQ8ZWdr0zc3ZPqHxSnUcjUkYtqHHftnP2GEfajoVvClOJB9 W1D1pndLJo02Mwo0j4JOgW7Uwj7yx6Ss3JP6XFVnwoHHxiauJC1sffcHLEMPx+mUd1qL EEqUWHSltYZKtDj5Gl7r6BNfO26otfhOrdCD6GVTiRQ6KsjUaNF3rNPn05Oq2IViyOVS es0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Lzw1b32aOXRIrnOPbkpopUDZN5WOTvTp/GvueQcPmsQ=; b=id32EDqV0OT5S77gL+qJCcFnNhUT+hT/DWcKEBB9dm9ddS9GUPQENOlFu+BwlqkLBK 3TFrog5+GNczrEXsiIh5+74l7nVJSyrEEF5tAq3pU05wGrpJFrRq+85vNLrXySAokDBf Q+LDhepSzI52OiNgnQkWmZhyOGQfEFdGEUqKF7SvPRdz4XClZtulE4hc5TVlwJDW0eY6 B29OXxj2UZM+ci/uj2zBJtLHNm4qYrOUueoXgcPz6J8WvRbk5YOdo6aLr4WBhccIs8jp M95qv9ud53QasbGnpmpVLUXk7Jr/jkk418gfgt5RJMnSuMJO2FJt6EqhUQn3gBDdctl/ CfLw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c64si1363985edf.114.2020.07.29.07.39.21; Wed, 29 Jul 2020 07:39:43 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726891AbgG2OjQ (ORCPT + 99 others); Wed, 29 Jul 2020 10:39:16 -0400 Received: from foss.arm.com ([217.140.110.172]:52760 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726645AbgG2OjP (ORCPT ); Wed, 29 Jul 2020 10:39:15 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EE3F530E; Wed, 29 Jul 2020 07:39:14 -0700 (PDT) Received: from localhost (unknown [10.1.198.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 901B63F66E; Wed, 29 Jul 2020 07:39:14 -0700 (PDT) Date: Wed, 29 Jul 2020 15:39:13 +0100 From: Ionela Voinescu To: "Rafael J. Wysocki" Cc: "Rafael J. Wysocki" , Viresh Kumar , Dietmar Eggemann , Catalin Marinas , Sudeep Holla , Will Deacon , Russell King - ARM Linux , Ingo Molnar , Peter Zijlstra , Linux PM , Linux ARM , Linux Kernel Mailing List Subject: Re: [PATCH v2 4/7] cpufreq: report whether cpufreq supports Frequency Invariance (FI) Message-ID: <20200729143903.GC12941@arm.com> References: <20200722093732.14297-1-ionela.voinescu@arm.com> <20200722093732.14297-5-ionela.voinescu@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Monday 27 Jul 2020 at 16:02:18 (+0200), Rafael J. Wysocki wrote: > On Wed, Jul 22, 2020 at 11:38 AM Ionela Voinescu > wrote: [..] > > +static inline > > +void enable_cpufreq_freq_invariance(struct cpufreq_driver *driver) > > +{ > > + if ((driver->target || driver->target_index || driver->fast_switch) && > > + !driver->setpolicy) { > > + > > + static_branch_enable_cpuslocked(&cpufreq_set_freq_scale); > > + pr_debug("%s: Driver %s can provide frequency invariance.", > > + __func__, driver->name); > > + } else > > + pr_err("%s: Driver %s cannot provide frequency invariance.", > > + __func__, driver->name); > > This doesn't follow the kernel coding style (the braces around the > pr_err() statement are missing). > I'll fix this. Also, depending on the result of the discussion below, it might be best for this to be a warning, not an error. > Besides, IMO on architectures where arch_set_freq_scale() is empty, > this should be empty as well. > Yes, you are right, there are two aspects here: - (1) Whether a driver *can* provide frequency invariance. IOW, whether it implements the callbacks that result in the call to arch_set_freq_scale(). - (2) Whether cpufreq/driver *does* provide frequency invariance. IOW, whether the call to arch_set_freq_scale() actually results in the setting of the scale factor. Even when creating this v2 I was going back and forth between the options for this: (a) cpufreq should report whether it *can* provide frequency invariance (as described at (1)). If we go for this, for clarity I should change s/cpufreq_set_freq_scale/cpufreq_can_set_freq_scale_key s/cpufreq_sets_freq_scale()/cpufreq_can_set_freq_scale() Through this, cpufreq only reports that it calls arch_set_freq_scale(), independent on whether that call results in a scale factor being set. Then it would be up to the caller to ensure this information is used with a proper definition of arch_set_freq_scale(). (b) cpufreq should report whether it *does* provide frequency invariance A way of doing this is to use a arch_set_freq_scale define (as done for other arch functions, for example arch_scale_freq_tick()) and guard this enable_cpufreq_freq_invariance() function based on that definition. Therefore, cpufreq_sets_freq_scale() would report whether enable_cpufreq_freq_invariance() was successful and there is an external definition of arch_set_freq_scale() that sets the scale factor. The current version is somewhat a combination of (a) and (b): cpufreq_set_freq_scale would initially be enabled if the proper callbacks are implemented (a), but later if the weak version of arch_set_freq_scale() is called, we disabled it (b) (as can be seen below). [..] > > __weak void arch_set_freq_scale(struct cpumask *cpus, unsigned long cur_freq, > > unsigned long max_freq) > > { > > + if (cpufreq_sets_freq_scale()) > > + static_branch_disable_cpuslocked(&cpufreq_set_freq_scale); > > + > > } > > EXPORT_SYMBOL_GPL(arch_set_freq_scale); I suppose a clear (a) or (b) solution might be better here. IMO, given that (b) cannot actually guarantee that a scale factor is set through arch_set_freq_scale() given cpufreq information about current and maximum frequencies, for me (a) is preferred as it conveys the only information that cpufreq can convey - the fact that it *can* set the scale factor, not that it *does*. Can you please confirm whether you still prefer (b), given the details above? Thank you, Ionela.