mm: enable MADV_FREE for swapless system
authorShaohua Li <shli@fb.com>
Wed, 3 May 2017 21:52:39 +0000 (14:52 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 3 May 2017 22:52:08 +0000 (15:52 -0700)
Now MADV_FREE pages can be easily reclaimed even for swapless system.
We can safely enable MADV_FREE for all systems.

Link: http://lkml.kernel.org/r/155648585589300bfae1d45078e7aebb3d988b87.1487965799.git.shli@fb.com
Signed-off-by: Shaohua Li <shli@fb.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Hillf Danton <hillf.zj@alibaba-inc.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/madvise.c

index d3a6712c3e14f237bdc9880243c511db452056e8..a09d2d3dfae9368d01e8ab9ca5ce475e49ca533b 100644 (file)
@@ -650,13 +650,7 @@ madvise_vma(struct vm_area_struct *vma, struct vm_area_struct **prev,
        case MADV_WILLNEED:
                return madvise_willneed(vma, prev, start, end);
        case MADV_FREE:
-               /*
-                * XXX: In this implementation, MADV_FREE works like
-                * MADV_DONTNEED on swapless system or full swap.
-                */
-               if (get_nr_swap_pages() > 0)
-                       return madvise_free(vma, prev, start, end);
-               /* passthrough */
+               return madvise_free(vma, prev, start, end);
        case MADV_DONTNEED:
                return madvise_dontneed(vma, prev, start, end);
        default: