[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0b403696-addb-45ab-a9b5-60f231d9dc4b@amazon.com>
Date: Thu, 30 Oct 2025 18:00:26 +0000
From: Nikita Kalyazin <kalyazin@...zon.com>
To: "Liam R. Howlett" <Liam.Howlett@...cle.com>, Peter Xu <peterx@...hat.com>,
David Hildenbrand <david@...hat.com>, <linux-kernel@...r.kernel.org>,
<linux-mm@...ck.org>, Mike Rapoport <rppt@...nel.org>, Muchun Song
<muchun.song@...ux.dev>, Vlastimil Babka <vbabka@...e.cz>, Axel Rasmussen
<axelrasmussen@...gle.com>, Andrew Morton <akpm@...ux-foundation.org>, "James
Houghton" <jthoughton@...gle.com>, Lorenzo Stoakes
<lorenzo.stoakes@...cle.com>, Hugh Dickins <hughd@...gle.com>, Michal Hocko
<mhocko@...e.com>, Ujwal Kundur <ujwal.kundur@...il.com>, Oscar Salvador
<osalvador@...e.de>, Suren Baghdasaryan <surenb@...gle.com>, Andrea Arcangeli
<aarcange@...hat.com>
Subject: Re: [PATCH v4 0/4] mm/userfaultfd: modulize memory types
On 30/10/2025 17:13, Liam R. Howlett wrote:
> * Peter Xu <peterx@...hat.com> [251021 12:28]:
>
> ...
>
>> Can you send some patches and show us the code, help everyone to support
>> guest-memfd minor fault, please?
>
> Patches are here:
>
> https://git.infradead.org/?p=users/jedix/linux-maple.git;a=shortlog;h=refs/heads/modularized_mem
>
> This is actually modularized memory types. That means there is no
> hugetlb.h or shmem.h included in mm/userfaultfd.c code.
>
> uffd_flag_t has been removed. This was turning into a middleware and
> it is not necessary. Neither is supported_ioctls.
>
> hugetlb now uses the same functions as every other memory type,
> including anon memory.
>
> Any memory type can change functionality without adding instructions or
> flags or anything to some other code.
>
> This code passes uffd-unit-test and uffd-wp-mremap (skipped the swap
> tests).
>
> guest-memfd can implement whatever it needs to (or use others
> implementations), like shmem_uffd_ops here:
>
> static const struct vm_uffd_ops shmem_uffd_ops = {
> .copy = shmem_mfill_atomic_pte_copy,
> .zeropage = shmem_mfill_atomic_pte_zeropage,
> .cont = shmem_mfill_atomic_pte_continue,
> .poison = mfill_atomic_pte_poison,
> .writeprotect = uffd_writeprotect,
> .is_dst_valid = shmem_is_dst_valid,
> .increment = mfill_size,
> .failed_do_unlock = uffd_failed_do_unlock,
> .page_shift = uffd_page_shift,
> .complete_register = uffd_complete_register,
> };
>
> Where guest-memfd needs to write the one function:
> guest_memfd_pte_continue(), from what I understand.
>
> Obviously some of the shmem_ functions would need to be added to a
> header, or such.
>
> And most of that can come from shmem_mfill_atomic_pte_continue(), from
> what I understand. This is about 40 lines of code, but may require
> exposing some shmem functions to keep the code that compact.
>
> So we don't need to expose getting a folio to a module, or decode any
> special flags or whatever. We just call the function that needs to be
> called on the vma that is found.
>
> If anyone has tests I can use for guest-memfd and instructions on
> guest-memfd setup, I'll just write it instead of expanding the
> userfaultfd middleware.
I used to use [1] as a test. The test function can be called from inside
if (flags & GUEST_MEMFD_FLAG_MMAP) {
test_mmap_supported(fd, page_size, total_size);
test_fault_overflow(fd, page_size, total_size);
} else {
in your tree (tools/testing/selftests/kvm/guest_memfd_test.c).
CONFIG_KVM_GUEST_MEMFD=y should be sufficient to enable guest_memfd support.
[1] https://lore.kernel.org/kvm/20250404154352.23078-7-kalyazin@amazon.com/
>
> Thanks,
> Liam
>
Powered by blists - more mailing lists