[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 2/6] xen/x86: move generically usable NUMA code from x86 to common


  • To: Wei Chen <Wei.Chen@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 6 Sep 2022 09:07:02 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6I/63x5qAG9k0n9qEXH2a0xgxLGEscX/MDRhYH8wntA=; b=FhiKETB9F67rU6VECki6fUTuOuRrqmyFZo3UQM4xmoY5/2nlrU6k/328wh2+4ueZaWSIkvJF34lbel1fRrx3pFoWVqZGe5UBDMAvQgcoId1NyjKq95Bot8xYn3pvjGArAdmdNyCgcBkGwZqgkDX6NIltQSTGeI1+NLvN6KvynHpvRrArGHgbO8bAhzQbMqmeJfFuKp7DGRqmtEApF0U+62itort/7r5sAKcXd952nIIRPsHb6+BjsDXg/KAh9dhP+ptsB442EgTchHi7x4+28Y9+3nYhh5kRZukGGoLy2NsZrbffs0fRn+dE9kpr+JstnX5eWMrV6ba6CW20xamMhQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eo28dIGOGO5GV/E4gSKb+miXFIAfpbtJVUV+DxzoYj07EudT+JdXoBKCh0M7mR5ECdIPrG5QZqlEHLQL/QVAFNvXkTRzfNepdClyu1xfVllzL3pqFAToxZ2gKyx/93YlqUiWSpSfWWzEqZbNF6JW7p/UunhX7ABaWDJczqq+8VcM1PhVAFAljbgC5b+k23zNUTnm5Y5mtJC3tamAfSsmsHSY58TLnNCrcItaCWO3AVQWblQh227wgoPxaL+qEA/GpQrCpAbJ5Uhm+lguo2gqEmy0rlsz9RS9mLFyEN+uuZyKoZoqiDS4Om03fl9AeBwZGfyTNO80vBzZyHILlnysIw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: nd <nd@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 06 Sep 2022 07:07:07 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 29.08.2022 11:49, Wei Chen wrote:
>> -----Original Message-----
>> From: Jan Beulich <jbeulich@xxxxxxxx>
>> Sent: 2022年8月25日 18:58
>>
>> On 22.08.2022 04:58, Wei Chen wrote:
>>> +nodemask_t __read_mostly node_online_map = { { [0] = 1UL } };
>>> +
>>> +bool __read_mostly numa_off;
>>
>> This, otoh, can be, or have I missed a place where it's written by a
>> non-__init function?
>>
> 
> I think yes, it will be used in numa_disabled and numa_disabled will
> be called in cpu_add.

In the original code I cannot spot such a path - can you please point
out how exactly you see numa_disabled() reachable from cpu_add()? I'm
clearly overlooking something ...

>>> +bool numa_disabled(void)
>>> +{
>>> +    return numa_off || arch_numa_disabled(false);
>>> +}
>>> +
>>> +/*
>>> + * Given a shift value, try to populate memnodemap[]
>>> + * Returns :
>>> + * 1 if OK
>>> + * 0 if memnodmap[] too small (of shift too small)
>>> + * -1 if node overlap or lost ram (shift too big)
>>> + */
>>> +static int __init populate_memnodemap(const struct node *nodes,
>>> +                                      nodeid_t numnodes, unsigned int
>> shift,
>>
>> I don't think you can use nodeid_t for a variable holding a node count.
>> Think of what would happen if there were 256 nodes, the IDs of which
>> all fit in nodeid_t. (Same again further down.)
>>
> 
> If we use u8 as nodeid_t, why there will be 256 nodes to here?
> And the MAX_NUMNODES has been limited to 64 (using NODES_SHIFT or
> CONFIG_NR_NUMA_NODES). If we allow 256 nodes, we have to update MAX_NUMNODES
> and nodeid_t first I think?

Well, when writing the reply I did forget about MAX_NUMNODES, so yes,
with that the value can't be larger than 255. Nevertheless I don't
think a count-of-nodes value should be expressed with nodeid_t. It
should be simply "unsigned int".

>>> +                                      nodeid_t *nodeids)
>>> +{
>>> +    unsigned long spdx, epdx;
>>> +    nodeid_t i;
>>
>> This is likely inefficient for a loop counter variable. Note how you
>> use "unsigned int" in e.g. extract_lsb_from_nodes().
>>
> 
> Did you mean u8 for "i" will cause something like unalignment, and will
> cause loop inefficient. If yes, I will use unsigned int for "i" in next
> version.

There's no issue with mis-alignment afaics, but there still is the
inefficiency issue requiring the loop variable to be zero-extended
before being usable as an array. Both x86-64 and aarch64 have the
zero-extension as a side effect when moving 32-bit quantities (from
memory or between registers), and arm wouldn't require any zero-
extension at all then.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.