From patchwork Fri May 10 11:47:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13661474 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 C72DCC25B10 for ; Fri, 10 May 2024 11:50:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 58F3A6B00D4; Fri, 10 May 2024 07:50:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 565F46B00D5; Fri, 10 May 2024 07:50:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42E836B00D6; Fri, 10 May 2024 07:50:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 214BD6B00D4 for ; Fri, 10 May 2024 07:50:42 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D5D1C1417FC for ; Fri, 10 May 2024 11:50:41 +0000 (UTC) X-FDA: 82102319082.10.61FA92F Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by imf23.hostedemail.com (Postfix) with ESMTP id 0AC5B140002 for ; Fri, 10 May 2024 11:50:39 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=S1IAPU89; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf23.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.179 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715341840; 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=on6kE/iT1Lkf0hlBPN696BIDabVjdoSu5WvxX7mut44=; b=aiyA7TEN26mlJ6yNFrdpNm6M+c1JavRicRaqkmjIW367XVrokcjx3DcSOh0dJ3CDg+YDk7 4Fa9gG9V/d3/v9A+UDz3DtQmIYZLPL+BkeN8NHe6mquNBucW6eNhlDQ3HyDDvG7+QUra3m KyKoineY4wij5i3NUHL0XyvYD/cInJ4= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=S1IAPU89; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf23.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.179 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715341840; a=rsa-sha256; cv=none; b=yWsjlp7JtpRQV65DAECj1L4u7e7FysW1OKDM59udAiYY0/tYql8MDz1oVnt9QB8DThP8fh xavtCfQDeEYEJS2xAUMKD4Vdlkqf40bktQEA47hPVL/xm4i5fPccv9ZU9V7a0/7ElwVPYz FskJpbkv8cV6aL4vwIAS7+hjBJyfKiM= Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1e4bf0b3e06so17059525ad.1 for ; Fri, 10 May 2024 04:50:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715341838; x=1715946638; 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=on6kE/iT1Lkf0hlBPN696BIDabVjdoSu5WvxX7mut44=; b=S1IAPU89vgEbhQnDD4JdrtHH0IcjEgoLmW+252f/qQ/xCGityIKZbu1rQg01ulsuXG uX9bLAtltLtMU1CnIO21Exc/GEtcdOTcF0xWmNsSOAmE7qszKyWjGMgdH+IinGDhOfn5 VPerH2OVoTqc0IKnyHt0Vkr6LsNrgIcy7AsSETDv3WCVROjekh9tfxFlt0PcOryIZXtU 6iiiqQq1ixGo/vVKpTTrKWGimCgnkwiIB9KsbUTVwUXsocAj/H3mhy0jLxpLLnUXG+V5 f+72Q7Cz5+C6c8/nBUTXCme0ki2DKkNJzD55ztshcckSZQ8DewMs+0yQbePyXBc1Fh0r Zxkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715341838; x=1715946638; 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=on6kE/iT1Lkf0hlBPN696BIDabVjdoSu5WvxX7mut44=; b=g3PJqVsQ/XLTkADddAv4d7euT/vyLkA4knNkxHCHAHeKQjCzGk7s41OowL7UeJrP2U hWRqnqVAJ6s42VNFK62vtlctMnOOjutDix6p/eGHK7P+ESql0H0pummeFSA3iTmb6Rb1 lLLudySbtnH6k9R9JGHeFJr6fcHxfjQ59PhWQ95MAFaFlR+uvbAu0vY7MTSqgMvFMwkD iBxFWwH+bawao8zONraW2uFq3w92io0nqwiaRP68YxcCNFkMyaBgZOMl7JL5Myhhzpn/ +91wV0EPexzmzRr7+mpoVZZuNXGi7qdImKIWqtUfP8IgENxjYlUowsY54Vel1HiApLJk YybQ== X-Gm-Message-State: AOJu0YysPU5zIEE14SNl1qMjHIKXuvJCpytjV5NZaOqSDqIaqsHtM5dP 1wSXUhcthBvcpWmjqoqWPElEnAXORS9myzSUonMXKzQh+Yvg9YK5T9UfSoR5P3Td0A== X-Google-Smtp-Source: AGHT+IF1A9PqpbJrq3X5IQGwkaZ9z75WJ/x5Qis3xG1g8x4Md20mqXmUkOulbCkRZ+eLmOE6iEf86w== X-Received: by 2002:a17:902:d4c8:b0:1e4:d548:818f with SMTP id d9443c01a7336-1ef4404fb62mr28624285ad.58.1715341838600; Fri, 10 May 2024 04:50:38 -0700 (PDT) Received: from KASONG-MC4.tencent.com ([43.132.141.20]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0c134155sm30183825ad.231.2024.05.10.04.50.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 10 May 2024 04:50:38 -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 , David Hildenbrand , Hugh Dickins , Yosry Ahmed , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH v5 11/12] mm: drop page_index and simplify folio_index Date: Fri, 10 May 2024 19:47:46 +0800 Message-ID: <20240510114747.21548-12-ryncsn@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240510114747.21548-1-ryncsn@gmail.com> References: <20240510114747.21548-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Stat-Signature: pgid57tmjxc83pkt74gnioiss917jho6 X-Rspam-User: X-Rspamd-Queue-Id: 0AC5B140002 X-HE-Tag: 1715341839-719914 X-HE-Meta: U2FsdGVkX19OVgFfFvc0cBSCN4psuR3n7ag+mnDMljXzIbYuXWCCAKiaTwDurup/vrK0BXGUgDd2wt1g2GuHiO4wByN6t41drabxw6st8EOA7J7UF8lsPUkaVs71sPQ8KgB6DYO4xyTNAMR6AhJhGPkBN4L7Ffh7Y13RT3buHVR41LRwHB6u+6oKHZNhXOs8dnHpgfGtOTQCu0c54jKGOpXucC7GbujSy/GQ7ABKGPV02UBb0/9od80Y8+t2q+gjQowselei/zcVoLoyFQVPkAruSyO3OqWD8oR4ds82D4ToqypXwCx4AYZ+GFs9auFQBBkdcdJdp+/BNK0veb0msLKuMRBUa+8BjJOGyzM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V3SORMNsldxEAECSHZ884Reffh91mpwBklpwkTinfKBtcfwg1Narnp6EPEKv+S652eoDSiNzLTDyAzNPyylQ4H9pxOYxK8czqZ576ZjnllJx//8O6RpKQjmhzUzRwSDmA9GLlrkxFBoBfDHYCOvM2m2dxywi9kUf+mV+iq+AfCbYxo2xKWJkHjEODhNQ5El477uWGG2fKU8KkXKlMU2ZnZ1Vr79BezAZAEW6pXM13gOUbzR2z7ESMPJgCWj6wiEf2fZD9+MgMUPurY8DascPkX/z1A9CotDS63ojJgwLyBragwZWYwnG 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 This commit drops page_index, as we have eliminated all users, and converts folio_index's helper __page_file_index to use folio to avoid the page convertion. Signed-off-by: Kairui Song Reviewed-by: "Huang, Ying" --- 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