Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp216176rdb; Thu, 8 Feb 2024 04:07:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW4GYzAqMkXs0GXrYzjysbcyB7bAXthKrthix6/YXNx/mucfB11dOrJtim7EpuuhwQcMEQrix59Ca6g9WQbeRpDOc5VoWA9kFXlxdKQOg== X-Google-Smtp-Source: AGHT+IGMINc6fSWrZh6MiqAizo1HRrQQtpMnSTa4THyPQNx3anHCYDG3mHgAyHx+fqvUyUE7Fnp/ X-Received: by 2002:a17:906:f946:b0:a35:f2a6:3172 with SMTP id ld6-20020a170906f94600b00a35f2a63172mr5638509ejb.43.1707394047016; Thu, 08 Feb 2024 04:07:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707394047; cv=pass; d=google.com; s=arc-20160816; b=qWn9V2Z8VXo/4dy87GXjbVjqo0cuxlkgFgsWdhIJF3+dVzHoI/Oelcol9umzutdlmJ OgBED/Xu0o03sX93Wx6bTNJ65SnPItN5YT+250oQUxYyuAEaFWjB70V4MdJ6wCyVpWuU rhkE7NVxpDF/bRjCsFMS6Tw5XW5OGXEdu1Gkz7tsnOUwx9jB1ry16ZJOM/4//Figc3sj hcE/dH+PuXsv8yid+gxVjmDX/Xmmn0yq0TesbC6pwiMmyB2NxKDJn0y6dEU6W8h3s5WV 3yWuErNvVbmVtMR3BieBGx7O6nx6yM4Q45hNU0+g96dhzgGkZJ4F+P1gfXjWIMx9MuoT Lc/Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=BBCshDgzvyYzGZn9xmC/6TISc2fmUCjGJYfyXQLT3Mw=; fh=kC4VsRMA594dDjcsLKTq8Kyhl0i3G4A21GJVBnt58Eg=; b=hFeS8rTcSjzwQNDjUBV33BkQN0b8LQArng7RBqIw3miuCneHY2ecv1zm6WH6AVPhJz 9Yd2GYwH6GpgbxxFfwpnVFxr+t1lMsFTUChooG0GBhsEveOPKVJdYgiSebscbR5tiqq2 CHPY/Jw4jWbhCqmpIM1xFp4ZJoqfRaUNnq5WjLwHIYuPUbZ+pg0p4W8KNPr7abptnAF8 3GA7M/21G3DtHajn5rB8UJobvbX4UEnnYlfldPdr/VpjJQ/17NIOedtb1E1khdhIgo/t oK4e7TdwkG1os/3dkDyQRfsetY9BUV/vh2upujGOqhAjc+IEVUwBb5n7xn8rBEfVGV6N 0jNA==; 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-58002-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58002-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCUI/LcAlYJzM/qBMdMqomqh3eJu3Qb6DXzGH6aLUqtgRbXq4kE3ZrrrRhh7zJHu5K8Hkztn4zvJDGYlC8v1BGOx8GRNgqLOWezs7JQIPQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ox7-20020a170907100700b00a3a40c7092esi835013ejb.609.2024.02.08.04.07.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 04:07:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58002-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; 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-58002-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58002-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 3D8BC1F2B358 for ; Thu, 8 Feb 2024 11:58:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 92A5F78B4E; Thu, 8 Feb 2024 11:56:35 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 502D276C8C; Thu, 8 Feb 2024 11:56:33 +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=1707393395; cv=none; b=EHPF3sn6H6Tm5Oj+djv0oSMzvK3o5G/YbsRd8xIQgRracFad4RShO/PwpoW0h8q0dbW8xtqx70716cl9ztLaha07auqhbdiaFvPyqTHzaCiq3E2xLq4iJaTAx2Ye3WVAFw2/g+DeZrm8adeymspOMOZ5XLxTOj/FfDZsZ+xVkBI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707393395; c=relaxed/simple; bh=jSDNw/gdJcgEyLMwynWhjBDaJb3Vfg+ndN6jLvTWrnk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jsDiU52HOnBD2TH1ARYvj99ykGkU3sxuCKb3mdeZZjdW9DAe+lLnUFcObwUNvL0tj/REtwVfPsK9SL9rzaN/khhr6fimeGgxYcmkEdYdWL11FPoPAiqI62WZOea23at/scH5J3ANugeJ04znIWqHL4p+Bw56+Gmt5t8CvRFad3o= 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 06C7B1FB; Thu, 8 Feb 2024 03:57:15 -0800 (PST) Received: from e129166.arm.com (unknown [10.57.8.23]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 274A53F5A1; Thu, 8 Feb 2024 03:56:30 -0800 (PST) From: Lukasz Luba To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rafael@kernel.org Cc: lukasz.luba@arm.com, 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, qyousef@layalina.io, wvw@google.com, xuewen.yan94@gmail.com Subject: [PATCH v8 09/23] PM: EM: Use runtime modified EM for CPUs energy estimation in EAS Date: Thu, 8 Feb 2024 11:55:43 +0000 Message-Id: <20240208115557.1273962-10-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240208115557.1273962-1-lukasz.luba@arm.com> References: <20240208115557.1273962-1-lukasz.luba@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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). Reviewed-by: Dietmar Eggemann Tested-by: Dietmar Eggemann Signed-off-by: Lukasz Luba --- include/linux/energy_model.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h index 8ddf1d8a9581..5f842da3bb0c 100644 --- a/include/linux/energy_model.h +++ b/include/linux/energy_model.h @@ -239,9 +239,14 @@ static inline unsigned long em_cpu_energy(struct em_perf_domain *pd, unsigned long allowed_cpu_cap) { unsigned long freq, ref_freq, scale_cpu; + struct em_perf_table *em_table; struct em_perf_state *ps; int cpu, i; +#ifdef CONFIG_SCHED_DEBUG + WARN_ONCE(!rcu_read_lock_held(), "EM: rcu read lock needed\n"); +#endif + if (!sum_util) return 0; @@ -264,9 +269,10 @@ static inline unsigned long em_cpu_energy(struct em_perf_domain *pd, * Find the lowest performance state of the Energy Model above the * requested frequency. */ - i = em_pd_get_efficient_state(pd->table, pd->nr_perf_states, freq, - pd->flags); - ps = &pd->table[i]; + em_table = rcu_dereference(pd->em_table); + i = em_pd_get_efficient_state(em_table->state, pd->nr_perf_states, + freq, pd->flags); + ps = &em_table->state[i]; /* * The capacity of a CPU in the domain at the performance state (ps) -- 2.25.1