Migrate-on-fault prototype 5/5 V0.1 - add MPOL_MF_LAZY
Subsystems (5)
I never saw this one hit the list.
Migrate-on-fault prototype 5/5 V0.1 - add MPOL_MF_LAZY
This patch adds another mbind() flag to request "lazy migration". The flag, MPOL_MF_LAZY, modifies MPOL_MF_MOVE* such that the selected pages are simply unmapped from the calling task's page table ['_MOVE] or from all referencing page tables [_MOVE_ALL]. Anon pages will first be added to the swap [or migration?] cache, if necessary. The pages will be migrated in the fault path on "first touch", if the policy dictates at that time.
"Lazy Migration" will allow testing of migrate-on-fault. If useful to applications, it could become a permanent part of the mbind() interface. Yes, it does duplicate some of the code in migrate_pages(). However, lazy migration doesn't need to do all that migrate_pages() does, nor does it need to try as hard. Trying to weave both functions into migrate_pages() could probably be done, but that could result in fairly ugly code.
include/linux/mempolicy.h +9 -4
@@ -22,9 +22,14 @@/* Flags for mbind */ #define MPOL_MF_STRICT (1<<0)/* Verify existing pages in the mapping */ -#define MPOL_MF_MOVE (1<<1)/* Move pages owned by this process to conform to mapping */ -#define MPOL_MF_MOVE_ALL (1<<2)/* Move every page to conform to mapping */ -#define MPOL_MF_INTERNAL (1<<3)/* Internal flags start here */ +#define MPOL_MF_MOVE (1<<1)/* Move pages owned by this process to conform +to policy */ +#define MPOL_MF_MOVE_ALL (1<<2)/* Move every page to conform to policy */ +#define MPOL_MF_LAZY (1<<3)/* Modifies '_MOVE: lazy migrate on fault */ +#define MPOL_MF_INTERNAL (1<<4)/* Internal flags start here */ + +#define MPOL_MF_VALID \ + (MPOL_MF_STRICT | MPOL_MF_MOVE | MPOL_MF_MOVE_ALL | MPOL_MF_LAZY)#ifdef __KERNEL__
@@ -179,7 +184,7 @@ int do_migrate_pages(struct mm_struct *m*/ #define MPOL_MIGRATE_NONINTERLEAVED 1#define MPOL_MIGRATE_INTERLEAVED 2 -#define misplaced_is_interleaved (pol) (MPOL_MIGRATE_INTERLEAVED - 1) +#define misplaced_is_interleaved (pol) (pol == MPOL_MIGRATE_INTERLEAVED)int mpol_misplaced (struct page *,struct vm_area_struct *,unsigned long ,int *);
mm/vmscan.c +61 -0
67 lines not on this page · raw message
mm/mempolicy.c +8 -5
@@ -744,9 +744,7 @@ long do_mbind(unsigned long start, unsigint err;LIST_HEAD (pagelist); -if ((flags & ~(unsigned long )(MPOL_MF_STRICT | -MPOL_MF_MOVE |MPOL_MF_MOVE_ALL )) - || mode >MPOL_MAX ) +if ((flags & ~(unsigned long )MPOL_MF_VALID ) || mode >MPOL_MAX )return -EINVAL ;if ((flags &MPOL_MF_MOVE_ALL ) && !capable (CAP_SYS_RESOURCE ))return -EPERM ;
@@ -792,8 +790,13 @@ long do_mbind(unsigned long start, unsig err =mbind_range (vma, start, end, new); -if (!list_empty (&pagelist)) - nr_failed =migrate_pages_to (&pagelist, vma,-1 ); +if (!list_empty (&pagelist)) { +if (!(flags &MPOL_MF_LAZY )) + nr_failed =migrate_pages_to (&pagelist, + vma,-1 ); +else + nr_failed =migrate_pages_unmap_only (&pagelist); + }if (!err && nr_failed && (flags &MPOL_MF_STRICT )) err = -EIO ;
include/linux/swap.h +1 -0
@@ -199,6 +199,7 @@ extern int migrate_page_unmap_and_replacextern int migrate_pages (struct list_head *l,struct list_head *t,struct list_head *moved,struct list_head *failed);struct page *migrate_misplaced_page (struct page *,int ,int ); +extern int migrate_pages_unmap_only (struct list_head *);extern int fail_migrate_page (struct page *,struct page *,int );#else static inline int isolate_lru_page (struct page *p) {return -ENOSYS ; }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>