Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp415421rdh; Tue, 19 Dec 2023 02:57:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IE4XR7PMWif+hM9xA4c4iakgK+xO9RTFYHWaWzb+EXNBFcPiQXHSbrrUHvg4umy1onSiUe6 X-Received: by 2002:a05:6a20:9151:b0:18f:1f13:e9e5 with SMTP id x17-20020a056a20915100b0018f1f13e9e5mr10028104pzc.86.1702983465740; Tue, 19 Dec 2023 02:57:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702983465; cv=none; d=google.com; s=arc-20160816; b=E/YjGRIEgbnZxIr5bGQpK0ewG60r8PlAu8ylzG1N1PPpFbbH3RVh89c/e8cr2LtZpt rPekEUtxfqbgSc64nGhCP1JKqglLdMZRMdueFMhYdZQvZGEBK8zkvmiEGuvHM9NOOTDd 1YUngExu/Z/jWFMX3j/Rmv15TIYxYD3ht7+5L3ba+QyAjw1Fujn44dIjL81Nq2pdDrsV e1Un1Ds4AoW0VoPDSun13O/2W47xEXzLRhStksVRzEHNxgXBHPMD1hPBvJMTngi9IgH7 HkS6sGPCu3vaLKyf9rvtFeoSFgnFGlIbuJF8yHnQq15R8YXWf22UZG80TCzNa3ESdAqD IiLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=aGyqa8Nv5vsmyHO5GTc2y9NMpBGilar5CyMkiZWMZ4Q=; fh=JKb+TWCmAwP7LS8dhe0hJmm2xgnpNV/fltp92CQtZbU=; b=N4/SUh3U/ZYnG0YLHyahzeAhr6XeEOQqz1G7/lAcZEr1ppLqlPcQvz/godkJ/S3+DP dTaKfx/wpwTHPbQky+bf3lGha7p2Ntd57iQg8QWavFlfmk9XpMQ6adZ2SBGUSnfIdFcR pplRiLp5MiYrE/Af5B+j3Ffdvk1y/ZiuQcAdYvME5CYjQaaMgz/kyXhrTJxlabGQTdOX ymhlFRZ4NpJrVPNJTlnqcGvcyXIF51D8uINmdcAyq3XKRu/Bv+7g37CYFtx1BK/JpzSe 7D7Xp2EEk07kWKnLkHc1wZVdgDvbA7XCjiL6QJCnJNIteVz/pNpjwRYa2VKCh8Ic3eUH l+aQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-5040-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5040-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h23-20020a17090ac39700b0028b98995a59si1026643pjt.110.2023.12.19.02.57.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 02:57:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5040-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-5040-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5040-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A3869B21880 for ; Tue, 19 Dec 2023 10:57:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E6D5C14F77; Tue, 19 Dec 2023 10:57:16 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C037514F69; Tue, 19 Dec 2023 10:57:14 +0000 (UTC) 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 621AA1FB; Tue, 19 Dec 2023 02:57:58 -0800 (PST) Received: from [10.57.85.227] (unknown [10.57.85.227]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D98FE3F738; Tue, 19 Dec 2023 02:57:11 -0800 (PST) Message-ID: <254a5071-5357-4c63-8fbb-75d68bf29221@arm.com> Date: Tue, 19 Dec 2023 10:58:17 +0000 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 v5 04/23] PM: EM: Refactor em_pd_get_efficient_state() to be more flexible Content-Language: en-US To: Dietmar Eggemann Cc: rui.zhang@intel.com, amit.kucheria@verdurent.com, rafael@kernel.org, linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, daniel.lezcano@linaro.org, viresh.kumar@linaro.org, len.brown@intel.com, pavel@ucw.cz, mhiramat@kernel.org, qyousef@layalina.io, wvw@google.com, linux-pm@vger.kernel.org References: <20231129110853.94344-1-lukasz.luba@arm.com> <20231129110853.94344-5-lukasz.luba@arm.com> <985618de-73cf-4b54-aef4-6e7bbfe86b17@arm.com> From: Lukasz Luba In-Reply-To: <985618de-73cf-4b54-aef4-6e7bbfe86b17@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12/12/23 18:49, Dietmar Eggemann wrote: > On 29/11/2023 12:08, Lukasz Luba wrote: >> The Energy Model (EM) is going to support runtime modification. There >> are going to be 2 EM tables which store information. This patch aims >> to prepare the code to be generic and use one of the tables. The function >> will no longer get a pointer to 'struct em_perf_domain' (the EM) but >> instead a pointer to 'struct em_perf_state' (which is one of the EM's >> tables). > I thought the 2 EM tables design is gone? > > IMHO it would be less code changes and hence a more enjoyable review > experience if you would add the 'modifiable' feature to the existing EM > (1) and not add (2) and then remove (1) in [21/23]. I have explained that to some other your email: such approach would create a patch monster, touching all drivers and frameworks, to just make sure they still can compile. This is not the right approach. > > > struct em_perf_domain { > - struct em_perf_state *table; <-- (1) > struct em_perf_table __rcu *runtime_table; <-- (2) > >> Prepare em_pd_get_efficient_state() for the upcoming changes and >> make it possible to re-use. Return an index for the best performance > > s/make it possible to re-use/make it possible to be re-used ? OK > >> state for a given EM table. The function arguments that are introduced >> should allow to work on different performance state arrays. The caller of >> em_pd_get_efficient_state() should be able to use the index either >> on the default or the modifiable EM table. >> >> Signed-off-by: Lukasz Luba >> Reviewed-by: Daniel Lezcano >> --- >> include/linux/energy_model.h | 30 +++++++++++++++++------------- >> 1 file changed, 17 insertions(+), 13 deletions(-) >> >> diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h >> index b9caa01dfac4..8069f526c9d8 100644 >> --- a/include/linux/energy_model.h >> +++ b/include/linux/energy_model.h >> @@ -175,33 +175,35 @@ void em_dev_unregister_perf_domain(struct device *dev); >> >> /** >> * em_pd_get_efficient_state() - Get an efficient performance state from the EM >> - * @pd : Performance domain for which we want an efficient frequency >> - * @freq : Frequency to map with the EM >> + * @state: List of performance states, in ascending order > > (3) > >> + * @nr_perf_states: Number of performance states >> + * @freq: Frequency to map with the EM >> + * @pd_flags: Performance Domain flags >> * >> * It is called from the scheduler code quite frequently and as a consequence >> * doesn't implement any check. >> * >> - * Return: An efficient performance state, high enough to meet @freq >> + * Return: An efficient performance state id, high enough to meet @freq >> * requirement. >> */ >> -static inline >> -struct em_perf_state *em_pd_get_efficient_state(struct em_perf_domain *pd, >> - unsigned long freq) >> +static inline int >> +em_pd_get_efficient_state(struct em_perf_state *table, int nr_perf_states, >> + unsigned long freq, unsigned long pd_flags) > > (3) but em_pd_get_efficient_state(struct em_perf_state *table > ^^^^^ > [...] Good catch, I'll change that.