Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2282978lqo; Mon, 20 May 2024 00:12:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX3Tz4y1lJbOTEHbzTrLvU+a9P34UIj5wuWx1D7sRoK0MNgB0zBr20RuSLmFzYY97qxsbynaWaFPtX0IGoOGMD0PWA+yl2+WL7xps/o8w== X-Google-Smtp-Source: AGHT+IHLc6N6aY7wIemhu+XlXw2zntQnZ7FlMm80CGQMPBDdE33s7PCVt1wQqD32HH5boqE9HVlI X-Received: by 2002:a17:90a:a58d:b0:2b3:2a3b:ddeb with SMTP id 98e67ed59e1d1-2b6cc3429b1mr23270761a91.18.1716189134737; Mon, 20 May 2024 00:12:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716189134; cv=pass; d=google.com; s=arc-20160816; b=GzIZF//1PvFp1bxRrL/pDuB2hwIVj9E9KKTy2u70KPgKIIl+rxCfiXlzWTJXjCJwgp Uxwz/AJYO70EH9l6uzKRYpLeGeE6QYDL9KMOVtL/DBJQ8jwCPur1XFq5pUcYrpfPnP4G 5jb8+W8C1Lcpev6FpxnVR0TI90CTpqcOo5d+b97e6YkIKc/iI9HvvA9hjPCAHZjGBvOP gpd/7kr8HxknGt2bQX/sEiACGDofaq5bYq2AcXbWZp/86aU+Yw6WvaB/6b2bhwGy6qai 1UzUQn7PNtDfVfAjmPOFSocxncffDPcCqjYrYUmTonfiJHzS0938349DPE/75diotQ3O majw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=MHRjk1UF5y6ZXolJPbrenklGO031NQi7q46Dk0j7hM4=; fh=paxW7nAh4Np3tjHEjXWZtD2Lxx8iki5EtFMBMNJq+UA=; b=jehSgtgMbjQahs2TfIpYsO4UXnWJHgYl02o/yHtgwGOIud1YYzHhpyoEnJnHNf8yv/ QFdHgmCKmxCHV4UzkX/wmmXNzf9OhMcGdSaxKASDlnuROPdPRAwVVs74O9f94HCCBhoU QiUOHP0EU/Vbok4QRHgj+1C7yXrmacCpITYc3wRMk5jt+5wahybLdDjJEsZWy3mpzvvJ Qh3yz3lfy5nZ6fLWYiPUvncj2Q/q73C1e34C6+WQR6XGG1qmW4zOFPIRdjQ54uBeOEuB hLAVMtSlJLpNrVj7yhJSZ6/FWnJmvKhjxvP0gFCUzxLdh7Dud3RdNjJBy87hvhuCVK/G lD9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NzicRqtm; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-183448-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183448-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b628ea7988si24304666a91.114.2024.05.20.00.12.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 00:12:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-183448-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NzicRqtm; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-183448-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183448-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5D132281863 for ; Mon, 20 May 2024 07:12:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6183E1865A; Mon, 20 May 2024 07:12:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NzicRqtm" Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) (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 092451BC4F for ; Mon, 20 May 2024 07:11:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716189121; cv=none; b=S4msKI2eRNg+6+i/lSHLbPYRRKtp6XvAlg7nU2quRUHT3ecaD78q/Hj5/wMpMUrXjr4YcZi9Q8Sn4FrOpbDQyHFUkDpCA/4kIasEzBmi13YVCkJjzA9t1OosEhaI6rXqjlDEVAnr/8Pd6GWNz7DlMacmQWKn+WIlWZe1Er9OaRg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716189121; c=relaxed/simple; bh=quW73Dwdi12WfG3At2nCwuAVaKbL7l554/u5u007xYU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=s0WX09TujXQLRKrhIG3/n0dTvJ+ABO2J4FopcJSiPyYkd2iAv/SFEFkAUeuwfDjYOb2S1zzVU0s1V3BKBWyIcit93iIl6TvPnJz7YaU5hFZMotMmQN9pL2waaNBINMbvAysMw8kKt8s90csuyRGUyZrZt4eSApCwYWbLxse394U= 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=NzicRqtm; arc=none smtp.client-ip=209.85.160.43 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 Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-24c39cedc7bso105574fac.0 for ; Mon, 20 May 2024 00:11:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716189119; x=1716793919; 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=MHRjk1UF5y6ZXolJPbrenklGO031NQi7q46Dk0j7hM4=; b=NzicRqtmrre+8Bi+vLep0NV+H+tdjDFEs3vnqZhaj2WciM48GL0Dp6A8wQdGV9SwsF g3zpi6UN8VCZmcuYF8nFSj4S1hwFlcAeUO/Pl/9PKoWuqf1dQz+7UT7n4TsuJZBHHXaF x8YCsYqoaTYvZecIcSFOhg0LIE5jGxdVnzfGNSc63nOs7uvAIpr3GN1QdgKrS7afVydH QWUkxTpNhisB73Aunz1Bm75TC6Xdk98J1tVvWjoc64kOOqNHZ8gEMeZ2mDHlFEgvdn72 avTu4g9tJ6yObS8NWPQ8G4s3cwFQZ6vq2djD2WYNbwQEoDOJv3LASNPI2tUbBOxuYwy8 VW5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716189119; x=1716793919; 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=MHRjk1UF5y6ZXolJPbrenklGO031NQi7q46Dk0j7hM4=; b=XFXV8EjyEMvLoUXLLXewX4l+ILO4KTZM/S6DAspOqml6gxVtCKmFhcJXRl0uLpE/Ts 9YBJ4dooe5t+o6rvn9j7ikIp6u/0FW/GFb29fd7i3Lwbdk0/YDXHmmI4ErtJbRvEUXDP Csnu0LAZRukD2pXyaM4vcxE2oo9V2EgAaTs1v9a5MUJu27h/dJiEYXHZfvy5yKaDwEan zbogk76P3mgOk6WHJeBhbAebPAeZ3xuNLHJj9r02q6Xn89SfSMWAIkCgxonv+UVKD7C1 L2wuhTpUpDbMkx2ri7pSDaqV1t9e+9S+FEZZi3yiEkq5FjDjUhQKB/HK9rnwbyXJLgJy nARg== X-Forwarded-Encrypted: i=1; AJvYcCXHJWsUXpJ4EbSjeGotTsn0vNGJdvqDGW+QLMjYLVBAKCJQ9BgYFs1DKmqCfNJgStz5r4ZDseBpxDlzwkLjCbMNcXS+PeLzUR6oqdK7 X-Gm-Message-State: AOJu0YxnuXlHDUA50jbI2IcTBzalL4S64FiB45PgmHGnZ91fDqbOiY5F bxZIWN71F3U0/MXjlB9YWn1njtfDKWy3tqn+1Kaa3kPJf1UAG2kGa1t6g78b/2w= X-Received: by 2002:a05:6870:aa89:b0:239:7801:dbd0 with SMTP id 586e51a60fabf-24172e08c8emr32974507fac.47.1716189118484; Mon, 20 May 2024 00:11:58 -0700 (PDT) Received: from localhost ([122.172.82.13]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2a665ccsm18518300b3a.23.2024.05.20.00.11.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 00:11:57 -0700 (PDT) Date: Mon, 20 May 2024 12:41:55 +0530 From: Viresh Kumar To: Fares Mehanna Cc: rkagan@amazon.de, "Rafael J. Wysocki" , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] cpufreq: fail to start a governor if limits weren't updated correctly Message-ID: <20240520071155.lbphk4dqbhibogtj@vireshk-i7> References: <20240430143923.40431-1-faresx@amazon.de> 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: <20240430143923.40431-1-faresx@amazon.de> On 30-04-24, 14:39, Fares Mehanna wrote: > Current cpufreq governors are using `__cpufreq_driver_target()` in their > `.limits()` functions to update the frequency. `__cpufreq_driver_target()` > will eventually call `.target()` or `.target_index()` in the cpufreq driver > to update the frequency. > > `.target()`, `.target_index()` and `__cpufreq_driver_target()` may fail and > all do return an error code, this error code is dropped by the governor and > not propagated to the core. > > This have the downside of accepting a new CPU governor even if it fails to > set the wanted limits. This is misleading to the sysfs user, as setting the > governor will be accepted but the governor itself is not functioning as > expected. Especially with `performance` and `powersave` where they only > target specific frequency during starting of the governor and stays the > same during their lifetime. > > This change will cause a failure to start the new governor if `.limits()` > failed, propagating back to userspace if the change is driven by sysfs. > > Signed-off-by: Fares Mehanna > --- > drivers/cpufreq/cpufreq.c | 7 +++++-- > drivers/cpufreq/cpufreq_governor.c | 6 ++++-- > drivers/cpufreq/cpufreq_governor.h | 2 +- > drivers/cpufreq/cpufreq_performance.c | 4 ++-- > drivers/cpufreq/cpufreq_powersave.c | 4 ++-- > drivers/cpufreq/cpufreq_userspace.c | 16 +++++++++------- > include/linux/cpufreq.h | 13 +++++++------ > kernel/sched/cpufreq_schedutil.c | 6 ++++-- > 8 files changed, 34 insertions(+), 24 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index 66e10a19d76a..5ac44a44d319 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -2474,8 +2474,11 @@ int cpufreq_start_governor(struct cpufreq_policy *policy) > return ret; > } > > - if (policy->governor->limits) > - policy->governor->limits(policy); > + if (policy->governor->limits) { > + ret = policy->governor->limits(policy); > + if (ret) > + return ret; You need to stop the governor here on failure as this function started it successfully. -- viresh