Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1051640rdh; Mon, 25 Sep 2023 01:26:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEMp4FuultvBpAzcjPDwvdLG9GMz6W3atx2eoktDKIvkewgsV3joxOgPB3RwlHLbZfxB+pt X-Received: by 2002:a05:6a20:6e12:b0:15e:b763:2422 with SMTP id go18-20020a056a206e1200b0015eb7632422mr3284706pzb.9.1695630382765; Mon, 25 Sep 2023 01:26:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695630382; cv=none; d=google.com; s=arc-20160816; b=0EcNSYc4AOAP7d3vClf9OGTsVa4mqryQ45jJUr48eI/TclY3Ft4NI9tTCMqhHbSNWA kKRU/5zNj7ekUBtS/y+VZaNyK4vR8vPCgKkuXP0ElD1tV8joSBng44FW/0KCb6ZgD6L2 8/lZKV1AjBTpWOtzKb3Gg63qhFmVLnbue+Dh2yf5ISXaYlphTFZeuEZBRyJa+p1TGKAU AyaehivmzqglBVygDRjh3KK4/NN3t5B6iCJBtsPp4+fTGdEbU92onOLFsrho/oIQfUJD Eg1TCqIi5aQtevGXgNaGvIuanWdfVCBQqUhcAItaaVacprZOa8Lpg92AQL1D//BXyx+r MBOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=RNT2PYm7kSj3h3KVn/jbYVLHFNXeVPDEOdTiaHUlobA=; fh=jF+j1UEDAwnYbShW3HmO1TshMsWh36Jt7pSLTP62NeE=; b=iwvq1AvkVnG4Vc5wymljt/Pcfn94xJ5u95koiB+Zq1ISq2jIsBYgdlVTqy3BYo2+Dc fGq3vGZQ7tZd6s+6t48Nn7aG0D1wIKt4bIKf+bObuIY4DXngVo88s7yoiGrcZ+2peKF7 quHlVr34z0BspFg8MbGC/epaVqn1Olk8xvL6haps7NJTXQaJIhIvC3hdhTNYuBzUuZKD OZt5TGSC4375V0nzLCnVPJlSyW7JzdE3Qk5GijDEl1fchFfPMgM1zlOgINHlueOwFy/u N7FTacifZE0H0GZqP8DIheiATtMmnmlMrlMKZlnTjPLAHnBKKOuBFwhfiB3fEy9nNXmI a3kQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id h64-20020a638343000000b00578a6694d63si9205408pge.828.2023.09.25.01.26.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 01:26:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id CE68B805F2CB; Mon, 25 Sep 2023 01:12:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232813AbjIYIMS (ORCPT + 99 others); Mon, 25 Sep 2023 04:12:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232810AbjIYIL5 (ORCPT ); Mon, 25 Sep 2023 04:11:57 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 761D7CCF; Mon, 25 Sep 2023 01:11:45 -0700 (PDT) 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 5F6251424; Mon, 25 Sep 2023 01:12:23 -0700 (PDT) Received: from e129166.arm.com (unknown [10.57.93.139]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B74273F5A1; Mon, 25 Sep 2023 01:11:42 -0700 (PDT) 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 Subject: [PATCH v4 12/18] PM: EM: Use runtime modified EM for CPUs energy estimation in EAS Date: Mon, 25 Sep 2023 09:11:33 +0100 Message-Id: <20230925081139.1305766-13-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230925081139.1305766-1-lukasz.luba@arm.com> References: <20230925081139.1305766-1-lukasz.luba@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 25 Sep 2023 01:12:24 -0700 (PDT) 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). Signed-off-by: Lukasz Luba --- include/linux/energy_model.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h index 8f055ab356ed..41290ee2cdd0 100644 --- a/include/linux/energy_model.h +++ b/include/linux/energy_model.h @@ -261,15 +261,14 @@ 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 *table, *ps; + struct em_perf_state *ps; int cpu, i; if (!sum_util) return 0; - table = pd->default_table->state; - /* * In order to predict the performance state, map the utilization of * the most utilized CPU of the performance domain to a requested @@ -280,7 +279,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 = &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. + */ + runtime_table = rcu_dereference(pd->runtime_table); + + ps = &runtime_table->state[pd->nr_perf_states - 1]; max_util = map_util_perf(max_util); max_util = min(max_util, allowed_cpu_cap); @@ -290,9 +296,9 @@ 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(table, pd->nr_perf_states, freq, - pd->flags); - ps = &table[i]; + i = em_pd_get_efficient_state(runtime_table->state, pd->nr_perf_states, + freq, pd->flags); + ps = &runtime_table->state[i]; /* * The capacity of a CPU in the domain at the performance state (ps) -- 2.25.1