linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Ken Chen" <kenchen@google.com>
To: Dave Hansen <haveblue@us.ibm.com>
Cc: Adam Litke <agl@us.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, Andy Whitcroft <apw@shadowen.org>
Subject: Re: [PATCH 1/3] [FIX] hugetlb: Fix broken fs quota management
Date: Wed, 24 Oct 2007 22:20:30 -0700	[thread overview]
Message-ID: <b040c32a0710242220w615be4f0kd34f86a9d9b048c5@mail.gmail.com> (raw)
In-Reply-To: <1193263944.4039.87.camel@localhost>

On 10/24/07, Dave Hansen <haveblue@us.ibm.com> wrote:
> But, I think what I'm realizing is that the free paths for shared vs.
> private are actually quite distinct.  Even more now after your patches
> abolish using and actual put_page() (and the destructors) on private
> pages losing their last mapping.
>
> I think it may make a lot of sense to have
> {alloc,free}_{private,shared}_huge_page().  It'll really help
> readability, and I _think_ it gives you a handy dandy place to add the
> different quota operations needed.

Here is my version of re-factoring hugetlb_put_quota() into
free_huge_page.  Not exactly what Dave suggested, but at least
consolidate quota credit in one place.


diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 12aca8e..6513f56 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -364,7 +364,6 @@ static void truncate_hugepages(
 			++next;
 			truncate_huge_page(page);
 			unlock_page(page);
-			hugetlb_put_quota(mapping);
 			freed++;
 		}
 		huge_pagevec_release(&pvec);
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 8b809ec..70c58cd 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -116,6 +116,9 @@
  static void free_huge_page(struct page *page)
 {
  	int nid = page_to_nid(page);
+	struct address_space *mapping;
+
+	mapping = (struct address_space *) page_private(page);

 	BUG_ON(page_count(page));
  	INIT_LIST_HEAD(&page->lru);
@@ -129,6 +132,9 @@ static void free_huge_page(struct page *page)
 		enqueue_huge_page(page);
 	}
 	spin_unlock(&hugetlb_lock);
+	if (mapping)
+		hugetlb_put_quota(mapping);
+	set_page_private(page, 0);
 }

 /*
@@ -369,6 +375,7 @@ static struct page *alloc_huge_page(

 	spin_unlock(&hugetlb_lock);
 	set_page_refcounted(page);
+	set_page_private(page, (unsigned long) vma->vm_file->f_mapping);
 	return page;

 fail:
@@ -382,6 +389,8 @@ fail:
 	if (!use_reserved_page)
  		page = alloc_buddy_huge_page(vma, addr);

+	if (page)
+		set_page_private(page, (unsigned long) vma->vm_file->f_mapping);
 	return page;
 }

@@ -788,7 +797,6 @@ retry:
  			err = add_to_page_cache(page, mapping, idx, GFP_KERNEL);
 			if (err) {
 				put_page(page);
-				hugetlb_put_quota(mapping);
  				if (err == -EEXIST)
  					goto retry;
  				goto out;
@@ -822,7 +830,6 @@ out:

  backout:
 	spin_unlock(&mm->page_table_lock);
-	hugetlb_put_quota(mapping);
 	unlock_page(page);
 	put_page(page);
  	goto out;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2007-10-25  5:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-24 13:23 [PATCH 0/3] hugetlb: Fix up filesystem quota accounting Adam Litke
2007-10-24 13:23 ` [PATCH 1/3] [FIX] hugetlb: Fix broken fs quota management Adam Litke
2007-10-24 18:43   ` Dave Hansen
2007-10-24 19:03     ` Adam Litke
2007-10-24 19:18       ` Dave Hansen
2007-10-24 19:21       ` Ken Chen
2007-10-24 20:02         ` Adam Litke
2007-10-24 22:12           ` Dave Hansen
2007-10-25  5:20             ` Ken Chen [this message]
2007-10-25 14:54               ` Adam Litke
2007-10-24 13:23 ` [PATCH 2/3] hugetlb: Allow bulk updating in hugetlb_*_quota() Adam Litke
2007-10-24 13:24 ` [PATCH 3/3] [PATCH] hugetlb: Enforce quotas during reservation for shared mappings Adam Litke
2007-10-24 19:07   ` Dave Hansen
2007-10-24 19:52     ` Adam Litke
2007-10-24 20:00       ` Dave Hansen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b040c32a0710242220w615be4f0kd34f86a9d9b048c5@mail.gmail.com \
    --to=kenchen@google.com \
    --cc=agl@us.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=apw@shadowen.org \
    --cc=haveblue@us.ibm.com \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).