Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4846803rdb; Tue, 12 Dec 2023 10:51:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IEfBgfsF2ZldkU/gdtKBQ3jtXfOTR/CjBmwiVvzrtfm/09ViRze8r2RzWX1j89NvWzT3ZBY X-Received: by 2002:a05:6a20:9706:b0:18a:e86f:f246 with SMTP id hr6-20020a056a20970600b0018ae86ff246mr6486702pzc.10.1702407118702; Tue, 12 Dec 2023 10:51:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702407118; cv=none; d=google.com; s=arc-20160816; b=BCWlpmpjV67fu/LfHegsiaAjuys9bn7Ue4PzvCmi0MBzmM7vFiS+t2PndqtkKklrmR 5EkBcK7AG3nhzR0uzxhLnS+MDGQNmJ8mn7bdW4f5j+kiHOIMMlQWlSkPl9GntWbUr8Lc XYuRrCstiAH7MhRQpQVd5spACJfAhAvYvzdEeYfzJRVzn7GYVw9IFukn9Yp5x6lzSy5n RoqYJx8R8VKhr7EMRsclLZpOra5SyBX2WYZvjoGAvB1SieQ5XgDB0YJaeJ1odF66bZzT 63rlTHUpPILlsoIC4SemoygDtgb3TFFUZnSS/m9xXakyGGwK/psbfsCbfKLJHGRGmOPF I53A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=q5OtyxHLlMJyzpkNDkHEqVYszkbqCcLx0E1eZJDlxrU=; fh=b6jz0bdxnlnt0RSJHliaH022TdeHcNL6OWCvUlnI6JM=; b=hxmdZ8Vtz2sFmixQqkhuCeV9Yo7TNAQXZmFTr90GRBMD20jL7yKeIAGYnMy/rjZKkW wIfYhUaTO5KIgRC+/0+K/+es92QDIQiVkbFwLvjx2xlRZb8JU4L+n5Q8ow4qiaoAd3lx 10rswmuv8iMR/+By9gcoROmUc95dX2U/YKBbblZ2+3e6D80/sIrxEJ5LJOIGhiaDCoz1 8285zgoU6lQ82NpFi4gFuymiadaqNR8ELDPUO2P1K8PDFnLrExzErCRW4bkn3toKJDWb 561iXBlMuP1whS7pEFdFkGAGFKUEq0JqPc55Q2+nJsHkh5G2MjN5p5jlPKVkvDofuY8F BWvQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id c11-20020aa78c0b000000b006cd8567235bsi7949925pfd.237.2023.12.12.10.51.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 10:51:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id E5477807BED0; Tue, 12 Dec 2023 10:51:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235105AbjLLSu6 (ORCPT + 99 others); Tue, 12 Dec 2023 13:50:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376975AbjLLSuj (ORCPT ); Tue, 12 Dec 2023 13:50:39 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C0BED1A5; Tue, 12 Dec 2023 10:50:36 -0800 (PST) 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 7589FFEC; Tue, 12 Dec 2023 10:51:22 -0800 (PST) Received: from [192.168.178.6] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C8F153F762; Tue, 12 Dec 2023 10:50:33 -0800 (PST) Message-ID: <7ecf31b4-3782-41e7-9372-a1d4e7a46d39@arm.com> Date: Tue, 12 Dec 2023 19:50:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 14/23] PM: EM: Support late CPUs booting and capacity adjustment Content-Language: en-US To: Lukasz Luba , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rafael@kernel.org Cc: 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 References: <20231129110853.94344-1-lukasz.luba@arm.com> <20231129110853.94344-15-lukasz.luba@arm.com> From: Dietmar Eggemann In-Reply-To: <20231129110853.94344-15-lukasz.luba@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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, 12 Dec 2023 10:51:13 -0800 (PST) On 29/11/2023 12:08, Lukasz Luba wrote: > The patch adds needed infrastructure to handle the late CPUs boot, which > might change the previous CPUs capacity values. With this changes the new > CPUs which try to register EM will trigger the needed re-calculations for > other CPUs EMs. Thanks to that the em_per_state::performance values will > be aligned with the CPU capacity information after all CPUs finish the > boot and EM registrations. IMHO, it's worth mentioning here that this added functionality is the 1. use case of the modifiable EM. [...] > + * Adjustment of CPU performance values after boot, when all CPUs capacites > + * are correctly calculated. > + */ > +static void em_adjust_new_capacity(struct device *dev, > + struct em_perf_domain *pd, > + u64 max_cap) > +{ [...] > + /* > + * This is one-time-update, so give up the ownership in this updater. > + * The EM fwk will keep the reference and free the memory when needed. s/fwk/framework ? > + */ > + em_free_table(runtime_table); > +} > + > +static void em_check_capacity_update(void) > +{ > + cpumask_var_t cpu_done_mask; > + struct em_perf_state *table; > + struct em_perf_domain *pd; > + unsigned long cpu_capacity; > + int cpu; > + > + if (!zalloc_cpumask_var(&cpu_done_mask, GFP_KERNEL)) { > + pr_warn("no free memory\n"); > + return; > + } > + > + /* Check if CPUs capacity has changed than update EM */ s/than/then ? Maybe this comment is not needed since there is (1) further down? > + for_each_possible_cpu(cpu) { > + struct cpufreq_policy *policy; > + unsigned long em_max_perf; > + struct device *dev; > + int nr_states; > + > + if (cpumask_test_cpu(cpu, cpu_done_mask)) > + continue; > + > + policy = cpufreq_cpu_get(cpu); > + if (!policy) { > + pr_debug("Accessing cpu%d policy failed\n", cpu); > + schedule_delayed_work(&em_update_work, > + msecs_to_jiffies(1000)); > + break; > + } > + cpufreq_cpu_put(policy); > + > + pd = em_cpu_get(cpu); > + if (!pd || em_is_artificial(pd)) > + continue; > + > + cpumask_or(cpu_done_mask, cpu_done_mask, > + em_span_cpus(pd)); > + > + nr_states = pd->nr_perf_states; > + cpu_capacity = arch_scale_cpu_capacity(cpu); > + > + table = em_get_table(pd); > + em_max_perf = table[pd->nr_perf_states - 1].performance; > + em_put_table(); > + > + /* > + * Check if the CPU capacity has been adjusted during boot > + * and trigger the update for new performance values. > + */ (1) [...]