linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Lynch <nathanl@linux.ibm.com>
To: Laurent Dufour <ldufour@linux.ibm.com>
Cc: cheloha@linux.ibm.com, linux-kernel@vger.kernel.org,
	paulus@samba.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v3] pseries: prevent free CPU ids to be reused on another node
Date: Wed, 07 Apr 2021 09:55:37 -0500	[thread overview]
Message-ID: <87blaqkuty.fsf@linux.ibm.com> (raw)
In-Reply-To: <20210406182554.85197-1-ldufour@linux.ibm.com>

Laurent Dufour <ldufour@linux.ibm.com> writes:
> Changes since V2, addressing Nathan's comments:
>  - Remove the retry feature
>  - Reduce the number of local variables (removing 'i')

I was more interested in not having two variables for NUMA nodes in the
function named 'node' and 'nid', hoping at least one of them could have
a more descriptive name. See below.

>  static int pseries_add_processor(struct device_node *np)
>  {
> -	unsigned int cpu;
> +	unsigned int cpu, node;
>  	cpumask_var_t candidate_mask, tmp;
> -	int err = -ENOSPC, len, nthreads, i;
> +	int err = -ENOSPC, len, nthreads, nid;
>  	const __be32 *intserv;
>  
>  	intserv = of_get_property(np, "ibm,ppc-interrupt-server#s", &len);
> @@ -163,9 +169,17 @@ static int pseries_add_processor(struct device_node *np)
>  	zalloc_cpumask_var(&candidate_mask, GFP_KERNEL);
>  	zalloc_cpumask_var(&tmp, GFP_KERNEL);
>  
> +	/*
> +	 * Fetch from the DT nodes read by dlpar_configure_connector() the NUMA
> +	 * node id the added CPU belongs to.
> +	 */
> +	nid = of_node_to_nid(np);
> +	if (nid < 0 || !node_possible(nid))
> +		nid = first_online_node;
> +
>  	nthreads = len / sizeof(u32);
> -	for (i = 0; i < nthreads; i++)
> -		cpumask_set_cpu(i, tmp);
> +	for (cpu = 0; cpu < nthreads; cpu++)
> +		cpumask_set_cpu(cpu, tmp);
>  
>  	cpu_maps_update_begin();
>  
> @@ -173,6 +187,19 @@ static int pseries_add_processor(struct device_node *np)
>  
>  	/* Get a bitmap of unoccupied slots. */
>  	cpumask_xor(candidate_mask, cpu_possible_mask, cpu_present_mask);
> +
> +	/*
> +	 * Remove free ids previously assigned on the other nodes. We can walk
> +	 * only online nodes because once a node became online it is not turned
> +	 * offlined back.
> +	 */
> +	for_each_online_node(node) {
> +		if (node == nid) /* Keep our node's recorded ids */
> +			continue;
> +		cpumask_andnot(candidate_mask, candidate_mask,
> +			       node_recorded_ids_map[node]);
> +	}
> +

e.g. change 'nid' to 'assigned_node' or similar, and I think this
becomes easier to follow.

Otherwise the patch looks fine to me now.

  reply	other threads:[~2021-04-07 14:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-06 18:25 [PATCH v3] pseries: prevent free CPU ids to be reused on another node Laurent Dufour
2021-04-07 14:55 ` Nathan Lynch [this message]
2021-04-07 15:00   ` Laurent Dufour

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87blaqkuty.fsf@linux.ibm.com \
    --to=nathanl@linux.ibm.com \
    --cc=cheloha@linux.ibm.com \
    --cc=ldufour@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).