Shared mmap [Take 3]
PATCH 1/1 Shared mmap [Take 3]
This patch changes shared mmaps of files to always be aligned at the same offset within the processor's d-cache. This fixes PA-RISC & MIPS. Sparc & IA-64 need some of their support changing, but I don't want to do that until everyone's had the chance to disagree with my changes :-)
Index: fs/inode.c
===================================================================
RCS file: /var/cvs/linux/fs/inode.c,v
retrieving revision 1.1.1.3
inode.c +1 -0
@@ -608,6 +608,7 @@ static void clean_inode(struct inode *in inode->i_data.a_ops = &empty_aops; inode->i_data.host = inode; inode->i_mapping = &inode->i_data; + inode->i_mmap_offset =-1 ; }/**
Index: include/linux/fs.h
===================================================================
RCS file: /var/cvs/linux/include/linux/fs.h,v
retrieving revision 1.1.1.4
linux/fs.h +1 -0
@@ -424,6 +424,7 @@ struct inode {unsigned long i_state; +unsigned int i_mmap_offset;/* Handle L1 d-cache aliasing */ unsigned int i_flags;unsigned char i_sock;
Index: include/linux/mm.h
===================================================================
RCS file: /var/cvs/linux/include/linux/mm.h,v
retrieving revision 1.1.1.4
linux/mm.h +1 -0
@@ -419,6 +419,7 @@ extern void insert_vm_struct(struct mm_sextern void __insert_vm_struct (struct mm_struct *,struct vm_area_struct *);extern void build_mmap_avl (struct mm_struct *);extern void exit_mmap (struct mm_struct *); +extern unsigned long get_shared_area (unsigned long ,unsigned long ,unsigned int );extern unsigned long get_unmapped_area (unsigned long ,unsigned long ); extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
Index: mm/mmap.c
===================================================================
RCS file: /var/cvs/linux/mm/mmap.c,v
retrieving revision 1.1.1.4
mmap.c +38 -4
87 lines not on this page · raw message
Index: mm/mremap.c
===================================================================
RCS file: /var/cvs/linux/mm/mremap.c,v
retrieving revision 1.1.1.4
mremap.c +5 -1
@@ -276,7 +276,11 @@ unsigned long do_mremap(unsigned long ad ret = -ENOMEM ;if (flags &MREMAP_MAYMOVE ) {if (!(flags &MREMAP_FIXED )) { - new_addr =get_unmapped_area (0 , new_len); +if (vma->vm_file && (vma->vm_flags &VM_SHARED )) { + new_addr =get_shared_area (0 , new_len, vma->vm_file->f_dentry->d_inode->i_mmap_offset); + }else { + new_addr =get_unmapped_area (0 , new_len); + }if (!new_addr) goto out; }
----- End forwarded message -----
Signature · 5 lines
Revolutions do not require corporate support. -- 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.eu.org/Linux-MM/
Quoted 5 lines · Matthew Wilcox
This patch changes shared mmaps of files to always be aligned at the same offset within the processor's d-cache. This fixes PA-RISC & MIPS. Sparc & IA-64 need some of their support changing, but I don't want to do that until everyone's had the chance to disagree with my changes :-)
What, no comment? no flames, no insults? is this an uncontroversial patch?
Anyway, I have some improvements.
* use inode->i_mapping->i_mmap_shared to determine whether there are any existing mappings rather than keeping track of it through i_mmap_offset.
* take `pgoff' into account. Oops, that was the whole point of the patch.
* ensure `offset' is limited to the range [0 .. SHMLBA)
this time it's actually tested on PA-RISC. Should work on MIPS too. Sparc & IA-64 will need work.
Index: include/linux/fs.h
===================================================================
RCS file: /home/cvs/parisc/linux/include/linux/fs.h,v retrieving revision 1.10
fs.h +1 -0
@@ -424,6 +424,7 @@ struct inode {unsigned long i_state; +unsigned int i_mmap_offset;/* Handle L1 d-cache aliasing */ unsigned int i_flags;unsigned char i_sock;
Index: include/linux/mm.h
===================================================================
RCS file: /home/cvs/parisc/linux/include/linux/mm.h,v retrieving revision 1.16
mm.h +1 -0
@@ -423,6 +423,7 @@ extern void insert_vm_struct(struct mm_sextern void __insert_vm_struct (struct mm_struct *,struct vm_area_struct *);extern void build_mmap_avl (struct mm_struct *);extern void exit_mmap (struct mm_struct *); +extern unsigned long get_shared_area (unsigned long ,unsigned long ,unsigned int );extern unsigned long get_unmapped_area (unsigned long ,unsigned long ); extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
Index: mm/mmap.c
===================================================================
RCS file: /home/cvs/parisc/linux/mm/mmap.c,v
retrieving revision 1.19
mmap.c +41 -6
95 lines not on this page · raw message
Index: mm/mremap.c
===================================================================
RCS file: /home/cvs/parisc/linux/mm/mremap.c,v
retrieving revision 1.7
mremap.c +5 -1
@@ -276,7 +276,11 @@ unsigned long do_mremap(unsigned long ad ret = -ENOMEM ;if (flags &MREMAP_MAYMOVE ) {if (!(flags &MREMAP_FIXED )) { - new_addr =get_unmapped_area (0 , new_len); +if (vma->vm_file && (vma->vm_flags &VM_SHARED )) { + new_addr =get_shared_area (0 , new_len, vma->vm_file->f_dentry->d_inode->i_mmap_offset + (vma->vm_pgoff <<PAGE_SHIFT )); + }else { + new_addr =get_unmapped_area (0 , new_len); + }if (!new_addr) goto out; }
_______________________________________________
parisc-linux-cvs mailing list
[email protected]
http://lists.parisc-linux.org/cgi-bin/mailman/listinfo/parisc-linux-cvs
Signature · 5 lines
Revolutions do not require corporate support. -- 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.eu.org/Linux-MM/