From patchwork Tue Apr 23 22:55:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13640870 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 AEB4FC4345F for ; Tue, 23 Apr 2024 22:56:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07B956B0195; Tue, 23 Apr 2024 18:56:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 02FC36B0197; Tue, 23 Apr 2024 18:56:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE7576B0198; Tue, 23 Apr 2024 18:56:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C05A56B0195 for ; Tue, 23 Apr 2024 18:56:16 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 45C95160167 for ; Tue, 23 Apr 2024 22:56:16 +0000 (UTC) X-FDA: 82042306752.26.FAC4A80 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf27.hostedemail.com (Postfix) with ESMTP id A4B3C4000E for ; Tue, 23 Apr 2024 22:56:14 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="p/a8joIL"; spf=none (imf27.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713912974; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=NEsYsbU8qr0emUe6mxit/OuVTFvxbBfZCV5/pFcVA2w=; b=EDyDaeq3bMAXzrIwbGPXeEiEiBiROqpR7DgjBLuCJTuhaNXtVaFcfWqqrWMZxvarzN35Qy Oq2/rP0sRowVPB1syUrXbVNrSQOcO/tMJl53JHcRSi9Wy45nWwHlpgoYQ5F6kqPgBjjx45 5HQVzp5yCLlTLFBOgOMCj7fjwr1I8oQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713912974; a=rsa-sha256; cv=none; b=xFuJ4/bFvOaIN95M6Jcno+mMgQclM9ByqUtZkdtRBrJYOrdfafuOMsBMODHxDY6AY4gvH0 cfliF9ZFdp64qXrcKXnMpdKrf89sW5zxb+KvDnC8i02KV77cx9iSAwnH0CIaGx5v84EAst eghPkuAYfpu/14qDzZqTiYB8szo8DW4= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="p/a8joIL"; spf=none (imf27.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none 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=NEsYsbU8qr0emUe6mxit/OuVTFvxbBfZCV5/pFcVA2w=; b=p/a8joILHo6OFpo2LhD6CykxRP WENvmFqHj0Ms3f2UKDAOSFJIen96AOJiItabSIxbfg/vMqH4dve5AA62QmtoQ748wuOlzizNjlL4v e/zDOTLlGiOzyDSauvcqu33bjQxTK2ZeUyy6PqvLrabr328y521cnxeM6BDh9iZ+s9TtErkhXew+z OlE6R3FkJueq/zlMKzBgdWdABtXTXqu/xN0aOtUuyE3D6tkefH6hr2EXw8kA4xvYiF6HC2uyxj/aj ukM0aTq63eh25mHnTS/tu5nyZN7C3c9ERJpH7Wgy6T/aPdNNYtvAGR8cnfSlANAxPuxsZxHnO/yht A2/G5ZJQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzP3K-0000000HG6M-2eAw; Tue, 23 Apr 2024 22:55:54 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton , linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, linux-fscrypt@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH 5/6] userfault; Expand folio use in mfill_atomic_install_pte() Date: Tue, 23 Apr 2024 23:55:36 +0100 Message-ID: <20240423225552.4113447-6-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423225552.4113447-1-willy@infradead.org> References: <20240423225552.4113447-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: A4B3C4000E X-Stat-Signature: jdurjn3h6aaaobebks8p5d531ppsmcb9 X-Rspam-User: X-HE-Tag: 1713912974-802880 X-HE-Meta: U2FsdGVkX1944iXHnxP3FybAv6L8OSxMySLpQcRRVctFDIDu6/9aZn7dGX5vbLuH5QDHJc44iIlQe/I1Ii6q28rod5pJqumz2E+W0AWKLzq97OQBIvdghpj8urC9DlMVnBNjSmGdyl/PhzGh7CNPfit92ESvIyZGrMHLYa4DyP4jhNa7X0m4c/A8kujL4xcLBSGhHxL5nrrosXq2pGYQDkRo6Go73rEa28Bfiu7tu4e+e8DMXanki6mZ/tToS18cnyMDkDlVjemtdyEhMbWbErSSr2v1NWX0+nmkNb1CYb8MZTDA3U/3YOsKJ5B7iP4ReciN/0EyvMuf+rDD+WVTkX0XhRduIfGTwO9vGSbEtBmfhG3RVqcidjdbs4woCT1CSu2lo6Lgvq1Q+BrGNsrHgjIPPIEsXUi0NjjQo7Yj5TTQ3m8kabcMVpTJnj7pYi4lf+CrWGMxfRKB98Y7ivO58OqukU+W2fcZmLe9M6eOvi1ZOyBDdSOw2iHzYTG/z49AF+TCFSxXJRY70wM2b4h4hfUGE8XHjnOWdocV2qBNqGSqhVyPZc58th8dvDzc44Y69ASWSS05iDf91imdU8uRCOXxrj8GjK6JAqcPDRiq/kZFQpMaQhkqQ79wIZECGDoGcE8WBIaqsph0AJ+K7QfyrOcYvZFudMWHrLzmFnvQccS+P9Pc6tnT+coLqIm0Y74+2s80d/Be5I8iOTpgLyBp3xSH6pL8fQynd9VGFg13AtrfhB/CM9Nf2BIDlFNPRe+m95iTlZgglRE2JToWnsGsBlxvjuVE3pwiOclopgw7Hi2n8QNubs1Jvl3R2lGAFZ0se/CWguz/dz/nJL4NLDxm89PuW5+koLHuD1xLPHvxOGFl7W2BMV/jNTPGT5fyq2AayZ3TOxd4ztuxL2tKFO37MWzK04T+YMjWCZB63Ylpo6xtdl4rqoY8sO+GDigVe+QFKGgtvZjGePlGEmXLTwS z9QwjXhB CnqPi93Y+qHxI5BAepzmjwWMs1myEr1eFiRK5cmDw/6nTMaJkDfdcTTlZedqp2yzyLOu574/X2W8gz9SmpLKoQ5aC4ZWQdF2xM4R8KfxTlGav98smxDPlMCnE6ea4V7GG3R9ZJ6vV2Pzv6GEs+9KzsT2gi6b/0eMjt/5Jcy/aKj3HMxTXZtUnhi+oEgQB7K1BQNqONQXgtQIb7YFPQ6Go3BYfpwgZ6JFeV32f 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: List-Subscribe: List-Unsubscribe: Call page_folio() a little earlier so we can use folio_mapping() instead of page_mapping(), saving a call to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: David Hildenbrand --- mm/userfaultfd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index d9dcc7d71a39..e6486923263c 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -180,9 +180,9 @@ int mfill_atomic_install_pte(pmd_t *dst_pmd, pte_t _dst_pte, *dst_pte; bool writable = dst_vma->vm_flags & VM_WRITE; bool vm_shared = dst_vma->vm_flags & VM_SHARED; - bool page_in_cache = page_mapping(page); spinlock_t *ptl; - struct folio *folio; + struct folio *folio = page_folio(page); + bool page_in_cache = folio_mapping(folio); _dst_pte = mk_pte(page, dst_vma->vm_page_prot); _dst_pte = pte_mkdirty(_dst_pte); @@ -212,7 +212,6 @@ int mfill_atomic_install_pte(pmd_t *dst_pmd, if (!pte_none_mostly(ptep_get(dst_pte))) goto out_unlock; - folio = page_folio(page); if (page_in_cache) { /* Usually, cache pages are already added to LRU */ if (newly_allocated)