From patchwork Wed Nov 16 06:55:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Shijie X-Patchwork-Id: 9430971 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A66E660469 for ; Wed, 16 Nov 2016 06:57:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9530728C46 for ; Wed, 16 Nov 2016 06:57:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87D5128DFC; Wed, 16 Nov 2016 06:57:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E6E9C28C46 for ; Wed, 16 Nov 2016 06:57:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c6u8r-0005QE-BN; Wed, 16 Nov 2016 06:56:21 +0000 Received: from mail-am5eur03on0629.outbound.protection.outlook.com ([2a01:111:f400:fe08::629] helo=EUR03-AM5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c6u8j-00059F-Ej for linux-arm-kernel@lists.infradead.org; Wed, 16 Nov 2016 06:56:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=dxYQ+pRZKF5tA8S0b4Sgb6gLmdTB/9/VEc3hVEuDQYE=; b=jzPIrETn0Wpsb/a33dKEtvTndnL4hrg2yCO0sj2cvbtaQDSntDV7joAP7WFsvJkKozJ0VmBKCLH9umFaH6ByKlvpdhXpMtadZP+BQy8VSZmy7+dkp53uqrOv5NuFeWTNZu1Oub2lllq3RVQS/IE8idUL9p7mqWK+qrpVW+aDwsQ= Received: from HE1PR08CA0016.eurprd08.prod.outlook.com (10.161.112.26) by AM5PR0801MB1778.eurprd08.prod.outlook.com (10.169.247.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.721.10; Wed, 16 Nov 2016 06:55:48 +0000 Received: from AM1FFO11FD022.protection.gbl (2a01:111:f400:7e00::136) by HE1PR08CA0016.outlook.office365.com (2a01:111:e400:5097::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.721.10 via Frontend Transport; Wed, 16 Nov 2016 06:55:48 +0000 Authentication-Results: spf=permerror (sender IP is 217.140.96.140) smtp.mailfrom=arm.com; oracle.com; dkim=none (message not signed) header.d=none; oracle.com; dmarc=none action=none header.from=arm.com; Received-SPF: PermError (protection.outlook.com: domain of arm.com used an invalid SPF mechanism) Received: from nebula.arm.com (217.140.96.140) by AM1FFO11FD022.mail.protection.outlook.com (10.174.64.211) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.721.5 via Frontend Transport; Wed, 16 Nov 2016 06:55:47 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:1092; Count:13 Received: from sha-win-210.shanghai.arm.com (10.1.2.79) by mail.arm.com (10.1.105.66) with Microsoft SMTP Server id 14.3.294.0; Wed, 16 Nov 2016 06:55:31 +0000 From: Huang Shijie To: , Subject: [PATCH V2 fix 5/6] mm: hugetlb: add a new function to allocate a new gigantic page Date: Wed, 16 Nov 2016 14:55:04 +0800 Message-ID: <1479279304-31379-1-git-send-email-shijie.huang@arm.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1479107259-2011-6-git-send-email-shijie.huang@arm.com> References: <1479107259-2011-6-git-send-email-shijie.huang@arm.com> MIME-Version: 1.0 X-IncomingHeaderCount: 13 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:217.140.96.140; IPV:CAL; SCL:-1; CTRY:GB; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(448002)(189002)(199003)(5001770100001)(36756003)(50226002)(5660300001)(92566002)(2950100002)(104016004)(4326007)(356003)(8936002)(76176999)(305945005)(86362001)(246002)(26826002)(7846002)(48376002)(47776003)(85326001)(77096005)(8676002)(2906002)(50986999)(626004)(5003940100001)(6666003)(6636002)(33646002)(87936001)(106466001)(189998001)(50466002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0801MB1778; H:nebula.arm.com; FPR:; SPF:PermError; PTR:fw-tnat.cambridge.arm.com; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; AM1FFO11FD022; 1:sjy4N3s3HaGR71JuV3ZjKh7kezjXXopgSVX3g4trnEuqpkDAN+kYzy65/Z03LhE4MQHyhL6ZFU/yNivU2sNlsqI/ta4XzLk8UI6hrXZOJQt/U9xsdZJvsqvLwNqmkGOWkGp36eMvJE688HvsaaDqEOx8Qas35mVktHP4Pb6QQOTxwR84C0jGIRfvDJqCXilcMo//tQPHoQ7VBaob3SH+2pXmPU58xZw7N9rr9wCClMhl0HA+LZI9uuyBoMhgrPuF72lB9CbyUteyTpJ/iYzkrE9qr4mPhGbP64HiSkoahku60azDyQazten44FuM0u+o6yniZdDQbfAjrz9h+8rSsLvY138hXyiTqieMCwhlPDmpETCWwT6Vc4IEuKSusuhsi5cAlSWkk7slqMAvvPPWm2IYKs//b/Q7q62cbe7FY1jN7WKtKMlwWY6E0bpF6rCRR+vfhtRwP7kOMyGtXbpItUqfBJfoCaNVRG0EoWfR8qupeUrl9gJykX79OokcNtNBToQ/8dFN1+1tUVvEBaOoDoJu6s88+hIulhJtbs0OooUg0UcZnry9fq6fpsW3E71Pib/mztriEWXwv/e65wBcGfiEQo9OHqLUrPc30tNc/guUvgVj9TTHwbC1CcOidYdctwMDDheMOhvlohWEknrrCA== X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1778; 2:rEf367kdMRLnnE+C87nNC67tLwh9ZbvVGRXjLh0i8AM4izMN1FRQOCyr+mLl7n4WtqBv0OVpr9tcXY/XltDQgwbnSBYI4Q6flfSIuR88QI/6nGp3XY6AKV/8TtNL9HiCwTCMSQXKp0xb0Se6+h6hp/sA1+xJGWbneKw86dIbe8U=; 3:G+W/Tej10cRfMyvNNcrnWj5JE5vVJVZwF8rneTuT8Cz1ej08L80Sry6mLcIo2uGnqaLfJpNYFCMPsxpVrFRrGwGHRONQmRkY2VMB1+OElcT/lNxFTUgqJUf2nENh3SEA/gOh8eGaiiktah7LHUyzGzsXrDr3Nph61UI88oQDkm9SBDOXh7vQjrqObyW2Y+VsUHENnDqMw975wg4IAilCwh4K9BBTzUhrCSzd4mPRjU9zUzGVwj9TuKMz7n/u5Z3/10RQz4GclI9IpXRzRaGvig== X-MS-Office365-Filtering-Correlation-Id: a0b16c7c-0e24-409c-abae-08d40ded987f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:AM5PR0801MB1778; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1778; 25:5LeXsK0zB6WWYMZby5Qd6B+1FRVPlaotyAG/5WTBZ/vkq3yfqST6jT6+vGL6kWhkzCsiW/+lmqnKfWwoQqAo8RVEh3eKO0vYARG35JIlOwbwvGYhtWMgC2vX+ktbhwGrR+NJLUW4w9PIrA7zdub4ESl2yotbNU3mfECRvZb/BzkdZ4p0+phjvDwPW/s1SycEn9g7iUlq6M0c9GUD16X5D8mjwpJo3MjmjPTrD9M84O9HlYPMM5pFP8khRwOALmXGVPo10nqtApurLVm3fZVN3AC+HsoqYy1B8Jk9pEmGCs9Tok71Spb66mzPiK+VTJ/tzaf53Ylu9HE8slskNLzwb5QNzkXOvcjPs7g1QnAgFjmBY2JmJTR5GvCxh0nLiefZWn+nkcnjZEXbK+mIMzWzo9C2Fo20tZ+E3GZvWUzuTQYEWWKs5tv2War+lcIfrKuzMyBtofK7gjzkrwCrVFE/qzYJzGUFy0V8Euw8xvVdC5GjGDrDVaM93eObQbyqY0f/gzoBUN99tlC+G3J+RUVQX2qpFNkHe1eXn9hpU+KIN3jY2VShsg8NLSg1zhl2Ih4xxIuWhdJO7eMuPXUMKxLcFPtreUB5nbLSed7fdlzjVz2RCmV9SrxOffELJ4dcVINrEstrJVoSPlSbG0p0UCHzOz7/1VoZ7VfZNcbjllh+9aPMuSxok1fNX7q7z38yPsredoifsYik3BoVvo6jho7pRpLrIPTbCLv89BAtshZFhAfj9EV1Yfg5+wXv1S9y1yzqn3qib/kxwfVmSxO5duDaLu13Lts3AqNq8x8/3zLWD7JQP4VNENoUQLVt7nvYjeid X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1778; 31:/okPkmn9TCDIoG17Q6Oq/+SH42Pxnww9y8eTRfFB6t4YlG0kG/3W2kHHGaLQcnYPT7jF8OlD124SiSoS4hsc0FvVUhWHzJP5CS+saPMNUIeYM5m/ovf1bWBl5HOPdOhQpsoLbd9DOfo4rJ8Rrkjn48PQ3sgC0nu6wpI6AaovvwWwvksykwITam5d79fZTESkNRXCMRBYeMz+aHNJvXte7clQ4V1PVSP1ZiSp13fDZegmmNhOpmxWaWiziyKLRYvVAmSBfIHrkoZ+/F9msXCBbHNfdZPZfqpdxMYvjRYB0Rk=; 20:0mBLg+RO/4cJ2QhWNueUQL2AwwWh44U4lOvOV5zuZ9gNF1jKS346LC3Tu+uzLclNSYyxpSwmtGAVpmDRmKbIWNeDDhYpFfhYwi8OTbQSQSwVWK6JmJNHwyaZDQqr4JvZnZJvch+0GRS+cDdHurYWpV4KyfQV6KYwqFMNXtdYBu7ghLnIFnmqmeJkQ+1bag36fJ/M0KjIor90eRax2ofEMXNprbW4DHfXy5qINZ/jOXv7uaB9/Iq4UQJGn2JkFygr NoDisclaimer: True X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6060326)(601004)(2401047)(13020025)(13023025)(13024025)(13013025)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6061324); SRVR:AM5PR0801MB1778; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0801MB1778; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1778; 4:3VO+bSSfp0GD65eNeO4E1jd2OcLZZqR09Lt3wVKwF0fvO+Ic68jA/YPcVnPCD+nQhjpiy5CSK0/L/2rKqOxkm1XV/FX+GJfpR346sL3fGxLunEI1HQ3svhWsS+4gLLxtcrxe6oAQgv+XGUKGt8laHb+1ttcHPljN5s/0rhrm1fKb1RjSbnvbhcDsYqJYcq1+qx8XJJWArcXrhtjvXcsLncDivhKf7eHagP2BONRkpw7HgYSraTX+SxeSJUn8xW8rWnKljJMw7TjTdJYmTvY71eXan5y0Xhcq0gpq8eujyypXVkWwPu/6XVCbOr0qY1ymA3iPj4goafo61FmHY8apwLNUhmWVfyvCxf8VQLN+liYIWPimt7wKtQpiSraQuGPAE/ZruEPi6Q82AfDl5dHX8E1LbKQgKrgNW225AimoSU6+9/YeE/Gx7Mt96Mz1JDqRxiPb1iIu8nXhGn7KFdRCEPTcLRwypS1aiTb5phfOwNt11volfhpytUDPNikxP8ekVyUkDzn9FhGjnbfx2kZo4aCJfgalTHddZjzX16XQKBe1Lnd2if7LsXmRUkTfhVB0 X-Forefront-PRVS: 01283822F8 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM5PR0801MB1778; 23:NBQDT+qKIrC9x4Aik5ixxqzyULJ3VeWEB9EzUJG?= =?us-ascii?Q?NPpNaWI3c5U395kRAkfsssW0d7s/+Jw/wExd3uSbEat2ULZfQ708G+rKUfde?= =?us-ascii?Q?wF8sLgwXzYGen5h6DrHtwz4B9Ji43RMCLg/RY1hBVRJp0epydg5oBtAa/Nne?= =?us-ascii?Q?knIH9E5SjR6rgsphxY+9t3MFyB3DySoJs8PXs+2pHIGEczabyuBtvKoyedPA?= =?us-ascii?Q?g1xBg4mUWZBmSKTXNQg9O0IfIe0aa+V8Rh0dDXGEgeJorObBNNy+UXVUTNDj?= =?us-ascii?Q?ewKtm8pTx7F3vLBXIw9GVmjHvMTVADg5bQ8HiWPOA9QAbODLTGSMre6GJaJD?= =?us-ascii?Q?TE/Hu8ALeKe0a+2MHzLg4lMj6T5Sg4bMi1XLYooNli5ew1ayJhfmV6EdCwFk?= =?us-ascii?Q?p3ZXkeEOcf7FZyMHPCGOjHkjWQrYfM5U1QMWffaCz5XlGp0sQVj7OhTCTapi?= =?us-ascii?Q?vZq915agb814thsd4T0zmE+pDMFuVcsd8lKPGT237NgmzhLtlJKScgnQXAkg?= =?us-ascii?Q?/lBDUaOxBzB3ybfR4QqZRomGb5BOU9ZoNDK3Zk6sXHmZRgJKG0hQLXWr8mhe?= =?us-ascii?Q?Fjf8Mj+E6KVYD5zVzyPPpinFws4QWXWmeDnvB14ur3FCQw41fnCyuyecAxNS?= =?us-ascii?Q?E2ROM5+f5A+aVbtjNJMxbH4jl6sxj/a731/EKb4G55sCH/HXE+pp1HkcmYgg?= =?us-ascii?Q?CF912jhgSNa3wmUu1mHrWKkFL6uMpZD9dIMLoGePSu2bvf3ufOPr4Sm9CCUu?= =?us-ascii?Q?44lBKM7fEpBTM5ddy8Pwq6xkxnkEPEUCD8kwSvJQjbmNVo4DDdPhGqCzEMrh?= =?us-ascii?Q?RxeXU0uN3xY+3TUrb60jDPPaEOw+r/rLmatbfWaFNshYblSHPHc4+9PNzQh9?= =?us-ascii?Q?BBbqVclqltzy2vKTsJ75ziM4tl969sY2n684RxG8/Bt6VO3aKQpo2jA89VJH?= =?us-ascii?Q?Yc3o1kjHWFFCW6Ha5Qk9ebG6z6eaJjVWJjE7fo1svYg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1778; 6:5Si15T1/V4gwQUhLacxAweZY6zhKRj/oz9NiTPJLVKqMhTGBdQEg/bCXlquhqGxalcFHEWkrI+q7hVym1u3nPyHPpVzGQUJE0yyn8kw8WUQkxNrcb/8CL3dEZg9iZvkCVPKB7gWlKJUc9Rb4zyj168XcRaNEwK30PbThT/JrA/ONRYxGkcwueQkHfnD9rlkWbE2U7fgToUMIuMTMtN/L+ixpWOTPZGvFMf4qqNyqe9MHxw/WH+d/N/NjsV30leqp/5+gcUAXu3gD+j0Guyxpsm1y/dRwv2SVoqe7ySJmIdXRAJpsNp+99v4n23Ooesp9XC7+9CjgMCksBr+AQ6f2f+LEzVELTmwISFNiZDQJRwAeHKLgimSi9nMylp3V3BQI; 5:KeetSjseC8inl4fcV6ULF3mJzM8MlGm0v3UnekJxMqKQ5ERvG38WbR09rTIULH/lMDAozyHYoYy73E02AgAH/Ped3dPJi5gTLv/auDGPwggOuL+PgzQyYCL+R2lbgKgZmccIZwsZomywyg5RdgKOPg==; 24:RpwSj2rApxSMnE60FAmiYOMA6A6wtzfTHCplnHqCpAFDI7LkzIwjydOCQUWtf+ZhleJ/zFAgLtHokD5MIuMRyMirARdGZW6bOB3O+5Iw3a0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1778; 7:p6Y6UFEiH4/1I+EQLZ7Pq4F10o/eH/eKqwSU6x0BWL2WtlgAI2KmOACnRuSLDU8lyNcGxaH7nqZ5Qo1A4PDbX8RL+6SERX6fL4ZMCk8cEtYs/PlmOoSwUksCCskoGui5Z1SU7FraFPg5E7DUov4z+ncHTeI4D37In+6Qq+ROezoTN28bPv3iPKwb+6WbwfYv2DYTk59/442wexRk3alogaGCC1cKlor0xgO6tNBZqKOlX+htU3vbfy5+3N9VupVD2qzoy8hMEkikLhGDLsD8QnhYvdrcFBheEX5VAiVFEDPq1Mwvjt1piwIQe4Tw46AQD56+pfEP0W2Z9Skl5L5eYrq+iGFvc0LBleb3mWX8ORg= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2016 06:55:47.5976 (UTC) X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[217.140.96.140]; Helo=[nebula.arm.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1778 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161115_225613_879519_E15A103D X-CRM114-Status: GOOD ( 14.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, kaly.xin@arm.com, mhocko@suse.com, kirill.shutemov@linux.intel.com, steve.capper@arm.com, will.deacon@arm.com, linux-mm@kvack.org, aneesh.kumar@linux.vnet.ibm.com, Huang Shijie , n-horiguchi@ah.jp.nec.com, nd@arm.com, gerald.schaefer@de.ibm.com, mike.kravetz@oracle.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP There are three ways we can allocate a new gigantic page: 1. When the NUMA is not enabled, use alloc_gigantic_page() to get the gigantic page. 2. The NUMA is enabled, but the vma is NULL. There is no memory policy we can refer to. So create a @nodes_allowed, initialize it with init_nodemask_of_mempolicy() or init_nodemask_of_node(). Then use alloc_fresh_gigantic_page() to get the gigantic page. 3. The NUMA is enabled, and the vma is valid. We can follow the memory policy of the @vma. Get @nodes_allowed by huge_nodemask(), and use alloc_fresh_gigantic_page() to get the gigantic page. Signed-off-by: Huang Shijie --- Since the huge_nodemask() is changed, we have to change this function a little. --- mm/hugetlb.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 6995087..c33bddc 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1502,6 +1502,69 @@ int dissolve_free_huge_pages(unsigned long start_pfn, unsigned long end_pfn) /* * There are 3 ways this can get called: + * + * 1. When the NUMA is not enabled, use alloc_gigantic_page() to get + * the gigantic page. + * + * 2. The NUMA is enabled, but the vma is NULL. + * Create a @nodes_allowed, and use alloc_fresh_gigantic_page() to get + * the gigantic page. + * + * 3. The NUMA is enabled, and the vma is valid. + * Use the @vma's memory policy. + * Get @nodes_allowed by huge_nodemask(), and use alloc_fresh_gigantic_page() + * to get the gigantic page. + */ +static struct page *__hugetlb_alloc_gigantic_page(struct hstate *h, + struct vm_area_struct *vma, unsigned long addr, int nid) +{ + NODEMASK_ALLOC(nodemask_t, nodes_allowed, GFP_KERNEL | __GFP_NORETRY); + struct page *page = NULL; + + /* Not NUMA */ + if (!IS_ENABLED(CONFIG_NUMA)) { + if (nid == NUMA_NO_NODE) + nid = numa_mem_id(); + + page = alloc_gigantic_page(nid, huge_page_order(h)); + if (page) + prep_compound_gigantic_page(page, huge_page_order(h)); + + NODEMASK_FREE(nodes_allowed); + return page; + } + + /* NUMA && !vma */ + if (!vma) { + if (nid == NUMA_NO_NODE) { + if (!init_nodemask_of_mempolicy(nodes_allowed)) { + NODEMASK_FREE(nodes_allowed); + nodes_allowed = &node_states[N_MEMORY]; + } + } else if (nodes_allowed) { + init_nodemask_of_node(nodes_allowed, nid); + } else { + nodes_allowed = &node_states[N_MEMORY]; + } + + page = alloc_fresh_gigantic_page(h, nodes_allowed, true); + + if (nodes_allowed != &node_states[N_MEMORY]) + NODEMASK_FREE(nodes_allowed); + + return page; + } + + /* NUMA && vma */ + if (huge_nodemask(vma, addr, nodes_allowed)) + page = alloc_fresh_gigantic_page(h, nodes_allowed, true); + + NODEMASK_FREE(nodes_allowed); + return page; +} + +/* + * There are 3 ways this can get called: * 1. With vma+addr: we use the VMA's memory policy * 2. With !vma, but nid=NUMA_NO_NODE: We try to allocate a huge * page from any node, and let the buddy allocator itself figure