mm/madvise: fix madvise_pageout for private file mappings
authorPavankumar Kondeti <quic_pkondeti@quicinc.com>
Wed, 9 Nov 2022 05:18:36 +0000 (10:48 +0530)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 12 Dec 2022 02:12:09 +0000 (18:12 -0800)
commitfd3b1bc3c86ee11ba77421b00c70280605b521c6
tree1490c5c79822c59a0ebf51974b7a665f7efe7c97
parent4c9473e87e75a2a77ccd02e55c91ffe6a52b5df6
mm/madvise: fix madvise_pageout for private file mappings

When MADV_PAGEOUT is called on a private file mapping VMA region, we bail
out early if the process is neither owner nor write capable of the file.
However, this VMA may have both private/shared clean pages and private
dirty pages.  The opportunity of paging out the private dirty pages (Anon
pages) is missed.  Fix this behavior by allowing private file mappings
pageout further and perform the file access check along with PageAnon()
during page walk.

We observe ~10% improvement in zram usage, thus leaving more available
memory on a 4GB RAM system running Android.

[quic_pkondeti@quicinc.com: v2]
Link: https://lkml.kernel.org/r/1669962597-27724-1-git-send-email-quic_pkondeti@quicinc.com
Link: https://lkml.kernel.org/r/1667971116-12900-1-git-send-email-quic_pkondeti@quicinc.com
Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
Cc: Charan Teja Kalla <quic_charante@quicinc.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: David Hildenbrand <david@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/madvise.c