[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] util: NUMA aware memory preallocation
From: |
David Hildenbrand |
Subject: |
Re: [PATCH] util: NUMA aware memory preallocation |
Date: |
Wed, 8 Jun 2022 12:34:01 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 |
On 11.05.22 11:34, Daniel P. Berrangé wrote:
> On Wed, May 11, 2022 at 11:31:23AM +0200, David Hildenbrand wrote:
>>>> Long story short, management application has no way of learning
>>>> TIDs of allocator threads so it can't make them run NUMA aware.
>>>
>>> This feels like the key issue. The preallocation threads are
>>> invisible to libvirt, regardless of whether we're doing coldplug
>>> or hotplug of memory-backends. Indeed the threads are invisible
>>> to all of QEMU, except the memory backend code.
>>>
>>> Conceptually we need 1 or more explicit worker threads, that we
>>> can assign CPU affinity to, and then QEMU can place jobs on them.
>>> I/O threads serve this role, but limited to blockdev work. We
>>> need a generalization of I/O threads, for arbitrary jobs that
>>> QEMU might want to farm out to specific numa nodes.
>>
>> At least the "-object iothread" thingy can already be used for actions
>> outside of blockdev. virtio-balloon uses one for free page hinting.
>
> Ah that's good to know, so my idea probably isn't so much work as
> I thought it might be.
Looking into the details, iothreads are the wrong tool to use here.
I can imagine use cases where you'd want to perform preallcoation
* Only one some specific CPUs of a NUMA node (especially, not ones where
we pinned VCPUs)
* On CPUs that are on a different NUMA node then the actual backend
memory ... just thinking about all of the CPU-less nodes for PMEM and
CXL that we're starting to see.
So ideally, we'd let the user configure either
* Set of physical CPUs to use (low hanging fruit)
* Set of NUMA nodes to use (harder)
and allow libvirt to easily configure it similarly by pinning threads.
As CPU affinity is inherited when creating a new thread, so here is one
IMHO reasonable simple thing to get the job done and allow for such
flexibility.
Introduce a "thread-context" user-creatable object that is used to
configure CPU affinity.
Internally, thread-context creates exactly one thread called "TC $id".
That thread serves no purpose besides spawning new threads that inherit the
affinity.
Internal users (like preallocation, but we could reuse the same concept for
other
non-io threads, such as userfaultfd, and some other potential non-io thread
users) simply use that thread context to spawn new threads.
Spawned threads get called "TC $id/$threadname", whereby $threadname is the
ordinary name supplied by the internal user. This could be used to identify
long-running threads if needed in the future.
It's worth nothing that this is not a thread pool.
a) Ordinary cmdline usage:
-object thread-context,id="tc1",cpus=0-9,cpus=12
QEMU tries setting the CPU affinity and fails if that's impossible.
-object
memory-backend-file,...,prealloc=on,prealloc-threads=16,prealloc-thread-context=tc1
When a context is set, preallcoation code will use the thread-context to spawn
threads.
b) Libvirt, ..., usage:
-object thread-context,id="tc1"
Then, libvirt identifies and sets the affinity for the "TC tc1" thread.
-object
memory-backend-file,...,prealloc=on,prealloc-threads=16,prealloc-thread-context=tc1
thread-context can be reused for successive preallcoation etc, obviously.
--
Thanks,
David / dhildenb
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [PATCH] util: NUMA aware memory preallocation,
David Hildenbrand <=