summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/ABI/testing/sysfs-kernel-mm-cma25
-rw-r--r--Documentation/admin-guide/kernel-parameters.txt17
-rw-r--r--Documentation/admin-guide/mm/memory-hotplug.rst9
-rw-r--r--Documentation/admin-guide/mm/userfaultfd.rst107
-rw-r--r--arch/arc/Kconfig9
-rw-r--r--arch/arm/Kconfig10
-rw-r--r--arch/arm64/Kconfig30
-rw-r--r--arch/arm64/mm/hugetlbpage.c7
-rw-r--r--arch/ia64/Kconfig14
-rw-r--r--arch/ia64/mm/hugetlbpage.c3
-rw-r--r--arch/mips/Kconfig6
-rw-r--r--arch/mips/mm/hugetlbpage.c4
-rw-r--r--arch/parisc/Kconfig5
-rw-r--r--arch/parisc/mm/hugetlbpage.c2
-rw-r--r--arch/powerpc/Kconfig17
-rw-r--r--arch/powerpc/mm/hugetlbpage.c3
-rw-r--r--arch/powerpc/platforms/Kconfig.cputype16
-rw-r--r--arch/riscv/Kconfig5
-rw-r--r--arch/s390/Kconfig12
-rw-r--r--arch/s390/mm/hugetlbpage.c2
-rw-r--r--arch/sh/Kconfig7
-rw-r--r--arch/sh/mm/Kconfig8
-rw-r--r--arch/sh/mm/hugetlbpage.c2
-rw-r--r--arch/sparc/mm/hugetlbpage.c2
-rw-r--r--arch/x86/Kconfig29
-rw-r--r--arch/x86/mm/pat/set_memory.c8
-rw-r--r--drivers/acpi/acpi_memhotplug.c5
-rw-r--r--drivers/base/memory.c101
-rw-r--r--fs/Kconfig5
-rw-r--r--fs/block_dev.c2
-rw-r--r--fs/btrfs/compression.c5
-rw-r--r--fs/btrfs/extent_io.c22
-rw-r--r--fs/btrfs/inode.c33
-rw-r--r--fs/btrfs/reflink.c6
-rw-r--r--fs/btrfs/zlib.c5
-rw-r--r--fs/btrfs/zstd.c5
-rw-r--r--fs/buffer.c36
-rw-r--r--fs/dax.c8
-rw-r--r--fs/gfs2/glock.c3
-rw-r--r--fs/hugetlbfs/inode.c9
-rw-r--r--fs/inode.c9
-rw-r--r--fs/proc/task_mmu.c3
-rw-r--r--fs/userfaultfd.c149
-rw-r--r--include/linux/buffer_head.h4
-rw-r--r--include/linux/cma.h4
-rw-r--r--include/linux/compaction.h1
-rw-r--r--include/linux/fs.h2
-rw-r--r--include/linux/gfp.h2
-rw-r--r--include/linux/highmem.h7
-rw-r--r--include/linux/huge_mm.h3
-rw-r--r--include/linux/hugetlb.h33
-rw-r--r--include/linux/memcontrol.h23
-rw-r--r--include/linux/memory.h8
-rw-r--r--include/linux/memory_hotplug.h15
-rw-r--r--include/linux/memremap.h2
-rw-r--r--include/linux/migrate.h7
-rw-r--r--include/linux/mm.h26
-rw-r--r--include/linux/mmzone.h20
-rw-r--r--include/linux/pagemap.h5
-rw-r--r--include/linux/pgtable.h12
-rw-r--r--include/linux/sched.h2
-rw-r--r--include/linux/sched/mm.h27
-rw-r--r--include/linux/shrinker.h7
-rw-r--r--include/linux/swap.h21
-rw-r--r--include/linux/userfaultfd_k.h49
-rw-r--r--include/linux/vm_event_item.h8
-rw-r--r--include/trace/events/cma.h68
-rw-r--r--include/trace/events/migrate.h25
-rw-r--r--include/trace/events/mmflags.h7
-rw-r--r--include/uapi/linux/mempolicy.h7
-rw-r--r--include/uapi/linux/userfaultfd.h36
-rw-r--r--init/Kconfig5
-rw-r--r--kernel/sysctl.c2
-rw-r--r--lib/Kconfig.kfence1
-rw-r--r--lib/iov_iter.c8
-rw-r--r--mm/Kconfig28
-rw-r--r--mm/Makefile6
-rw-r--r--mm/cma.c62
-rw-r--r--mm/cma.h25
-rw-r--r--mm/cma_debug.c8
-rw-r--r--mm/cma_sysfs.c112
-rw-r--r--mm/compaction.c107
-rw-r--r--mm/filemap.c24
-rw-r--r--mm/frontswap.c12
-rw-r--r--mm/gup.c174
-rw-r--r--mm/gup_test.c29
-rw-r--r--mm/gup_test.h3
-rw-r--r--mm/highmem.c11
-rw-r--r--mm/huge_memory.c324
-rw-r--r--mm/hugetlb.c777
-rw-r--r--mm/hugetlb_cgroup.c9
-rw-r--r--mm/internal.h10
-rw-r--r--mm/kfence/core.c59
-rw-r--r--mm/khugepaged.c63
-rw-r--r--mm/ksm.c17
-rw-r--r--mm/list_lru.c6
-rw-r--r--mm/memcontrol.c131
-rw-r--r--mm/memory_hotplug.c216
-rw-r--r--mm/mempolicy.c12
-rw-r--r--mm/mempool.c2
-rw-r--r--mm/migrate.c89
-rw-r--r--mm/mlock.c4
-rw-r--r--mm/mmap.c18
-rw-r--r--mm/oom_kill.c2
-rw-r--r--mm/page_alloc.c75
-rw-r--r--mm/process_vm_access.c1
-rw-r--r--mm/shmem.c2
-rw-r--r--mm/sparse.c4
-rw-r--r--mm/swap.c69
-rw-r--r--mm/swap_state.c4
-rw-r--r--mm/swapfile.c4
-rw-r--r--mm/truncate.c19
-rw-r--r--mm/userfaultfd.c39
-rw-r--r--mm/util.c26
-rw-r--r--mm/vmalloc.c2
-rw-r--r--mm/vmscan.c411
-rw-r--r--mm/vmstat.c35
-rw-r--r--mm/workingset.c1
-rw-r--r--mm/zsmalloc.c6
-rw-r--r--mm/zswap.c2
-rw-r--r--tools/testing/selftests/vm/.gitignore1
-rw-r--r--tools/testing/selftests/vm/Makefile1
-rw-r--r--tools/testing/selftests/vm/gup_test.c36
-rw-r--r--tools/testing/selftests/vm/split_huge_page_test.c390
-rw-r--r--tools/testing/selftests/vm/userfaultfd.c164
125 files changed, 3386 insertions, 1458 deletions
diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-cma b/Documentation/ABI/testing/sysfs-kernel-mm-cma
new file mode 100644
index 000000000000..02b2bb60c296
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-kernel-mm-cma
@@ -0,0 +1,25 @@
+What: /sys/kernel/mm/cma/
+Date: Feb 2021
+Contact: Minchan Kim <minchan@kernel.org>
+Description:
+ /sys/kernel/mm/cma/ contains a subdirectory for each CMA
+ heap name (also sometimes called CMA areas).
+
+ Each CMA heap subdirectory (that is, each
+ /sys/kernel/mm/cma/<cma-heap-name> directory) contains the
+ following items:
+
+ alloc_pages_success
+ alloc_pages_fail
+
+What: /sys/kernel/mm/cma/<cma-heap-name>/alloc_pages_success
+Date: Feb 2021
+Contact: Minchan Kim <minchan@kernel.org>
+Description:
+ the number of pages CMA API succeeded to allocate
+
+What: /sys/kernel/mm/cma/<cma-heap-name>/alloc_pages_fail
+Date: Feb 2021
+Contact: Minchan Kim <minchan@kernel.org>
+Description:
+ the number of pages CMA API failed to allocate
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 0d48fbd9107f..a1266f33d6e6 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -2804,6 +2804,23 @@
seconds. Use this parameter to check at some
other rate. 0 disables periodic checking.
+ memory_hotplug.memmap_on_memory
+ [KNL,X86,ARM] Boolean flag to enable this feature.
+ Format: {on | off (default)}
+ When enabled, runtime hotplugged memory will
+ allocate its internal metadata (struct pages)
+ from the hotadded memory which will allow to
+ hotadd a lot of memory without requiring
+ additional memory to do so.
+ This feature is disabled by default because it
+ has some implication on large (e.g. GB)
+ allocations in some configurations (e.g. small
+ memory blocks).
+ The state of the flag can be read in
+ /sys/module/memory_hotplug/parameters/memmap_on_memory.
+ Note that even when enabled, there are a few cases where
+ the feature is not effective.
+
memtest= [KNL,X86,ARM,PPC] Enable memtest
Format: <integer>
default : 0 <disable>
diff --git a/Documentation/admin-guide/mm/memory-hotplug.rst b/Documentation/admin-guide/mm/memory-hotplug.rst
index 5307f90738aa..05d51d2d8beb 100644
--- a/Documentation/admin-guide/mm/memory-hotplug.rst
+++ b/Documentation/admin-guide/mm/memory-hotplug.rst
@@ -357,6 +357,15 @@ creates ZONE_MOVABLE as following.
Unfortunately, there is no information to show which memory block belongs
to ZONE_MOVABLE. This is TBD.
+.. note::
+ Techniques that rely on long-term pinnings of memory (especially, RDMA and
+ vfio) are fundamentally problematic with ZONE_MOVABLE and, therefore, memory
+ hot remove. Pinned pages cannot reside on ZONE_MOVABLE, to guarantee that
+ memory can still get hot removed - be aware that pinning can fail even if
+ there is plenty of free memory in ZONE_MOVABLE. In addition, using
+ ZONE_MOVABLE might make page pinning more expensive, because pages have to be
+ migrated off that zone first.
+
.. _memory_hotplug_how_to_offline_memory:
How to offline memory
diff --git a/Documentation/admin-guide/mm/userfaultfd.rst b/Documentation/admin-guide/mm/userfaultfd.rst
index 65eefa66c0ba..3aa38e8b8361 100644
--- a/Documentation/admin-guide/mm/userfaultfd.rst
+++ b/Documentation/admin-guide/mm/userfaultfd.rst
@@ -63,36 +63,36 @@ the generic ioctl available.
The ``uffdio_api.features`` bitmask returned by the ``UFFDIO_API`` ioctl
defines what memory types are supported by the ``userfaultfd`` and what
-events, except page fault notifications, may be generated.
-
-If the kernel supports registering ``userfaultfd`` ranges on hugetlbfs
-virtual memory areas, ``UFFD_FEATURE_MISSING_HUGETLBFS`` will be set in
-``uffdio_api.features``. Similarly, ``UFFD_FEATURE_MISSING_SHMEM`` will be
-set if the kernel supports registering ``userfaultfd`` ranges on shared
-memory (covering all shmem APIs, i.e. tmpfs, ``IPCSHM``, ``/dev/zero``,
-``MAP_SHARED``, ``memfd_create``, etc).
-
-The userland application that wants to use ``userfaultfd`` with hugetlbfs
-or shared memory need to set the corresponding flag in
-``uffdio_api.features`` to enable those features.
-
-If the userland desires to receive notifications for events other than
-page faults, it has to verify that ``uffdio_api.features`` has appropriate
-``UFFD_FEATURE_EVENT_*`` bits set. These events are described in more
-detail below in `Non-cooperative userfaultfd`_ section.
-
-Once the ``userfaultfd`` has been enabled the ``UFFDIO_REGISTER`` ioctl should
-be invoked (if present in the returned ``uffdio_api.ioctls`` bitmask) to
-register a memory range in the ``userfaultfd`` by setting the
+events, except page fault notifications, may be generated:
+
+- The ``UFFD_FEATURE_EVENT_*`` flags indicate that various other events
+ other than page faults are supported. These events are described in more
+ detail below in the `Non-cooperative userfaultfd`_ section.
+
+- ``UFFD_FEATURE_MISSING_HUGETLBFS`` and ``UFFD_FEATURE_MISSING_SHMEM``
+ indicate that the kernel supports ``UFFDIO_REGISTER_MODE_MISSING``
+ registrations for hugetlbfs and shared memory (covering all shmem APIs,
+ i.e. tmpfs, ``IPCSHM``, ``/dev/zero``, ``MAP_SHARED``, ``memfd_create``,
+ etc) virtual memory areas, respectively.
+
+- ``UFFD_FEATURE_MINOR_HUGETLBFS`` indicates that the kernel supports
+ ``UFFDIO_REGISTER_MODE_MINOR`` registration for hugetlbfs virtual memory
+ areas.
+
+The userland application should set the feature flags it intends to use
+when invoking the ``UFFDIO_API`` ioctl, to request that those features be
+enabled if supported.
+
+Once the ``userfaultfd`` API has been enabled the ``UFFDIO_REGISTER``
+ioctl should be invoked (if present in the returned ``uffdio_api.ioctls``
+bitmask) to register a memory range in the ``userfaultfd`` by setting the
uffdio_register structure accordingly. The ``uffdio_register.mode``
bitmask will specify to the kernel which kind of faults to track for
-the range (``UFFDIO_REGISTER_MODE_MISSING`` would track missing
-pages). The ``UFFDIO_REGISTER`` ioctl will return the