lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yrm1CbXzgj4uowOV@arm.com>
Date:   Mon, 27 Jun 2022 14:47:53 +0100
From:   Ionela Voinescu <ionela.voinescu@....com>
To:     Sudeep Holla <sudeep.holla@....com>
Cc:     linux-kernel@...r.kernel.org, Greg KH <gregkh@...uxfoundation.org>,
        Atish Patra <atishp@...shpatra.org>,
        Atish Patra <atishp@...osinc.com>,
        Vincent Guittot <vincent.guittot@...aro.org>,
        Dietmar Eggemann <dietmar.eggemann@....com>,
        Qing Wang <wangqing@...o.com>,
        Rob Herring <robh+dt@...nel.org>,
        "Rafael J . Wysocki" <rafael@...nel.org>,
        Pierre Gondois <pierre.gondois@....com>,
        linux-arm-kernel@...ts.infradead.org,
        linux-riscv@...ts.infradead.org
Subject: Re: [PATCH v4 19/20] arch_topology: Add support for parsing sockets
 in /cpu-map

On Tuesday 21 Jun 2022 at 20:20:33 (+0100), Sudeep Holla wrote:
> Finally let us add support for socket nodes in /cpu-map in the device
> tree. Since this may not be present in all the old platforms and even
> most of the existing platforms, we need to assume absence of the socket
> node indicates that it is a single socket system and handle appropriately.
> 
> Also it is likely that most single socket systems skip to as the node
> since it is optional.
> 
> Signed-off-by: Sudeep Holla <sudeep.holla@....com>
> ---
>  drivers/base/arch_topology.c | 37 +++++++++++++++++++++++++++++++-----
>  1 file changed, 32 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
> index 75604f783bfc..ed1cb64a95aa 100644
> --- a/drivers/base/arch_topology.c
> +++ b/drivers/base/arch_topology.c
> @@ -545,8 +545,8 @@ static int __init parse_core(struct device_node *core, int package_id,
>  	return 0;
>  }
>  
> -static int __init
> -parse_cluster(struct device_node *cluster, int cluster_id, int depth)
> +static int __init parse_cluster(struct device_node *cluster, int package_id,
> +				int cluster_id, int depth)
>  {
>  	char name[20];
>  	bool leaf = true;
> @@ -566,7 +566,7 @@ parse_cluster(struct device_node *cluster, int cluster_id, int depth)
>  		c = of_get_child_by_name(cluster, name);
>  		if (c) {
>  			leaf = false;
> -			ret = parse_cluster(c, i, depth + 1);
> +			ret = parse_cluster(c, package_id, i, depth + 1);
>  			of_node_put(c);
>  			if (ret != 0)
>  				return ret;
> @@ -590,7 +590,8 @@ parse_cluster(struct device_node *cluster, int cluster_id, int depth)
>  			}
>  
>  			if (leaf) {
> -				ret = parse_core(c, 0, cluster_id, core_id++);
> +				ret = parse_core(c, package_id, cluster_id,
> +						 core_id++);
>  			} else {
>  				pr_err("%pOF: Non-leaf cluster with core %s\n",
>  				       cluster, name);
> @@ -610,6 +611,32 @@ parse_cluster(struct device_node *cluster, int cluster_id, int depth)
>  	return 0;
>  }
>  
> +static int __init parse_socket(struct device_node *socket)
> +{
> +	char name[20];
> +	struct device_node *c;
> +	bool has_socket = false;
> +	int package_id = 0, ret;
> +
> +	do {
> +		snprintf(name, sizeof(name), "socket%d", package_id);
> +		c = of_get_child_by_name(socket, name);
> +		if (c) {
> +			has_socket = true;
> +			ret = parse_cluster(c, package_id, -1, 0);
> +			of_node_put(c);
> +			if (ret != 0)
> +				return ret;
> +		}
> +		package_id++;
> +	} while (c);
> +
> +	if (!has_socket)
> +		ret = parse_cluster(socket, 0, -1, 0);
> +
> +	return ret;
> +}
> +
>  static int __init parse_dt_topology(void)
>  {
>  	struct device_node *cn, *map;
> @@ -629,7 +656,7 @@ static int __init parse_dt_topology(void)
>  	if (!map)
>  		goto out;
>  
> -	ret = parse_cluster(map, -1, 0);
> +	ret = parse_socket(map);
>  	if (ret != 0)
>  		goto out_map;
>  
> -- 
> 2.36.1
> 

Reviewed-by: Ionela Voinescu <ionela.voinescu@....com>

Thanks,
Ionela.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