[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8161aa90-5535-4ef9-ad30-1655746a1053@linux.microsoft.com>
Date: Thu, 17 Aug 2023 17:17:44 -0700
From: Nuno Das Neves <nunodasneves@...ux.microsoft.com>
To: Dave Hansen <dave.hansen@...el.com>, linux-hyperv@...r.kernel.org,
linux-kernel@...r.kernel.org, x86@...nel.org,
linux-arm-kernel@...ts.infradead.org, linux-arch@...r.kernel.org
Cc: patches@...ts.linux.dev, mikelley@...rosoft.com, kys@...rosoft.com,
wei.liu@...nel.org, haiyangz@...rosoft.com, decui@...rosoft.com,
apais@...ux.microsoft.com, Tianyu.Lan@...rosoft.com,
ssengar@...ux.microsoft.com, mukeshrathor@...rosoft.com,
stanislav.kinsburskiy@...il.com, jinankjain@...ux.microsoft.com,
vkuznets@...hat.com, tglx@...utronix.de, mingo@...hat.com,
bp@...en8.de, dave.hansen@...ux.intel.com, hpa@...or.com,
will@...nel.org, catalin.marinas@....com
Subject: Re: [PATCH v2 03/15] mshyperv: Introduce
numa_node_to_proximity_domain_info
On 8/17/2023 4:22 PM, Dave Hansen wrote:
> On 8/17/23 15:01, Nuno Das Neves wrote:
>> +static inline union hv_proximity_domain_info
>> +numa_node_to_proximity_domain_info(int node)
>> +{
>> + union hv_proximity_domain_info proximity_domain_info;
>> +
>> + if (node != NUMA_NO_NODE) {
>> + proximity_domain_info.domain_id = node_to_pxm(node);
>> + proximity_domain_info.flags.reserved = 0;
>> + proximity_domain_info.flags.proximity_info_valid = 1;
>> + proximity_domain_info.flags.proximity_preferred = 1;
>> + } else {
>> + proximity_domain_info.as_uint64 = 0;
>> + }
>> +
>> + return proximity_domain_info;
>> +}
>
> Pop quiz: What are the rules for the 30 bits of uninitialized data of
> proximity_domain_info.flags in the (node != NUMA_NO_NODE) case?
>
> I actually don't know off the top of my head. I generally avoid
> bitfields, but if they were normal stack-allocated variable space,
> they'd be garbage.
I'm not sure what you are getting at here - all the fields are
initialized.
>
> I'd also *much* rather see the "as_uint64 = 0" coded up as a memset() or
> even explicitly zeroing all the same variables as the other half of the
> if(). As it stands, it's not 100% obvious that proximity_domain_info is
> 64 bits and that .as_uint64=0 zeroes the whole thing. It *WOULD* be
> totally obvious if it were a memset().
I agree that it could be made clearer with memset().
Now that I'm thinking about it, hv_proximity_domain_info should really
just be a struct...then zeroing it is just:
struct hv_proximity_domain_info proximity_domain_info = {};
and I can remove the else branch and zeroing the reserved bits.
Powered by blists - more mailing lists