Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp4233795imc; Mon, 25 Feb 2019 00:59:34 -0800 (PST) X-Google-Smtp-Source: AHgI3IYilixTA9jAtMI0q6acX/IJ92JaYjgtP7i3ppHoORYu+RsgIA8YVvAN8tQumQBPnCM9wHDS X-Received: by 2002:a17:902:e60e:: with SMTP id cm14mr19260259plb.192.1551085174811; Mon, 25 Feb 2019 00:59:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551085174; cv=none; d=google.com; s=arc-20160816; b=EeOqmsvVVWFHgzsozQ7sfMK3new066UPmOhLv/r3deUSlrVR8gTWecmSzEX12Z6gk+ fS8WGYpgr0x2M2h04ogWvzxrk7QpE+ityhi6GAh2qfXevde6Hw9qasdG6rnmGwyA1hJQ uDpEOWzrQrkY3sG8gLoYu+5vGiNpOIZYaAEg4tGef7sCQPkDWyzjpbD8rd6wBzbW73MU v7UZjrbxPSRZxK2DoVabVJVxE73/BT2uofnd1sGnY1g09x8d+1WUUveaVfbnb3RseoWw 7NQysiSk9LSiVLs6QkUPERufYlPPp9f0r6UOp7g2Uyeymhz3U6E1pnDmWA76pRmQ+ImY WbOQ== 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=P0518apl4gFe1fZGfnl3yUS9FpgixcKVB0F3Hf9daoI=; b=ckAgDAwBj8a179mZqfXJkAw9D3tTliMCDN1x5mC0CSn8f2McuEQpy7zAqU2hZb2oQ/ 8z/IOYvfynzm98MDvgiA+ntGq/ne0S5od3xiGv6iKW3TLj47e1wei6Ih1U8wvFWN+Aw3 3ANhgD9xvFmdtmqzzwpYBWeJrDcjCwCTkmLG0v3dXBkCAC7idJURu2onY/S1dBlBeghv XnuOMrTEwTY3Ge4A/XNIfl5FkhcgRXpF0t4ht3JSLTxE4iH2Zcl4HoXbQWIuVtBkU0Qd 0hgQA0WbuiwHBphc0EcDhh6F1xMbjyZFLX2zwRAObxqeFgUCHrVRcyqwtjeXitAeaYYv wDyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b20si9051603pls.193.2019.02.25.00.59.19; Mon, 25 Feb 2019 00:59:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726346AbfBYI6w (ORCPT + 99 others); Mon, 25 Feb 2019 03:58:52 -0500 Received: from foss.arm.com ([217.140.101.70]:58128 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726116AbfBYI6w (ORCPT ); Mon, 25 Feb 2019 03:58:52 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2C0BDA78; Mon, 25 Feb 2019 00:58:52 -0800 (PST) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.195.17]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C649D3F703; Mon, 25 Feb 2019 00:58:50 -0800 (PST) Date: Mon, 25 Feb 2019 08:58:47 +0000 From: Qais Yousef To: Viresh Kumar Cc: Rafael Wysocki , linux-pm@vger.kernel.org, Vincent Guittot , mka@chromium.org, juri.lelli@gmail.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH V2 4/5] cpufreq: Register notifiers with the PM QoS framework Message-ID: <20190225085847.yvrtmxtwvk725b7v@e107158-lin.cambridge.arm.com> References: <20190222114446.cmwoe7tanxvf2gxh@e107158-lin.cambridge.arm.com> <20190225043149.bfl5vdb57xaaje2w@vireshk-i7> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190225043149.bfl5vdb57xaaje2w@vireshk-i7> User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/25/19 10:01, Viresh Kumar wrote: > On 22-02-19, 11:44, Qais Yousef wrote: > > Hi Verish > > > > On 02/21/19 16:59, Viresh Kumar wrote: > > > > [...] > > > > > @@ -2239,6 +2314,8 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, > > > struct cpufreq_policy *new_policy) > > > { > > > struct cpufreq_governor *old_gov; > > > + struct device *cpu_dev = get_cpu_device(policy->cpu); > > > + unsigned long min, max; > > > int ret; > > > > > > pr_debug("setting new policy for CPU %u: %u - %u kHz\n", > > > @@ -2253,11 +2330,23 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, > > > if (new_policy->min > new_policy->max) > > > return -EINVAL; > > > > > > + min = dev_pm_qos_read_value(cpu_dev, DEV_PM_QOS_MIN_FREQUENCY); > > > + max = dev_pm_qos_read_value(cpu_dev, DEV_PM_QOS_MAX_FREQUENCY); > > > + > > > + if (min > new_policy->min) > > > + new_policy->min = min; > > > + if (max < new_policy->max) > > > + new_policy->max = max; > > > + > > > > Assuming for example min and max range from 1-10, and thermal throttles max to > > 5 using pm_qos to deal with temporary thermal pressure. But shortly after > > a driver thinks that max shouldn't be greater than 7 for one reason or another. > > > > What will happen after thermal pressure removes its constraint? Will we still > > remember the driver's request and apply it so max is set to 7 instead of 10? > > Once everything comes via PM QoS, it will remember all the presently available > requests and choose a target min/max frequency based on that. OK I can see the logic now in kernel/power/qos.c now. Sorry I missed it and it was easier to ask :-) > > But even with this patchset, with half stuff done with PM QoS and half done with > cpufreq notifiers, it should still work that way only. And this is why we need to check here if the PM QoS value doesn't conflict with the current min/max, right? Until the current notifier code is removed they could trip over each others. It would be nice to add a comment here about PM QoS managing and remembering values and that we need to be careful that both mechanisms don't trip over each others until this transient period is over. I have a nit too. It would be nice to explicitly state this is CPU_{MIN,MAX}_FREQUENCY. I can see someone else adding {MIN,MAX}_FREQUENCY for something elsee (memory maybe?) Although I looked at the previous series briefly, but this one looks more compact and easier to follow, so +1 for that. -- Qais Yousef