Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp146248pxv; Thu, 15 Jul 2021 00:50:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyef2J2xMitqeS+BteoRW3j4Cn+woCS2+z+cMmDqjDMgy9f0nJQXyp0i1UPfJ6HjGsV+x2t X-Received: by 2002:a17:906:7012:: with SMTP id n18mr3963197ejj.236.1626335452100; Thu, 15 Jul 2021 00:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626335452; cv=none; d=google.com; s=arc-20160816; b=U+GqNB2fokKRCIcyjkNyJyqXHMXxRK9td+t4YwF5NyYy7IwATQ83QwTalr9dtXBHaF vJVUgsyr20FY/6hJvhUG55leteEPtpAfTRFWCmtlmcWPhp16/SNupWpISdVSIUT3xlkp gr69CKpbCZ/jAVyIE1FbNax2oLFFpFXztgtkC/NldKMiuQaVLn38mr568Bxd5gAA2JLa yzoMuKltzSqL9RcDZw8SKmwHwI0wd7ffiQsnEffJ63P6g+kgPE2bi45ksEyJxxwe1s8n jLYkguX5ezT30Q9wj1sK8oNVxL3TTV+C9GIEPUSwFENf84H12g4Ork2iuM+Q2DuHFSWI XKFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=flIpsNI9pEz0i4v6s1nQcu/zmXv7ucD3WLL0ysBrFV4=; b=U7ky3c1XHFSWO1WZU1raxO7mwM0vMzpQLUFxKXQErv4gtURw3F9ez9xJDlPXNx5V5B +AJAkE36Sxi2AL3Z/qUIHxAIbQzqFaxIZy7fiTlHNsBYZf46G2O2jLfhCakcNy5Gq356 Hn8Fey4IGwls+MCURrRCYaqBMK/tcHQWdOKR7TATNntFPxzCZ3vv21OAJyLa/R8CUyfg 1qhc1xE631JYCKEpA5Aw4W+zaEe8h7VnoxlinOCvJS7eBEpKiSqYxfdu7xE6NgpvsJ91 4AUz5rZRTf+KiOXmmRc4cmlc5wQx0m+VG5sIzKc0ehKPb+LoFpLBw8eLzH2YPDgBts+a ZPfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=MTaL5Qmq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x23si6634862eds.52.2021.07.15.00.50.29; Thu, 15 Jul 2021 00:50:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=MTaL5Qmq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239441AbhGOFUo (ORCPT + 99 others); Thu, 15 Jul 2021 01:20:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239471AbhGOFUo (ORCPT ); Thu, 15 Jul 2021 01:20:44 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68660C06175F; Wed, 14 Jul 2021 22:17:51 -0700 (PDT) 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=flIpsNI9pEz0i4v6s1nQcu/zmXv7ucD3WLL0ysBrFV4=; b=MTaL5QmqTwvXLYRjXInQhfECKn LMYLQGrdCZ15BADiUIQCt8S7IEBMtR15uYRMiLvIwB0TjigHmJ6Ng1Wi1Mt+BRaX3yL2RIvdiIESY T9ah2IItnexdXvQbQodWTwoRo3g70u0aZy5fgBmcJPO4JP/XCtXptLepQMCT5OAA3kNRYewm1N+KO 7TNi+WJx1OxbTJFpacmyKisWuHvz2l253ajLotJFoKU6079rOSCEGhDu0o3EU+0tdxXqbNafxcEXo 7I8Spcp1dH5N6hOHmII1WGW6l6YpcPcPIEfeK0PuGSmHx6YQ5j70VMZHxH86Ew4qhJw1VlxavdLVW 58Mu0avQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m3tji-0030VQ-Ao; Thu, 15 Jul 2021 05:16:45 +0000 From: "Matthew Wilcox (Oracle)" To: linux-kernel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v14 123/138] mm/filemap: Use a folio in filemap_map_pages Date: Thu, 15 Jul 2021 04:36:49 +0100 Message-Id: <20210715033704.692967-124-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210715033704.692967-1-willy@infradead.org> References: <20210715033704.692967-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Saves 61 bytes due to fewer calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- mm/filemap.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 545323a77c1c..1c0c2663c57d 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3105,7 +3105,7 @@ static bool filemap_map_pmd(struct vm_fault *vmf, struct page *page) return false; } -static struct page *next_uptodate_page(struct folio *folio, +static struct folio *next_uptodate_page(struct folio *folio, struct address_space *mapping, struct xa_state *xas, pgoff_t end_pgoff) { @@ -3136,7 +3136,7 @@ static struct page *next_uptodate_page(struct folio *folio, max_idx = DIV_ROUND_UP(i_size_read(mapping->host), PAGE_SIZE); if (xas->xa_index >= max_idx) goto unlock; - return &folio->page; + return folio; unlock: folio_unlock(folio); skip: @@ -3146,7 +3146,7 @@ static struct page *next_uptodate_page(struct folio *folio, return NULL; } -static inline struct page *first_map_page(struct address_space *mapping, +static inline struct folio *first_map_page(struct address_space *mapping, struct xa_state *xas, pgoff_t end_pgoff) { @@ -3154,7 +3154,7 @@ static inline struct page *first_map_page(struct address_space *mapping, mapping, xas, end_pgoff); } -static inline struct page *next_map_page(struct address_space *mapping, +static inline struct folio *next_map_page(struct address_space *mapping, struct xa_state *xas, pgoff_t end_pgoff) { @@ -3171,16 +3171,17 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf, pgoff_t last_pgoff = start_pgoff; unsigned long addr; XA_STATE(xas, &mapping->i_pages, start_pgoff); - struct page *head, *page; + struct folio *folio; + struct page *page; unsigned int mmap_miss = READ_ONCE(file->f_ra.mmap_miss); vm_fault_t ret = 0; rcu_read_lock(); - head = first_map_page(mapping, &xas, end_pgoff); - if (!head) + folio = first_map_page(mapping, &xas, end_pgoff); + if (!folio) goto out; - if (filemap_map_pmd(vmf, head)) { + if (filemap_map_pmd(vmf, &folio->page)) { ret = VM_FAULT_NOPAGE; goto out; } @@ -3188,7 +3189,7 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf, addr = vma->vm_start + ((start_pgoff - vma->vm_pgoff) << PAGE_SHIFT); vmf->pte = pte_offset_map_lock(vma->vm_mm, vmf->pmd, addr, &vmf->ptl); do { - page = find_subpage(head, xas.xa_index); + page = folio_file_page(folio, xas.xa_index); if (PageHWPoison(page)) goto unlock; @@ -3209,12 +3210,12 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf, do_set_pte(vmf, page, addr); /* no need to invalidate: a not-present page won't be cached */ update_mmu_cache(vma, addr, vmf->pte); - unlock_page(head); + folio_unlock(folio); continue; unlock: - unlock_page(head); - put_page(head); - } while ((head = next_map_page(mapping, &xas, end_pgoff)) != NULL); + folio_unlock(folio); + folio_put(folio); + } while ((folio = next_map_page(mapping, &xas, end_pgoff)) != NULL); pte_unmap_unlock(vmf->pte, vmf->ptl); out: rcu_read_unlock(); -- 2.30.2