[PATCH 0/2] userfaultfd: merge fs/userfaultfd.c into mm/userfaultfd.c

Mike Rapoport posted 2 patches 1 month, 2 weeks ago
There is a newer version of this series
MAINTAINERS                   |    1 -
fs/Makefile                   |    1 -
fs/userfaultfd.c              | 2231 --------------------------------
include/linux/userfaultfd_k.h |   36 -
mm/userfaultfd.c              | 2238 ++++++++++++++++++++++++++++++++-
5 files changed, 2226 insertions(+), 2281 deletions(-)
delete mode 100644 fs/userfaultfd.c
[PATCH 0/2] userfaultfd: merge fs/userfaultfd.c into mm/userfaultfd.c
Posted by Mike Rapoport 1 month, 2 weeks ago
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>

Hi,

These patches merge fs/userfaultfd.c into mm/userfaultfd.c and make
functions used only inside mm/userfaultfd.c static.

Mike Rapoport (Microsoft) (2):
  userfaultfd: merge fs/userfaultfd.c into mm/userfaultfd.c
  userfaultfd: make functions that are not used outside uffd static

 MAINTAINERS                   |    1 -
 fs/Makefile                   |    1 -
 fs/userfaultfd.c              | 2231 --------------------------------
 include/linux/userfaultfd_k.h |   36 -
 mm/userfaultfd.c              | 2238 ++++++++++++++++++++++++++++++++-
 5 files changed, 2226 insertions(+), 2281 deletions(-)
 delete mode 100644 fs/userfaultfd.c


base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
-- 
2.53.0
Re: [PATCH 0/2] userfaultfd: merge fs/userfaultfd.c into mm/userfaultfd.c
Posted by Andrew Morton 1 month, 2 weeks ago
On Thu, 30 Apr 2026 14:35:10 +0300 Mike Rapoport <rppt@kernel.org> wrote:

> These patches merge fs/userfaultfd.c into mm/userfaultfd.c and make
> functions used only inside mm/userfaultfd.c static.

It's kinda scary how often Sashiko finds existing issues just because
we made it look.

	https://sashiko.dev/#/patchset/20260430113512.115938-1-rppt@kernel.org

Do either of these look legit?  If so, it would be better to fix them
before doing the code movement, for backporting ease.
Re: [PATCH 0/2] userfaultfd: merge fs/userfaultfd.c into mm/userfaultfd.c
Posted by Mike Rapoport 1 month, 2 weeks ago
On Thu, Apr 30, 2026 at 09:01:10AM -0700, Andrew Morton wrote:
> On Thu, 30 Apr 2026 14:35:10 +0300 Mike Rapoport <rppt@kernel.org> wrote:
> 
> > These patches merge fs/userfaultfd.c into mm/userfaultfd.c and make
> > functions used only inside mm/userfaultfd.c static.
> 
> It's kinda scary how often Sashiko finds existing issues just because
> we made it look.
> 
> 	https://sashiko.dev/#/patchset/20260430113512.115938-1-rppt@kernel.org
> 
> Do either of these look legit?  If so, it would be better to fix them
> before doing the code movement, for backporting ease.

One is real, another one is not.

> Another issue in the moved code: the ctx variable is annotated with
> __free(kfree) but allocated using kmem_cache_alloc() from the custom
> userfaultfd_ctx_cachep cache.

@Roman, can you please explain to sashiko that kfree() is fine with
kmem_cache_alloc()?

-- 
Sincerely yours,
Mike.
Re: [PATCH 0/2] userfaultfd: merge fs/userfaultfd.c into mm/userfaultfd.c
Posted by David Hildenbrand (Arm) 1 month, 2 weeks ago
On 4/30/26 13:35, Mike Rapoport wrote:
> From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
> 
> Hi,
> 
> These patches merge fs/userfaultfd.c into mm/userfaultfd.c and make
> functions used only inside mm/userfaultfd.c static.

