The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] hugetlb_no_page might break hugetlb quota
@ 2006-03-06  6:21 Zhang, Yanmin
  2006-03-06  8:15 ` Chen, Kenneth W
  0 siblings, 1 reply; 13+ messages in thread
From: Zhang, Yanmin @ 2006-03-06  6:21 UTC (permalink / raw)
  To: linux-kernel@vger.kernel.org; +Cc: David Gibson, kenneth.w.chen

From: Zhang Yanmin <yanmin.zhang@intel.com>

In function hugetlb_no_page, backout path always calls hugetlb_put_quota.
It's incorrect when find_lock_page gets the page or the new page is added
into page cache.

In addition, if the vma->vm_flags doesn't include VM_SHARED, the quota
shouldn't be decreased.

My patch against 2.6.16-rc5-mm2 fixes it.

Signed-off-by: Zhang Yanmin <yanmin.zhang@intel.com>

---

diff -Nraup linux-2.6.16-rc5-mm2/mm/hugetlb.c linux-2.6.16-rc5-mm2_quota/mm/hugetlb.c
--- linux-2.6.16-rc5-mm2/mm/hugetlb.c	2006-03-06 18:48:18.000000000 +0800
+++ linux-2.6.16-rc5-mm2_quota/mm/hugetlb.c	2006-03-06 18:48:58.000000000 +0800
@@ -562,11 +562,12 @@ int hugetlb_no_page(struct mm_struct *mm
 retry:
 	page = find_lock_page(mapping, idx);
 	if (!page) {
-		if (hugetlb_get_quota(mapping))
+		if (vma->vm_flags & VM_SHARED && hugetlb_get_quota(mapping))
 			goto out;
 		page = alloc_huge_page(vma, address);
 		if (!page) {
-			hugetlb_put_quota(mapping);
+			if (vma->vm_flags & VM_SHARED)
+				hugetlb_put_quota(mapping);
 			ret = VM_FAULT_OOM;
 			goto out;
 		}
@@ -613,7 +614,6 @@ out:
 
 backout:
 	spin_unlock(&mm->page_table_lock);
-	hugetlb_put_quota(mapping);
 	unlock_page(page);
 	put_page(page);
 	goto out;



^ permalink raw reply	[flat|nested] 13+ messages in thread
* RE: [PATCH] ftruncate on huge page couldn't extend hugetlb file
@ 2006-03-08 19:03 Chen, Kenneth W
  0 siblings, 0 replies; 13+ messages in thread
From: Chen, Kenneth W @ 2006-03-08 19:03 UTC (permalink / raw)
  To: Zhang, Yanmin, Andrew Morton; +Cc: Chen, David Gibson, linux-kernel

Zhang, Yanmin wrote on Tuesday, March 07, 2006 10:54 PM
> From: Zhang Yanmin <yanmin.zhang@intel.com>
> 
> Currently, ftruncate on hugetlb files couldn't extend them. My patch
enables it.
> 
> This patch is against 2.6.16-rc5-mm3 and on the top of the patch which
> implements mmap on zero-length hugetlb files with PROT_NONE.

Reservation should be already done at the mmap time.
Like this?


Signed-off-by: Ken Chen <kenneth.w.chen@intel.com>

--- linux-2.6.15/fs/hugetlbfs/inode.c.orig	2006-03-08
11:39:49.782708398 -0800
+++ linux-2.6.15/fs/hugetlbfs/inode.c	2006-03-08 11:51:04.382309509
-0800
@@ -337,20 +337,18 @@ hugetlb_vmtruncate_list(struct prio_tree
 	}
 }
 
-/*
- * Expanding truncates are not allowed.
- */
 static int hugetlb_vmtruncate(struct inode *inode, loff_t offset)
 {
 	unsigned long pgoff;
 	struct address_space *mapping = inode->i_mapping;
 
-	if (offset > inode->i_size)
-		return -EINVAL;
-
 	BUG_ON(offset & ~HPAGE_MASK);
 	pgoff = offset >> HPAGE_SHIFT;
 
+	if (offset > inode->i_size) {
+		inode->i_size = offset;
+		return 0;
+	}
 	inode->i_size = offset;
 	spin_lock(&mapping->i_mmap_lock);
 	if (!prio_tree_empty(&mapping->i_mmap))

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2006-03-09  1:03 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-06  6:21 [PATCH] hugetlb_no_page might break hugetlb quota Zhang, Yanmin
2006-03-06  8:15 ` Chen, Kenneth W
2006-03-06  9:06   ` Zhang, Yanmin
2006-03-08  3:14     ` Zhang, Yanmin
2006-03-08  3:24       ` [PATCH] ftruncate on huge page couldn't extend hugetlb file Zhang, Yanmin
     [not found]         ` <20060307222148.76e5dc45.akpm@osdl.org>
2006-03-08  6:54           ` Zhang, Yanmin
2006-03-08 18:28         ` Chen, Kenneth W
2006-03-08 23:58           ` David Gibson
2006-03-09  0:12             ` Chen, Kenneth W
2006-03-09  0:22               ` 'David Gibson'
2006-03-09  0:33                 ` Chen, Kenneth W
2006-03-09  1:03                   ` 'David Gibson'
  -- strict thread matches above, loose matches on Subject: below --
2006-03-08 19:03 Chen, Kenneth W

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox