From patchwork Thu May 3 23:29:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 10379455 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 E9CAF60159 for ; Thu, 3 May 2018 23:30:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1E21292A5 for ; Thu, 3 May 2018 23:30:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D61D1292A9; Thu, 3 May 2018 23:30:03 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48FB6292A5 for ; Thu, 3 May 2018 23:30:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 97FD76B0012; Thu, 3 May 2018 19:29:57 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 933396B0022; Thu, 3 May 2018 19:29:57 -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 7FD1B6B0023; Thu, 3 May 2018 19:29:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ua0-f197.google.com (mail-ua0-f197.google.com [209.85.217.197]) by kanga.kvack.org (Postfix) with ESMTP id 5127E6B0012 for ; Thu, 3 May 2018 19:29:57 -0400 (EDT) Received: by mail-ua0-f197.google.com with SMTP id t46so7276048uad.3 for ; Thu, 03 May 2018 16:29:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=Cu/nvaY6hOAR27EPnspG8e40STNFGQF7EKGuCDSZk1g=; b=RjqzK9DpDltyuaAwDhQMm2L7QWlJcsC/Q10Zlv6xED/7Vrlw2Mtsey29Bx9phos4Kc WtkjZXt91kGyd+Tr9ERtuae/WJPlDXhLHVjgleaof9M79uF3VIBTFkuZElUEiNnFOiGV 3LNIcXStlyIHz0I4imvUr8W2JIE5zveoX+PuMCGIJe+8VyXzChK5/0dCnvBXDW9yT14H dHB/JwH4nGkrOQoohyPT100BoZgzVx5JSXhHvXwaFSCBQRNrhZ3xK+qnHjVAluTRpIi4 9ez9eJ/+XI0ygt/UBmD8YeaaU1lIzNveAh8VW9REfAeCmpm5oglUgvfjTJvf6cYqLiNE /4aw== X-Gm-Message-State: ALQs6tB5xtAILELxzuIXWHC6yGpJJo8r/6k4Q/FaFr2DmNCnTWGdztNf eVBN3LX2Br2o9H+BgFBSIB7V2RlSBAjsBSxGuN3bBYBtThwy+jjZW0o2cnxJzsShaK+bBwLSIxl 1oxpkCDf9/HSO8i1jRFwBGapRDLhlpMxzkMHVDFRPaJWHRQf1qpCQUeTuyHcyT8hD+w== X-Received: by 2002:a1f:954c:: with SMTP id x73-v6mr17318337vkd.129.1525390197025; Thu, 03 May 2018 16:29:57 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoTAHJh/kQVGvi0oJKPOwjyWV+pBj9KCBot/meneWGEoRoVDNxm3J8DBIADgNOPiyLNSYoU X-Received: by 2002:a1f:954c:: with SMTP id x73-v6mr17318302vkd.129.1525390196315; Thu, 03 May 2018 16:29:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525390196; cv=none; d=google.com; s=arc-20160816; b=ns+ddIVwVBPWbx8YkK4QWi/8dw27nx8Z1ahL/+5VFkmSbpNHMtbScZp6lgbFgEupOo /Gf7glB9d3bF7QE3BtqHIfNy9frk8UNc6oG77F9DBRtD4CgRdGhdlp4Mqw2jL3h/z967 3drsdVeK8GQo7Cz5VPg8H1KINGMnBkp4aDU+DQdLCCR66oQqEaHxAYnPNw5Bp16i2j0m QMyzNNCw8Z6xHpjmxfI2HN/CoWypHaq9VLHSjVQdrAT7CCl4CDGYhM5zpxfNOKhlGlu0 AFQs0HPLmLae9iM/nmKVqlEkRuvQJq63IUPnKRyFikTYjto4gC0ydglKiqUzq/oGJ1YC 2x1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Cu/nvaY6hOAR27EPnspG8e40STNFGQF7EKGuCDSZk1g=; b=qFw3KMN1K4z8T+yEVtcJC9uWWUngyNNB7Ar7S4gQKjQyvF6DIZTfgXPOYnrffBf4MY iBgTCK+3siM5ECkOYDvCQRNePd2wCRAr2byLo5DbqJagWU/+dkOXHs2UwPZdYu97ACI4 Ebny0eGl9fIbMjadzzKdz13Hoj238KetZU0BCBlzGLj4COw62G+RCSKiAf0tGKr2y0ti GvbI35xseDMMiTG2Ni6Z3y5e+jht+uvYoR43CbEsWPy6ftKpch7BwKfJqmWtsXp+lLvr tphFcl1rhG9lCu4kupDkEbmuWE3NRdTkxfmTwYnmFUcqFLXUCOUbwYxN0b/pSKU+UkqT t6tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=pcgJTRcN; spf=pass (google.com: domain of mike.kravetz@oracle.com designates 141.146.126.79 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from aserp2130.oracle.com (aserp2130.oracle.com. [141.146.126.79]) by mx.google.com with ESMTPS id k80-v6si7593083vki.103.2018.05.03.16.29.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 16:29:56 -0700 (PDT) Received-SPF: pass (google.com: domain of mike.kravetz@oracle.com designates 141.146.126.79 as permitted sender) client-ip=141.146.126.79; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=pcgJTRcN; spf=pass (google.com: domain of mike.kravetz@oracle.com designates 141.146.126.79 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w43NLlRP176562; Thu, 3 May 2018 23:29:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=Cu/nvaY6hOAR27EPnspG8e40STNFGQF7EKGuCDSZk1g=; b=pcgJTRcN0Y8uNFuSb+IzbDZPjKpBTWWDTwMx/nC5SF5+J/7gN6npiio0khTwMzKFX9JN 5YvyIp0fj+wPhuAcSaTqGJhPNDxFwiepZN4olLRGfXnfGgbkW7Ckdd1M5+qOyD216+VU estGHAqIlqJpeiXUZyP9mD/fF6dzUTieZ8ClEKaf+x4ugIkiJsaXxFGJDfPNxE9B/9je JsHqsIOt6bQIEi6qwWSYmTPUlqOzjZe784fDhgJ4MXPw661j8acZmbF/GJ262hOUFL4x 2BOdWtwQjR5M8mM/CpL/N7gWlVbTFmWR9GJxne0RswK0wtDlFj+RPn77fS/amSMTtq37 8A== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2130.oracle.com with ESMTP id 2hmeg642uw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 03 May 2018 23:29:52 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w43NTpBh021567 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 3 May 2018 23:29:51 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w43NTpNZ023768; Thu, 3 May 2018 23:29:51 GMT Received: from monkey.oracle.com (/50.38.38.67) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 03 May 2018 16:29:51 -0700 From: Mike Kravetz To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org Cc: Reinette Chatre , Michal Hocko , Christopher Lameter , Guy Shattah , Anshuman Khandual , Michal Nazarewicz , Vlastimil Babka , David Nellans , Laura Abbott , Pavel Machek , Dave Hansen , Andrew Morton , Mike Kravetz Subject: [PATCH v2 4/4] mm/hugetlb: use find_alloc_contig_pages() to allocate gigantic pages Date: Thu, 3 May 2018 16:29:35 -0700 Message-Id: <20180503232935.22539-5-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180503232935.22539-1-mike.kravetz@oracle.com> References: <20180503232935.22539-1-mike.kravetz@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8882 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=551 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805030204 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: X-Virus-Scanned: ClamAV using ClamSMTP Use the new find_alloc_contig_pages() interface for the allocation of gigantic pages and remove associated code in hugetlb.c. Signed-off-by: Mike Kravetz --- mm/hugetlb.c | 87 +++++------------------------------------------------------- 1 file changed, 6 insertions(+), 81 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index c81072ce7510..91edf1df3592 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1053,91 +1053,16 @@ static void destroy_compound_gigantic_page(struct page *page, __ClearPageHead(page); } -static void free_gigantic_page(struct page *page, unsigned int order) +static void free_gigantic_page(struct page *page, struct hstate *h) { - free_contig_range(page_to_pfn(page), 1UL << order); -} - -static int __alloc_gigantic_page(unsigned long start_pfn, - unsigned long nr_pages, gfp_t gfp_mask) -{ - unsigned long end_pfn = start_pfn + nr_pages; - return alloc_contig_range(start_pfn, end_pfn, MIGRATE_MOVABLE, - gfp_mask); -} - -static bool pfn_range_valid_gigantic(struct zone *z, - unsigned long start_pfn, unsigned long nr_pages) -{ - unsigned long i, end_pfn = start_pfn + nr_pages; - struct page *page; - - for (i = start_pfn; i < end_pfn; i++) { - if (!pfn_valid(i)) - return false; - - page = pfn_to_page(i); - - if (page_zone(page) != z) - return false; - - if (PageReserved(page)) - return false; - - if (page_count(page) > 0) - return false; - - if (PageHuge(page)) - return false; - } - - return true; -} - -static bool zone_spans_last_pfn(const struct zone *zone, - unsigned long start_pfn, unsigned long nr_pages) -{ - unsigned long last_pfn = start_pfn + nr_pages - 1; - return zone_spans_pfn(zone, last_pfn); + free_contig_pages(page, (unsigned long)pages_per_huge_page(h)); } static struct page *alloc_gigantic_page(struct hstate *h, gfp_t gfp_mask, int nid, nodemask_t *nodemask) { - unsigned int order = huge_page_order(h); - unsigned long nr_pages = 1 << order; - unsigned long ret, pfn, flags; - struct zonelist *zonelist; - struct zone *zone; - struct zoneref *z; - - zonelist = node_zonelist(nid, gfp_mask); - for_each_zone_zonelist_nodemask(zone, z, zonelist, gfp_zone(gfp_mask), nodemask) { - spin_lock_irqsave(&zone->lock, flags); - - pfn = ALIGN(zone->zone_start_pfn, nr_pages); - while (zone_spans_last_pfn(zone, pfn, nr_pages)) { - if (pfn_range_valid_gigantic(zone, pfn, nr_pages)) { - /* - * We release the zone lock here because - * alloc_contig_range() will also lock the zone - * at some point. If there's an allocation - * spinning on this lock, it may win the race - * and cause alloc_contig_range() to fail... - */ - spin_unlock_irqrestore(&zone->lock, flags); - ret = __alloc_gigantic_page(pfn, nr_pages, gfp_mask); - if (!ret) - return pfn_to_page(pfn); - spin_lock_irqsave(&zone->lock, flags); - } - pfn += nr_pages; - } - - spin_unlock_irqrestore(&zone->lock, flags); - } - - return NULL; + return find_alloc_contig_pages((unsigned long)pages_per_huge_page(h), + gfp_mask, nid, nodemask); } static void prep_new_huge_page(struct hstate *h, struct page *page, int nid); @@ -1147,7 +1072,7 @@ static void prep_compound_gigantic_page(struct page *page, unsigned int order); static inline bool gigantic_page_supported(void) { return false; } static struct page *alloc_gigantic_page(struct hstate *h, gfp_t gfp_mask, int nid, nodemask_t *nodemask) { return NULL; } -static inline void free_gigantic_page(struct page *page, unsigned int order) { } +static inline void free_gigantic_page(struct page *page, struct hstate *h) { } static inline void destroy_compound_gigantic_page(struct page *page, unsigned int order) { } #endif @@ -1172,7 +1097,7 @@ static void update_and_free_page(struct hstate *h, struct page *page) set_page_refcounted(page); if (hstate_is_gigantic(h)) { destroy_compound_gigantic_page(page, huge_page_order(h)); - free_gigantic_page(page, huge_page_order(h)); + free_gigantic_page(page, h); } else { __free_pages(page, huge_page_order(h)); }