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 X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83E04C433E0 for ; Wed, 29 Jul 2020 14:40:53 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 45E0E207E8 for ; Wed, 29 Jul 2020 14:40:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="R41LHjAv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 45E0E207E8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=fzZnOhOL98tpEkBws1KN210T3gQuSBczAdCVT8lCcOA=; b=R41LHjAvAVQbiRiqECNtzzGPo jPavefD8TjX4TBCui4QhxJ/cqfchofSvJgEr8gz90x0wX1wWgGCgmJWrRjfuc6OvmcG4TDnBwUpir cYdH7C7N3+Xqz7EnF6L+PPxmNpxNsbW9THqgeSRmf+H5vuubc+a07mNj69o3awI0XLkzTEJ/Ff0OG Qyn9hCjf17HSqqxCUHm/Z1tz7a280fSBXLksjwJmCGWxEGFM0CSUoWqMHqtVxbh+3yuxG1HLf0g3z peUkqtTCVFVnEJSTQUOpPOXLzucDihvLLbBRtEaOQGmArMT5wfzNLSpyiGlxyJbgM1AM9SRKGtzJL Lw3HSVZgA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0nEk-0007B9-NQ; Wed, 29 Jul 2020 14:39:18 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0nEh-00079v-O2 for linux-arm-kernel@lists.infradead.org; Wed, 29 Jul 2020 14:39:17 +0000 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" 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-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200729_103915_918937_FB4CFBF7 X-CRM114-Status: GOOD ( 22.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Catalin Marinas , Linux PM , Peter Zijlstra , Viresh Kumar , "Rafael J. Wysocki" , Russell King - ARM Linux , Linux Kernel Mailing List , Ingo Molnar , Sudeep Holla , Will Deacon , Dietmar Eggemann , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel