From: Tony Luck <tony.luck@intel.com>
To: Peter Newman <peternewman@google.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>,
Reinette Chatre <reinette.chatre@intel.com>,
Jonathan Corbet <corbet@lwn.net>,
x86@kernel.org, Shaopeng Tan <tan.shaopeng@fujitsu.com>,
James Morse <james.morse@arm.com>,
Jamie Iles <quic_jiles@quicinc.com>,
Babu Moger <babu.moger@amd.com>,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
patches@lists.linux.dev, tony.luck@intel.com
Subject: Re: [PATCH 7/7] x86/resctrl: Determine if Sub-NUMA Cluster is enabled and initialize.
Date: Fri, 10 Mar 2023 09:30:54 -0800 [thread overview]
Message-ID: <ZAtpTl+um3nbCOz8@agluck-desk3.sc.intel.com> (raw)
In-Reply-To: <CALPaoCgnOWLdEqKtonNeq+d_Fj0yr3Y7tgwwmAHmuhL5xBhqyg@mail.gmail.com>
On Mon, Feb 27, 2023 at 02:30:38PM +0100, Peter Newman wrote:
> Hi Tony,
>
> On Thu, Jan 26, 2023 at 7:42 PM Tony Luck <tony.luck@intel.com> wrote:
> > +static __init int find_snc_ways(void)
> > +{
> > + unsigned long *node_caches;
> > + int cpu, node, ret;
> > +
> > + node_caches = kcalloc(BITS_TO_LONGS(nr_node_ids), sizeof(*node_caches), GFP_KERNEL);
> > + if (!node_caches)
> > + return 1;
> > +
> > + cpus_read_lock();
> > + for_each_node(node) {
>
> Someone tried this patch on a machine with a CPU-less node...
>
> We need to check for this:
>
> + if (cpumask_empty(cpumask_of_node(node)))
> + continue;
>
> > + cpu = cpumask_first(cpumask_of_node(node));
> > + set_bit(get_cpu_cacheinfo_id(cpu, 3), node_caches);
> > + }
> > + cpus_read_unlock();
Peter,
Tell me more about your CPU-less nodes. Your fix avoids a bad
pointer reference (because cpumask_first() returns cpu >= nr_cpu_ids
for an empty bitmask).
But now I'm worried about whether I have the right values in the
formula:
nr_node_ids / bitmap_weight(node_caches, nr_node_ids);
This fix avoids counting the L3 from a non-existent CPU, but still
counts the node in the numerator.
Is your CPU-less node a full (non-SNC) node? Like this:
Socket 0 Socket 1
+--------------------+ +--------------------+
| . | | . |
| SNC 0.0 . SNC 0.1 | | zero . zero |
| . | | CPUs . CPUs |
| . | | . |
| . | | . |
+--------------------+ +--------------------+
| L3 Cache | | L3 Cache |
+--------------------+ +--------------------+
I could fix this case by counting how many CPU-less
nodes I find, and reducing the numerator (the denominator
didn't count the L3 cache from socket 1 because there
are no CPUs there)
(nr_node_ids - n_empty_nodes) / bitmap_weight(node_caches, nr_node_ids);
=> 2 / 1
But that won't work if your CPU-less node is an SNC node
and the other SNC node in the same socket does have some
CPUs:
Socket 0 Socket 1
+--------------------+ +--------------------+
| . | | . |
| SNC 0.0 . SNC 0.1 | | zero . SNC 1.1 |
| . | | CPUs . |
| . | | . |
| . | | . |
+--------------------+ +--------------------+
| L3 Cache | | L3 Cache |
+--------------------+ +--------------------+
This would get 3 / 2 ... i.e. I should still count the
empty node because its cache was counted by its SNC
buddy.
-Tony
next prev parent reply other threads:[~2023-03-10 17:31 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-26 18:41 [PATCH 0/7] x86/resctrl: Add support for Sub-NUMA cluster (SNC) systems Tony Luck
2023-01-26 18:41 ` [PATCH 1/7] x86/resctrl: Refactor in preparation for node-scoped resources Tony Luck
2023-01-26 18:41 ` [PATCH 2/7] x86/resctrl: Remove hard code of RDT_RESOURCE_L3 in monitor.c Tony Luck
2023-01-27 4:51 ` Yu, Fenghua
2023-01-26 18:41 ` [PATCH 3/7] x86/resctrl: Add a new node-scoped resource to rdt_resources_all[] Tony Luck
2023-01-27 5:24 ` Yu, Fenghua
2023-01-27 16:02 ` Peter Newman
2023-01-27 18:23 ` Luck, Tony
2023-01-28 2:25 ` Yu, Fenghua
2023-01-28 2:22 ` Yu, Fenghua
2023-01-28 2:36 ` Yu, Fenghua
2023-01-30 19:04 ` Luck, Tony
2023-02-28 14:27 ` Moger, Babu
2023-02-28 17:05 ` Luck, Tony
2023-01-26 18:41 ` [PATCH 4/7] x86/resctrl: Add code to setup monitoring at L3 or NODE scope Tony Luck
2023-02-28 17:13 ` James Morse
2023-02-28 17:28 ` Luck, Tony
2023-01-26 18:41 ` [PATCH 5/7] x86/resctrl: Add a new "snc_ways" file to the monitoring info directory Tony Luck
2023-02-28 17:13 ` James Morse
2023-02-28 17:44 ` Luck, Tony
2023-03-03 18:32 ` James Morse
2023-01-26 18:41 ` [PATCH 6/7] x86/resctrl: Update documentation with Sub-NUMA cluster changes Tony Luck
2023-02-28 17:14 ` James Morse
2023-01-26 18:41 ` [PATCH 7/7] x86/resctrl: Determine if Sub-NUMA Cluster is enabled and initialize Tony Luck
2023-02-27 13:30 ` Peter Newman
2023-03-10 17:30 ` Tony Luck [this message]
2023-03-13 9:19 ` Peter Newman
2023-03-13 16:38 ` Luck, Tony
2023-02-28 19:51 ` Moger, Babu
2023-03-14 20:23 ` Tony Luck
[not found] ` <85d7e70a-b9c8-6551-b1ac-229b51ee18d7@amd.com>
2023-02-28 20:39 ` Luck, Tony
2023-02-28 22:31 ` Moger, Babu
2023-02-28 17:12 ` [PATCH 0/7] x86/resctrl: Add support for Sub-NUMA cluster (SNC) systems James Morse
2023-02-28 18:04 ` Luck, Tony
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=ZAtpTl+um3nbCOz8@agluck-desk3.sc.intel.com \
--to=tony.luck@intel.com \
--cc=babu.moger@amd.com \
--cc=corbet@lwn.net \
--cc=fenghua.yu@intel.com \
--cc=james.morse@arm.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@lists.linux.dev \
--cc=peternewman@google.com \
--cc=quic_jiles@quicinc.com \
--cc=reinette.chatre@intel.com \
--cc=tan.shaopeng@fujitsu.com \
--cc=x86@kernel.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