From patchwork Wed Nov 16 06:53:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Shijie X-Patchwork-Id: 9430969 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 07C0660469 for ; Wed, 16 Nov 2016 06:55:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC1EC28C46 for ; Wed, 16 Nov 2016 06:55:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF13728DFC; Wed, 16 Nov 2016 06:55:45 +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 4EC4928C46 for ; Wed, 16 Nov 2016 06:55:45 +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 1c6u6i-0002js-Rx; Wed, 16 Nov 2016 06:54:08 +0000 Received: from mail-eopbgr20065.outbound.protection.outlook.com ([40.107.2.65] helo=EUR02-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c6u6R-0002bc-1Y for linux-arm-kernel@lists.infradead.org; Wed, 16 Nov 2016 06:53:56 +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=I59cMvNbGGKdPoRTVqKS/jI8GBeDP2y3041MLjb8Lq0=; b=BUJeyqNgSBOxZFJ4jzrtMU73EJkYhouE857oJC5bsbBbOpLH480Sz2IEKt78WJf1V6EJD+mfLg3zIVCzYMCrP/k10mVNZNnULaS9o8cuWhRlhteZxnLzVMjI7OK0oNbi8reHESo5Xfa8FQ/mki5tiTypzHP4KkW7ZO6Vrm2rcZw= Received: from DB6PR0802CA0046.eurprd08.prod.outlook.com (10.172.252.160) by DB5PR08MB0565.eurprd08.prod.outlook.com (10.161.246.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.707.6; Wed, 16 Nov 2016 06:53:26 +0000 Received: from AM1FFO11OLC001.protection.gbl (2a01:111:f400:7e00::161) by DB6PR0802CA0046.outlook.office365.com (2603:10a6:4:a3::32) 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:53:25 +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 AM1FFO11OLC001.mail.protection.outlook.com (10.174.65.76) 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:53:25 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:1078; 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:53:22 +0000 From: Huang Shijie To: , Subject: [PATCH V2 fix 4/6] mm: mempolicy: intruduce a helper huge_nodemask() Date: Wed, 16 Nov 2016 14:53:02 +0800 Message-ID: <1479279182-31294-1-git-send-email-shijie.huang@arm.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1479107259-2011-5-git-send-email-shijie.huang@arm.com> References: <1479107259-2011-5-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)(76176999)(7846002)(305945005)(5660300001)(626004)(26826002)(6666003)(106466001)(8936002)(2950100002)(47776003)(36756003)(92566002)(8676002)(85326001)(87936001)(50226002)(5003940100001)(6636002)(5001770100001)(2906002)(50466002)(86362001)(4326007)(356003)(48376002)(50986999)(77096005)(189998001)(104016004)(246002)(33646002)(14583001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR08MB0565; H:nebula.arm.com; FPR:; SPF:PermError; PTR:fw-tnat.cambridge.arm.com; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; AM1FFO11OLC001; 1:tYKC/VIuEWAG9H7r+3v2Qven7i3mXsSeJymUCRrOQPdomBzuacvqeLU1dkOzoNQ1ZYaduMOFnPF+NO6gsHE9ugohFJ+/gLYvL/r5DUOqQgzle9e7IB6+4WIaPj5XHTQlejWvNsz9E8fyO7tSNFb4pVB5pfvz224D6531Gkq476751YTzLegjRL963oiAZQCJqb39K5qiJyMt9c0vIj2LLN8685yfyl71c2Itj1IYzSoK3n2jMeBhBMPURROaNCR7ZbPYirjW11gGRrbhFDK/pUvHRj5s1ypbol6v1Fd0bhIA8pnVTfg09fVXAkKhyxZB/axKCci0rrm401acP5dzTZOQ15f/U+Vys75iIAmHhCx8y+Tk/OsS95QHzkvbDQTQIt2wq/ufwlM0MJUkI8bB4LGIoFgXvERS5N9QfvIcDgid3IKdzuPxXqg/UqcB/OZPwMEndgGrLao0SsycArxe5ZzDWKhPTely5tNcQ0Tj8e4B4rqkwkfm46sFnzJbjtOYgYb7BMQugkHwKKoMaNt2BVOXkFvrLzsE/JiD4e7Kq+l76Cz5lH1V6ojziBDTgEI1lyYEyxRi0aoRa+9qLFYMRwH+lk9cR/f2lpXdMbNVVcsXQ4Y54dG3E9E8ntLMLaTfZpJZK7upKDdlnU9dyH4+wA== X-Microsoft-Exchange-Diagnostics: 1; DB5PR08MB0565; 2:8p8V3Z1b00bE88G3lt7u0psuKpBi2NQcMFFSf8rLn5x1+whGH1uDqaCR42Y0k9LwbQMgLA1Z/P8o4H3+fErhpHZoio2GuMYv31RyuWK+T6iCr+0pvWZPw+AGGFBVMemoR1ixC8IoCmrGUK66RdcI+tfrTf0lXqrUSnWhj2s6tAk=; 3:cYkX2PR7L8jg/ximVhPHr3tDMFES5P8ylEhYXc2MrB5xl5TDhkmdA2XsheOVVqk9Gy0w1PkUzfRgfaEy0Yj5Eeubi6YAQwqDGeVqaIBx8uuBP2Tf4z2U3HtJJBSpFltX6CbEhaEvjceeAMirtrblMVe4oDzMdi20Ngt+KmVcYUg2mFJ8EXlobOIHJ9HMDovt8Xai7rpviBi4Ax06sU4G+V2wAio4OUnWKVksGvRUuT+yUZ66zgSS4452lXKoKPp8u6fq1SX1BMoR1IwS6ZiYJw== X-MS-Office365-Filtering-Correlation-Id: 8fe1afcb-6946-456f-8b81-08d40ded4367 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:DB5PR08MB0565; X-Microsoft-Exchange-Diagnostics: 1; DB5PR08MB0565; 25:TdH8UyYr7FOF6kbM8F677s1/bhUgVlm1UMH5OZmY5jeic7v3gcGIqMBiT2WqXTK65p0LQQq7dHZRADgyLO6QSVdYYh2U/DPcnNhomCZup1hh4jpTnB06t/ezjWEXCdFWQH1QQdeRXLCrwvxEwSSzDB+Et5j4KlCuqzX0PMls6l0IHxfJHbPub4HocYbfApQ3T79bv1xJsNTG58V9+LSwRYP4PIBcRHhWTS+i5NyFg4tyVyYxSfdVBIpYKWFBx7kZqaKcwWxfX/KfoRFlRixYVwFUYwJi39NwyXkChPxxnUuxpYiH0GP8At8UdTENCr3Js4NggBxZYtBMb0KsnKiG4JlmNWUgQ2szLrsP8abmZyWfhmwr7Hkvz/b02vc/aeDz1ynkw1BvoGWQSNpSwt77AXd0/g2GkJEvormtqSjU5ITp4C0MF2J4qtVrg+sM07sJRGW1CGeZz4hz+mCCOpvd7lJdbpKSbPvglxcYthvDsuGqUJAcEuQ9fLV2KY3XXwo5lcFR939jPhWiHBjcuBc/FlWZScitWcsWNmSLBBNk7WPDC/Y5dDtYYMQMeQX4HZE9ZoGFNXoOo+VFmtwFBmVkNlD93sCBWCgyBBgmNrPzuLZfb1EuArIq0U6jf/8btTLyZE7jpB/rf9jzXsIaoAorUowphPnC3htmSraCP7WZ7NRIsTFK3TGOso8dUmkFGS69+buzfYprPny6JGIxvIMOkE55USKXBe7i5urncSkJ6grMS+Bp9AULKF01ncobwlfT9/C5DV3TLhaO5OdEV6qMx9cQeu8xoJ6eUgzpJXZkQKA= X-Microsoft-Exchange-Diagnostics: 1; DB5PR08MB0565; 31:DmN6xRbFXA5P2ahUM17Lxrlz4K/kN5c8j1Nr3lZxx3L42TB2IhODckQbIMOz2WoR5ru5zGtEGFrGgoAGqUSAb0+vI3rW6L4Fv59QPbCIOA8BwDAiMwPueL0jVVPBACKRJMJ9xhDOASwYJy8p+mjT1ABWji1Oj8LjG2n+xOteJl/MLXWL8RW9GEX16DUGJ2if5UTvFib7jF1pXMloLKkl6ltfqt4uEFsM96CW+T4x9B4FB7woAsXxUqInIO2RFQ+mZBwXc1P+MCgSX0KvzmoJQQ==; 20:s9YkEmjm7gumOVMNtO/jK1Whl+vO0nyINnN0uTdFi2aj67lzTZVYKQxbQYdUaUkOSJ82COnA2Bu75EtnbJ6ph/fQPjfF5DvygGDsGkp/sfpQAf1WxGaXt1Qnx55nMAVu+iDWLI1MdnRI33nVjhg52XI1bXawuIwr8qq4WwxdkFiVVHWD0CIkaLk6WUV+bt+o4LyT74KYX6B4YYBAZkT3yVBwb8ZfWUV3TsjVhbfG7FdgW9qpyIOypUsYSB0N4In+ 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)(13024025)(13020025)(8121501046)(13013025)(13023025)(5005006)(10201501046)(3002001)(6055026)(6061324); SRVR:DB5PR08MB0565; BCL:0; PCL:0; RULEID:; SRVR:DB5PR08MB0565; X-Microsoft-Exchange-Diagnostics: 1; DB5PR08MB0565; 4:jSdv/e/aA04/M8DK11LKmAZurW6konG9rZ/H6M8rQQh0iBqRUlisAhw9D+PHd0OJx1jgneJ3PJYpu+VgUY2FjD3p5ZFOL2HpFRfxnnBLZk/vq6eEmpk7cHOiL8yEzvYvTUvIDDkdjprxb/MzVUPhZcVIp1zearkMJkps0cCDm1WmzkPLvclJKvEObg9O9tlCUKTZUfDmlaiyWpV1B6voGWZ0WV2rFzCbw32cr/6P1gIT36ljTMPi/pDZ98aUxNYmmYudxxgHPfuW6uDMiF0kO2TWM311YrP73B9D20r4lPS/y2btLSn2hODIo0XhX8V3RxdcecoNGi1H7ZbsnaS6aQzhevHfcTMn5DOPwqrQ17vxwTTtqIv4x7Ghhs3RfVKrReb+7oCiTMI4sy6nBVA0vMl/yvnhjcw3DtBVrZBljD5xENVWoPJse45ocSEHQxQZTc2QdogBjLxvyyNI8DmjTRNGcUTYZ4/LJMo6A9SDANshsI3tlaO7fni/5EEe3sVcE2EOH+iBVHHmThlRHAC8d4X5JGA0QeMgDpLNTt9ThZKIJyekgrW48STnTlQcwD+w X-Forefront-PRVS: 01283822F8 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB5PR08MB0565; 23:iWdICtR1fSBr/Wnd6kt6uZf+PGlOyQA2SB0G1NTcb?= =?us-ascii?Q?BfcJwAr/TSaeGO3CGj54kpyQCTWYfVKxqtqMmiY04S1mJy+iYsWPN8TSMZKX?= =?us-ascii?Q?mfnohoO28g47F7xjf8z2CMnQwn7PdeVDmGz5TMKpgfXVEH0Y1PyBqMiwh1mD?= =?us-ascii?Q?qxeyXIADEXdNGMvd0+plzqp6rriM3o783nb+BIr8uesSZh47buokxTVzRNHj?= =?us-ascii?Q?NWtSeM19/YsIXptKJ94wig0Ar3gQ1ZLDYZGdcXF7Ds7ysIsK0P0kkaHjzLFr?= =?us-ascii?Q?y798T9mLD70Xk0ejDMcqY3c0l2SH029G8x7QSfzmdlC5Z4ZnEWme9H+DDWIq?= =?us-ascii?Q?yVBudI1UhjyrYGBu17ApCenPx7Quok+TZqXaygVZUCShyFIdgF1jnXda1YaC?= =?us-ascii?Q?HtPlb32uuSK3B9Hu6XmEaS3X48L/AjYUvFkZCDAQhluH1Tu6kTfvQxDW48pi?= =?us-ascii?Q?bsKlYsd+vLGsc/w5hI7Avh3MnxArUIJoTrR4UVNAS9ze88oLmcdSJ/Fn3+Td?= =?us-ascii?Q?SQCZprr5nXFr/Hgc3zZVaTZo0Vio0VXmpOkf3rorCvVW337eUG3jMnMYAois?= =?us-ascii?Q?6kCF6bSLnRkl56TDgWpsK2WefHZK6wsVDu+Si/Je7Hb3nx2qh9MzItejZdPt?= =?us-ascii?Q?ZLKytBbCx10tSecaCBPPwOwbd3+GCFQtmE7ZLeiGR7GTRZ2YCBb/V0Q43zXr?= =?us-ascii?Q?ZE5BR0rQKuIgZv/xSWJPmt5jMmGwil1uOpFwxYVtLatU3qXduQji4hvZFPmS?= =?us-ascii?Q?hp0R6gDe44t2XTnb8+ybTygigsSkTlxQYNCcQNLHhAmH428Oddr2zSIJ84ex?= =?us-ascii?Q?NAI7eP4Js6bqyKq+gagCZn7E8VUUslX0Rd0mZtu8shEWUi9qN3R7j/ZOrqTE?= =?us-ascii?Q?Oc9z+g0pykp9qLGDM/+2jVkibbn91iuSm8HNGJ6KL3+xX7/rim0dxmnuY38o?= =?us-ascii?Q?n4mnQtCXpMvjzICiSLaYCBiKNet9hNW1LIo9psP0iZtoepdDJbb0chW5bu/j?= =?us-ascii?Q?u0=3D?= X-Microsoft-Exchange-Diagnostics: 1; DB5PR08MB0565; 6:WzZ5DikXPa8i4NmNuj68KTA4QaU8q3mBMphiw/XHAnotbLSUJULuwmw/CBmb4pPWmDrmzJ6kQFG+zUQcuBevAILPfkfJpKFs8qOmq7bfO0dNB7+XEmYPGqR+1e7HOU/jYXpTEGx52Y/6JpKKcY/o69MqOmqkyxwf3A2tpJwI8TcgJUGWsQ17VE+F5olEt3WR6hWWsu0YqxAL0KBSpxzErdPx81O69pXwNsbc1mZEE8+Oybu9x3fEEf14wFEstLWbP/o0E/4df2duDP6jk8XPVy060NMVAtkV9RefWZUdW/5smBuieeULQExXCDofzw9Fbq4rWdzkIKCg+wuRRQkAuIU+GwNaC6ih2PDaIG/eTB5iHSRpo+VQJmjN4qi8bB6h; 5:wN0thGz50ViLjg3IjEchcMQaJFDkLRmpkMhV1ws3gtd48A+5yUkphc5jbTte9cXHH8ARiT+MKpxet1j1ggc9JHS4xulLi800r8S6Ef3tsERyJdTf1K/REAPeqXnQUFBHmzrwjU7EJNFdZYmveuCJ2g==; 24:cL8m51mvZ8nxI/8T4c5i6jcnq+O2AZoCfM3WTT+mzQWADr4FIKs26EX4A5b54/+Tdfu+tB4s9X9jLxKRCcrR0g8bWOJAQGAo1Dl64kmeg/w= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB5PR08MB0565; 7:MQIBhuPmaRFUQcP81vx6Jpua+lmA5FP3fyu9y8Ck0Ve2HoDcJ9neiCpEySWYfp892BFu9EU0Ex/x4kIsnR2Ol+rs2QLe3GXG5s7hB2TqDAbSmUUcDDXQT0zd+qiQwDk3HeIQA1LFWI4/6wL0kMU4noUMeMqlKBrWZuOf8feHwIx2WDIXOPriLOFX7IUzhEeHEoxOi3wOgvTpQSOY+JLLXwt6zSrJAhbV6DIRGv9ugcx4HduDajfBxpOFlA3nemeI2dtZpr3vCxor6gq8Mrpt+7BLVha/C3wbaoBxOwnH5eoy5UDJPlZzsqYyVNP00hIoJB9Z2fkSG14bkZxPeBeYrCZ2BWtVqqWkmmZIQeXwv2o= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2016 06:53:25.2856 (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: DB5PR08MB0565 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161115_225351_589545_BF736EE1 X-CRM114-Status: GOOD ( 11.60 ) 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 This patch intruduces a new helper huge_nodemask(), we can use it to get the node mask. This idea of the function is from the init_nodemask_of_mempolicy(): Return true if we can succeed in extracting the node_mask for 'bind' or 'interleave' policy or initializing the node_mask to contain the single node for 'preferred' or 'local' policy. Signed-off-by: Huang Shijie --- The previous version does not treat the MPOL_PREFERRED/MPOL_INTERLEAVE cases. This patch adds the code to set proper node mask for MPOL_PREFERRED/MPOL_INTERLEAVE. --- include/linux/mempolicy.h | 8 ++++++++ mm/mempolicy.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h index 5e5b296..7796a40 100644 --- a/include/linux/mempolicy.h +++ b/include/linux/mempolicy.h @@ -145,6 +145,8 @@ extern void mpol_rebind_task(struct task_struct *tsk, const nodemask_t *new, enum mpol_rebind_step step); extern void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new); +extern bool huge_nodemask(struct vm_area_struct *vma, + unsigned long addr, nodemask_t *mask); extern struct zonelist *huge_zonelist(struct vm_area_struct *vma, unsigned long addr, gfp_t gfp_flags, struct mempolicy **mpol, nodemask_t **nodemask); @@ -261,6 +263,12 @@ static inline void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new) { } +static inline bool huge_nodemask(struct vm_area_struct *vma, + unsigned long addr, nodemask_t *mask) +{ + return false; +} + static inline struct zonelist *huge_zonelist(struct vm_area_struct *vma, unsigned long addr, gfp_t gfp_flags, struct mempolicy **mpol, nodemask_t **nodemask) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 6d3639e..5063a69 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1800,6 +1800,53 @@ static inline unsigned interleave_nid(struct mempolicy *pol, #ifdef CONFIG_HUGETLBFS /* + * huge_nodemask(@vma, @addr, @mask) + * @vma: virtual memory area whose policy is sought + * @addr: address in @vma + * @mask: a nodemask pointer + * + * Return true if we can succeed in extracting the policy nodemask + * for 'bind' or 'interleave' policy into the argument @mask, or + * initializing the argument @mask to contain the single node for + * 'preferred' or 'local' policy. + */ +bool huge_nodemask(struct vm_area_struct *vma, unsigned long addr, + nodemask_t *mask) +{ + struct mempolicy *mpol; + bool ret = true; + int nid; + + if (!mask) + return false; + + mpol = get_vma_policy(vma, addr); + + switch (mpol->mode) { + case MPOL_PREFERRED: + if (mpol->flags & MPOL_F_LOCAL) + nid = numa_node_id(); + else + nid = mpol->v.preferred_node; + init_nodemask_of_node(mask, nid); + break; + + case MPOL_BIND: + /* Fall through */ + case MPOL_INTERLEAVE: + *mask = mpol->v.nodes; + break; + + default: + ret = false; + break; + } + mpol_cond_put(mpol); + + return ret; +} + +/* * huge_zonelist(@vma, @addr, @gfp_flags, @mpol) * @vma: virtual memory area whose policy is sought * @addr: address in @vma for shared policy lookup and interleave policy