From patchwork Tue May 21 17:58:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669618 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 EA2F0C25B74 for ; Tue, 21 May 2024 17:59:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 815876B00A2; Tue, 21 May 2024 13:59:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7CECC6B00A3; Tue, 21 May 2024 13:59:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 63E1D6B00A4; Tue, 21 May 2024 13:59:51 -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 4748F6B00A2 for ; Tue, 21 May 2024 13:59:51 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id BCD4F80773 for ; Tue, 21 May 2024 17:59:50 +0000 (UTC) X-FDA: 82143166140.21.0530C84 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf10.hostedemail.com (Postfix) with ESMTP id BD951C0011 for ; Tue, 21 May 2024 17:59:48 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Bo1NgC1U; spf=pass (imf10.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=1716314388; 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=7qQgvaLUE9M4rws6iEQt+/SaZKzeTop758mxKe3fzns=; b=M1DqFc55M99GmF7rpJg9fGn2U/iCMgNEYnwq6/9HKFJoerXxR/LSIi9NI/BNx/mXisZf+K js1lTiomiSAHKFGEKH90www5l7KQ8lAz0N+/pBVkibpaw3wfV7Rnee/+qhwUOEzfWxz7x0 acZ8SDrnfz1CC7oBbqm3gcj1uLDJb/g= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Bo1NgC1U; spf=pass (imf10.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=1716314388; a=rsa-sha256; cv=none; b=LTwdZq7btzXyJg7e9pKHw6gXQZQHE6Gf0Kj3/saD2NmwmZVuOacVJegiz0GVC+wyGKskIp vgCopjz0XITO8LZvVFtoupWQKdvdXdOKqArEZ/IfblSW4zFc3bBbCOal8E5RRIL2WrDQvm cvVxux8flYm0GazKhridWFAXupxdC9Y= Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1ecd3867556so3833325ad.0 for ; Tue, 21 May 2024 10:59:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314387; x=1716919187; 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=7qQgvaLUE9M4rws6iEQt+/SaZKzeTop758mxKe3fzns=; b=Bo1NgC1UMDxPBSozU1KWD4aepsdJ5mFVlLe9XPAtk/cMmgioxCdgb6mTwLybS4lAxD xdBfgV9VL2bO5RZ7J5kJTmADReRHhe0oDIPyzyV+0VHyaKlKoVmEMJw2VPQisT+E6c2y 2IhayjxdcBZVxFUaKkvejM4tmBgF9mvLlIw/b3N/qpnj2n1J7eP71Vo8ozTH0DDUm26N 9cSwilhyrHKuOBmByVpwZ7t43jpficQcTZEsAtyFpIAeAv+aowzAQZV4AFFK+T4m+oTa n4gUvBsnnwMzQgUeZmWLTJ7JX5N9PLEOeQRE5YIRAItVSirgekpEh16ciVrxdVvEr6nD 45jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314387; x=1716919187; 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=7qQgvaLUE9M4rws6iEQt+/SaZKzeTop758mxKe3fzns=; b=NOEt4j6SAYk2hqao8rJwv5JKQDLl0I9bCaH97kUb60FEUh5whjxhry8QsKxP/3DTQb /DZkWeAv+yAF3c+Z9KFWAcO22fzPBrhxoinuJCWP4SM0YZ8K7vW6Fc6SPl5lSqUHLCfc xwhfFSYQSrCz/zsQ2Ehl/fzTaS8IsxzqP/P9rIr49FaO2t9CuBdIiGdn21sY3Ko3PNx9 ASFJytD29uj/kpKfCec+z6o+OIfU1XnfmjCPAkkPE1QJBueWbYTzg7owuLspBi36hwiI aBSb6aXtjCy0679zThR7aahLxC5sZt1QI6Pm90qkrjrfokLBdConJnneInWIkx31A2x6 BIQQ== X-Gm-Message-State: AOJu0Ywa44tO4rRzI8DV4Bvvh1HmHFK9nakWmDkwHad0jqlEwUbc2cTR eICLS1NBuOhNkXEk6Tb7PmR+ixrgy00XOGQjTGZJcj0SXHw5bwLbMU55tuyCCEo= X-Google-Smtp-Source: AGHT+IEZakWrbVxlRp22N1fNkpJSK0qMF00Dd6C/77G4znr2CuE4Uf3FXSSlP5KZRo8UMc08FAqQKQ== X-Received: by 2002:a17:902:dac1:b0:1f3:3ab:a4fb with SMTP id d9443c01a7336-1f303aba649mr57889605ad.10.1716314387027; Tue, 21 May 2024 10:59:47 -0700 (PDT) Received: from localhost.localdomain ([101.32.222.185]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f2fcdf87besm44646935ad.105.2024.05.21.10.59.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59:46 -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 v6 10/11] mm: drop page_index and simplify folio_index Date: Wed, 22 May 2024 01:58:52 +0800 Message-ID: <20240521175854.96038-11-ryncsn@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240521175854.96038-1-ryncsn@gmail.com> References: <20240521175854.96038-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: BD951C0011 X-Stat-Signature: k16wesut6i6wg5bn9x1ntx5d6k6cziy9 X-HE-Tag: 1716314388-161280 X-HE-Meta: U2FsdGVkX18bp+T6TDmfSwffD6Lojs8d1jkFINCKoN5AyG5DSk7DIjFjYXrnvy7CfTdrO25jiK25oaB7JsrB2H2rzAxZWCv3xfLC2wOT5KyYCMG8dfN05DLGN/WOBToe9a8I8S77igiEnLLPq+5LiBsw1bRv90nHlCcYzVr/uX3JzXLRac3qLkv9+igU/+wEFEJfi/X5Wyu6SWvnBfn/OfL/ovhcbecULldJrTlCnXJNkICYz6NYwYOVOeBVxuf10KMelD4ZVZhhDuNFnMcZaj8DW8EiFMVglExGXRQmrnyeNmtuSZB9j1wvc2X1ewZcf5C3sbcyzLXwMYfk94x+TkW+z4yzrxRt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ip80hfHQVEgxErGgqCB6/OnAADt4nWpfJyo6RcWD3N13jqkrHX0nDwc/AfF+8Ss9OfowThigKB7/jp28k6RvhQBWU8eLS/x5IBcbNreHiPgIHCKUF9sw60zq2S6MiwlS2RzDI+kQtplszVeEP4v22wlldf38BPvx0UnyJLrIQAXsNC3U1lQzosGwgQbtZtefOgwLvECW3V/Mam2xvsrDLOJz6fl26vje4Y5mzybh1cgCVa9SFMlGzEpQhrFy2NoW/eVsjXKEGxWp+RQxRiTiowUCPDiLvxnxNbBq9YQVfPB7NGfBSbtbaM7uH9s33HIjrgfAuHuHr0FiS+q55tFlPjdmaPUONRMlG1dykH51eMlsF4ogDpdtaJh2Q== 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 conversion. 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 010ce7340244..7fd67edc0bcf 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -780,7 +780,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. @@ -795,9 +795,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