qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v1 2/2] osdep: support mempolicy for preallocation in os_mem_


From: Daniil Tatianin
Subject: Re: [PATCH v1 2/2] osdep: support mempolicy for preallocation in os_mem_prealloc
Date: Tue, 07 Dec 2021 16:58:56 +0300

I believe you're right. Looking at the implementation of shmem_alloc_page, it uses the inode policy, which is set via
vma->set_policy (from the mbind() call in this case). set_mempolicy is both useless and redundant here, as thread's
policy is only ever used in case vma->get_policy returns NULL (which it doesn't in our case).
Sorry for the confusion.

Thanks,
Daniil
 
07.12.2021, 11:13, "David Hildenbrand" <david@redhat.com>:

On 07.12.21 08:06, Daniil Tatianin wrote:

 This is needed for cases where we want to make sure that a shared memory
 region gets allocated from a specific NUMA node. This is impossible to do
 with mbind(2) because it ignores the policy for memory mapped with
 MAP_SHARED. We work around this by calling set_mempolicy from prealloc
 threads instead.


That's not quite true I think, how were you able to observe this? Do you
have a reproducer?

While the man page says:

"
The specified policy will be ignored for any MAP_SHARED mappings in
the specified memory range. Rather the pages will be allocated
according to the memory policy of the thread that caused the page to be
allocated. Again, this may not be the thread that called mbind().
"

What it really means is that as long as we access that memory via the
*VMA* for which we called mbind(), which is the case when *not* using
fallocate() to preallocate memory, we end up using the correct policy.


I did experiments a while ago with hugetlbfs shared memory and it
properly allocated from the right node. So I'd be curious how you
trigger this.
 

--
Thanks,

David / dhildenb
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]