Re: [PATCH v3 3/3] mm: restructure memfd code

From: Khalid Aziz
Date: Tue Apr 10 2018 - 12:55:35 EST


On 04/09/2018 05:05 PM, Mike Kravetz wrote:
With the addition of memfd hugetlbfs support, we now have the situation
where memfd depends on TMPFS -or- HUGETLBFS. Previously, memfd was only
supported on tmpfs, so it made sense that the code resided in shmem.c.
In the current code, memfd is only functional if TMPFS is defined. If
HUGETLFS is defined and TMPFS is not defined, then memfd functionality
will not be available for hugetlbfs. This does not cause BUGs, just a
lack of potentially desired functionality.

Code is restructured in the following way:
- include/linux/memfd.h is a new file containing memfd specific
definitions previously contained in shmem_fs.h.
- mm/memfd.c is a new file containing memfd specific code previously
contained in shmem.c.
- memfd specific code is removed from shmem_fs.h and shmem.c.
- A new config option MEMFD_CREATE is added that is defined if TMPFS
or HUGETLBFS is defined.

No functional changes are made to the code: restructuring only.

Signed-off-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx>
---
fs/Kconfig | 3 +
fs/fcntl.c | 2 +-
include/linux/memfd.h | 16 +++
include/linux/shmem_fs.h | 13 --
mm/Makefile | 1 +
mm/memfd.c | 344 +++++++++++++++++++++++++++++++++++++++++++++++
mm/shmem.c | 323 --------------------------------------------
7 files changed, 365 insertions(+), 337 deletions(-)
create mode 100644 include/linux/memfd.h
create mode 100644 mm/memfd.c


Reviewed-by: Khalid Aziz <khalid.aziz@xxxxxxxxxx>