From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C5E21A01D4 for ; Mon, 20 Jan 2025 09:01:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737363667; cv=none; b=tgnYqOrT/jFvEBib3hmCpOSB4so1czRiJ/hCZtD2GRmAhBseEhSoWoT0QgLEXQJ4Y2Xnk8henAXlYszdXsWTEEPe0/eVPQbncheE7PjJFXaWLYpr+KS/d7omhQpzyje6OQHLqlEVnn2djKHWxh7ZJImxrTeGccYR9iFIzmn7KlE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737363667; c=relaxed/simple; bh=N38qZoCHcgqzJ2cloh8L9PRfDVNTtK1+A7StBJyL13w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fU7VJit91smojV6YDKhnimYpef5HXY0OT9Mk93RWVdcV9zEXKqAIki7rke8uahgoT2b8r1PN7ld/KaPyf+FCi279suZAReJwdfXzmJPvVm1piWr2hvOOjuTfvEG8eoNtw2Vd0ixA/Pr39wxl9IOX6JZ/hht/ci6inev/0ApJlmk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=HlOAU3WR; arc=none smtp.client-ip=209.85.216.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="HlOAU3WR" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-2ef760a1001so7330229a91.0 for ; Mon, 20 Jan 2025 01:01:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737363665; x=1737968465; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=3Itnj3IOrEs6gi3JiCfTY/60+x3xztEOPRsyrRqJIyY=; b=HlOAU3WRdAafNDndOnhfCPWSS0ujMirIp0E75WPnoB2oTrDg+Xd8m6FjJe8fqm40m2 8tzx1cQIww8JujUwLRuL5qYrGnzrfeiv0RRVXW0q1dRFlQAxV+g+FUHeyz0Q0J8+DdSX YSWYnUHjyCqJO0F17p1vHazw3fWaR5DuB8zgJ8KEVyiq9u8g80izZ9utMeCoKQdu4zK4 sQpN9RWj4csmuwpc8OY+hOm36gx3hQGuDOmaTjlOnklbRTSDXVRwkib2nov/vF6KfKxv WUp42/5yDpCvyg+60ZhBWF593+C0ANPiRa4paaSUA4A5dnSjFKZ3m7qD2D4LdL62WWQ/ N5zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737363665; x=1737968465; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=3Itnj3IOrEs6gi3JiCfTY/60+x3xztEOPRsyrRqJIyY=; b=uvN6dn5HECW5W+Tpd4pA/qF6r7mcPqwK/DEV7Hedm32bDtCP+qKeKCANYgF/mRcCMa /Xs05TpQ9Ar5euAOUeiO42sCdon0c1+9VIHoJMKalZuVcICPfxhdZ1z72SFG1AyZzfos FvNnBgaBV61WqaK18KG54zmvF3T/2LI8U3rvCInuvSbUHPS25M5abnaxCImyPsBQ2x4u ZKeZYib6jqKcMrDPgBFWGD6M+L2MRi3iOpcIQ5na/tpKD4S0UcwtRITclSnrWXBi0QwS psTEg5VuFxHUXZcauLLDUOoNIGMsQgKKBj0QizN8yzXIq04H/qcv+jRtiQVvl9IAWiYL p/3g== X-Forwarded-Encrypted: i=1; AJvYcCWhgtbYm14Kw7nJOUASXueOaCZw+76uZ0p2IIDUFPoWVmXnKqXF/LTxMhLqPAS33Po4h8Xk2PCKLyonxek=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9DCaiSexfoqL7IBbi7BpybcOQYSrsXua4kdiuOtzjmlppgANA RYjOVEwvd+r5Yws+GZMeYWGx1ntaluv6+I1HcOwswULKULgJbRE+tnhnxyxlK6A= X-Gm-Gg: ASbGncuxE3XsE23AqIt4nYAjZNPdzF8Vewc95uW1pr6ZBA9h44BZGV2d2C4tvysLwOF aCddp3TGzJV7+bWRFxRmaAGVwu0rehupIhS02wkjA8RDzYIG0PP/11HsAZ8ei/NAozNcrUt1pdY tJore3oxVEj/Flu09UtIjr+JFSuSra8CIplofhG087hnnOfe/AXojrbybSShGZbvZz0/J9wmVPR /YBtzergSNhHFI1WVY1FYQKmwZTmEs40Zh2hmgCLGD/BevwuiuzHKAiSbtmo0vyZnoFv4xa X-Google-Smtp-Source: AGHT+IFALmijJfFaLhV1Mkvb2L6OTEoGi+Wz2LmZuokbQl05UuRJVPCcuD5yRIFcPpr2fW23WrgIOg== X-Received: by 2002:a05:6a00:3018:b0:725:df1a:275 with SMTP id d2e1a72fcca58-72dafbd97b0mr18464265b3a.23.1737363665248; Mon, 20 Jan 2025 01:01:05 -0800 (PST) Received: from localhost ([122.172.84.139]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72dabab64b8sm6557870b3a.166.2025.01.20.01.01.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2025 01:01:04 -0800 (PST) Date: Mon, 20 Jan 2025 14:31:02 +0530 From: Viresh Kumar To: Lifeng Zheng Cc: rafael@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linuxarm@huawei.com, jonathan.cameron@huawei.com, zhanjie9@hisilicon.com, lihuisong@huawei.com, fanghao11@huawei.com Subject: Re: [PATCH v2 2/4] cpufreq: Introduce a more generic way to set default per-policy boost flag Message-ID: <20250120090102.erm2ffkbnwa5vraa@vireshk-i7> References: <20250117101457.1530653-1-zhenglifeng1@huawei.com> <20250117101457.1530653-3-zhenglifeng1@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250117101457.1530653-3-zhenglifeng1@huawei.com> On 17-01-25, 18:14, Lifeng Zheng wrote: > In cpufreq_online() of cpufreq.c, the per-policy boost flag is already set > to mirror the cpufreq_driver boost during init but using freq_table to > judge if the policy has boost frequency. There are two drawbacks to this > approach: > > 1. It doesn't work for the cpufreq drivers that do not use a frequency > table. For now, acpi-cpufreq and amd-pstate have to enable boost in policy > initialization. And cppc_cpufreq never set policy to boost when going > online no matter what the cpufreq_driver boost flag is. > > 2. If the cpu goes offline when cpufreq_driver boost enabled and then goes > online when cpufreq_driver boost disabled, the per-policy boost flag will > unreasonably remain true. > > Running set_boost at the end of the online process is a more generic way > for all cpufreq drivers. > > Signed-off-by: Lifeng Zheng > --- > drivers/cpufreq/cpufreq.c | 16 ++++++++++++---- > 1 file changed, 12 insertions(+), 4 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index 5882d7f5e3c1..5a3566c2eb8d 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -1409,10 +1409,6 @@ static int cpufreq_online(unsigned int cpu) > goto out_free_policy; > } > > - /* Let the per-policy boost flag mirror the cpufreq_driver boost during init */ > - if (cpufreq_boost_enabled() && policy_has_boost_freq(policy)) > - policy->boost_enabled = true; > - > /* > * The initialization has succeeded and the policy is online. > * If there is a problem with its frequency table, take it > @@ -1573,6 +1569,18 @@ static int cpufreq_online(unsigned int cpu) > if (new_policy && cpufreq_thermal_control_enabled(cpufreq_driver)) > policy->cdev = of_cpufreq_cooling_register(policy); > > + /* Let the per-policy boost flag mirror the cpufreq_driver boost during init */ > + if (policy->boost_enabled != cpufreq_boost_enabled()) { > + policy->boost_enabled = cpufreq_boost_enabled(); > + ret = cpufreq_driver->set_boost(policy, policy->boost_enabled); I though you agreed to do some optimization here ? > + if (ret) { > + /* If the set_boost fails, the online operation is not affected */ > + pr_info("%s: CPU%d: Cannot %s BOOST\n", __func__, policy->cpu, > + policy->boost_enabled ? "enable" : "disable"); > + policy->boost_enabled = !policy->boost_enabled; > + } > + } > + > pr_debug("initialization complete\n"); > > return 0; > -- > 2.33.0 -- viresh