From patchwork Wed Sep 2 18:06:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 11751503 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 F417C109A for ; Wed, 2 Sep 2020 18:07:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id ACE2B2083B for ; Wed, 2 Sep 2020 18:07:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sent.com header.i=@sent.com header.b="d0fu8CF1"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="D+VDVEja" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ACE2B2083B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 97BD8900019; Wed, 2 Sep 2020 14:06:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2C3FE900025; Wed, 2 Sep 2020 14:06:37 -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 A913290001F; Wed, 2 Sep 2020 14:06:36 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0078.hostedemail.com [216.40.44.78]) by kanga.kvack.org (Postfix) with ESMTP id 1A6AA900023 for ; Wed, 2 Sep 2020 14:06:36 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id D1FEF8248047 for ; Wed, 2 Sep 2020 18:06:35 +0000 (UTC) X-FDA: 77218901550.13.girls97_0114837270a2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id A656718140B60 for ; Wed, 2 Sep 2020 18:06:35 +0000 (UTC) X-Spam-Summary: 1,0,0,0d7882436ded0b65,d41d8cd98f00b204,zi.yan@sent.com,,RULES_HIT:41:69:355:379:541:560:800:960:966:973:988:989:1260:1261:1311:1314:1345:1359:1437:1515:1535:1544:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:2731:2895:3138:3139:3140:3141:3142:3352:3867:3868:3871:4119:4250:4321:4385:5007:6119:6120:6261:6630:6653:7576:7903:7904:8957:9592:10004:11026:11473:11658:11914:12043:12291:12296:12438:12555:12679:12683:12895:12986:13894:14096:14110:14181:14721:21080:21627:21966:21990:30054:30064:30070,0,RBL:66.111.4.25:@sent.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04yrc3f66hx1agz7q66fxooouxqrrocr9d7k8miq5yty48aw661ychix3monajd.q8mjbizexzm3our1kg39ogajbcmo1jttu9zxwfx8cqhhaamjjeewhmym8ufmhzu.r-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:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: girls97_0114837270a2 X-Filterd-Recvd-Size: 8657 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Wed, 2 Sep 2020 18:06:35 +0000 (UTC) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id C83AF5C0228; Wed, 2 Sep 2020 14:06:34 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 02 Sep 2020 14:06:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sent.com; h=from :to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; s=fm1; bh=s9cLKQkvqUgXX 9qXewNv9AkRjEs8xeCBdkOQExd8Kic=; b=d0fu8CF1/88vb3bsZ//Ho24Y0suIX KQI0dXvhwHw6lSXXK7Ssxhq8nomgdsyFgR63v8tb4xjpetozezYfOHCe3yqAhe9A cYfpbx/ETEuYd/8hWLjP6GD/YHxEggMXs14iCEW1MKR2+To1GaMYxOTSkuxijhwt EJJp9HrWfU/MphR0SME/Wa8eMYuM7b+XasdN83zg6zSNQIv1AopRE2/IR6SLbwve Dmm6+TE1oskLFZAA9AcZyxqwytCQDcV1n12kESu6xGbLch4Tsb4XgQGODsWTsGBs lKVyENQ+EdxAkKBlqzvtbYbq02eBWevmzOuKac+VoIj49z4KpNP7CpIgg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:reply-to:subject :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=s9cLKQkvqUgXX9qXewNv9AkRjEs8xeCBdkOQExd8Kic=; b=D+VDVEja tEWQh/q4xvCmWQ0PreIazjh+j4MqjMIrUNRr3K2yx0KtC/6EOTtdJm8YrGIlbNj1 saYcp8FpDifWHUxM/AKiHxxrUknO7J+MW8WLawZJfMJOaZhvV51jdI0An7xgeBQt UFw+3s4Cy3Owm1e6EhqKu0zzw2oXyVBF2egbD31IiiI/USetF9iUqIlnt/Rw3OaP Vaj8AO01ZnSddKw8xORhiFSA9XeOSRR7G08/UwEhLna0ECpd7pcE6vA+94FgnQ44 zzJ3uYxq+poFQ2jBUzjNkTJOH3QkoEKdFQeykpggx2OzbIEVLyZRxrGOf0y1s8cK XO8WYhIsaegQIw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudefledguddvudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpegkihcu jggrnhcuoeiiihdrhigrnhesshgvnhhtrdgtohhmqeenucggtffrrghtthgvrhhnpeduhf ffveektdduhfdutdfgtdekkedvhfetuedufedtgffgvdevleehheevjefgtdenucfkphep uddvrdegiedruddtiedrudeigeenucevlhhushhtvghrufhiiigvpeduvdenucfrrghrrg hmpehmrghilhhfrhhomhepiihirdihrghnsehsvghnthdrtghomh X-ME-Proxy: Received: from nvrsysarch6.NVidia.COM (unknown [12.46.106.164]) by mail.messagingengine.com (Postfix) with ESMTPA id 1633630600A6; Wed, 2 Sep 2020 14:06:34 -0400 (EDT) From: Zi Yan To: linux-mm@kvack.org, Roman Gushchin Cc: Rik van Riel , "Kirill A . Shutemov" , Matthew Wilcox , Shakeel Butt , Yang Shi , David Nellans , linux-kernel@vger.kernel.org, Zi Yan Subject: [RFC PATCH 14/16] mm: page_alloc: >=MAX_ORDER pages allocation an deallocation. Date: Wed, 2 Sep 2020 14:06:26 -0400 Message-Id: <20200902180628.4052244-15-zi.yan@sent.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200902180628.4052244-1-zi.yan@sent.com> References: <20200902180628.4052244-1-zi.yan@sent.com> Reply-To: Zi Yan MIME-Version: 1.0 X-Rspamd-Queue-Id: A656718140B60 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: From: Zi Yan Use alloc_contig_pages for allocation and destroy_compound_gigantic_page for deallocation, so 1GB THP can be created and destroyed without changing MAX_ORDER. Signed-off-by: Zi Yan --- mm/hugetlb.c | 22 ---------------------- mm/internal.h | 2 ++ mm/mempolicy.c | 15 ++++++++++++++- mm/page_alloc.c | 33 ++++++++++++++++++++++++++++----- 4 files changed, 44 insertions(+), 28 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 4113d7b66fee..d5357778b026 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1211,26 +1211,6 @@ static int hstate_next_node_to_free(struct hstate *h, nodemask_t *nodes_allowed) nr_nodes--) #ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE -static void destroy_compound_gigantic_page(struct page *page, - unsigned int order) -{ - int i; - int nr_pages = 1 << order; - struct page *p = page + 1; - - atomic_set(compound_mapcount_ptr(page), 0); - if (hpage_pincount_available(page)) - atomic_set(compound_pincount_ptr(page), 0); - - for (i = 1; i < nr_pages; i++, p = mem_map_next(p, page, i)) { - clear_compound_head(p); - set_page_refcounted(p); - } - - set_compound_order(page, 0); - __ClearPageHead(page); -} - static void free_gigantic_page(struct page *page, unsigned int order) { /* @@ -1288,8 +1268,6 @@ static struct page *alloc_gigantic_page(struct hstate *h, gfp_t gfp_mask, return NULL; } static inline void free_gigantic_page(struct page *page, unsigned int order) { } -static inline void destroy_compound_gigantic_page(struct page *page, - unsigned int order) { } #endif static void update_and_free_page(struct hstate *h, struct page *page) diff --git a/mm/internal.h b/mm/internal.h index 10c677655912..520fd9b5e18a 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -620,4 +620,6 @@ struct migration_target_control { gfp_t gfp_mask; }; +void destroy_compound_gigantic_page(struct page *page, + unsigned int order); #endif /* __MM_INTERNAL_H */ diff --git a/mm/mempolicy.c b/mm/mempolicy.c index eddbe4e56c73..4bae089e7a89 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -2138,7 +2138,12 @@ static struct page *alloc_page_interleave(gfp_t gfp, unsigned order, { struct page *page; - page = __alloc_pages(gfp, order, nid); + if (order > MAX_ORDER) { + page = alloc_contig_pages(1UL< MAX_ORDER) { + page = alloc_contig_pages(1UL<= MAX_ORDER) { + destroy_compound_gigantic_page(page, order); + free_contig_range(page_to_pfn(page), 1 << order); + } else { + migratetype = get_pfnblock_migratetype(page, pfn); + local_irq_save(flags); + __count_vm_events(PGFREE, 1 << order); + free_one_page(page_zone(page), page, pfn, order, migratetype); + local_irq_restore(flags); + } } void __free_pages_core(struct page *page, unsigned int order)