Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp522769lqt; Fri, 19 Apr 2024 02:57:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVfJFxZI1UEHWQkt4PMQQjPU9WNqfVUvtnFGO++khStRKCcyiXkI7kpaJTUg5OgTqXdGd3ZnwA7Ne01HYMm3sz2YJ0vHpaI1bD+IGitvA== X-Google-Smtp-Source: AGHT+IFLoD2u1JRdl7HN90gq4pLkzrY7mDiUtkeLYhd9ZI/4aN+vCiX6T2heNQDfcJ7TRU61piEt X-Received: by 2002:a50:9f43:0:b0:56e:2b80:d87e with SMTP id b61-20020a509f43000000b0056e2b80d87emr1466139edf.2.1713520669893; Fri, 19 Apr 2024 02:57:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713520669; cv=pass; d=google.com; s=arc-20160816; b=zfQPlFTyb6UUeVc7htAc8CLjpZ7UQzxWBqxb9/2UTfUo7xyNTfJIQNjsuucE301DPZ WmXMpBHZ/lha9/AHSV+dW5rTgRooDnLraP8r/xndYDbKtifRENn0Gh19vevWUDckNgug 1KZPVVkkHBO35rGhjpMi6DCqUQsQpMozSMhCMVvx51iWK9PyqTsF1PooV1XnuQVhzLx+ +ypPCEnlZAZzjch5O4uid3rginsuhHyt9vRnoq0KndKKFNlo/nzY2mOHO6GOa4RhzEI8 qOOwFwW4G0Fqqebq+7XXl/lDeW1PGT2zhztTQnQNHaM78XTBmh5IHKPtuFh9CmCnz8TU 0oyw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=X3JSfvEEY6b0BeZKnBFeWmJFAr0os3TSiRYpvsYrPDQ=; fh=NWbihT0n2LVGI0eIabKMMzs0D4KhesRC0I1HJGdvI0I=; b=P61ephAioi/ZzkjPmEZPoM5Oat2QkK3/oz8/ZAGZsbquEpOclTZVjFhKexMyoAqbrF fm7aBZdUmkJtktywae5PKwIDavO5esAJ2AgRbJRwE0lmIA+MElDNEcXUHFsl58dsDWCS ii83LeOyA6XTE7A378fG8k7yaCZJ6efiwRikob3SXplw9Bpi6oJHuQpvcJtGPAbzPkXx I53f0l0M+w5AbRn8igTwD1tQSqudhRVCh0ypE7kSjvzv0CE3AeSkd1gC5d6EC8pC4zUU GRnoFJ8reVepU/Uo7tya2SYN0+p3eJspA2yaXy9a25n3lw/1FBcHn892YO7hOJWMgDHp 2yLA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-151274-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151274-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i20-20020aa7dd14000000b0056fd9c8e697si1913736edv.24.2024.04.19.02.57.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:57:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-151274-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-151274-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151274-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9E06F1F210A1 for ; Fri, 19 Apr 2024 09:57:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D6397E586; Fri, 19 Apr 2024 09:50:34 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D579A7C089; Fri, 19 Apr 2024 09:50:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713520234; cv=none; b=QcFaDr/wQ36b2NMybWgw141Z6n3SclzlOKLPnWtSMpfmJM4gyLxh+IrBG/cRn+Kn6/hvSLvxMaMWhy2Rq+SYgFugV0bOuOD3tQWQ6V5FuTbOgMLialG66/pdp4p7prA3boAEDUv8fr7BliT9TYxgOZA2meCK6B/Vfhe27o7tAJA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713520234; c=relaxed/simple; bh=b4VeMxGW9X8WiYuqPIAdftlZ07cIQLA99zvPqeuuI2U=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=WtLnsItwQFq0K+YrAOHyLNH/R+FIENpd1UUrm84EyXVZyajqrPayKTSdhOJqzvkxCi+5AtqIgP6X+1OVHcEsJcoL039A047Ybj9+0ngHIBthtbZyeJ8zDDHj8Q/Gltm4YDh6IzgOq4zESCnYkZmxp7mSOr5fENFzbmhERuveB0E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2E89B2F; Fri, 19 Apr 2024 02:50:59 -0700 (PDT) Received: from [10.57.77.69] (unknown [10.57.77.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F06EF3F792; Fri, 19 Apr 2024 02:50:29 -0700 (PDT) Message-ID: <1aea8475-e47c-479b-b06e-638d442f277e@arm.com> Date: Fri, 19 Apr 2024 10:50:37 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 06/16] thermal: gov_power_allocator: Use .manage() callback instead of .throttle() To: "Rafael J. Wysocki" Cc: LKML , Linux PM , Daniel Lezcano , Srinivas Pandruvada References: <13515747.uLZWGnKmhe@kreacher> <1815410.VLH7GnMWUR@kreacher> Content-Language: en-US From: Lukasz Luba In-Reply-To: <1815410.VLH7GnMWUR@kreacher> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/10/24 17:10, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > The Power Allocator governor really only wants to be called once per > thermal zone update and it does a special check to skip the extra, > from its perspective, invocations of the .throttle() callback. > > Make it use .manage() instead of .throttle(). > > Signed-off-by: Rafael J. Wysocki > --- > drivers/thermal/gov_power_allocator.c | 24 +++++++----------------- > 1 file changed, 7 insertions(+), 17 deletions(-) > > Index: linux-pm/drivers/thermal/gov_power_allocator.c > =================================================================== > --- linux-pm.orig/drivers/thermal/gov_power_allocator.c > +++ linux-pm/drivers/thermal/gov_power_allocator.c > @@ -395,7 +395,7 @@ static void divvy_up_power(struct power_ > } > } > > -static int allocate_power(struct thermal_zone_device *tz, int control_temp) > +static void allocate_power(struct thermal_zone_device *tz, int control_temp) > { > struct power_allocator_params *params = tz->governor_data; > unsigned int num_actors = params->num_actors; > @@ -410,7 +410,7 @@ static int allocate_power(struct thermal > int i = 0, ret; > > if (!num_actors) > - return -ENODEV; > + return; > > /* Clean all buffers for new power estimations */ > memset(power, 0, params->buffer_size); > @@ -471,8 +471,6 @@ static int allocate_power(struct thermal > num_actors, power_range, > max_allocatable_power, tz->temperature, > control_temp - tz->temperature); > - > - return 0; > } > > /** > @@ -745,40 +743,32 @@ static void power_allocator_unbind(struc > tz->governor_data = NULL; > } > > -static int power_allocator_throttle(struct thermal_zone_device *tz, > - const struct thermal_trip *trip) > +static void power_allocator_manage(struct thermal_zone_device *tz) > { > struct power_allocator_params *params = tz->governor_data; > + const struct thermal_trip *trip = params->trip_switch_on; > bool update; > > lockdep_assert_held(&tz->lock); > > - /* > - * We get called for every trip point but we only need to do > - * our calculations once > - */ > - if (trip != params->trip_max) > - return 0; > - > - trip = params->trip_switch_on; > if (trip && tz->temperature < trip->temperature) { > update = tz->passive; > tz->passive = 0; > reset_pid_controller(params); > allow_maximum_power(tz, update); > - return 0; > + return; > } > > tz->passive = 1; > > - return allocate_power(tz, params->trip_max->temperature); > + allocate_power(tz, params->trip_max->temperature); > } > > static struct thermal_governor thermal_gov_power_allocator = { > .name = "power_allocator", > .bind_to_tz = power_allocator_bind, > .unbind_from_tz = power_allocator_unbind, > - .throttle = power_allocator_throttle, > + .manage = power_allocator_manage, > .update_tz = power_allocator_update_tz, > }; > THERMAL_GOVERNOR_DECLARE(thermal_gov_power_allocator); > > > LGTM Reviewed-by: Lukasz Luba