Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1282191pxb; Thu, 28 Oct 2021 00:21:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxuZLioU+5t7cwQCHQrN5NKhQMUaXzCLZX7ySxCt8XGQ7/AA5uzMkW87Kf7XOzgp9uW/Tv X-Received: by 2002:a17:902:7001:b0:13d:d5b7:d06e with SMTP id y1-20020a170902700100b0013dd5b7d06emr2194644plk.61.1635405695143; Thu, 28 Oct 2021 00:21:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635405695; cv=none; d=google.com; s=arc-20160816; b=xKc243/t3jpoGzU3IWfCNsn7Mk4QP4Jic1v4WFdfrOPmC7HfmcHquxl8TZeL4i6oba V+CKiVihMav2YeGkM3KMyNl00UbVMvoTC4GxiDW4KbdSYXCyX/1EsJZF07g//zVcZXin vBc0bsazGY/b9WrgFgOfI4dFF1WuCveKvpieHlJVkIHZglvbQ2kDeq3krenc7+ZXi+Dg ADgMd9dqu+rtgpnpuIRsqi0oVwjNTEqYPPwx8doLSCq65ZHMEnx/BIl1r3dpn7NtJZ+C S0LAoNlu7wm2QBqk0BVOaSyMv2abwH8CmVaYBlvOPYG0uJrIjTZ/uIluMtGZI0fzg7Lf 7baw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=y8LmSnI8L1A86ymh9K+7bfCAOnKnoRr6BHndd6L2eUU=; b=hzgX29mV42l7EwYSRVd8fG2Xd+HkzX/CS1l24VDSjkMwJKAAXTaL3DkytOTsTzLOYF gHkhcQJcwjBQTFt2dOQOYO2vgHjxGFgRgTSMfU2IQwS3j3ykThdPPpqqzi1LJqwIa2hZ hAiT2doSpHppRSiwNvMjzMRxhRU6RWRyqwyAsFZwX/Sli7/HB9u0e+RINAT5fOxuTq4A FKpyWQufO5hUiZspJDK0hC04sZvwBj1/3Bo2UalDALGqYMAQl8rn91YYwD/dcjiEjjVL CeuDjwUuXps5rJF7w07qZMNwjbbg4doAnQjGXL5i2xNWTmYV34lp1cBVFDFKpo6PCASX 9Wyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e25si3078591pgv.258.2021.10.28.00.21.22; Thu, 28 Oct 2021 00:21:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229881AbhJ1HVq (ORCPT + 99 others); Thu, 28 Oct 2021 03:21:46 -0400 Received: from foss.arm.com ([217.140.110.172]:51590 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229656AbhJ1HVi (ORCPT ); Thu, 28 Oct 2021 03:21:38 -0400 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 965D01063; Thu, 28 Oct 2021 00:19:11 -0700 (PDT) Received: from [10.57.25.153] (unknown [10.57.25.153]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DF1B13F73D; Thu, 28 Oct 2021 00:19:07 -0700 (PDT) Subject: Re: [PATCH v2 1/5] arch_topology: Introduce thermal pressure update function To: Viresh Kumar Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, sudeep.holla@arm.com, will@kernel.org, catalin.marinas@arm.com, linux@armlinux.org.uk, gregkh@linuxfoundation.org, rafael@kernel.org, amitk@kernel.org, daniel.lezcano@linaro.org, amit.kachhap@gmail.com, thara.gopinath@linaro.org, bjorn.andersson@linaro.org, agross@kernel.org References: <20211015144550.23719-1-lukasz.luba@arm.com> <20211015144550.23719-2-lukasz.luba@arm.com> <20211028054459.dve6s2my2tq7odem@vireshk-i7> From: Lukasz Luba Message-ID: <3e1807d3-82cd-7ade-d361-e1982a4848a9@arm.com> Date: Thu, 28 Oct 2021 08:19:05 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20211028054459.dve6s2my2tq7odem@vireshk-i7> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/28/21 6:44 AM, Viresh Kumar wrote: > On 15-10-21, 15:45, Lukasz Luba wrote: >> +/** >> + * topology_thermal_pressure_update() - Update thermal pressure for CPUs >> + * @cpus : The related CPUs for which capacity has been reduced >> + * @capped_freq : The maximum allowed frequency that CPUs can run at > > Maybe replace tabs with spaces here ? Sure > >> + * >> + * Update the value of thermal pressure for all @cpus in the mask. The >> + * cpumask should include all (online+offline) affected CPUs, to avoid >> + * operating on stale data when hot-plug is used for some CPUs. The >> + * @capped_freq must be less or equal to the max possible frequency and >> + * reflects the currently allowed max CPUs frequency due to thermal capping. >> + * The @capped_freq must be provided in kHz. >> + */ >> +void topology_thermal_pressure_update(const struct cpumask *cpus, >> + unsigned long capped_freq) >> +{ >> + unsigned long max_capacity, capacity; >> + int cpu; >> + >> + if (!cpus) > > I will drop this and let the kernel crash :) OK :) > >> + return; >> + >> + cpu = cpumask_first(cpus); >> + max_capacity = arch_scale_cpu_capacity(cpu); >> + >> + /* Convert to MHz scale which is used in 'freq_factor' */ >> + capped_freq /= 1000; > > We should make sure capped_freq > freq_factor and WARN if not. This will also > get rid of similar checks at the users. OK, I'll change that. Thank you for the review. Regards, Lukasz