From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2F2AEEDE9AD for ; Thu, 14 Sep 2023 12:02:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:CC:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6zXGsSJTdOZtXP3xGggfZhijCly7oZs3a7DebFq5jpE=; b=AwvdW1ZVus3th2 jBo0pIS0e4uhUwGkBSo1gVbQjFVJ+pE3W8gqerAPkJqMQkFIxhirPrt1y0+SF4Wkd+srAksYRW2/N 0az35h2SdEObB7HhMDtJ3OaA7Rm0aptgFGEGynKgwhX8JSbWy0udlHPNLq6QIGRtLtJlcuFP7zKCo Vvg3LugCnJ1zNKkCfnZ4lT+c3R25Y46udxVpoXBdZMb9Bf00HYBqV0JdDxfs6pDg+YcJHViBsq+ks HcQ1k3Kil42Sj9m223EtmTjYJw7yu2unIJMuOmteExFgCHEYTRhcWEAs24Wrn9vWNAZr+/Ro5Ii1w nB7ygLymPniK5vXQrxDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qgl2T-008Hbf-0s; Thu, 14 Sep 2023 12:01:41 +0000 Received: from frasgout.his.huawei.com ([185.176.79.56]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qgl2P-008HaE-1e; Thu, 14 Sep 2023 12:01:39 +0000 Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4RmbQR00lDz68944; Thu, 14 Sep 2023 19:56:46 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 14 Sep 2023 13:01:27 +0100 Date: Thu, 14 Sep 2023 13:01:26 +0100 From: Jonathan Cameron To: James Morse CC: , , , , , , , , , Salil Mehta , Russell King , Jean-Philippe Brucker , , , Subject: Re: [RFC PATCH v2 11/35] arch_topology: Make register_cpu_capacity_sysctl() tolerant to late CPUs Message-ID: <20230914130126.000069db@Huawei.com> In-Reply-To: <20230913163823.7880-12-james.morse@arm.com> References: <20230913163823.7880-1-james.morse@arm.com> <20230913163823.7880-12-james.morse@arm.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml100003.china.huawei.com (7.191.160.210) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230914_050137_840309_50A986BB X-CRM114-Status: GOOD ( 25.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, 13 Sep 2023 16:37:59 +0000 James Morse wrote: > register_cpu_capacity_sysctl() adds a property to sysfs that describes > the CPUs capacity. This is done from a subsys_initcall() that assumes > all possible CPUs are registered. > > With CPU hotplug, possible CPUs aren't registered until they become > present, (or for arm64 enabled). This leads to messages during boot: > | register_cpu_capacity_sysctl: too early to get CPU1 device! > and once these CPUs are added to the system, the file is missing. > > Move this to a cpuhp callback, so that the file is created once > CPUs are brought online. This covers CPUs that are added late by > mechanisms like hotplug. > One observable difference is the file is now missing for offline CPUs. > > Signed-off-by: James Morse > --- > If the offline CPUs thing is a problem for the tools that consume > this value, we'd need to move cpu_capacity to be part of cpu.c's > common_cpu_attr_groups. I think we should do that anyway and then use an is_visible() if we want to change whether it is visible in offline cpus. Dynamic sysfs file creation is horrible - particularly when done from an totally different file from where the rest of the attributes are registered. I'm curious what the history behind that is. Whilst here, why is there a common_cpu_attr_groups which is identical to the hotpluggable_cpu_attr_groups in base/cpu.c? +CC GregKH Given changes in drivers/base/ > --- > drivers/base/arch_topology.c | 38 ++++++++++++++++++++++++------------ > 1 file changed, 26 insertions(+), 12 deletions(-) > > diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c > index b741b5ba82bd..9ccb7daee78e 100644 > --- a/drivers/base/arch_topology.c > +++ b/drivers/base/arch_topology.c > @@ -220,20 +220,34 @@ static DECLARE_WORK(update_topology_flags_work, update_topology_flags_workfn); > > static DEVICE_ATTR_RO(cpu_capacity); > > +static int cpu_capacity_sysctl_add(unsigned int cpu) > +{ > + struct device *cpu_dev = get_cpu_device(cpu); > + > + if (!cpu_dev) > + return -ENOENT; > + > + device_create_file(cpu_dev, &dev_attr_cpu_capacity); > + > + return 0; > +} > + > +static int cpu_capacity_sysctl_remove(unsigned int cpu) > +{ > + struct device *cpu_dev = get_cpu_device(cpu); > + > + if (!cpu_dev) > + return -ENOENT; > + > + device_remove_file(cpu_dev, &dev_attr_cpu_capacity); > + > + return 0; > +} > + > static int register_cpu_capacity_sysctl(void) > { > - int i; > - struct device *cpu; > - > - for_each_possible_cpu(i) { > - cpu = get_cpu_device(i); > - if (!cpu) { > - pr_err("%s: too early to get CPU%d device!\n", > - __func__, i); > - continue; > - } > - device_create_file(cpu, &dev_attr_cpu_capacity); > - } > + cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "topology/cpu-capacity", > + cpu_capacity_sysctl_add, cpu_capacity_sysctl_remove); > > return 0; > } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel