Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2123756rdh; Tue, 26 Sep 2023 13:13:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFoiYr3EdrJLHClhP1F3jhxJLdRizQxpXsejgBYUbSrbXDNnWYMzg+SMgl7+onfsQPvpKlK X-Received: by 2002:a05:6808:14c5:b0:3a7:3100:f8b9 with SMTP id f5-20020a05680814c500b003a73100f8b9mr89409oiw.31.1695759184043; Tue, 26 Sep 2023 13:13:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695759184; cv=none; d=google.com; s=arc-20160816; b=PuP32ygIEiVcqvY0cfvIsQrAX8mAP7menotqVsH3v7je8H6ukb0/RilqmRLN1R/nz/ /KwrS0i1SYm/1+ePNmcEXwlGhE7hmeifTj99tfq5Bvy+XymgHN1KZHXDRfgEnxX1VwAv /wPi33e41spyl4K0Vctnl0XbwWn2wAA7HsYjlnkM2eVVDfoL2sHbJ/scQdKQF0NOYf/9 /iQXTKOjoXTcgCiTQQewl491W8CI/3ngDVwqnleKtZ1MnQ9Euqv6ullZVs54aang2Rsb kXb6PU7vOzeD0YktQ3ERhn7FMG8y281uo9v4SD+nqT8xOkn12+zuCUCaxet2bq56NCbk bGmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=Yl7icCgAnFEoVUtMTabyfB8vTpRAt6Qbjv7foPzMv98=; fh=O6YYF95gEoTquszwa1x1Mp3NZS9Am1klEUxdtkLeXmY=; b=Ayg+Ocutpfpr9KCfmPD1QYAbjQy2Nmsq68s/e+WRcQXuuG3yb+kvv+l0k5xOKRiCAk TIL9hXoy5XMWlD03Ng5mwCJ7aJ4QNJ+599H0CK1tkQGFf6e7nlRWGM8AQYASrH6oSKPk FaSJcVTTEVQrpWxaSXae9T+VsZLXVoYb4jNy2j9fY/WLBcMXr4aBuJe0SHIcMV2iQfSl tTkP75kkKqVMiA/pnc7g5jag/sx7rV3NKnlSft8Ked630yS9015M01b31nU+gFql28AJ sGaM7CbNShaQpu5dOOGBcBv8ucLxjKWQlSU301AlQMrjJaGu9u7JpzlhqMaWuYbO+hqJ /Zqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id s7-20020a056a00178700b00690258a9766si14305015pfg.373.2023.09.26.13.13.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 13:13:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id D40C38025424; Tue, 26 Sep 2023 12:54:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235713AbjIZTy2 convert rfc822-to-8bit (ORCPT + 99 others); Tue, 26 Sep 2023 15:54:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235606AbjIZTy1 (ORCPT ); Tue, 26 Sep 2023 15:54:27 -0400 Received: from mail-oo1-f48.google.com (mail-oo1-f48.google.com [209.85.161.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DE55C0; Tue, 26 Sep 2023 12:54:21 -0700 (PDT) Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-57be74614c0so317848eaf.1; Tue, 26 Sep 2023 12:54:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695758060; x=1696362860; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=06BDXw+aAsRZJmkH29TBr2CENepoEaV3xhr3PlQFcqA=; b=j8pJ0Iv7DFKZqJoZR3C+GSAl68bWY35bLPTo0DqbNgMb5Ve1Kcftpbc0/2b6jYmOCK Af6lrMTsc7n6bzPzf4ksMAa3ZTBu0vPmhJKz8b5vkfxRAlqZALAmIXOtx4MX2lOt80vw KaHiMKw4zgtwquxC9egJRprTcQX+lro78xzJpKpU9Kzuj7HeGlgivKuFqxHD4/lXw7V+ r9fuBSdYXdl/GFmwtYUtzOONxYfOyVh/76GWjiwx/Latr1BNWqFlUL49LPOXpYUTywmN jC0T+ZTOWW8nHV/aZRbg6UJPcgGMcEE6KGoBvu20NPjA8JktUIXvD79ON+phrxMw5PcU 4ZWA== X-Gm-Message-State: AOJu0Yxi7PtJsfiKhvB57bXiCZ7l5qF9E4NckRrEEegJvuU7Z4ethPuo cYCI7g0m18jHjOuPXBirn96OREeIIc4vWZVNheY= X-Received: by 2002:a4a:e687:0:b0:57b:3b64:7ea5 with SMTP id u7-20020a4ae687000000b0057b3b647ea5mr80798oot.1.1695758060246; Tue, 26 Sep 2023 12:54:20 -0700 (PDT) MIME-Version: 1.0 References: <20230925081139.1305766-1-lukasz.luba@arm.com> <20230925081139.1305766-13-lukasz.luba@arm.com> In-Reply-To: <20230925081139.1305766-13-lukasz.luba@arm.com> From: "Rafael J. Wysocki" Date: Tue, 26 Sep 2023 21:54:09 +0200 Message-ID: Subject: Re: [PATCH v4 12/18] PM: EM: Use runtime modified EM for CPUs energy estimation in EAS To: Lukasz Luba 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, qyousef@layalina.io, wvw@google.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Tue, 26 Sep 2023 12:54:32 -0700 (PDT) On Mon, Sep 25, 2023 at 10:11 AM 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). > > 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; You may as well call it just "table". The "runtime_" prefix doesn't add much value here IMO. > 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) > --