From: Laurent Dufour <ldufour@linux.ibm.com>
To: Nathan Lynch <nathanl@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, 7 Apr 2021 17:00:38 +0200 [thread overview]
Message-ID: <955e0f2f-bd5b-1610-2dfc-6c0b8e94e295@linux.ibm.com> (raw)
In-Reply-To: <87blaqkuty.fsf@linux.ibm.com>
Le 07/04/2021 à 16:55, Nathan Lynch a écrit :
> 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.
Fair enough, will send a v4
> Otherwise the patch looks fine to me now.
>
prev parent reply other threads:[~2021-04-07 15:01 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
2021-04-07 15:00 ` Laurent Dufour [this message]
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=955e0f2f-bd5b-1610-2dfc-6c0b8e94e295@linux.ibm.com \
--to=ldufour@linux.ibm.com \
--cc=cheloha@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=nathanl@linux.ibm.com \
--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).