From patchwork Mon Aug 21 14:17:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13359503 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 3D218EE4993 for ; Mon, 21 Aug 2023 14:17:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF0858E000E; Mon, 21 Aug 2023 10:17:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CA1788E0006; Mon, 21 Aug 2023 10:17:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B8FED8E000E; Mon, 21 Aug 2023 10:17:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id AA1598E0006 for ; Mon, 21 Aug 2023 10:17:34 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 89E4EB1E26 for ; Mon, 21 Aug 2023 14:17:34 +0000 (UTC) X-FDA: 81148314828.01.804C8F3 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf01.hostedemail.com (Postfix) with ESMTP id 83FBF4001B for ; Mon, 21 Aug 2023 14:17:32 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Batd1Q4M; spf=none (imf01.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=1692627452; 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:references:dkim-signature; bh=wrH9ysMUwGikCkXUdpOWi6aY8joVu3BuaUTARzy6umA=; b=YktyiJ8cugZ3CRS608xHwKwDjLPR7ZIwA4+W8sVDUMUYbGdjMVKhJ39sygTEBwhUMl4kMp n4UOonyFIQ0BwYWwnlLFRUy40sfDv40DXdpcJJjU8SmskKZdIXk+KQg2za/Xc9oPsTXOvD so3O+taBylcF+7UmJs1CxmrIPz4qvko= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692627452; a=rsa-sha256; cv=none; b=HoMatMPgcmcCM7ZGBjhZfDb4sQXIbacQUfhvt+2XV+UllKfARQTcAlmARaXvUfGK45Ku5a LA9RBA1uogKmxJG8536+FglUsTSHOypW/c5QSEw3B3SOSeTg9Tml95C0plsRQ9xRquFl+X 4/n40xGfp6L9vID7qsSpJsOGbT33FEA= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Batd1Q4M; spf=none (imf01.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: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=wrH9ysMUwGikCkXUdpOWi6aY8joVu3BuaUTARzy6umA=; b=Batd1Q4Mq2Iz+2zSje4415GjNW XxJp3sW0NWqGolXsTBzWkA1s+CEKIEhFYfphASf1SkqCqrlDI6Ae/Dd3VBxJnb+cHVaAaP6QxE8f/ Bmhc6LiRc42FHRR4UQMCv1Gvp3ftNyUZYu0rxM2izTos7fsJGyMQy11lefJDD8Wz+oINPsTJsk5SX PyVESezzyIxSwVuM7q1MuxahhRBQJaO6TSf2l7n6BTswScfdZKWeaeVT5Y1C68KtKVNjUS2kxys6O sZzD1WabaBVR72apvBXq5mIqjMAbVaaeyeVNukBQe0nvjN+7BJ0QpLaS+KN2pTuLVU+KpXYpqpYiZ VIPMUjPQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qY5ik-00Adoe-4R; Mon, 21 Aug 2023 14:17:30 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Mike Rapoport Subject: [PATCH] secretmem: Conert page_is_secretmem() to folio_is_secretmem() Date: Mon, 21 Aug 2023 15:17:28 +0100 Message-Id: <20230821141728.2536317-1-willy@infradead.org> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 X-Stat-Signature: s47t9igdc1dj13yt8qupgk4kcmdfkgfy X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 83FBF4001B X-Rspam-User: X-HE-Tag: 1692627452-70564 X-HE-Meta: U2FsdGVkX1+n2zb9j3Z5gjwFr4c/08b6/EWmQK2/KGIAFLSIcN/qHljbOaWg9/NCGAy6O8/5GvCWJXQJAeo1jYom4ykuH3iRAmUgvfu4BOhqBnN2C3o0UVK52UPe4o74tUaB+ATZi6KGRPZUrgsC/3206rbSpP07I+jNh8RabZcIbxg8Jc7qg64GFg7wMs03fXrKTn0DzLIIblSD3lCmF2Lmwyj+FqTYF9YkpFKsJinduSQLo6vV0Z0RIXCbq+kEHbX5CZaRyLsu2g8yBxyUNQXsp+4k2i2aIqg0k4dpI6RwLLeFVOZDRivYLgc+OxSuerdWYpiwYyMsfJ86oZ6ZERDgdkrurEYLj/Z4TO7YEOA0QXEFKnCYXOgRjPz+hOADsj0FEcNT73ZWZw/P19jKBxLHj2DZiQMlhf3ih1Q8yqRHP2ssfL8jA4fIORTU6N/sR4vkorVWNTcDzLXeJK0NQlYiF9wCVWdHZ2VqBBYDKNggsGu8sKggLwfN2NaXLEatyHNi1nnQGXHntj2503uzU2NCdCKdLDLo9cQdC6RS3nQvu51bBTpoou8wjDjktVLpHQh8Qk8ycUzou6ppJ2t47L7QoyXpbin/apFYSpb/t2jUgRZfombKoA9q7raKMaLWzTDIl89HkCKqCXuhkrtUfl3IJQJ6LKf4haXpr8p5zypRuhNL8Vi0Aogj4DOahB/NSm5Q/dhFp6gvtzXUuNMFWWUUbF8mzo4CGdAybmoStvanwe6D9+asHUalzWQVNTyrO0xo8jAw4LWHpDBuuy9IGx/iHIKUS496t0S5jaydwB4mD3AoqEcX+L0OD/cja1cX+OoUtkfCqncjS7jEwWH+7gTd8eHlnMne0Mw9gaxkNoM9+BMekKPY58HL9FCpGCnIswNVQtu6NyiCT+19XlStX/BUzjRTaz4LG/HctaF8gmQP9/aLvytMtlIfBArp2tLJvET/9lPbUw2bcIXNPWf LzvtGTum vmXbtPw8HEckeE5E3qQoTTgNSLjHtYEXefVEk8cFf2RhISTCxZGF7c1oYFDWTDhSRUiTl9h6EnGIJKDjsa1APoAbK/m4F2B8jVMsdQWutumA08WbnyAtToQJwdQMg+8G3ngKsVyl9a3OUu1XXsNn9uTViOhEHzQZBBB8RFjRn66fmenS1H8dmh4f6NQ9uEA+5PO5Ld7nP8qnfQhaP+Rbo/RjN3bvQwaFPAXtV 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: The only caller already has a folio, so use it to save calling compound_head() in PageLRU() and remove a use of page->mapping. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Mike Rapoport (IBM) --- include/linux/secretmem.h | 15 +++++++-------- mm/gup.c | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/linux/secretmem.h b/include/linux/secretmem.h index 988528b5da43..6996f1f53f14 100644 --- a/include/linux/secretmem.h +++ b/include/linux/secretmem.h @@ -6,24 +6,23 @@ extern const struct address_space_operations secretmem_aops; -static inline bool page_is_secretmem(struct page *page) +static inline bool folio_is_secretmem(struct folio *folio) { struct address_space *mapping; /* - * Using page_mapping() is quite slow because of the actual call - * instruction and repeated compound_head(page) inside the - * page_mapping() function. + * Using folio_mapping() is quite slow because of the actual call + * instruction. * We know that secretmem pages are not compound and LRU so we can * save a couple of cycles here. */ - if (PageCompound(page) || !PageLRU(page)) + if (folio_test_large(folio) || folio_test_lru(folio)) return false; mapping = (struct address_space *) - ((unsigned long)page->mapping & ~PAGE_MAPPING_FLAGS); + ((unsigned long)folio->mapping & ~PAGE_MAPPING_FLAGS); - if (!mapping || mapping != page->mapping) + if (!mapping || mapping != folio->mapping) return false; return mapping->a_ops == &secretmem_aops; @@ -39,7 +38,7 @@ static inline bool vma_is_secretmem(struct vm_area_struct *vma) return false; } -static inline bool page_is_secretmem(struct page *page) +static inline bool folio_is_secretmem(struct folio *folio) { return false; } diff --git a/mm/gup.c b/mm/gup.c index 6d0c24e93425..2f8a2d89fde1 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2600,7 +2600,7 @@ static int gup_pte_range(pmd_t pmd, pmd_t *pmdp, unsigned long addr, if (!folio) goto pte_unmap; - if (unlikely(page_is_secretmem(page))) { + if (unlikely(folio_is_secretmem(folio))) { gup_put_folio(folio, 1, flags); goto pte_unmap; }