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=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,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 D4D5EC2BA83 for ; Wed, 12 Feb 2020 04:19:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8D52B2082F for ; Wed, 12 Feb 2020 04:19:36 +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="SnUC7w/y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D52B2082F 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 5A89A6B03AA; Tue, 11 Feb 2020 23:18:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 530E36B03B0; Tue, 11 Feb 2020 23:18:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 29AA26B03AA; Tue, 11 Feb 2020 23:18:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E1BED6B03AF for ; Tue, 11 Feb 2020 23:18:50 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 96A17247F for ; Wed, 12 Feb 2020 04:18:50 +0000 (UTC) X-FDA: 76480169220.08.spy07_12f63348dd739 X-HE-Tag: spy07_12f63348dd739 X-Filterd-Recvd-Size: 4454 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Wed, 12 Feb 2020 04:18:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=jC8GtqN7d2PIFCD2G3A5qYYZdOVd9+NyuF2giQfeE+o=; b=SnUC7w/yzeO9wGbmJ2fnvAHg89 K5jXSIBNG58NYxIMnIxF21rJkwkCQYrEkore2fZNo1VJUUYPGzVtcNmb30mYaSZpvPQ1y9/HBi30Q ihriKwGl6uluD0O34tdvP28toUE4cDKNstqK9oF1csHhTMaTegIsCdmmbMEWx720j7RKCkLtDCBHl f/tImbi4SOkmns7CSo9mpGgVQ7cdb4s3Occ8ld3mmAe9XLVzNA6svmT5unVEozWJfcFLuqQowPSNN B+zKBDGLCj1zhTKXB6udltcwdAMlV3iQ2t8dhHlyZTvf3EpY/3GJYFEg+B3YuvLEwtecTbcOYSIkL /e4SD9XA==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j1jU7-0006op-CJ; Wed, 12 Feb 2020 04:18:47 +0000 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, "Kirill A . Shutemov" Subject: [PATCH v2 21/25] mm: Add __page_cache_alloc_order Date: Tue, 11 Feb 2020 20:18:41 -0800 Message-Id: <20200212041845.25879-22-willy@infradead.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200212041845.25879-1-willy@infradead.org> References: <20200212041845.25879-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: From: "Matthew Wilcox (Oracle)" 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 | 12 ++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 497197315b73..64a3cf79611f 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -207,15 +207,33 @@ static inline int page_cache_add_speculative(struct= page *page, int count) return __page_cache_add_speculative(page, count); } =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 prep_transhuge_page(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 3204293f9b58..1061463a169e 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -941,24 +941,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); + prep_transhuge_page(page); } while (!page && read_mems_allowed_retry(cpuset_mems_cookie)); =20 return page; } - return alloc_pages(gfp, 0); + return prep_transhuge_page(alloc_pages(gfp, order)); } -EXPORT_SYMBOL(__page_cache_alloc); +EXPORT_SYMBOL(__page_cache_alloc_order); #endif =20 /* --=20 2.25.0