From: Nadav Amit <namit@xxxxxxxxxx> The goal of these patches is to add support for process_madvise(MADV_DONTNEED). Yet, in the process some (arguably) useful cleanups, a bug fix and performance enhancements are performed. The patches try to consolidate the logic across different behaviors, and to a certain extent overlap/conflict with an outstanding patch that does something similar [1]. This consolidation however is mostly orthogonal to the aforementioned one and done in order to clarify what is done in respect to locks and TLB for each behavior and to batch these operations more efficiently on process_madvise(). process_madvise(MADV_DONTNEED) is useful for two reasons: (a) it allows userfaultfd monitors to unmap memory from monitored processes; and (b) it is more efficient than madvise() since it is vectored and batches TLB flushes more aggressively. The first three patches should not interfere with the outstanding patch [1]. The rest might need to be rebased after [1] is applied. [1] https://lore.kernel.org/linux-mm/CAJuCfpFDBJ_W1y2tqAT4BGtPbWrjjDud_JuKO8ZbnjYfeVNvRg@xxxxxxxxxxxxxx/ Cc: Peter Xu <peterx@xxxxxxxxxx> Cc: Andrea Arcangeli <aarcange@xxxxxxxxxx> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Cc: Minchan Kim <minchan@xxxxxxxxxx> Cc: Colin Cross <ccross@xxxxxxxxxx> Cc: Suren Baghdasarya <surenb@xxxxxxxxxx> Cc: Mike Rapoport <rppt@xxxxxxxxxxxxxxxxxx> Nadav Amit (8): mm/madvise: propagate vma->vm_end changes mm/madvise: remove unnecessary check on madvise_dontneed_free() mm/madvise: remove unnecessary checks on madvise_free_single_vma() mm/madvise: define madvise behavior in a struct mm/madvise: perform certain operations once on process_madvise() mm/madvise: more aggressive TLB batching mm/madvise: deduplicate code in madvise_dontneed_free() mm/madvise: process_madvise(MADV_DONTNEED) mm/internal.h | 5 + mm/madvise.c | 396 ++++++++++++++++++++++++++++++-------------------- mm/memory.c | 2 +- 3 files changed, 248 insertions(+), 155 deletions(-) -- 2.25.1