From patchwork Wed Nov 9 07:08:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Shijie X-Patchwork-Id: 9418523 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 44B3F601C0 for ; Wed, 9 Nov 2016 07:13:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B3ED287FB for ; Wed, 9 Nov 2016 07:13:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BCBD2917F; Wed, 9 Nov 2016 07:13:04 +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 89CAE287FB for ; Wed, 9 Nov 2016 07:13:02 +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 1c4N18-0003fK-HY; Wed, 09 Nov 2016 07:09:54 +0000 Received: from mail-he1eur01on0087.outbound.protection.outlook.com ([104.47.0.87] helo=EUR01-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c4N0x-0003d6-Vc for linux-arm-kernel@lists.infradead.org; Wed, 09 Nov 2016 07:09:49 +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=yw5L3SyiM0XjIeCka1TE0vovacY4m92Z4zWggXyQm+U=; b=R+oJgDfglRg8ZlIOFh6Tlbq0ZKqf4LFU2+ItUkZ5FvvWjInNuRxsvTf5THShcV2cWihaR8KpFIwggDvN4DARiNeQA4d1gVaT5eKuom6TK6LQ34VJ+x4hRUGgQgiCB9zrqBazV8m8HdLwtvzVWun7M/gOtYwhDy42LokubCGqttQ= Received: from DB6PR0801CA0011.eurprd08.prod.outlook.com (10.165.173.149) by VI1PR08MB0573.eurprd08.prod.outlook.com (10.162.17.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.707.6; Wed, 9 Nov 2016 07:09:12 +0000 Received: from DB3FFO11FD008.protection.gbl (2a01:111:f400:7e04::100) by DB6PR0801CA0011.outlook.office365.com (2603:10a6:4:2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.707.6 via Frontend Transport; Wed, 9 Nov 2016 07:09:11 +0000 Authentication-Results: spf=pass (sender IP is 217.140.96.140) smtp.mailfrom=arm.com; oracle.com; dkim=none (message not signed) header.d=none;oracle.com; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 217.140.96.140 as permitted sender) receiver=protection.outlook.com; client-ip=217.140.96.140; helo=nebula.arm.com; Received: from nebula.arm.com (217.140.96.140) by DB3FFO11FD008.mail.protection.outlook.com (10.47.216.97) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.707.3 via Frontend Transport; Wed, 9 Nov 2016 07:09:11 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:1078; Count:13 Received: from ent-kernel-softiron-01.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, 9 Nov 2016 07:08:53 +0000 From: Huang Shijie To: , Subject: [PATCH v2 2/2] mm: hugetlb: support gigantic surplus pages Date: Wed, 9 Nov 2016 15:08:14 +0800 Message-ID: <1478675294-2507-1-git-send-email-shijie.huang@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1478141499-13825-3-git-send-email-shijie.huang@arm.com> References: <1478141499-13825-3-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)(438002)(189002)(199003)(86362001)(47776003)(8936002)(189998001)(2906002)(87936001)(586003)(106466001)(7846002)(626004)(229853001)(305945005)(104016004)(8676002)(356003)(77096005)(4326007)(50226002)(92566002)(246002)(50986999)(6636002)(48376002)(5001770100001)(36756003)(50466002)(5660300001)(2950100002)(6666003)(33646002)(26826002)(5003940100001)(76176999); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB0573; H:nebula.arm.com; FPR:; SPF:Pass; PTR:fw-tnat.cambridge.arm.com; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD008; 1:QhhoUXuHOboiaxL4nhgEvhxsKI8P5CVMloGs0kdr5Pe9pOiB3xWT9Ts8+ry/FjHj5P7aSJgRWjAKt6HSNag4PXgPDil5LLk69Wmy5KMbHAwVFAuAtoDvOO3HFpzPh5UwRb73OPBBQWxkBgBb87O+vrRuegZa4zKodwoIAis6rxuSq/EJS5ffLL6W4bnjoVgT8clgJ3Pf81x+933moR9QAXqM7ruC0kI1moCv4CdKyjUQzgbOCXK/ZXO33rivhO12laOrnHW7MeydK56QjdT8ev0sM77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wu5SDdVo7wkvEyzXpAbgFggN3k5QYwVGKtQsw2mA==; 20:Zp/Fk1kNXk4sr1ARIXVYa14KeHBNiZz/cLqjQQnMkdOk4jJgYhJrz1C/Ne5vNhYcQpF80CFgMbp34KHABLfblv3pyuj95HLwihfu2ZyvuOFN6cqlrC+4AzkEKMKo0JfivnvsP6/L6NYLaqBxUV18DVBOEPQ+mJvquPDGIjnqLCK13RQEh2Lt++Hu9RfjxNgZ20mWgjNgAhDTIQqNUPWmsltCZnmb7bUz8pd9sZuhqT3fgUR+ASVINiE4vHSf3PG/ NoDisclaimer: True X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(13013025)(8121501046)(13020025)(5005006)(13024025)(13023025)(3002001)(10201501046)(6055026); SRVR:VI1PR08MB0573; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB0573; X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB0573; 4:OHucTgIIC+k4I5EjWzadlNaUn5ovNCiILdJ3Ykqeul4JL5G/eGPFzEFbecVNyFsgfa7Q2PyEwvs1yRYe/76HEImhYpX2SMvQGbgmWeWvsfjkwxbxiUFqPpQwR49ZuKbeg9fC8s1yHRbFSvnou91dDA9TCcESQa5tbYI+uGzXeYbVTbLZkD6caEkF8ESNFNQ4R0MwEwXTLqfN7gfsI6/o/5+0oef5uJw2WW559CEGh96P7HZyqDHemUw1stOt7rlBiAx13OuLy3j9B2A92qUjuzeak22CcPLEywqzuLJvflYySNGYYBHs33hNlzPvUiTbO3htRFKf4K9a+hHxR7zzYwc/fL3lRRJaqhMrYmGHOG1aRJWBLKaslE/hK1j8z6FwskIFa93hTpRyvyK9RZYo6kY9o055XhxqHrKkEqd5yZDvUqZxyrjHvMy1hadwqj17S8FFLl2BEadxArq1PdhAoilVe4JUrhsm/ZAkdLZZFN3cmCZczZ0+WZuh9yDxX99m1KAWNlYLCJh0M5knvHkGpnB35m8lBKZ1OCmv/VgfhOg= X-Forefront-PRVS: 0121F24F22 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR08MB0573; 23:SL84+3VDNQN4tWWIHeuP05VsofcTI3ZQ1fcuIWUdO?= =?us-ascii?Q?Tj0xT25bNn/JXatv8CObKWtvdikmhWOj3H/II/qjiu+HKUwjwLU5zrCIbqNn?= =?us-ascii?Q?2SUTGodk8kdr5Xsm5XgCxCK3EXe1iPjdSchlf0FruELjht/qqZFX+5M+Ft7G?= =?us-ascii?Q?3SFCZuqKTuaO3GF1c0z/+NRvKYqdOomeTXPwtXSUUAEbq/KvydnaLMVxtf3I?= =?us-ascii?Q?VCk8qXmjrXDPzkRsqvVOz3UFfUCd8RjfLALfIh/GjlhR+CToJhqUIGO2jw37?= =?us-ascii?Q?wuR++sY5UrYgsxThUiy5/Cnd6AI2Q8bhGWY3vN7IGtv4daw8dXcPD0a4a8BH?= =?us-ascii?Q?Xp0Ci9P+kswe0vaFqGxXCzcf7NEPJsDKWfX2LqChCd1Fc/fKQDL6obIt4V3J?= =?us-ascii?Q?3ky+XBx2MzxsB/K6qutDgRmpG/15FlycaO0s01X66hokJkSxQCElSRWOCi1g?= =?us-ascii?Q?4vJI3oCqIYCyZWMGInJnt74rpN8Ss5r4Mu4pUKLE46Zq94iYKPZuNFzBZH5/?= =?us-ascii?Q?ax1VevujJRpImPrdQbQmTwoISOusBk9wC5uSELK4pWYUbQ/CBxa5OLFLgsP0?= =?us-ascii?Q?zqoQS+7cej2x9NEEPkzouP4XROlS134/8s/4JIcPMizfy3nNCeb75KALSctE?= =?us-ascii?Q?78o4/6evnZXjAbzc9Gn4tfIfld9VcDpA9SZjXYx5TIN+dnxIPAkLR0srNP4i?= =?us-ascii?Q?uzl5QQRs9FCnLcJ76/3Yc5TnD06AsoeYYy9qs6SgYaHbwkl67md6TEVWKbtR?= =?us-ascii?Q?VWh5U6AHULuITmqgFCu3WHQHshG37yvOTE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ew0RKpleEvVRbliUBihubuLAZQla4Ycl9IaJxUfa/v5ZSUrKjBX8ouC2e2k5JELSPpeuc1Ai+V1EDFXVo2Y0SvKn66PkeQS47XFe0T7a7YLBdqYauYDsStljZTnad9h35e1A/1w7CnlAtXjV61v5vlKZveM2+za2RFBOH/bwkhACb/8n44s0THhmgCg2wyHerLjowhV0t8m9P6Eu5AAFAtFgJyoDuzFqjyVNtIzX/JjOuagX/IJC4ySy6sKkejt5KcGZGOtbbiSipqZ/bmoTyLx3R6sG2E+kG7B1ng1qxrYoJGkbjaP3XZ82jYA8kqtNrs= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2016 07:09:11.3990 (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: VI1PR08MB0573 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161108_230947_618076_D1D8C494 X-CRM114-Status: GOOD ( 14.01 ) 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 When testing the gigantic page whose order is too large for the buddy allocator, the libhugetlbfs test case "counter.sh" will fail. The failure is caused by: 1) kernel fails to allocate a gigantic page for the surplus case. And the gather_surplus_pages() will return NULL in the end. 2) The condition checks for "over-commit" is wrong. This patch adds code to allocate the gigantic page in the __alloc_huge_page(). After this patch, gather_surplus_pages() can return a gigantic page for the surplus case. This patch changes the condition checks for: return_unused_surplus_pages() nr_overcommit_hugepages_store() hugetlb_overcommit_handler() This patch also set @nid with proper value when NUMA_NO_NODE is passed to alloc_gigantic_page(). After this patch, the counter.sh can pass for the gigantic page. Acked-by: Steve Capper Signed-off-by: Huang Shijie --- 1. fix the wrong check in hugetlb_overcommit_handler(); 2. try to fix the s390 issue. --- mm/hugetlb.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 9fdfc24..5dbfd62 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1095,6 +1095,9 @@ static struct page *alloc_gigantic_page(int nid, unsigned int order) unsigned long ret, pfn, flags; struct zone *z; + if (nid == NUMA_NO_NODE) + nid = numa_mem_id(); + z = NODE_DATA(nid)->node_zones; for (; z - NODE_DATA(nid)->node_zones < MAX_NR_ZONES; z++) { spin_lock_irqsave(&z->lock, flags); @@ -1578,7 +1581,7 @@ static struct page *__alloc_huge_page(struct hstate *h, struct page *page; unsigned int r_nid; - if (hstate_is_gigantic(h)) + if (hstate_is_gigantic(h) && !gigantic_page_supported()) return NULL; /* @@ -1623,7 +1626,13 @@ static struct page *__alloc_huge_page(struct hstate *h, } spin_unlock(&hugetlb_lock); - page = __hugetlb_alloc_buddy_huge_page(h, vma, addr, nid); + if (hstate_is_gigantic(h)) { + page = alloc_gigantic_page(nid, huge_page_order(h)); + if (page) + prep_compound_gigantic_page(page, huge_page_order(h)); + } else { + page = __hugetlb_alloc_buddy_huge_page(h, vma, addr, nid); + } spin_lock(&hugetlb_lock); if (page) { @@ -1790,8 +1799,7 @@ static void return_unused_surplus_pages(struct hstate *h, /* Uncommit the reservation */ h->resv_huge_pages -= unused_resv_pages; - /* Cannot return gigantic pages currently */ - if (hstate_is_gigantic(h)) + if (hstate_is_gigantic(h) && !gigantic_page_supported()) return; nr_pages = min(unused_resv_pages, h->surplus_huge_pages); @@ -2443,7 +2451,7 @@ static ssize_t nr_overcommit_hugepages_store(struct kobject *kobj, unsigned long input; struct hstate *h = kobj_to_hstate(kobj, NULL); - if (hstate_is_gigantic(h)) + if (hstate_is_gigantic(h) && !gigantic_page_supported()) return -EINVAL; err = kstrtoul(buf, 10, &input); @@ -2884,7 +2892,7 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write, tmp = h->nr_overcommit_huge_pages; - if (write && hstate_is_gigantic(h)) + if (write && hstate_is_gigantic(h) && !gigantic_page_supported()) return -EINVAL; table->data = &tmp;