From patchwork Thu May 2 08:49:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13651437 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 266C1C4345F for ; Thu, 2 May 2024 08:50:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA1996B009F; Thu, 2 May 2024 04:50:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A2A826B00A0; Thu, 2 May 2024 04:50:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 87F016B00A1; Thu, 2 May 2024 04:50:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 611E36B009F for ; Thu, 2 May 2024 04:50:38 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 115EE1602EC for ; Thu, 2 May 2024 08:50:38 +0000 (UTC) X-FDA: 82072834956.05.A704A9E Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf22.hostedemail.com (Postfix) with ESMTP id 61749C000B for ; Thu, 2 May 2024 08:50:36 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=g6bDI16S; spf=pass (imf22.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714639836; h=from:from:sender:reply-to: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=Yc7f0BGrdGPhDGlU0I7BQHsZ8DqIMKXeboNv+kAHs2g=; b=7yBuGFOcl3hT3k1ZGLAcCocV5ton+HcI/5Y2v7c///QajxwnQPa0cCMj/26yzamkAzLtqe lFdCLnNxoSLGmj7rK8m460vxELHVFV2bDl2UVFzMWKMAwJDvf9jNYjihMnzY0WQF8qrEJ1 Zs5kv+yIyaWzYnCd4A7D2003ODhck6w= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=g6bDI16S; spf=pass (imf22.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714639836; a=rsa-sha256; cv=none; b=qUs8CTo9eOcDVzDO4uwZTAFJz1HiJ/DGo7Fo7OAFFhcrTq09+ivJHC89YqzkX0p02Puywa xJVocDzRChCg9pgLP9dX6J7q9nX9f9f8yJf17MfllRzv+rhZF2tfqpYF2tDErbM8LEgemT 9vZuru1HqIUMiep+DdBO2kqt29HCDh4= Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1e8bbcbc2b7so69621475ad.0 for ; Thu, 02 May 2024 01:50:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714639835; x=1715244635; darn=kvack.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=Yc7f0BGrdGPhDGlU0I7BQHsZ8DqIMKXeboNv+kAHs2g=; b=g6bDI16SGtIyuRUT9stKfGNQpD9O08ozzn0si3lNoYbtZSiqpR+QFjnM3Kn+GVUo0Q frldJAIOjm4VC6h+k/lYdt2rVUoVU63dpCHfMdUjmphb7Kk8vi56zxiSRn5I5DEAD4Jr dYGc+fgAucv1UUEYq/hv7Ch0ZtXFfHTFRzga0natcHSPvcKAOL+wLlpdbAbYxUFzRr5i ZLbDXU693WIojm2e5gBCFtqre6D3cVRPJdR/B3KQpMdkN4eusxYLIxMyXyfNjrKqpLLz 8FwZsnJwEe3NyMfCGhtCL2XLCTDjiI/sBGQhEf7eS2iZQTuzVOeilnR7daoyctG4KOnU 13Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714639835; x=1715244635; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Yc7f0BGrdGPhDGlU0I7BQHsZ8DqIMKXeboNv+kAHs2g=; b=AdP+HCBlOFPPYq2o1EP8SVIQkNbclt+AV9+DZ4SM6f02JGVe8Ti6ayJrpuK3unRK/1 oBOjhnvLhOqGeg9AJGIgCSxfN2DRDapfzuuV3BOwxlVyXSXAcjcO45n0c7SC9UMlo7uo hOy11bVO0AoutARj+zXasx6BkYSxBcjTnsCr5UiuMWgnf5to+c0MdTAcCKeG06hRGQIj 5dTskJULhUvicve1H6CSF5HFdOPVeZhR+vRcwOQQu3sNAPQ3KJMxPLsXAbBzFcIQvDk7 fr8BU5v0gc8v5dYkCa7Fw/7S4Wf+MC3o+AxfIvnznte57UPNqQk+2SS4rjdgZkZl0Xp9 O1RA== X-Gm-Message-State: AOJu0YyMaU2qM/uQh0HIMkL+lL96k0esRrekw9gMbr3j3sqMpCYb/MRy GQp30p1Ia94vxjNjKe5f2lxdtLmZ+EtbeEkorMbQ/0/MmVpwr0oOvs7UGt8wStY= X-Google-Smtp-Source: AGHT+IF8JauY0lS+CclTlem6YP0P2WISNCLiZMNb+dGq5Yq+NqFjwzPOoTCiT1f3BMH1TlaypNnwnA== X-Received: by 2002:a17:90a:fd81:b0:2b2:b1c7:74cc with SMTP id cx1-20020a17090afd8100b002b2b1c774ccmr1628463pjb.26.1714639834668; Thu, 02 May 2024 01:50:34 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id j12-20020a170903024c00b001e43576a7a1sm737712plh.222.2024.05.02.01.50.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 May 2024 01:50:33 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , "Huang, Ying" , Matthew Wilcox , Chris Li , Barry Song , Ryan Roberts , Neil Brown , Minchan Kim , Hugh Dickins , David Hildenbrand , Yosry Ahmed , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH v4 11/12] mm: drop page_index and convert folio_index to use folio Date: Thu, 2 May 2024 16:49:38 +0800 Message-ID: <20240502084939.30250-4-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240502084609.28376-1-ryncsn@gmail.com> References: <20240502084609.28376-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Stat-Signature: byrr5nghmypka51ennzi4u4jxqtjnixu X-Rspamd-Queue-Id: 61749C000B X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1714639836-663208 X-HE-Meta: U2FsdGVkX19zFSelHyr9ytrHfsSZkHmXozbU2xCrYtyx5jqPLZY1Q7VmXP4eJJn8k/gEiz1wp6ZLBj46dbisV1Of0HjCHxwA+efdJ0P8MG91zj4a1gcMwkPRzJFnfUg23XvZCuOqXVicjkM0fwy1HbnC9m2uBNICBtbClCRTLcTjMscLyG852ESeG0hmpjeMPujgaA8axZCkUZ3UDW+3Z5oM1/i4/trFhV/pgk1DntPc1pToNvx4MyVHJwa70l+lS9mSw/ukiqcJVSagdsnn9WSnzxsSW7oMvv5nfkDi0t3pljbUtu6OEwLrZ625Q28wO982bA71f4QLDoHCDaSjG5to0v0QndmhzkFWhtLR9+a/Vn2kiMfgOIFuQ8DRtLOQG3T9t8qhK1Qu9zpDRN6ji/BSaEWK36ee4N9aKYL2b8+ekeJyE0IDzDObNq0qnh1HVBnn3Gk4PJ6Opafpf7Par7P+A2OmyYa6xjo00Fjo2y97xvXRyfcdOpJsMxkfaRAMDFkjctodV01NgbIUd0AlowU2PBy5+8Lqh7Ss+3W9MdDqoOLE6kwJypOCes1oNO0ZjC7z3qPklnj8PMF71nw82O7gCR7ykoqeFZ51YRlDQgL3tG4dAdI/SnPQmvqEj3gnWmKYuB0JYBWt9+8ySHnY3PhV2LKgxjUuf/J51DFyIBnrX0qTlQvTxr07Zk7P3OGIa2Z1xy1JCKZ9NRgxKE8WZuSUY0iDoT6J9q6UwwBX0cS7KWjpA1O4M7XoYi5/ZhUuzjCmhNV8AaXQhxirZADaZubCJxb7ApbBZkhynQ4XUDQ70rftQtcamUpeSLgN6LDrnjsD3OuyUrYgEv/CcoSGH1+Ae1yRqn7gYerMtlc0yFi4HvTECa1fl4C9IQcm/KRDXUZVVOlUSKx2bTs0vG38GZKAhHj1U61uzOsJb7v3IS7Om+D/2eQh1j7lpN1RwGChFOoPq6CA+AYzdSBqm/G 3zMM0JH4 mbST9W6CU1HwzHg9zQNnk8senSzUx3CKBhQeudJG68rD6l9gdrfopj+D0rIKDoKr7OVX24n202kkp9quf88LPQEMxYgDhuUD61aWnMNsv/wmFthU05N/uqWnk/EnVeOC3E+sPRhSto//A2zy4TbakUPMh1TQgx9xgzXj3y/KEhdX80/x2zcosYLqaMxrsguGVbX3y0NcmrXlpzob134drSunazDRx7ZKd5WX2HqOqjkdtCWfqR9C2dFxYAlkyQzRgkn9FQlChq0esherSpgBcPV69K6k7U9G0JFiFN71kN9atZ2XM5jbAwzIOAQ== 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: From: Kairui Song There are two helpers for retrieving the index within address space for mixed usage of swap cache and page cache: - page_index - folio_index (wrapper of page_index) This commit drops page_index, as we have eliminated all users, and converts folio_index to use folio internally. Signed-off-by: Kairui Song --- include/linux/mm.h | 13 ------------- include/linux/pagemap.h | 8 ++++---- mm/swapfile.c | 7 +++---- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 9849dfda44d4..e2718cac0fda 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2290,19 +2290,6 @@ static inline void *folio_address(const struct folio *folio) return page_address(&folio->page); } -extern pgoff_t __page_file_index(struct page *page); - -/* - * Return the pagecache index of the passed page. Regular pagecache pages - * use ->index whereas swapcache pages use swp_offset(->private) - */ -static inline pgoff_t page_index(struct page *page) -{ - if (unlikely(PageSwapCache(page))) - return __page_file_index(page); - return page->index; -} - /* * Return true only if the page has been allocated with * ALLOC_NO_WATERMARKS and the low watermark was not diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index a324582ea702..0cfa5810cde3 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -778,7 +778,7 @@ static inline struct page *grab_cache_page_nowait(struct address_space *mapping, mapping_gfp_mask(mapping)); } -#define swapcache_index(folio) __page_file_index(&(folio)->page) +extern pgoff_t __folio_swap_cache_index(struct folio *folio); /** * folio_index - File index of a folio. @@ -793,9 +793,9 @@ static inline struct page *grab_cache_page_nowait(struct address_space *mapping, */ static inline pgoff_t folio_index(struct folio *folio) { - if (unlikely(folio_test_swapcache(folio))) - return swapcache_index(folio); - return folio->index; + if (unlikely(folio_test_swapcache(folio))) + return __folio_swap_cache_index(folio); + return folio->index; } /** diff --git a/mm/swapfile.c b/mm/swapfile.c index f6ca215fb92f..0b0ae6e8c764 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -3474,12 +3474,11 @@ struct address_space *swapcache_mapping(struct folio *folio) } EXPORT_SYMBOL_GPL(swapcache_mapping); -pgoff_t __page_file_index(struct page *page) +pgoff_t __folio_swap_cache_index(struct folio *folio) { - swp_entry_t swap = page_swap_entry(page); - return swp_offset(swap); + return swp_offset(folio->swap); } -EXPORT_SYMBOL_GPL(__page_file_index); +EXPORT_SYMBOL_GPL(__folio_swap_cache_index); /* * add_swap_count_continuation - called when a swap count is duplicated