linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Adam Litke <agl@us.ibm.com>
To: Dave Hansen <haveblue@us.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>, linux-mm@kvack.org
Subject: Re: [PATCH] hugetlb: Fix dynamic pool resize failure case
Date: Wed, 10 Oct 2007 08:58:06 -0500	[thread overview]
Message-ID: <1192024686.19775.70.camel@localhost.localdomain> (raw)
In-Reply-To: <1191964844.31114.28.camel@localhost>

On Tue, 2007-10-09 at 14:20 -0700, Dave Hansen wrote:
> On Tue, 2007-10-09 at 08:58 -0700, Adam Litke wrote:
> > index 9b3dfac..f349c16 100644
> > --- a/mm/hugetlb.c
> > +++ b/mm/hugetlb.c
> > @@ -281,8 +281,11 @@ free:
> >  		list_del(&page->lru);
> >  		if ((--needed) >= 0)
> >  			enqueue_huge_page(page);
> > -		else
> > -			update_and_free_page(page);
> > +		else {
> > +			spin_unlock(&hugetlb_lock);
> > +			put_page(page);
> > +			spin_lock(&hugetlb_lock);
> > +		}
> >  	}
> 
> update_and_free_page() does several things:
> 1. it decrements nr_huge_pages(_node[])
> 2. it resets the member page flags to some known values
> 3. clears the compound page destructor
> 4. clears the page refcount (to 1)
> 5. actually frees the page back to the allocator
> 
> put_page() does several things, too:
> 1. put_page() hits PageCompound(), then calls put_compound_page()
> 2. put_compound_page() calls the compound page destructor which is set
>    to free_huge_page() (this was set in alloc_buddy_huge_page())
> 3. free_huge_page() checks page_count(), takes the hugetlb_lock, and
>    calls enqueue_huge_page()

Here's where I know your looking at different kernel source than this
was meant to patch :)

> 4. enqueue_huge_page() puts the page back in hugepage_freelists[nid],
>    then _increments_ nr_huge_pages(_node[])
> 
> This seems weird to me that you're replacing a function with something
> that eventually does the opposite.  update_and_free_page() also did
> nothing with the hugepage_freelists[], which enqueue_huge_page() does.
> Something doesn't quite add up here.  Did you realize that the destuctor
> was going to get called?  Or, did I misread it, and the destructor is
> _not_ called?

With my patches applied, free_huge_page() deals with both regular and
surplus pages.  When there is a surplus, the pool needs to gravitate
back to its configured size.  In that case, pages are freed to the buddy
allocator.  In the absence of a surplus, pages are dealt with in the way
you describe above.  So put_page() does _precisely_ what is needed in
this scenario.

> I also think it's a crime that alloc_buddy_huge_page() doesn't share
> code with alloc_fresh_huge_page().  

Different issue (unrelated to this patch), but I'll have a look and see
if I can consolidate them.

-- 
Adam Litke - (agl at us.ibm.com)
IBM Linux Technology Center

--
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-10 13:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-09 15:58 [PATCH] hugetlb: Fix dynamic pool resize failure case Adam Litke
2007-10-09 21:20 ` Dave Hansen
2007-10-10 13:58   ` Adam Litke [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-10-12 19:15 Adam Litke
2007-10-12 19:31 ` 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=1192024686.19775.70.camel@localhost.localdomain \
    --to=agl@us.ibm.com \
    --cc=akpm@linux-foundation.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).