Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750787AbcCEQtL (ORCPT ); Sat, 5 Mar 2016 11:49:11 -0500 Received: from casper.infradead.org ([85.118.1.10]:60580 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750702AbcCEQtH (ORCPT ); Sat, 5 Mar 2016 11:49:07 -0500 Date: Sat, 5 Mar 2016 17:49:00 +0100 From: Peter Zijlstra To: "Rafael J. Wysocki" Cc: Steve Muckle , "Rafael J. Wysocki" , Linux PM list , Juri Lelli , ACPI Devel Maling List , Linux Kernel Mailing List , Srinivas Pandruvada , Viresh Kumar , Vincent Guittot , Michael Turquette , Ingo Molnar Subject: Re: [PATCH v2 6/10] cpufreq: Support for fast frequency switching Message-ID: <20160305164900.GX6356@twins.programming.kicks-ass.net> References: <2495375.dFbdlAZmA6@vostro.rjw.lan> <2409306.qzzMXcm4dm@vostro.rjw.lan> <15684081.T4iOMUSHCY@vostro.rjw.lan> <56DA09B1.4010005@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2535 Lines: 59 On Sat, Mar 05, 2016 at 12:18:54AM +0100, Rafael J. Wysocki wrote: > >>> Even if there are platforms which may change the CPU frequency behind > >>> cpufreq's back, breaking the transition notifiers, I'm worried about the > >>> addition of an interface which itself breaks them. The platforms which > >>> do change CPU frequency on their own have probably evolved to live with > >>> or work around this behavior. As other platforms migrate to fast > >>> frequency switching they might be surprised when things don't work as > >>> advertised. There's only 43 sites of cpufreq_register_notifier in 37 files, that should be fairly simple to audit. > >>> I'm not sure what the easiest way to deal with this is. I see the > >>> transition notifiers are the srcu type, which I understand to be > >>> blocking. Going through the tree and reworking everyone's callbacks and > >>> changing the type to atomic is obviously not realistic. > >> > >> Right. Even if it was (and per the above it looks entirely feasible), that's just not going to happen. We're not ever going to call random notifier crap from this deep within the scheduler. > >>> How about modifying cpufreq_register_notifier to return an error if the > >>> driver has a fast_switch callback installed and an attempt to register a > >>> transition notifier is made? > >> > >> That sounds like a good idea. Agreed, fail the stuff hard. Simply make cpufreq_register_notifier a __must_check function and add error handling to all call sites. > > I guess what might be done would be to spawn a work item to carry out > > a notify when the frequency changes. > > In fact, the mechanism may be relatively simple if I'm not mistaken. > > In the "fast switch" case, the governor may spawn a work item that > will just execute cpufreq_get() on policy->cpu. That will notice that > policy->cur is different from the real current frequency and will > re-adjust. > > Of course, cpufreq_driver_fast_switch() will need to be modified so it > doesn't update policy->cur then perhaps with a comment that the > governor using it will be responsible for that. No no no, that's just horrible. Why would you want to keep this notification stuff alive? If your platform can change frequency 'fast' you don't want notifiers. What's the point of a notification that says: "At some point in the random past my frequency has changed, and it likely has changed again since then, do 'something'." That's pointless. If you have dependent clock domains or whatever, you simply _cannot_ be fast.