From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752346AbZGQTtU (ORCPT ); Fri, 17 Jul 2009 15:49:20 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752021AbZGQTtU (ORCPT ); Fri, 17 Jul 2009 15:49:20 -0400 Received: from g1t0026.austin.hp.com ([15.216.28.33]:2042 "EHLO g1t0026.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751858AbZGQTtT (ORCPT ); Fri, 17 Jul 2009 15:49:19 -0400 Subject: [PATCH] hugetlb: restore interleaving of bootmem huge pages From: Lee Schermerhorn To: Andrew Morton Cc: linux-kernel , stable , Andi Kleen , Mel Gorman , David Rientjes , Adam Litke , Andy Whitcroft , Eric Whitney Content-Type: text/plain Organization: HP/LKTT Date: Fri, 17 Jul 2009 15:49:14 -0400 Message-Id: <1247860154.11565.45.camel@useless.americas.hpqcorp.net> Mime-Version: 1.0 X-Mailer: Evolution 2.26.1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org PATCH fix distribution of bootmem huge pages Against: 2.6.31-rc3 For stable, applicable back through 2.6.27 [A version of this patch has been added to the -mm tree. That patch won't apply cleanly to mainline nor stable trees because of function renaming. This one should.] I noticed that alloc_bootmem_huge_page() will only advance to the next node on failure to allocate a huge page. I asked about this on linux-mm and linux-numa, cc'ing the usual huge page suspects. Mel Gorman responded: I strongly suspect that the same node being used until allocation failure instead of round-robin is an oversight and not deliberate at all. It appears to be a side-effect of a fix made way back in commit 63b4613c3f0d4b724ba259dc6c201bb68b884e1a ["hugetlb: fix hugepage allocation with memoryless nodes"]. Prior to that patch it looked like allocations would always round-robin even when allocation was successful. Andy Whitcroft countered that the existing behavior looked like Andi Kleen's original implementation and suggested that we ask him. We did and Andy replied that his intention was to interleave the allocations. So, ... This patch moves the advance of the hstate next node from which to allocate up before the test for success of the attempted allocation. This will unconditionally advance the next node from which to alloc, interleaving successful allocations over the nodes with sufficient contiguous memory, and skipping over nodes that fail the huge page allocation attempt. Note that alloc_bootmem_huge_page() will only be called for huge pages of order > MAX_ORDER. Signed-off-by: Lee Schermerhorn mm/hugetlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: linux-2.6.31-rc3-mmotm-090715-2057/mm/hugetlb.c =================================================================== --- linux-2.6.31-rc3-mmotm-090715-2057.orig/mm/hugetlb.c 2009-07-17 11:30:20.000000000 -0400 +++ linux-2.6.31-rc3-mmotm-090715-2057/mm/hugetlb.c 2009-07-17 11:37:30.000000000 -0400 @@ -1010,6 +1010,7 @@ int __weak alloc_bootmem_huge_page(struc NODE_DATA(h->hugetlb_next_nid), huge_page_size(h), huge_page_size(h), 0); + hstate_next_node(h); if (addr) { /* * Use the beginning of the huge page to store the @@ -1019,7 +1020,6 @@ int __weak alloc_bootmem_huge_page(struc m = addr; goto found; } - hstate_next_node(h); nr_nodes--; } return 0;