Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1251280pxu; Thu, 17 Dec 2020 06:00:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyCZe/YMhHjIrNGa+LF8L0aE6CAP9ttp1jYz//vTMuP74b1ea4J3aHWcVqO5khs3uU0hcLk X-Received: by 2002:a17:906:7d98:: with SMTP id v24mr35658534ejo.129.1608213628251; Thu, 17 Dec 2020 06:00:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608213628; cv=none; d=google.com; s=arc-20160816; b=ATsekJzsmANrzwTraLeY5RBZY0XC/1qC18udHQc2AyogI/+wjxX7HN721iNc8J846Q DYf6uc2a1Uv4FP0cvV2GRWGoavNs5/WVDAt2K2H/tnwBvbqNvCrtKcACidGpk3OoVmiD pVEg+Cy+i7ZpomIlpn35q/lexdCBFGMIH6/k6dp9C3Zs8101PNU6MhmLLzuxdRQte7gY LvrYNqFC5iNKRA9xzsDXhReEOnyVhSgk3OEEGMSkZt/pq1/+2/mIEtTxyjMIcSqev+Yg SEu/+QE465iNTEiX6MiQ2LeJub5gms7k9OL7UB7q9kjrgYCav0Ql2gvu9ZjJcb46FK9r nbEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=z7gwvGVWjL+AxRFG9mZnNHSbjEVuL8pXqT0fw2E47yM=; b=BCb/HivoknmPQryTubvAebi/JJ+rgKsQTpQTMOh9nEmq1/0U1SWjp9z/jLjbSR5ATS JsE2IDATeaz+gvhOgUyhjokxX9QZ71fN6DpJM8Hw9yBiPGooI6/FQst5reuzMwMGTnxr vzjwnK0vFeGDIw1JYMi3m5QdVfP//vmEieZccxRkcAMCU31+rIa0eFo/m8b2lZ436nCI YMkB6eEv452GUlFFpMG+uWHwrk/Etpo3NgvhM9YitvMNidZEfCI7Aavi5DA0aiqp3yMY iQcDC2GjV8rHdIbO/01lWiSGJMcc4Uy9L1/oHPOZexD2Z0X6XnpNz+A+m8/xp9PlLGoY KATg== 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c20si3148438ejr.339.2020.12.17.06.00.05; Thu, 17 Dec 2020 06:00:28 -0800 (PST) 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727376AbgLQN7i (ORCPT + 99 others); Thu, 17 Dec 2020 08:59:38 -0500 Received: from mail-ot1-f48.google.com ([209.85.210.48]:42421 "EHLO mail-ot1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726488AbgLQN7h (ORCPT ); Thu, 17 Dec 2020 08:59:37 -0500 Received: by mail-ot1-f48.google.com with SMTP id 11so27311265oty.9; Thu, 17 Dec 2020 05:59:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=z7gwvGVWjL+AxRFG9mZnNHSbjEVuL8pXqT0fw2E47yM=; b=PqZ/dEdOvf5iWmTSl8ds9ysybKzV6rkqPECL7Gry4mgZtxt4m75zShoHnJVWYiD0Tv ZsHrGj+6LmVAsetymy6L4YTufw3jXlPqxZpfJHKZcmDeJD98+YfbtwDiNMUUJsa6kC6d ev7y8lS5vfPy7NIn0rJqESuGhWbp9MCd9ka21+TkSbjNe+u8S27ZgybCo/JduHD8JC7T t0XN9N4WqNc/Y9lH7hHmUJ/VzYOnkAfv2L9YsPDD3QfuUEmLwEzG9KZE1lldqZs0zwvs 42iOMd7achWZDOLscxwS2U0D6TeRORUpWHuYgssKEut1KcIgIOmTk/mvtnW49TDmteME kMbQ== X-Gm-Message-State: AOAM533r3iLMZ+yZ4EWDphrwXl4idwh8leGMRb09ZgNgw5HMUCEKRNWV QqRB1b3nf0oFSfHwp1ZuMssTvcM2+jAPyRdI/Gk= X-Received: by 2002:a9d:745a:: with SMTP id p26mr30290443otk.206.1608213536569; Thu, 17 Dec 2020 05:58:56 -0800 (PST) MIME-Version: 1.0 References: <20201217104215.2544837-1-srinivas.pandruvada@linux.intel.com> In-Reply-To: <20201217104215.2544837-1-srinivas.pandruvada@linux.intel.com> From: "Rafael J. Wysocki" Date: Thu, 17 Dec 2020 14:58:45 +0100 Message-ID: Subject: Re: [PATCH] cpufreq: intel_pstate: Use the latest guaranteed freq during verify To: Srinivas Pandruvada Cc: Len Brown , "Rafael J. Wysocki" , Viresh Kumar , Linux PM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 17, 2020 at 11:44 AM Srinivas Pandruvada wrote: > > This change tries to address an issue, when BIOS disabled turbo > but HWP_CAP guaranteed is changed later and user space wants to take > advantage of this increased guaranteed performance. > > The HWP_CAP.GUARANTEED value is not a static value. It can be changed > by some out of band agent or during Intel Speed Select performance > level change. The HWP_CAP.MAX still shows max possible performance when > BIOS disabled turbo. So guaranteed can still change as long as this is > same or below HWP_CAP.MAX. > > When guaranteed is changed, the sysfs base_frequency attributes shows > the latest guaranteed frequency. This attribute can be used by user > space software to update scaling min/max frequency. > > Currently the setpolicy callback already uses the latest HWP_CAP > values when setting HWP_REQ. But the verify callback will still restrict > the user settings to the to old guaranteed value. So if the guaranteed > is increased, user space can't take advantage of it. > > To solve this similar to setpolicy callback, read the latest HWP_CAP > values and use it to restrict the maximum setting. This is done by > calling intel_pstate_get_hwp_max(), which already accounts for user > and BIOS turbo disable to get the current max performance. > > This issue is side effect of fixing the issue of scaling frequency > limits by the > 'commit eacc9c5a927e ("cpufreq: intel_pstate: > Fix intel_pstate_get_hwp_max() for turbo disabled")' > The fix resulted in correct setting of reduced scaling frequencies, > but this resulted in capping HWP.REQ to HWP_CAP.GUARANTEED in this case. > > Cc: 5.8+ # 5.8+ > Signed-off-by: Srinivas Pandruvada > --- > drivers/cpufreq/intel_pstate.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c > index 2a4db856222f..7081d1edb22b 100644 > --- a/drivers/cpufreq/intel_pstate.c > +++ b/drivers/cpufreq/intel_pstate.c > @@ -2199,6 +2199,12 @@ static void intel_pstate_clear_update_util_hook(unsigned int cpu) > > static int intel_pstate_get_max_freq(struct cpudata *cpu) > { > + if (hwp_active) { > + int turbo_max, max_state; > + > + intel_pstate_get_hwp_max(cpu->cpu, &turbo_max, &max_state); This would cause intel_pstate_get_hwp_max() to be called twice in intel_pstate_update_perf_limits() which is not perfect. > + return max_state * cpu->pstate.scaling; > + } > return global.turbo_disabled || global.no_turbo ? > cpu->pstate.max_freq : cpu->pstate.turbo_freq; > } > --