Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756641Ab3GVOpy (ORCPT ); Mon, 22 Jul 2013 10:45:54 -0400 Received: from cantor2.suse.de ([195.135.220.15]:55892 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756196Ab3GVOpx (ORCPT ); Mon, 22 Jul 2013 10:45:53 -0400 Date: Mon, 22 Jul 2013 16:45:48 +0200 From: Michal Hocko To: Joonsoo Kim Cc: Andrew Morton , Rik van Riel , Mel Gorman , "Aneesh Kumar K.V" , KAMEZAWA Hiroyuki , Hugh Dickins , Davidlohr Bueso , David Gibson , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Joonsoo Kim Subject: Re: [PATCH 1/9] mm, hugetlb: move up the code which check availability of free huge page Message-ID: <20130722144548.GD24400@dhcp22.suse.cz> References: <1373881967-16153-1-git-send-email-iamjoonsoo.kim@lge.com> <1373881967-16153-2-git-send-email-iamjoonsoo.kim@lge.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1373881967-16153-2-git-send-email-iamjoonsoo.kim@lge.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2141 Lines: 69 On Mon 15-07-13 18:52:39, Joonsoo Kim wrote: > We don't need to proceede the processing if we don't have any usable > free huge page. So move this code up. > > Signed-off-by: Joonsoo Kim Acked-by: Michal Hocko after you add a note about hugetlb_lock which stabilizes hstate so the retry doesn't have to re-check reserves and other stuff as suggested by Aneesh. > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index e2bfbf7..d87f70b 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -539,10 +539,6 @@ static struct page *dequeue_huge_page_vma(struct hstate *h, > struct zoneref *z; > unsigned int cpuset_mems_cookie; > > -retry_cpuset: > - cpuset_mems_cookie = get_mems_allowed(); > - zonelist = huge_zonelist(vma, address, > - htlb_alloc_mask, &mpol, &nodemask); > /* > * A child process with MAP_PRIVATE mappings created by their parent > * have no page reserves. This check ensures that reservations are > @@ -550,11 +546,16 @@ retry_cpuset: > */ > if (!vma_has_reserves(vma) && > h->free_huge_pages - h->resv_huge_pages == 0) > - goto err; > + return NULL; > > /* If reserves cannot be used, ensure enough pages are in the pool */ > if (avoid_reserve && h->free_huge_pages - h->resv_huge_pages == 0) > - goto err; > + return NULL; > + > +retry_cpuset: > + cpuset_mems_cookie = get_mems_allowed(); > + zonelist = huge_zonelist(vma, address, > + htlb_alloc_mask, &mpol, &nodemask); > > for_each_zone_zonelist_nodemask(zone, z, zonelist, > MAX_NR_ZONES - 1, nodemask) { > @@ -572,10 +573,6 @@ retry_cpuset: > if (unlikely(!put_mems_allowed(cpuset_mems_cookie) && !page)) > goto retry_cpuset; > return page; > - > -err: > - mpol_cond_put(mpol); > - return NULL; > } > > static void update_and_free_page(struct hstate *h, struct page *page) > -- > 1.7.9.5 > -- Michal Hocko SUSE Labs -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/