[RFC 1/1] mm/madvise: fail MADV_PAGEOUT on VM_DROPPABLE VMA

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



MADV_PAGEOUT should fail on VMAs with the VM_DROPPABLE flag. While
MADV_PAGEOUT is intended to move anonymous pages to swap, VM_DROPPABLE
should not be swapped out.

There is an issue where using MADV_PAGEOUT on a VMA with the VM_DROPPABLE
flag behaves like MADV_DONTNEED, causing the pages to be dropped. This
could break the semantics of MADV_PAGEOUT, IMO.

So, let's add a check to detect the VM_DROPPABLE flag before doing
MADV_PAGEOUT and returns -EINVAL.

Fixes: 9651fcedf7b9 ("mm: add MAP_DROPPABLE for designating always lazily freeable mappings")
Signed-off-by: Mingzhe Yang <mingzhe.yang@xxxxxx>
Signed-off-by: Lance Yang <ioworker0@xxxxxxxxx>
---
 mm/madvise.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/madvise.c b/mm/madvise.c
index 49f3a75046f6..29d0234da8a1 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -1263,6 +1263,8 @@ static int madvise_vma_behavior(struct vm_area_struct *vma,
 	case MADV_COLD:
 		return madvise_cold(vma, prev, start, end);
 	case MADV_PAGEOUT:
+		if (vma->vm_flags & VM_DROPPABLE)
+			return -EINVAL;
 		return madvise_pageout(vma, prev, start, end);
 	case MADV_FREE:
 	case MADV_DONTNEED:
-- 
2.45.2





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux