Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

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

 



On 24.10.22 16:59, Kirill A . Shutemov wrote:
On Fri, Oct 21, 2022 at 04:18:14PM +0000, Sean Christopherson wrote:
On Fri, Oct 21, 2022, Chao Peng wrote:

In the context of userspace inaccessible memfd, what would be a
suggested way to enforce NUMA memory policy for physical memory
allocation? mbind[1] won't work here in absence of virtual address
range.

How about set_mempolicy():
https://www.man7.org/linux/man-pages/man2/set_mempolicy.2.html

Andy Lutomirski brought this up in an off-list discussion way back when the whole
private-fd thing was first being proposed.

   : The current Linux NUMA APIs (mbind, move_pages) work on virtual addresses.  If
   : we want to support them for TDX private memory, we either need TDX private
   : memory to have an HVA or we need file-based equivalents. Arguably we should add
   : fmove_pages and fbind syscalls anyway, since the current API is quite awkward
   : even for tools like numactl.

Yeah, we definitely have gaps in API wrt NUMA, but I don't think it be
addressed in the initial submission.

BTW, it is not regression comparing to old KVM slots, if the memory is
backed by memfd or other file:

MBIND(2)
        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().

IIRC, that documentation is imprecise/incorrect especially when it comes to memfd. Page faults in shared mappings will similarly obey the set mbind() policy when allocating new pages.

QEMU relies on that.

The "fun" begins when we have multiple mappings, and only some have a policy set ... or if we already, previously allocated the pages.

--
Thanks,

David / dhildenb




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux