Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3773016ybl; Mon, 13 Jan 2020 02:20:36 -0800 (PST) X-Google-Smtp-Source: APXvYqzl0CbPFqsTlS7dEt8ye8AzR0F4aewR7+b1YE0+bdJO0yC/2FeoiHRWJznLciN+YxwvuLw8 X-Received: by 2002:aca:dc45:: with SMTP id t66mr12673241oig.39.1578910836233; Mon, 13 Jan 2020 02:20:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578910836; cv=none; d=google.com; s=arc-20160816; b=nVs5jRfj40hbd7OOTUJRqEhY4uhBb6sd/SLBHcW6bR0PDKhlndcGUJGLU4j+QfuXNG YYiRsPLfqf3CqbhHTg5q0J7XZ/drZW8nrxm8e6mJhtckJ1Ks/sB/Zvn6F0gt4ncucuL6 gTmcWnr4Z2046RFkPA0ndSZOjx+s2zI/7X2vHy0GlK60lGnFf6PEw785I4FH2M80URWl mjxhgbdIX3Abzqk5Bgj9hsMA7KGTmTf91XT2vRVbqOhySi1v3AmpgRVyHH+WWwhe5d1D gRCfMLP9UytHp0LggZMZvVryAkylFRcjK80ZNSsZdOPB/G+E8zLFEvRfPBUN/UVhT2zm 1QAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=1qRNjocpfGor2fpWca7br2uvIRNCbEvr7JWlc+8IRY4=; b=og9uD2Fc/4ctc89C7auI8qokHiLMcyXXSgAj/k2wc0mFS8vQMPCSj/NlCO6zXwVBYx 7Nqa+W7/MSYK45eg/ZXJe0Ez7zXlXWFdYs6oO49n1zBnuCkl2MtQXYrB4fS5xPkNq/GZ CCtdTonSYxbqGbdWQDqqdFes081xI1uTzCyzBz2cTISB7RgUkLiWoDmTabsHHGumLXJf vbns1cSH14ALiXkJecjkjFv3yO4YfFllWHrC7L1Pqk2zhtHxGZVTZ8DzVWgHSq7rfetI GHxZLsI6bkmYZ8AWQjSfqbkK38ANw8h7nkbU8RpVcUTbfz74OqdyTNpOw4PSVKseeP/x MH9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u16si6743056otg.325.2020.01.13.02.20.24; Mon, 13 Jan 2020 02:20:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728558AbgAMKT0 (ORCPT + 99 others); Mon, 13 Jan 2020 05:19:26 -0500 Received: from foss.arm.com ([217.140.110.172]:37116 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726001AbgAMKTZ (ORCPT ); Mon, 13 Jan 2020 05:19:25 -0500 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 4A02213D5; Mon, 13 Jan 2020 02:19:25 -0800 (PST) Received: from bogus (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 660493F534; Mon, 13 Jan 2020 02:19:24 -0800 (PST) Date: Mon, 13 Jan 2020 10:19:22 +0000 From: Sudeep Holla To: Zeng Tao Cc: linuxarm@huawei.com, Greg Kroah-Hartman , "Rafael J. Wysocki" , Sudeep Holla , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] cpu-topology: Skip the exist but not possible cpu nodes Message-ID: <20200113101922.GE52694@bogus> References: <1578725620-39677-1-git-send-email-prime.zeng@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1578725620-39677-1-git-send-email-prime.zeng@hisilicon.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jan 11, 2020 at 02:53:40PM +0800, Zeng Tao wrote: > When CONFIG_NR_CPUS is smaller than the cpu nodes defined in the device > tree, all the cpu nodes parsing will fail. > And this is not reasonable for a legal device tree configs. > In this patch, skip such cpu nodes rather than return an error. > With CONFIG_NR_CPUS = 128 and cpus nodes num in device tree is 130, > The following warning messages will be print during boot: > CPU node for /cpus/cpu@128 exist but the possible cpu range is :0-127 > CPU node for /cpus/cpu@129 exist but the possible cpu range is :0-127 > CPU node for /cpus/cpu@130 exist but the possible cpu range is :0-127 > > Signed-off-by: Zeng Tao > --- > Changelog: > v1->v2: > -Remove redundant -ENODEV assignment in get_cpu_for_node > -Add comment to describe the get_cpu_for_node return values > -Add skip process for cpu threads > -Update the commit log with more detail > --- > drivers/base/arch_topology.c | 37 +++++++++++++++++++++++++++++-------- > 1 file changed, 29 insertions(+), 8 deletions(-) > > diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c > index 5fe44b3..01f0e21 100644 > --- a/drivers/base/arch_topology.c > +++ b/drivers/base/arch_topology.c > @@ -248,22 +248,44 @@ core_initcall(free_raw_capacity); > #endif > > #if defined(CONFIG_ARM64) || defined(CONFIG_RISCV) > +/* > + * This function returns the logic cpu number of the node. > + * There are totally three kinds of return values: > + * (1) logic cpu number which is > 0. > + * (2) -ENDEV when the node is valid one which can be found in the device tree > + * but there is no possible cpu nodes to match, when the CONFIG_NR_CPUS is > + * smaller than cpus node numbers in device tree, this will happen. It's > + * suggested to just ignore this case. s/ENDEV/ENODEV/ Also as I mentioned earlier, I prefer not to add any extra logic here other than the above comment to make it explicit. This triggers unnecessary warnings when someone boots with limited CPUs for valid reasons. > + * (3) -EINVAL when other errors occur. > + */ > static int __init get_cpu_for_node(struct device_node *node) > { > - struct device_node *cpu_node; > + struct device_node *cpu_node, *t; > int cpu; > + bool found = false; > > cpu_node = of_parse_phandle(node, "cpu", 0); > if (!cpu_node) > - return -1; > + return -EINVAL; > + > + for_each_of_cpu_node(t) > + if (t == cpu_node) { > + found = true; > + break; > + } > + > + if (!found) { > + pr_crit("Unable to find CPU node for %pOF\n", cpu_node); > + return -EINVAL; > + } > > cpu = of_cpu_node_to_id(cpu_node); > if (cpu >= 0) > topology_parse_cpu_capacity(cpu_node, cpu); > else > - pr_crit("Unable to find CPU node for %pOF\n", cpu_node); > + pr_warn("CPU node for %pOF exist but the possible cpu range is :%*pbl\n", > + cpu_node, cpumask_pr_args(cpu_possible_mask)); > > - of_node_put(cpu_node); Why is this dropped ? -- Regards, Sudeep