Yeah, makes sense to me!

-- 
Cheers,

David
Re: [PATCH 0/2] userfaultfd: merge fs/userfaultfd.c into mm/userfaultfd.c
Posted by David Hildenbrand (Arm) 1 month, 2 weeks ago
On 4/30/26 13:38, David Hildenbrand (Arm) wrote:
> On 4/30/26 13:35, Mike Rapoport wrote:
>> From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
>>
>> Hi,
>>
>> These patches merge fs/userfaultfd.c into mm/userfaultfd.c and make
>> functions used only inside mm/userfaultfd.c static.
> 
> Yeah, makes sense to me!
> 

Thinking about this, is it reasonable that the kconfig stuff stays in fs/ ?

-- 
Cheers,

David
Re: [PATCH 0/2] userfaultfd: merge fs/userfaultfd.c into mm/userfaultfd.c
Posted by Mike Rapoport 1 month, 2 weeks ago
On Thu, Apr 30, 2026 at 04:23:08PM +0200, David Hildenbrand (Arm) wrote:
> On 4/30/26 13:38, David Hildenbrand (Arm) wrote:
> > On 4/30/26 13:35, Mike Rapoport wrote:
> >> From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
> >>
> >> Hi,
> >>
> >> These patches merge fs/userfaultfd.c into mm/userfaultfd.c and make
> >> functions used only inside mm/userfaultfd.c static.
> > 
> > Yeah, makes sense to me!
> > 
> 
> Thinking about this, is it reasonable that the kconfig stuff stays in fs/ ?

But it's in mm already.
 
> -- 
> Cheers,
> 
> David

-- 
Sincerely yours,
Mike.
Re: [PATCH 0/2] userfaultfd: merge fs/userfaultfd.c into mm/userfaultfd.c
Posted by David Hildenbrand (Arm) 1 month, 2 weeks ago
On 4/30/26 16:56, Mike Rapoport wrote:
> On Thu, Apr 30, 2026 at 04:23:08PM +0200, David Hildenbrand (Arm) wrote:
>> On 4/30/26 13:38, David Hildenbrand (Arm) wrote:
>>>
>>> Yeah, makes sense to me!
>>>
>>
>> Thinking about this, is it reasonable that the kconfig stuff stays in fs/ ?
> 
> But it's in mm already.

$ grep HUGETLB fs/Kconfig
config ARCH_SUPPORTS_HUGETLBFS
menuconfig HUGETLBFS
        depends on ARCH_SUPPORTS_HUGETLBFS
if HUGETLBFS
config HUGETLB_PAGE_OPTIMIZE_VMEMMAP_DEFAULT_ON
        depends on HUGETLB_PAGE_OPTIMIZE_VMEMMAP
endif # HUGETLBFS
config HUGETLB_PAGE
        def_bool HUGETLBFS
config HUGETLB_PAGE_OPTIMIZE_VMEMMAP
        def_bool HUGETLB_PAGE
        depends on ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP
        select SPARSEMEM_VMEMMAP_PREINIT if ARCH_WANT_HUGETLB_VMEMMAP_PREINIT
config HUGETLB_PMD_PAGE_TABLE_SHARING
        def_bool HUGETLB_PAGE


-- 
Cheers,

