From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16407C55178 for ; Thu, 29 Oct 2020 19:34:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4C939214DB for ; Thu, 29 Oct 2020 19:34:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="p/v9M6ww" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C939214DB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 290756B007E; Thu, 29 Oct 2020 15:34:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DD4346B0080; Thu, 29 Oct 2020 15:34:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AC7D46B007D; Thu, 29 Oct 2020 15:34:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0190.hostedemail.com [216.40.44.190]) by kanga.kvack.org (Postfix) with ESMTP id 737416B0078 for ; Thu, 29 Oct 2020 15:34:14 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 1D0A71EF1 for ; Thu, 29 Oct 2020 19:34:14 +0000 (UTC) X-FDA: 77425964028.01.drum23_041026e27290 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id EBA771004B368 for ; Thu, 29 Oct 2020 19:34:13 +0000 (UTC) X-HE-Tag: drum23_041026e27290 X-Filterd-Recvd-Size: 4298 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Thu, 29 Oct 2020 19:34:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=3hbUZbM6zGykKpCg4QK7R1IyrA2YegBa7tJLLyOCQP8=; b=p/v9M6wwP8wJfhOVYcSHALP0Io 3ej4nUuX+G7NfN+JzKtFwVXYKBam//vH81nE63uNuDSeBOw5rj4OC224lElZqXsWNO64xOKWA8o6F IlDGD2L12OB1yA/v0dTtDxQfM2DdX61F3ztgR6qe0LVOSK1jDZJeXExzanTsNNPwmvlTMDkIDCHQF jO08whbEyiEI5CAPCZtDl5MC4VAbe7QPl2T6cSoV/wElmRuSXTWsy/ZFbqCvplBzncx9zl30DI8t1 cXfYXtvBCBDiuDuCbux4HV+2XwCbTipydb+5yHYGR7r9qdQId48QcUKTafbUXV0us+YseE+osJHe0 s3l/dKMg==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kYDgX-0007bu-IX; Thu, 29 Oct 2020 19:34:09 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , "Kirill A . Shutemov" Subject: [PATCH 08/19] mm/filemap: Add __page_cache_alloc_order Date: Thu, 29 Oct 2020 19:33:54 +0000 Message-Id: <20201029193405.29125-9-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201029193405.29125-1-willy@infradead.org> References: <20201029193405.29125-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: This new function allows page cache pages to be allocated that are larger than an order-0 page. Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Kirill A. Shutemov --- include/linux/pagemap.h | 24 +++++++++++++++++++++--- mm/filemap.c | 16 ++++++++++------ 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 00288ed24698..bb6692001028 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -284,15 +284,33 @@ static inline void *detach_page_private(struct page= *page) return data; } =20 +static inline gfp_t thp_gfpmask(gfp_t gfp) +{ +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + /* We'd rather allocate smaller pages than stall a page fault */ + gfp |=3D GFP_TRANSHUGE_LIGHT; + gfp &=3D ~__GFP_DIRECT_RECLAIM; +#endif + return gfp; +} + #ifdef CONFIG_NUMA -extern struct page *__page_cache_alloc(gfp_t gfp); +extern struct page *__page_cache_alloc_order(gfp_t gfp, unsigned int ord= er); #else -static inline struct page *__page_cache_alloc(gfp_t gfp) +static inline +struct page *__page_cache_alloc_order(gfp_t gfp, unsigned int order) { - return alloc_pages(gfp, 0); + if (order =3D=3D 0) + return alloc_pages(gfp, 0); + return thp_prep(alloc_pages(thp_gfpmask(gfp), order)); } #endif =20 +static inline struct page *__page_cache_alloc(gfp_t gfp) +{ + return __page_cache_alloc_order(gfp, 0); +} + static inline struct page *page_cache_alloc(struct address_space *x) { return __page_cache_alloc(mapping_gfp_mask(x)); diff --git a/mm/filemap.c b/mm/filemap.c index c0161f42f37d..64fe0018ee17 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -934,24 +934,28 @@ int add_to_page_cache_lru(struct page *page, struct= address_space *mapping, EXPORT_SYMBOL_GPL(add_to_page_cache_lru); =20 #ifdef CONFIG_NUMA -struct page *__page_cache_alloc(gfp_t gfp) +struct page *__page_cache_alloc_order(gfp_t gfp, unsigned int order) { int n; struct page *page; =20 + if (order > 0) + gfp =3D thp_gfpmask(gfp); + if (cpuset_do_page_mem_spread()) { unsigned int cpuset_mems_cookie; do { cpuset_mems_cookie =3D read_mems_allowed_begin(); n =3D cpuset_mem_spread_node(); - page =3D __alloc_pages_node(n, gfp, 0); + page =3D __alloc_pages_node(n, gfp, order); } while (!page && read_mems_allowed_retry(cpuset_mems_cookie)); - - return page; + } else { + page =3D alloc_pages(gfp, order); } - return alloc_pages(gfp, 0); + + return thp_prep(page); } -EXPORT_SYMBOL(__page_cache_alloc); +EXPORT_SYMBOL(__page_cache_alloc_order); #endif =20 /* --=20 2.28.0