Page Cache Policy V0.0 2/5 move shared policy to inode
Subsystems (5)
Page Cache Policy V0.0 2/5 move shared policy to inode
This patch starts the process of generalizing the shmem shared [mem]policy infrastructure for use with generic mmap()ed files.
1) add a struct shared_policy pointer to the generic inode structure--actually to the address_space in i_data. We'll locate this via vma->vm_file->f_mapping->spolicy.
2) create a shared_policy.h header in anticipation of not needing all of mempolicy.h in some places that we'll use shared policies.
TODO: may not turn out to be the case. but might be nice
to have shared policy stuff in a separate header?
3) add [byte] start, end args to set_policy vma operation in anticipation of allowing multiple policies per vma for file/shmem mappings. Get file/shmem policies in terms of start,end instead of entire vma.
4) modify mbind_range() to allow set_policy() vma ops, if any, to handle policies on subranges of vma. I.e., don't split the vma at this level if mapping has set_policy() vma op set_policy() op could choose to do that. But, don't need to for generic "shared policies".
N.B. this breaks any assumptions about one policy per vma.
TODO: fix up display of numamaps for vma with multiple policy ranges.
5) modify shmem, the only existing user of shared policy infrastructure, to work with changes above. At this point, just use the shared_policy embedded in the shmem inode info struct. A later patch will dynamically allocate the struct when needed.
include/linux/fs.h +3 -0
@@ -391,6 +391,9 @@ struct address_space {struct address_space_operations *a_ops;/* methods */ unsigned long flags;/* error bits/gfp mask */ struct backing_dev_info *backing_dev_info;/* device readahead, etc */ +//TODO: #ifdef CONFIG_NUMA ??? +struct shared_policy *spolicy; +spinlock_t private_lock;/* for use by the address_space */ struct list_head private_list;/* ditto */ struct address_space *assoc_mapping;/* ditto */
include/linux/mempolicy.h +1 -53
76 lines not on this page · raw message
include/linux/shared_policy.h new file +65 -0
65 lines not on this page · raw message
include/linux/mm.h +12 -4
@@ -201,9 +201,10 @@ struct vm_operations_struct {struct page * (*nopage)(struct vm_area_struct * area,unsigned long address,int *type);int (*populate)(struct vm_area_struct * area,unsigned long address,unsigned long len,pgprot_t prot,unsigned long pgoff,int nonblock);#ifdef CONFIG_NUMA -int (*set_policy)(struct vm_area_struct *vma,struct mempolicy *new); -struct mempolicy *(*get_policy)(struct vm_area_struct *vma, -unsigned long addr); +int (*set_policy)(struct vm_area_struct *,unsigned long , +unsigned long ,struct mempolicy *); +struct mempolicy *(*get_policy)(struct vm_area_struct *, +unsigned long );#endif };
@@ -648,7 +649,8 @@ extern void show_free_areas(void);#ifdef CONFIG_SHMEM struct page *shmem_nopage (struct vm_area_struct *vma,unsigned long address,int *type); -int shmem_set_policy (struct vm_area_struct *vma,struct mempolicy *new); +int shmem_set_policy (struct vm_area_struct *,unsigned long ,unsigned long , +struct mempolicy *);struct mempolicy *shmem_get_policy (struct vm_area_struct *vma,unsigned long addr);int shmem_lock (struct file *file,int lock,struct user_struct *user);
@@ -1051,6 +1053,12 @@ static inline unsigned long vma_pages(streturn (vma->vm_end - vma->vm_start) >>PAGE_SHIFT ; } +static inline pgoff_t vma_addr_to_pgoff (struct vm_area_struct *vma, +unsigned long addr,int shift) +{ +return ((addr - vma->vm_start) >> shift) + vma->vm_pgoff; +} +struct vm_area_struct *find_extend_vma (struct mm_struct *,unsigned long addr);struct page *vmalloc_to_page (void *addr);unsigned long vmalloc_to_pfn (void *addr);
mm/mempolicy.c +50 -25
154 lines not on this page · raw message
mm/shmem.c +25 -26
144 lines not on this page · raw message
--
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>