David
Re: [PATCH 0/2] userfaultfd: merge fs/userfaultfd.c into mm/userfaultfd.c
Posted by Mike Rapoport 1 month, 2 weeks ago
On Fri, May 01, 2026 at 08:33:04PM +0200, David Hildenbrand (Arm) wrote:
> On 4/30/26 16:56, Mike Rapoport wrote:
> > On Thu, Apr 30, 2026 at 04:23:08PM +0200, David Hildenbrand (Arm) wrote:
> >> On 4/30/26 13:38, David Hildenbrand (Arm) wrote:
> >>>
> >>> Yeah, makes sense to me!
> >>>
> >>
> >> Thinking about this, is it reasonable that the kconfig stuff stays in fs/ ?
> > 
> > But it's in mm already.
> 
> $ grep HUGETLB fs/Kconfig
> config ARCH_SUPPORTS_HUGETLBFS
> menuconfig HUGETLBFS
>         depends on ARCH_SUPPORTS_HUGETLBFS
> if HUGETLBFS
> config HUGETLB_PAGE_OPTIMIZE_VMEMMAP_DEFAULT_ON
>         depends on HUGETLB_PAGE_OPTIMIZE_VMEMMAP
> endif # HUGETLBFS
> config HUGETLB_PAGE
>         def_bool HUGETLBFS
> config HUGETLB_PAGE_OPTIMIZE_VMEMMAP
>         def_bool HUGETLB_PAGE
>         depends on ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP
>         select SPARSEMEM_VMEMMAP_PREINIT if ARCH_WANT_HUGETLB_VMEMMAP_PREINIT
> config HUGETLB_PMD_PAGE_TABLE_SHARING
>         def_bool HUGETLB_PAGE
> 

$ grep -c USERFAULT fs/Kconfig
0

HugeTLB is another story.
 
> -- 
> Cheers,
> David

-- 
Sincerely yours,
Mike.
Re: [PATCH 0/2] userfaultfd: merge fs/userfaultfd.c into mm/userfaultfd.c
Posted by David Hildenbrand (Arm) 1 month, 2 weeks ago
On 5/2/26 06:38, Mike Rapoport wrote:
> On Fri, May 01, 2026 at 08:33:04PM +0200, David Hildenbrand (Arm) wrote:
>> On 4/30/26 16:56, Mike Rapoport wrote:
>>>
>>> But it's in mm already.
>>
>> $ grep HUGETLB fs/Kconfig
>> config ARCH_SUPPORTS_HUGETLBFS
>> menuconfig HUGETLBFS
>>         depends on ARCH_SUPPORTS_HUGETLBFS
>> if HUGETLBFS
>> config HUGETLB_PAGE_OPTIMIZE_VMEMMAP_DEFAULT_ON
>>         depends on HUGETLB_PAGE_OPTIMIZE_VMEMMAP
>> endif # HUGETLBFS
>> config HUGETLB_PAGE
>>         def_bool HUGETLBFS
>> config HUGETLB_PAGE_OPTIMIZE_VMEMMAP
>>         def_bool HUGETLB_PAGE
>>         depends on ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP
>>         select SPARSEMEM_VMEMMAP_PREINIT if ARCH_WANT_HUGETLB_VMEMMAP_PREINIT
>> config HUGETLB_PMD_PAGE_TABLE_SHARING
>>         def_bool HUGETLB_PAGE
>>
> 
> $ grep -c USERFAULT fs/Kconfig
> 0
> 
> HugeTLB is another story.

Oh my, what did my brain mess up there.

Sorry, please move along, nothing to see here :)

-- 
Cheers,

David
Re: [PATCH 0/2] userfaultfd: merge fs/userfaultfd.c into mm/userfaultfd.c
Posted by Mike Rapoport 1 month, 2 weeks ago
On Thu, Apr 30, 2026 at 04:23:08PM +0200, David Hildenbrand (Arm) wrote:
> On 4/30/26 13:38, David Hildenbrand (Arm) wrote:
> > On 4/30/26 13:35, Mike Rapoport wrote:
> >> From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
> >>
> >> Hi,
> >>
> >> These patches merge fs/userfaultfd.c into mm/userfaultfd.c and make
> >> functions used only inside mm/userfaultfd.c static.
> > 
> > Yeah, makes sense to me!
> > 
> 
> Thinking about this, is it reasonable that the kconfig stuff stays in fs/ ?

Nope, missed that.
 
> -- 
> Cheers,
> 
> David

-- 
Sincerely yours,
Mike.