mm: support madvise(MADV_FREE)

Linux doesn't have an ability to free pages lazy while other OS
already have been supported that named by madvise(MADV_FREE).

The gain is clear that kernel can evict freed pages rather than
swapping out or OOM if memory pressure happens.

Without memory pressure, freed pages would be reused by userspace
without another additional overhead(ex, page fault + allocation
+ zeroing).

Firstly, heavy users would be general allocators(ex, jemalloc,
I hope ptmalloc support it) and jemalloc already have supported
the feature for other OS(ex, FreeBSD)

One thing I hate in this patch is to change do_swap_page which
make pte dirty forcefully although fault is caused by swap-page
read. It would make more amount of diff for CRIU project.
So Ccing softdirty guys with hope they would have a brilliant
idea.

We could use SetPageDirty in do_swap_page forcefully and check
it in try_to_unmap_one to detect lazyfree as well as pte dirtiness
but it would cause unnecessary swapout although same page was
wroten to swap device. :(

If there isn't great idea, I should roll back to PG_lazyfree
approach.

Signed-off-by: Minchan Kim <minchan@kernel.org>
9 files changed