[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v1 4/7] util: Add write-only "node-affinity" property for Thr
From: |
David Hildenbrand |
Subject: |
Re: [PATCH v1 4/7] util: Add write-only "node-affinity" property for ThreadContext |
Date: |
Fri, 30 Sep 2022 11:17:03 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 |
On 29.09.22 13:13, Markus Armbruster wrote:
David Hildenbrand <david@redhat.com> writes:
Let's make it easier to pin threads created via a ThreadContext to
all current CPUs belonging to given NUMA nodes.
As "node-affinity" is simply a shortcut for setting "cpu-affinity", that
property cannot be read and if the CPUs for a node change due do CPU
hotplug, the CPU affinity will not get updated.
Color me confused.
I adjusted that to:
util: Add write-only "node-affinity" property for ThreadContext
Let's make it easier to pin threads created via a ThreadContext to
all CPUs currently belonging to a given set of NUMA nodes -- which is the
common case.
"node-affinity" is simply a shortcut for setting "cpu-affinity" manually
to the list of CPUs belonging to the set of nodes. This property can only
be written.
A simple QEMU example to set the CPU affinity to Node 1 on a system with
two NUMA nodes, 24 CPUs each:
qemu-system-x86_64 -S \
-object thread-context,id=tc1,node-affinity=1
And we can query the cpu-affinity via HMP/QMP:
(qemu) qom-get tc1 cpu-affinity
[
1,
3,
5,
7,
9,
11,
13,
15,
17,
19,
21,
23,
25,
27,
29,
31,
33,
35,
37,
39,
41,
43,
45,
47
]
We cannot query the node-affinity:
(qemu) qom-get tc1 node-affinity
Error: Insufficient permission to perform this operation
But note that due to dynamic library loading this example will not work
before we actually make use of thread_context_create_thread() in QEMU
code, because the type will otherwise not get registered.
Note that if the CPUs for a node change due do physical CPU hotplug or
hotunplug (e.g., lscpu output changes) after the ThreadContext was started,
the CPU affinity will not get updated.
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
qapi/qom.json | 7 +++-
util/meson.build | 2 +-
util/thread-context.c | 84 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 91 insertions(+), 2 deletions(-)
diff --git a/qapi/qom.json b/qapi/qom.json
index 4775a333ed..d36bf3355f 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -838,10 +838,15 @@
# @cpu-affinity: the CPU affinity for all threads created in the thread
# context (default: QEMU main thread affinity)
#
+# @node-affinity: shortcut for looking up the current CPUs for the given nodes
+# and setting @cpu-affinity (default: QEMU main thread
+# affinity)
+#
Still confused. Explain for dummies? With an example, perhaps?
I adjusted that to:
+# @node-affinity: the list of node numbers that will be resolved to a list
+# of CPU numbers used as CPU affinity. This is a shortcut for
+# specifying the list of CPU numbers belonging to the nodes
+# manually by setting @cpu-affinity. (default: QEMU main thread
+# affinity)
+#
Thanks!
--
Thanks,
David / dhildenb
[PATCH v1 4/7] util: Add write-only "node-affinity" property for ThreadContext, David Hildenbrand, 2022/09/28
[PATCH v1 5/7] util: Make qemu_prealloc_mem() optionally consume a ThreadContext, David Hildenbrand, 2022/09/28
[PATCH v1 6/7] hostmem: Allow for specifying a ThreadContext for preallocation, David Hildenbrand, 2022/09/28
[PATCH v1 7/7] vl: Allow ThreadContext objects to be created before the sandbox option, David Hildenbrand, 2022/09/28