From patchwork Fri Apr 29 19:23:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 12832642 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56C55C433F5 for ; Fri, 29 Apr 2022 19:23:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 81C7F6B007B; Fri, 29 Apr 2022 15:23:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DE9AE6B008A; Fri, 29 Apr 2022 15:23:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9CF516B0081; Fri, 29 Apr 2022 15:23:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 390406B007B for ; Fri, 29 Apr 2022 15:23:41 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 1EB806052E for ; Fri, 29 Apr 2022 19:23:41 +0000 (UTC) X-FDA: 79410891042.17.EAE0C4D Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf30.hostedemail.com (Postfix) with ESMTP id 82CBA80070 for ; Fri, 29 Apr 2022 19:23:31 +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=+zAiCyBjvrTuBhEtoMOqrBMm0fkCkbcSgpHZRa3d/Yo=; b=j/w0u/De0/iMn9Y+w0aIyIN9E0 /L0+fc16fKLCpMr2UZvb4UdgnUxV7DR92wCQ7A6kTCF7DuUIe3kbsVKA+dtYDrhxTsdQOVAFSD9Y5 zp8RSMNIWO37W/CF6D605tzCkKQeZSBrifRsIWG9QBT91Lo2O7rDx/x22hYdroZvg5SNxC+bQywlL sMwZ6AlXKRIdoedCGJcZ6qyV6KiXF7G5ynd26NLWe5iCITMHOvPvqsladbTSSBI1IOtM1VXtH4RjK McZuu3NHBHydCowif5LpGkndAXWtQW8tYDz0uLoQEUanSPcvsWBoJzNHIaMnAKHTSm0BzuBUK4Fzu SRPFJRlg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nkWDL-00CjQA-0E; Fri, 29 Apr 2022 19:23:39 +0000 From: "Matthew Wilcox (Oracle)" To: akpm@linuxfoundation.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 19/21] mm/shmem: Convert shmem_alloc_and_acct_page to use a folio Date: Fri, 29 Apr 2022 20:23:27 +0100 Message-Id: <20220429192329.3034378-20-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220429192329.3034378-1-willy@infradead.org> References: <20220429192329.3034378-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 82CBA80070 X-Stat-Signature: smkxds1hkfwa556auagbsynyxtkfnroy Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="j/w0u/De"; dmarc=none; spf=none (imf30.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1651260211-847011 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: Convert shmem_alloc_hugepage() to return the folio that it uses and use a folio throughout shmem_alloc_and_acct_page(). Continue to return a page from shmem_alloc_and_acct_page() for now. Signed-off-by: Matthew Wilcox (Oracle) --- mm/shmem.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index afee80747647..e65daf511a9b 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1522,7 +1522,7 @@ static gfp_t limit_gfp_mask(gfp_t huge_gfp, gfp_t limit_gfp) return result; } -static struct page *shmem_alloc_hugepage(gfp_t gfp, +static struct folio *shmem_alloc_hugefolio(gfp_t gfp, struct shmem_inode_info *info, pgoff_t index) { struct vm_area_struct pvma; @@ -1540,7 +1540,7 @@ static struct page *shmem_alloc_hugepage(gfp_t gfp, shmem_pseudo_vma_destroy(&pvma); if (!folio) count_vm_event(THP_FILE_FALLBACK); - return &folio->page; + return folio; } static struct folio *shmem_alloc_folio(gfp_t gfp, @@ -1561,7 +1561,7 @@ static struct page *shmem_alloc_and_acct_page(gfp_t gfp, pgoff_t index, bool huge) { struct shmem_inode_info *info = SHMEM_I(inode); - struct page *page; + struct folio *folio; int nr; int err = -ENOSPC; @@ -1573,13 +1573,13 @@ static struct page *shmem_alloc_and_acct_page(gfp_t gfp, goto failed; if (huge) - page = shmem_alloc_hugepage(gfp, info, index); + folio = shmem_alloc_hugefolio(gfp, info, index); else - page = &shmem_alloc_folio(gfp, info, index)->page; - if (page) { - __SetPageLocked(page); - __SetPageSwapBacked(page); - return page; + folio = shmem_alloc_folio(gfp, info, index); + if (folio) { + __folio_set_locked(folio); + __folio_set_swapbacked(folio); + return &folio->page; } err = -ENOMEM;