hugetlb changes in -mm
Subsystems (6)
Guys, I've queued up the four attached patches in -mm. They're fairly significant, possibly controversial, possibly even unfeasible on ppc64?
I'd ask that you take a look sometime. It's not 2.6.5 material, so no huge rush.
Thanks.
From: Andy Whitcroft <[email protected]>
Handle hugetlb commitment tracking. Track commitments against the fixed hugetlb page pool created by shm and mmap activity. Ensure that we never commit more pages than available even when the pages are not allocated immediatly, for example when created via shmget(). By separating commitment from allocation it provide the necessary framework to allow allocation on first reference under demang page instantiation and for NUMA placement.
---
25-akpm/arch/i386/mm/hugetlbpage.c | 7 25-akpm/arch/ia64/mm/hugetlbpage.c | 7 25-akpm/arch/ppc64/mm/hugetlbpage.c | 7 25-akpm/arch/sh/mm/hugetlbpage.c | 7 25-akpm/arch/sparc64/mm/hugetlbpage.c | 7 25-akpm/fs/hugetlbfs/inode.c | 254 ++++++++++++++++++++++++++++++++-- 25-akpm/fs/proc/proc_misc.c | 1 25-akpm/include/linux/hugetlb.h | 7 8 files changed, 249 insertions(+), 48 deletions(-)
arch/i386/mm/hugetlbpage.c renamed from arch/i386/mm/hugetlbpage.c~hugetlb-commitment-tracking-patch +0 -7
@@ -263,21 +263,14 @@ int hugetlb_prefault(struct address_spac + (vma->vm_pgoff >> (HPAGE_SHIFT -PAGE_SHIFT )); page =find_get_page (mapping, idx);if (!page) { -/* charge the fs quota first */ -if (hugetlb_get_quota (mapping)) { - ret = -ENOMEM ; - goto out; - } page =alloc_huge_page ();if (!page) { -hugetlb_put_quota (mapping); ret = -ENOMEM ; goto out; } ret =add_to_page_cache (page, mapping, idx,GFP_ATOMIC );unlock_page (page);if (ret) { -hugetlb_put_quota (mapping);free_huge_page (page); goto out; }
arch/ia64/mm/hugetlbpage.c renamed from arch/ia64/mm/hugetlbpage.c~hugetlb-commitment-tracking-patch +0 -7
@@ -284,21 +284,14 @@ int hugetlb_prefault(struct address_spac + (vma->vm_pgoff >> (HPAGE_SHIFT -PAGE_SHIFT )); page =find_get_page (mapping, idx);if (!page) { -/* charge the fs quota first */ -if (hugetlb_get_quota (mapping)) { - ret = -ENOMEM ; - goto out; - } page =alloc_huge_page ();if (!page) { -hugetlb_put_quota (mapping); ret = -ENOMEM ; goto out; } ret =add_to_page_cache (page, mapping, idx,GFP_ATOMIC );unlock_page (page);if (ret) { -hugetlb_put_quota (mapping);free_huge_page (page); goto out; }
arch/ppc64/mm/hugetlbpage.c renamed from arch/ppc64/mm/hugetlbpage.c~hugetlb-commitment-tracking-patch +0 -7
@@ -438,21 +438,14 @@ int hugetlb_prefault(struct address_spac + (vma->vm_pgoff >> (HPAGE_SHIFT -PAGE_SHIFT )); page =find_get_page (mapping, idx);if (!page) { -/* charge the fs quota first */ -if (hugetlb_get_quota (mapping)) { - ret = -ENOMEM ; - goto out; - } page =alloc_huge_page ();if (!page) { -hugetlb_put_quota (mapping); ret = -ENOMEM ; goto out; } ret =add_to_page_cache (page, mapping, idx,GFP_ATOMIC );unlock_page (page);if (ret) { -hugetlb_put_quota (mapping);free_huge_page (page); goto out; }
arch/sh/mm/hugetlbpage.c renamed from arch/sh/mm/hugetlbpage.c~hugetlb-commitment-tracking-patch +0 -7
@@ -242,21 +242,14 @@ int hugetlb_prefault(struct address_spac + (vma->vm_pgoff >> (HPAGE_SHIFT -PAGE_SHIFT )); page =find_get_page (mapping, idx);if (!page) { -/* charge the fs quota first */ -if (hugetlb_get_quota (mapping)) { - ret = -ENOMEM ; - goto out; - } page =alloc_huge_page ();if (!page) { -hugetlb_put_quota (mapping); ret = -ENOMEM ; goto out; } ret =add_to_page_cache (page, mapping, idx,GFP_ATOMIC );unlock_page (page);if (ret) { -hugetlb_put_quota (mapping);free_huge_page (page); goto out; }
arch/sparc64/mm/hugetlbpage.c renamed from arch/sparc64/mm/hugetlbpage.c~hugetlb-commitment-tracking-patch +0 -7
@@ -239,21 +239,14 @@ int hugetlb_prefault(struct address_spac + (vma->vm_pgoff >> (HPAGE_SHIFT -PAGE_SHIFT )); page =find_get_page (mapping, idx);if (!page) { -/* charge the fs quota first */ -if (hugetlb_get_quota (mapping)) { - ret = -ENOMEM ; - goto out; - } page =alloc_huge_page ();if (!page) { -hugetlb_put_quota (mapping); ret = -ENOMEM ; goto out; } ret =add_to_page_cache (page, mapping, idx,GFP_ATOMIC );unlock_page (page);if (ret) { -hugetlb_put_quota (mapping);free_huge_page (page); goto out; }
fs/hugetlbfs/inode.c renamed from fs/hugetlbfs/inode.c~hugetlb-commitment-tracking-patch +243 -11
342 lines not on this page · raw message
fs/proc/proc_misc.c renamed from fs/proc/proc_misc.c~hugetlb-commitment-tracking-patch +1 -0
@@ -231,6 +231,7 @@ static int meminfo_read_proc(char *page, vmi.largest_chunk ); + len +=hugetlbfs_report_meminfo (page + len); len +=hugetlb_report_meminfo (page + len);return proc_calc_metrics (page, start, off, count, eof, len);
include/linux/hugetlb.h renamed from include/linux/hugetlb.h~hugetlb-commitment-tracking-patch +5 -2
@@ -129,8 +129,8 @@ static inline struct hugetlbfs_sb_info *extern struct file_operations hugetlbfs_file_operations;extern struct vm_operations_struct hugetlb_vm_ops;struct file *hugetlb_zero_setup (size_t ); -int hugetlb_get_quota (struct address_space *mapping); -void hugetlb_put_quota (struct address_space *mapping); +int hugetlb_get_quota (struct address_space *mapping,int blocks); +void hugetlb_put_quota (struct address_space *mapping,int blocks);static inline int is_file_hugepages (struct file *file) {
@@ -141,11 +141,14 @@ static inline void set_file_hugepages(st { file->f_op = &hugetlbfs_file_operations; } +int hugetlbfs_report_meminfo (char *); +#else /* !CONFIG_HUGETLBFS */ #define is_file_hugepages (file) 0#define set_file_hugepages (file) BUG()#define hugetlb_zero_setup (size) ERR_PTR(-ENOSYS) +#define hugetlbfs_report_meminfo (buf) 0#endif /* !CONFIG_HUGETLBFS */
_
From: "Chen, Kenneth W" <[email protected]>
With demand paging, we can not unconditionally assume valid pmd/pte. Fix it up in arch specific huge_pge_offset() and have all caller check the return value.
---
25-akpm/arch/i386/mm/hugetlbpage.c | 11 +++++++---- 25-akpm/arch/ia64/mm/hugetlbpage.c | 18 ++++++++++++------ 25-akpm/arch/sh/mm/hugetlbpage.c | 15 +++++++-------- 25-akpm/arch/sparc64/mm/hugetlbpage.c | 15 +++++++-------- 4 files changed, 33 insertions(+), 26 deletions(-)
arch/i386/mm/hugetlbpage.c renamed from arch/i386/mm/hugetlbpage.c~hugetlb_fix_pte +7 -4
@@ -36,7 +36,8 @@ static pte_t *huge_pte_offset(struct mm_pmd_t *pmd =NULL ; pgd =pgd_offset (mm, addr); - pmd =pmd_offset (pgd, addr); +if (pgd_present (*pgd)) + pmd =pmd_offset (pgd, addr);return (pte_t *) pmd; }
@@ -75,11 +76,13 @@ int copy_hugetlb_page_range(struct mm_stunsigned long addr = vma->vm_start;unsigned long end = vma->vm_end; -while (addr < end) { +for (; addr < end; addr+=HPAGE_SIZE ) { + src_pte =huge_pte_offset (src, addr); +if (!src_pte ||pte_none (*src_pte)) +continue ; dst_pte =huge_pte_alloc (dst, addr);if (!dst_pte) goto nomem; - src_pte =huge_pte_offset (src, addr); entry = *src_pte; ptepage =pte_page (entry);get_page (ptepage);
@@ -227,7 +230,7 @@ void unmap_hugepage_range(struct vm_areafor (address = start; address < end; address +=HPAGE_SIZE ) { pte =huge_pte_offset (mm, address); -if (pte_none (*pte)) +if (!pte ||pte_none (*pte))continue ; page =pte_page (*pte);huge_page_release (page);
arch/ia64/mm/hugetlbpage.c renamed from arch/ia64/mm/hugetlbpage.c~hugetlb_fix_pte +12 -6
@@ -49,8 +49,11 @@ huge_pte_offset (struct mm_struct *mm, upte_t *pte =NULL ; pgd =pgd_offset (mm, taddr); - pmd =pmd_offset (pgd, taddr); - pte =pte_offset_map (pmd, taddr); +if (pgd_present (*pgd)) { + pmd =pmd_offset (pgd, taddr); +if (pmd_present (*pmd)) + pte =pte_offset_map (pmd, taddr); + }return pte; }
@@ -96,17 +99,18 @@ int copy_hugetlb_page_range(struct mm_stunsigned long addr = vma->vm_start;unsigned long end = vma->vm_end; -while (addr < end) { +for (; addr < end; addr +=HPAGE_SIZE ) { + src_pte =huge_pte_offset (src, addr); +if (!src_pte ||pte_none (*src_pte)) +continue ; dst_pte =huge_pte_alloc (dst, addr);if (!dst_pte) goto nomem; - src_pte =huge_pte_offset (src, addr); entry = *src_pte; ptepage =pte_page (entry);get_page (ptepage);set_pte (dst_pte, entry); dst->rss += (HPAGE_SIZE /PAGE_SIZE ); - addr +=HPAGE_SIZE ; }return 0 ; nomem:
@@ -168,6 +172,8 @@ struct page *follow_huge_addr(struct mm_pte_t *ptep; ptep =huge_pte_offset (mm, addr); +if (!ptep ||pte_none (*ptep)) +return NULL ; page =pte_page (*ptep); page += ((addr & ~HPAGE_MASK ) >>PAGE_SHIFT );get_page (page);
@@ -248,7 +254,7 @@ void unmap_hugepage_range(struct vm_areafor (address = start; address < end; address +=HPAGE_SIZE ) { pte =huge_pte_offset (mm, address); -if (pte_none (*pte)) +if (!pte ||pte_none (*pte))continue ; page =pte_page (*pte);huge_page_release (page);
arch/sh/mm/hugetlbpage.c renamed from arch/sh/mm/hugetlbpage.c~hugetlb_fix_pte +7 -8
@@ -46,9 +46,9 @@ static pte_t *huge_pte_offset(struct mm_pte_t *pte =NULL ; pgd =pgd_offset (mm, addr); -if (pgd) { +if (pgd_present (*pgd)) { pmd =pmd_offset (pgd, addr); -if (pmd) +if (pmd_present (*pmd)) pte =pte_offset_map (pmd, addr); }return pte;
@@ -101,12 +101,13 @@ int copy_hugetlb_page_range(struct mm_stunsigned long end = vma->vm_end;int i; -while (addr < end) { +for (; addr < end; addr +=HPAGE_SIZE ) { + src_pte =huge_pte_offset (src, addr); +if (!src_pte ||pte_none (*src_pte)) +continue ; dst_pte =huge_pte_alloc (dst, addr);if (!dst_pte) goto nomem; - src_pte =huge_pte_offset (src, addr); -BUG_ON (!src_pte ||pte_none (*src_pte)); entry = *src_pte; ptepage =pte_page (entry);get_page (ptepage);
@@ -116,7 +117,6 @@ int copy_hugetlb_page_range(struct mm_st dst_pte++; } dst->rss += (HPAGE_SIZE /PAGE_SIZE ); - addr +=HPAGE_SIZE ; }return 0 ;
@@ -202,8 +202,7 @@ void unmap_hugepage_range(struct vm_areafor (address = start; address < end; address +=HPAGE_SIZE ) { pte =huge_pte_offset (mm, address); -BUG_ON (!pte); -if (pte_none (*pte)) +if (!pte ||pte_none (*pte))continue ; page =pte_page (*pte);huge_page_release (page);
arch/sparc64/mm/hugetlbpage.c renamed from arch/sparc64/mm/hugetlbpage.c~hugetlb_fix_pte +7 -8
@@ -43,9 +43,9 @@ static pte_t *huge_pte_offset(struct mm_pte_t *pte =NULL ; pgd =pgd_offset (mm, addr); -if (pgd) { +if (pgd_present (*pgd)) { pmd =pmd_offset (pgd, addr); -if (pmd) +if (pmd_present (*pmd)) pte =pte_offset_map (pmd, addr); }return pte;
@@ -98,12 +98,13 @@ int copy_hugetlb_page_range(struct mm_stunsigned long end = vma->vm_end;int i; -while (addr < end) { +for (; addr < end; addr +=HPAGE_SIZE ) { + src_pte =huge_pte_offset (src, addr); +if (!src_pte ||pte_none (*src_pte)) +continue ; dst_pte =huge_pte_alloc (dst, addr);if (!dst_pte) goto nomem; - src_pte =huge_pte_offset (src, addr); -BUG_ON (!src_pte ||pte_none (*src_pte)); entry = *src_pte; ptepage =pte_page (entry);get_page (ptepage);
@@ -113,7 +114,6 @@ int copy_hugetlb_page_range(struct mm_st dst_pte++; } dst->rss += (HPAGE_SIZE /PAGE_SIZE ); - addr +=HPAGE_SIZE ; }return 0 ;
@@ -199,8 +199,7 @@ void unmap_hugepage_range(struct vm_areafor (address = start; address < end; address +=HPAGE_SIZE ) { pte =huge_pte_offset (mm, address); -BUG_ON (!pte); -if (pte_none (*pte)) +if (!pte ||pte_none (*pte))continue ; page =pte_page (*pte);huge_page_release (page);
_
From: "Chen, Kenneth W" <[email protected]>
This handles bulk of hugetlb demand paging for generic portion of the kernel. I've put hugetlb fault handler in mm/hugetlbpage.c since the fault handler is *exactly* the same for all arch, but that requires opening up huge_pte_alloc() and set_huge_pte() functions in each arch.
---
25-akpm/fs/hugetlbfs/inode.c | 18 ++---------- 25-akpm/include/linux/hugetlb.h | 9 +++--- 25-akpm/mm/hugetlb.c | 56 +++++++++++++++++++++++++++++++++++++--- 25-akpm/mm/memory.c | 7 ----- 4 files changed, 62 insertions(+), 28 deletions(-)
fs/hugetlbfs/inode.c renamed from fs/hugetlbfs/inode.c~hugetlb_demand_generic +4 -14
@@ -218,11 +218,6 @@ static int hugetlb_acct_commit(struct in {return region_add (&inode->i_mapping->private_list, from, to); } -static void hugetlb_acct_undo (struct inode *inode,int chg) -{ -hugetlb_put_quota (inode->i_mapping, chg); -hugetlb_acct_memory (-chg); -}static void hugetlb_acct_release (struct inode *inode,int to) {int chg;
@@ -252,9 +247,8 @@ static struct backing_dev_info hugetlbfsstatic int hugetlbfs_file_mmap (struct file *file,struct vm_area_struct *vma) {struct inode *inode = file->f_dentry->d_inode; -struct address_space *mapping = inode->i_mapping;loff_t len, vma_len; -int ret; +int ret =0 ;int chg;if (vma->vm_start & ~HPAGE_MASK )
@@ -281,15 +275,11 @@ static int hugetlbfs_file_mmap(struct fifile_accessed (file); vma->vm_flags |=VM_HUGETLB |VM_RESERVED ; vma->vm_ops = &hugetlb_vm_ops; - ret =hugetlb_prefault (mapping, vma); len = vma_len + ((loff_t )vma->vm_pgoff <<PAGE_SHIFT ); -if (ret ==0 ) { -if (inode->i_size < len) - inode->i_size = len; -hugetlb_acct_commit (inode,VMACCTPG (vma->vm_pgoff), +if (inode->i_size < len) + inode->i_size = len; +hugetlb_acct_commit (inode,VMACCTPG (vma->vm_pgoff),VMACCTPG (vma->vm_pgoff + (vma_len >>PAGE_SHIFT ))); - }else -hugetlb_acct_undo (inode, chg); unlock_out:up (&inode->i_sem);
include/linux/hugetlb.h renamed from include/linux/hugetlb.h~hugetlb_demand_generic +5 -4
@@ -14,10 +14,12 @@ static inline int is_vm_hugetlb_page(strint hugetlb_sysctl_handler (struct ctl_table *,int ,struct file *,void *,size_t *);int copy_hugetlb_page_range (struct mm_struct *,struct mm_struct *,struct vm_area_struct *); -int follow_hugetlb_page (struct mm_struct *,struct vm_area_struct *,struct page **,struct vm_area_struct **,unsigned long *,int *,int );void zap_hugepage_range (struct vm_area_struct *,unsigned long ,unsigned long );void unmap_hugepage_range (struct vm_area_struct *,unsigned long ,unsigned long ); -int hugetlb_prefault (struct address_space *,struct vm_area_struct *); +pte_t *huge_pte_alloc (struct mm_struct *,unsigned long ); +void set_huge_pte (struct mm_struct *,struct vm_area_struct *,struct page *,pte_t *,int ); +int handle_hugetlb_mm_fault (struct mm_struct *,struct vm_area_struct *, +unsigned long ,int );void huge_page_release (struct page *);int hugetlb_report_meminfo (char *);int is_hugepage_mem_enough (size_t );
@@ -66,10 +68,9 @@ static inline unsigned long hugetlb_totareturn 0 ; } -#define follow_hugetlb_page (m,v,p,vs,a,b,i) ({ BUG(); 0; })#define follow_huge_addr (mm, vma, addr, write) 0#define copy_hugetlb_page_range (src, dst, vma) ({ BUG(); 0; }) -#define hugetlb_prefault (mapping, vma) ({ BUG(); 0; }) +#define handle_hugetlb_mm_fault (mm, vma, addr, write) ({ BUG(); 0; })#define zap_hugepage_range (vma, start, len) BUG()#define unmap_hugepage_range (vma, start, end) BUG()#define huge_page_release (page) BUG()
mm/hugetlb.c renamed from mm/hugetlb.c~hugetlb_demand_generic +52 -4
69 lines not on this page · raw message
mm/memory.c renamed from mm/memory.c~hugetlb_demand_generic +1 -6
@@ -800,11 +800,6 @@ int get_user_pages(struct task_struct *tif ((pages && vm_io) || !(flags & vma->vm_flags))return i ? : -EFAULT ; -if (is_vm_hugetlb_page (vma)) { - i =follow_hugetlb_page (mm, vma, pages, vmas, - &start, &len, i); -continue ; - }spin_lock (&mm->page_table_lock); do { struct page *map = NULL;
@@ -1748,7 +1743,7 @@ int handle_mm_fault(struct mm_struct *mminc_page_state (pgfault);if (is_vm_hugetlb_page (vma)) -return VM_FAULT_SIGBUS ;/* mapping truncation does this. */ +return handle_hugetlb_mm_fault (mm, vma, address, write_access);/* * We need the page table lock to synchronize with kswapd
_
From: "Chen, Kenneth W" <[email protected]>
This adds additional arch specific fixes for x86 and ia64 when generic demand paging is turned on. Also bulk of the patch is to clean up with functions that no longer needed.
---
25-akpm/arch/i386/mm/hugetlbpage.c | 148 ---------------------------------- 25-akpm/arch/ia64/mm/hugetlbpage.c | 93 --------------------- 25-akpm/arch/sh/mm/hugetlbpage.c | 94 --------------------- 25-akpm/arch/sparc64/mm/hugetlbpage.c | 94 --------------------- 4 files changed, 10 insertions(+), 419 deletions(-)
arch/i386/mm/hugetlbpage.c renamed from arch/i386/mm/hugetlbpage.c~hugetlb_demand_arch +4 -144
185 lines not on this page · raw message
arch/ia64/mm/hugetlbpage.c renamed from arch/ia64/mm/hugetlbpage.c~hugetlb_demand_arch +2 -91
129 lines not on this page · raw message
arch/sh/mm/hugetlbpage.c renamed from arch/sh/mm/hugetlbpage.c~hugetlb_demand_arch +2 -92
121 lines not on this page · raw message
arch/sparc64/mm/hugetlbpage.c renamed from arch/sparc64/mm/hugetlbpage.c~hugetlb_demand_arch +2 -92
121 lines not on this page · raw message
_