From patchwork Fri Feb 27 22:17:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Rientjes X-Patchwork-Id: 444511 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 473CD14007D for ; Sat, 28 Feb 2015 09:18:21 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=google.com header.i=@google.com header.b=g1tmaNE/; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755817AbbB0WR0 (ORCPT ); Fri, 27 Feb 2015 17:17:26 -0500 Received: from mail-ie0-f169.google.com ([209.85.223.169]:34947 "EHLO mail-ie0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755814AbbB0WRY (ORCPT ); Fri, 27 Feb 2015 17:17:24 -0500 Received: by iecrl12 with SMTP id rl12so34601534iec.2 for ; Fri, 27 Feb 2015 14:17:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version:content-type; bh=TaLuK2Impbr64cHlgBGrnADsQg1yM6eR98eknS3IcKE=; b=g1tmaNE/hl/129GWC741FUzjrarJW1jNk9AFPjZZEE0aLv1Rei3VwXMOnqRZCswq02 M9/yxaiznj2MAp8brzju1ZWGHfd9iPyfXdv1ptaUKZSidW5jItUYyKRB1qoD0Glua/MV UdTFbHfLEWGilyvKNjHn+8HKlKBVjtxQvPsaY1yKms7qfGksvo3yT9FlUBns6MbXxyFX 9LxIynmUzG6PLElyDWFtuWeJS4wen4MQp9EnZ1ybARx9eJozWIZ4Zg/h6SYcbIf11vPl qKEmkvbOu/c64hj/Oycfa6PjA9WxcVbEzaiuHjgGzZLPUgf9lQpveaURgH9/Q5Dmg+0D K0Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version:content-type; bh=TaLuK2Impbr64cHlgBGrnADsQg1yM6eR98eknS3IcKE=; b=f44znZ0dZ1wfftjh2Lr03WrjRa1UUOGitKRpM7rsy9Z5a36XibE6y5oiX8AaxhUNJv rDhpovzF//BeCTv1OLv9dSG2JH7tYzLBaYcU1oSGgpBuesUTut2a2fE79We45z/UcQck uwTuhftFuNRGBjUxgV7c3cAC/5o5JuyYyn7gX9Qb+y3piv8A74kDZXz3wav/1jgOT8Yc 9NMmvZMy9Kadd2HG3djp8d18zZtpUdjISUBug40tpkzOrc1stN6AxJ5/vef7uSCmnEPY XAWLIQLtHCLtlm4R2aeQCh/yJtJmCSUbN26gCpRwrMnMTGfXvqXbZ0sjvqmOVCmUXQXx DPzg== X-Gm-Message-State: ALoCoQkAsDmkmQFkJ/gL0wd3vAhGiwas58Q/7skCqPlpnAhwBuWpdEMLsJGD3E/jB+70/m3nFACH X-Received: by 10.42.28.199 with SMTP id o7mr18257088icc.23.1425075443849; Fri, 27 Feb 2015 14:17:23 -0800 (PST) Received: from [2620:0:1008:1101:5857:11a:6e14:dd84] ([2620:0:1008:1101:5857:11a:6e14:dd84]) by mx.google.com with ESMTPSA id g20sm2019253igt.14.2015.02.27.14.17.22 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Feb 2015 14:17:23 -0800 (PST) Date: Fri, 27 Feb 2015 14:17:21 -0800 (PST) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Andrew Morton cc: Vlastimil Babka , Christoph Lameter , Pekka Enberg , Joonsoo Kim , Johannes Weiner , Mel Gorman , Pravin Shelar , Jarno Rajahalme , Li Zefan , Greg Thelen , linux-kernel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, cgroups@vger.kernel.org, dev@openvswitch.org Subject: [patch v2 2/3] mm, thp: really limit transparent hugepage allocation to local node In-Reply-To: Message-ID: References: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Commit 077fcf116c8c ("mm/thp: allocate transparent hugepages on local node") restructured alloc_hugepage_vma() with the intent of only allocating transparent hugepages locally when there was not an effective interleave mempolicy. alloc_pages_exact_node() does not limit the allocation to the single node, however, but rather prefers it. This is because __GFP_THISNODE is not set which would cause the node-local nodemask to be passed. Without it, only a nodemask that prefers the local node is passed. Fix this by passing __GFP_THISNODE and falling back to small pages when the allocation fails. Commit 9f1b868a13ac ("mm: thp: khugepaged: add policy for finding target node") suffers from a similar problem for khugepaged, which is also fixed. Fixes: 077fcf116c8c ("mm/thp: allocate transparent hugepages on local node") Fixes: 9f1b868a13ac ("mm: thp: khugepaged: add policy for finding target node") Signed-off-by: David Rientjes Acked-by: Vlastimil Babka --- mm/huge_memory.c | 9 +++++++-- mm/mempolicy.c | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/mm/huge_memory.c b/mm/huge_memory.c --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2311,8 +2311,14 @@ static struct page struct vm_area_struct *vma, unsigned long address, int node) { + gfp_t flags; + VM_BUG_ON_PAGE(*hpage, *hpage); + /* Only allocate from the target node */ + flags = alloc_hugepage_gfpmask(khugepaged_defrag(), __GFP_OTHER_NODE) | + __GFP_THISNODE; + /* * Before allocating the hugepage, release the mmap_sem read lock. * The allocation can take potentially a long time if it involves @@ -2321,8 +2327,7 @@ static struct page */ up_read(&mm->mmap_sem); - *hpage = alloc_pages_exact_node(node, alloc_hugepage_gfpmask( - khugepaged_defrag(), __GFP_OTHER_NODE), HPAGE_PMD_ORDER); + *hpage = alloc_pages_exact_node(node, flags, HPAGE_PMD_ORDER); if (unlikely(!*hpage)) { count_vm_event(THP_COLLAPSE_ALLOC_FAILED); *hpage = ERR_PTR(-ENOMEM); diff --git a/mm/mempolicy.c b/mm/mempolicy.c --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1985,7 +1985,8 @@ retry_cpuset: nmask = policy_nodemask(gfp, pol); if (!nmask || node_isset(node, *nmask)) { mpol_cond_put(pol); - page = alloc_pages_exact_node(node, gfp, order); + page = alloc_pages_exact_node(node, + gfp | __GFP_THISNODE, order); goto out; } }