Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp356322rdh; Tue, 19 Dec 2023 00:31:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IG4S4flGjVo6PI77GA9ktzbogtY4EAiTPW0mCBxc5aW/ypxt+LDr5I5vw97RPhiJ+dRogT4 X-Received: by 2002:a05:6358:3a1b:b0:172:c005:b0e6 with SMTP id g27-20020a0563583a1b00b00172c005b0e6mr4697372rwe.35.1702974712984; Tue, 19 Dec 2023 00:31:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702974712; cv=none; d=google.com; s=arc-20160816; b=ucD/x8ByRgA54S6eB31rGhSZ7hJviHnJoVVjVhmU/tjdgCoR4nqVtKj9UgYz9szi0Q PauQmyqiZFvFkpdDwUrrCnyDBYzX2RBxQLIBERQ/tm//nNm+2EoTKSVX9NKgpcCSNzJx xyp+UaahWTWnsW5g4qD6kJtZGDRjeyYJJaO3xqm0Ka5GLbXcuSYb/vpv/4yvFYNr9Una V1KzwSEso36WrlJek2lvYuKIezlAQMikF8Uude/xADyU3MKrx2EuCukyDhvFv+I6Ow+7 mK+JTxJHjkzsNjxbJoWmIfzE32wsfEfr1A7fOonTaBoiPGjnOYSOvwMHu5EvQLubjCEC bjRw== 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=yVwCeqzitGPkKINhS9hP2gx5kGwX926226lxc/SUHQw=; fh=s7eDFXYORJ03RoMCBoxTqaZ5ccdRLAy8egvf2TD+mQk=; b=jcdLuWxXCs4GEo1MF9vCTlPoWRUWHSKny1VIfRE/Xu0mpIfrtSx0R36rWzcf3Jg3PS mzRB++lLXnOGVFtKGpFN7wtqIvyPrFFNDs3yBVGaAZ2Iyvg3v3WsY9HtA2+sqVm1VzqV n7JjF13T/PT4q+kEppsbCJQpMKJZM6em4dLsEQNf+ilbrHacA3QoxfL+JJS9Pfx4x3m3 AXlD08iK64cl60zYV1zyme6IU4z47R6XPkuxMoQZsFZVMUZo7bmnYCfCANx+G3+HSmv5 FZblUFuPL8MSbtp59+G2YM9cCPEh1zCAzuhp6eDW+va3Ek5J2wps9iGqaas0coI5Qltc FRhw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-4892-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4892-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 u6-20020aa78486000000b006cef68cfbdbsi2269271pfn.189.2023.12.19.00.31.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 00:31:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4892-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-4892-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4892-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 2CDF2B243FF for ; Tue, 19 Dec 2023 08:31:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E6B7412B69; Tue, 19 Dec 2023 08:31:18 +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 F031211739; Tue, 19 Dec 2023 08:31:16 +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 7BAE41FB; Tue, 19 Dec 2023 00:32:00 -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 E1ABB3F738; Tue, 19 Dec 2023 00:31:13 -0800 (PST) Message-ID: <1ccd7a20-0479-46f7-a968-57a18f0c0152@arm.com> Date: Tue, 19 Dec 2023 08:32:19 +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 09/23] PM: EM: Use runtime modified EM for CPUs energy estimation in EAS Content-Language: en-US To: Xuewen Yan , Qais Yousef Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rafael@kernel.org, dietmar.eggemann@arm.com, rui.zhang@intel.com, amit.kucheria@verdurent.com, amit.kachhap@gmail.com, daniel.lezcano@linaro.org, viresh.kumar@linaro.org, len.brown@intel.com, pavel@ucw.cz, mhiramat@kernel.org, wvw@google.com References: <20231129110853.94344-1-lukasz.luba@arm.com> <20231129110853.94344-10-lukasz.luba@arm.com> <20231217175923.wxmfocgckpaytptb@airbuntu> From: Lukasz Luba In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi Qais and Xuewen, On 12/19/23 04:03, Xuewen Yan wrote: > On Mon, Dec 18, 2023 at 1:59 AM Qais Yousef wrote: >> >> On 11/29/23 11:08, Lukasz Luba wrote: >>> The new Energy Model (EM) supports runtime modification of the performance >>> state table to better model the power used by the SoC. Use this new >>> feature to improve energy estimation and therefore task placement in >>> Energy Aware Scheduler (EAS). >> >> nit: you moved the code to use the new runtime em table instead of the one >> parsed at boot. >> >>> >>> Signed-off-by: Lukasz Luba >>> --- >>> include/linux/energy_model.h | 16 ++++++++++++---- >>> 1 file changed, 12 insertions(+), 4 deletions(-) >>> >>> diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h >>> index 1e618e431cac..94a77a813724 100644 >>> --- a/include/linux/energy_model.h >>> +++ b/include/linux/energy_model.h >>> @@ -238,6 +238,7 @@ static inline unsigned long em_cpu_energy(struct em_perf_domain *pd, >>> unsigned long max_util, unsigned long sum_util, >>> unsigned long allowed_cpu_cap) >>> { >>> + struct em_perf_table *runtime_table; >>> unsigned long freq, scale_cpu; >>> struct em_perf_state *ps; >>> int cpu, i; >>> @@ -255,7 +256,14 @@ static inline unsigned long em_cpu_energy(struct em_perf_domain *pd, >>> */ >>> cpu = cpumask_first(to_cpumask(pd->cpus)); >>> scale_cpu = arch_scale_cpu_capacity(cpu); >>> - ps = &pd->table[pd->nr_perf_states - 1]; >>> + >>> + /* >>> + * No rcu_read_lock() since it's already called by task scheduler. >>> + * The runtime_table is always there for CPUs, so we don't check. >>> + */ >> >> WARN_ON(rcu_read_lock_held()) instead? > > I agree, or SCHED_WARN_ON(!rcu_read_lock_held()) ? I disagree here. This is a sched function in hot path and as comment says: ----------------------- * This function must be used only for CPU devices. There is no validation, * i.e. if the EM is a CPU type and has cpumask allocated. It is called from * the scheduler code quite frequently and that is why there is not checks. ----------------------- We don't have to put the checks or warnings everywhere in the kernel functions. Especially hot one like this one. As you might not notice, we don't even check if the pd->cpus is not NULL Regards, Lukasz