From patchwork Sun Aug 30 14:04:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Xinhai X-Patchwork-Id: 11745091 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D83AA13A4 for ; Sun, 30 Aug 2020 14:04:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 845ED2078D for ; Sun, 30 Aug 2020 14:04:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="umXwg8NT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 845ED2078D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0AFB98E0006; Sun, 30 Aug 2020 10:04:30 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 061768E0003; Sun, 30 Aug 2020 10:04:30 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB9788E0006; Sun, 30 Aug 2020 10:04:29 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0171.hostedemail.com [216.40.44.171]) by kanga.kvack.org (Postfix) with ESMTP id DF67E8E0003 for ; Sun, 30 Aug 2020 10:04:29 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id ABC4A5008 for ; Sun, 30 Aug 2020 14:04:29 +0000 (UTC) X-FDA: 77207405058.11.band16_4a1572127087 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 76E62180F8B81 for ; Sun, 30 Aug 2020 14:04:29 +0000 (UTC) X-Spam-Summary: 1,0,0,f6a69ef174a7c7e7,d41d8cd98f00b204,lixinhai.lxh@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1437:1534:1541:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:2898:3138:3139:3140:3141:3142:3352:3865:3870:3871:3874:4321:5007:6120:6261:6653:7514:7901:9413:10004:11026:11658:11914:12297:12517:12519:12555:12679:12895:13069:13311:13357:14093:14181:14384:14394:14687:14721:14819:21080:21444:21451:21627:21666:21990:30054:30064:30070,0,RBL:209.85.208.196:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.18.84.100;04yf9uerxd66szyrgwm1td8bhngb4ycoaxbf9ozobznmfhmqek3u9fgg7o8ch4u.1uf1xb7jrc38mu4uii5gd5nexuha8mbxyit4pfj95m1kq16rtrmro6u5bzb9dy6.1-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: band16_4a1572127087 X-Filterd-Recvd-Size: 4007 Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Sun, 30 Aug 2020 14:04:28 +0000 (UTC) Received: by mail-lj1-f196.google.com with SMTP id v12so3774532ljc.10 for ; Sun, 30 Aug 2020 07:04:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=RR0kGOV/UQKzP35UYRezbCwP5AZ9DNeP5h1NxX2iLm4=; b=umXwg8NT934UfO5MT+RlP5w84qUUGexq3psfiM3bf0UwTmPrplASmFDwHOCuNVuVrC Az5zhyvh7Z/cNiM0CVCL7V42Z2Z2k1MYlwstaxxn85f6gcbIOSsjkU5RB9KreJ8+vvTL MM6+SdrDu/5r6wj9wDmdNX/Fe53zd6FXWkHPmBkiU/c3vm4r7sSPnz733/1aoVvnPGvc p80FDJ5bHtF3MCINPWly6D71h37fZTLbaowwMMW3ku5jL3v+NPNur4SlKikpEHdbntK1 1vyPQ4h0WN2tyVaClACo1GocIEeyB41ZxLmAPGFwkKvZxCpGuCWAVMQOvkndoWKteKNY 0xHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=RR0kGOV/UQKzP35UYRezbCwP5AZ9DNeP5h1NxX2iLm4=; b=uMh0ZINQncI5MZAxicQbvhVEPFyet+wIQNJdOThjD6S+kraJPNmMA/yLrUQw5An007 wZHfKM9m2m5Pbt82JTMK5hZfJRegwOERL93oPaFzDwCDvZmAAe63k6N/UkY4gWvLQ8Yn t4f3bRzDrNYV7FSn4KnL5JK5NO0tbKYQc+ARTv7LK3v0mQG6OQtQXaReX7BJnpcPJztp HuQ4Eg7u0Uf0biGokihv2UJmB7AhefEXlJqTyvKZZWXtSia+kymT7LyDvG1DRMm0e3hh xu5JlSMolndzYQZwApOVZKKSzRhqRf2/0QaCb+aPFbpRn7YRL0cw4Xg/61fwwP97o7Aq rUgQ== X-Gm-Message-State: AOAM532CeCnB9EP4bgbxARkNE2q1Z+y8ZUA0wx60gz9JvdA6zckDgEU7 8Ongv5P/RKkIV0Hb+lANGPEU9s8RwZQ= X-Google-Smtp-Source: ABdhPJzRFmB0HcIiMnyB3sSW1+PHYg/2hjhYgPMGXdO6+z/4cuyLS9+4XTArGMN4TzU6QitWMnsuWg== X-Received: by 2002:a2e:a483:: with SMTP id h3mr3400353lji.76.1598796267163; Sun, 30 Aug 2020 07:04:27 -0700 (PDT) Received: from localhost.localdomain ([131.228.2.20]) by smtp.gmail.com with ESMTPSA id s127sm973500lja.119.2020.08.30.07.04.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Aug 2020 07:04:26 -0700 (PDT) From: Li Xinhai To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, Roman Gushchin , Mike Kravetz , Michal Hocko Subject: [PATCH] mm/hugetlb: try preferred node first when alloc gigantic page from cma Date: Sun, 30 Aug 2020 22:04:18 +0800 Message-Id: <20200830140418.605627-1-lixinhai.lxh@gmail.com> X-Mailer: git-send-email 2.18.4 X-Rspamd-Queue-Id: 76E62180F8B81 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Since commit cf11e85fc08cc6a4 ("mm: hugetlb: optionally allocate gigantic hugepages using cma"), the gigantic page would be allocated from node which is not the preferred node, although there are pages available from that node. The reason is that the nid parameter has been ignored in alloc_gigantic_page(). After this patch, the preferred node is tried first before other allowed nodes. Fixes: cf11e85fc08cc6a4 ("mm: hugetlb: optionally allocate gigantic hugepages using cma") Cc: Roman Gushchin Cc: Mike Kravetz Cc: Michal Hocko Signed-off-by: Li Xinhai --- mm/hugetlb.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index a301c2d672bf..4a28b8853d47 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1256,8 +1256,15 @@ static struct page *alloc_gigantic_page(struct hstate *h, gfp_t gfp_mask, struct page *page; int node; + if (hugetlb_cma[nid]) { + page = cma_alloc(hugetlb_cma[nid], nr_pages, + huge_page_order(h), true); + if (page) + return page; + } + for_each_node_mask(node, *nodemask) { - if (!hugetlb_cma[node]) + if (node == nid || !hugetlb_cma[node]) continue; page = cma_alloc(hugetlb_cma[node], nr_pages,