Re: [PATCH] userfaultfd: hugetlbfs: only compile UFFD helpers if config enabled

From: Peter Xu
Date: Tue Feb 02 2021 - 15:40:41 EST


On Tue, Feb 02, 2021 at 12:31:27PM -0800, Axel Rasmussen wrote:
> For background, mm/userfaultfd.c provides a general mcopy_atomic
> implementation. But some types of memory (e.g., hugetlb and shmem) need
> a slightly different implementation, so they provide their own helpers
> for this. In other words, userfaultfd is the only caller of this
> function.
>
> This patch achieves two things:
>
> 1. Don't spend time compiling code which will end up never being
> referenced anyway (a small build time optimization).
>
> 2. In future patches (e.g. [1]), we plan to extend the signature of
> these helpers with UFFD-specific state (e.g., enums or structs defined
> conditionally in userfaultfd_k.h). Once this happens, this patch will be
> needed to avoid build errors (or, we'd need to define more UFFD-only
> stuff unconditionally, which seems messier to me).
>
> Peter Xu suggested this be sent as a standalone patch, in the mailing
> list discussion for [1].
>
> [1] https://patchwork.kernel.org/project/linux-mm/list/?series=424091
>
> Signed-off-by: Axel Rasmussen <axelrasmussen@xxxxxxxxxx>

I meant a standalone patch along with the next version of your series would be
good enough... :) If Mike is fine I won't complain if you'd squashed it into
that patch either. The patch itself looks correct to me.

Reviewed-by: Peter Xu <peterx@xxxxxxxxxx>

Thanks,

--
Peter Xu