Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp995881lqm; Thu, 2 May 2024 01:59:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWDWNAajoREyketkLa2WJgmdC0CAFxZEz59Y+l1MPmSChYMP6xey9xIL3KJdEfBF13K37BHReVxEkyNoxFajToMwJhNrIBFQVjTpPi0JQ== X-Google-Smtp-Source: AGHT+IHJGOl8XqgbbA9hCQkGNFQwzJkSl/blwMAalDpyiUKGvnl3ZTzSqivKjmqmQsm3nXeYV2e5 X-Received: by 2002:a17:90a:12c5:b0:2a2:e56a:ca8f with SMTP id b5-20020a17090a12c500b002a2e56aca8fmr1535446pjg.42.1714640352948; Thu, 02 May 2024 01:59:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714640352; cv=pass; d=google.com; s=arc-20160816; b=NKY4nl/f7fEom9XvF04o2n9tLqxxiCQysqA3g8XEPHg9D7iYTU3OHfRcbXeLid484n RPmCWgA2FpmNODfUu3HylvRfeBPwfww8j67EsW7wn03LmoI0ihrfYXbZybSi7c+IdRFU /5OJZaQhQT5KzF57MNBjRPAlnUiYVt0gaPmXxkex0YGP5A3faDI+glN12YtsSQmG6mur V2IBhyTcYqrtQrxagzP5WuQtiqNKbZazLYJ2SdwD5txQ29L4p19OqXaojzJeWSkXeP4F otRHkm1jx3iowbK+MP6EWe5m3WlyvTNNTFUtBm0HsFneMut5RFHio+1zSnrkv+idC+uT DVNQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:reply-to:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Yc7f0BGrdGPhDGlU0I7BQHsZ8DqIMKXeboNv+kAHs2g=; fh=szUlyU31aSp79/y8gEqFs383duhoBkHDKiAsmfgTyYs=; b=X41TOj3ZvVxlkl3gMKD86R486QQCMrJSH0++dyuXYZ4erjf5C1cWyIJ5wNbKQYQpHL fh+P42zrgSvwtvT/4yJ5MvrJ1FReVtX+t/WPBYMKCHJtVPRhYV6XRY43wg67Pao6z9sc ShcDJAZQiz8lQ1zBO8lN8BY3VG9rL6bpoXWpc/VYcn8cqSoRmYCMQmjKC8jaGxSGQpZD CKVru5pjApRXF3xeMHTTPFZFsimJzVnr+Ov7T8RZ1X+htLsv9f7gjIUZM7pvZ86tKQG1 eAXD5OLTihzxCZXyge3UesZKzUEIgxEl6btqIbj8YN+EpodmHfXMoWAu6aNwnfnVyJca g98g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GNZ7iUYx; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-166152-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166152-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id bx1-20020a17090af48100b002b13338249asi3082006pjb.113.2024.05.02.01.59.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 01:59:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166152-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GNZ7iUYx; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-166152-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166152-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id AC93BB21CB6 for ; Thu, 2 May 2024 08:51:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E86250A65; Thu, 2 May 2024 08:50:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GNZ7iUYx" Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5AC20548E3; Thu, 2 May 2024 08:50:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639836; cv=none; b=sC/cyN+zUi/igPdhpKulqFxD8ZV+Pork3nby8+yihQmNC0520hMxO0/EnnWTgMWnPwFvxgmMMbztDMjYqIFewFgfkOF8v3gtjstM1/+uIiBJdyuGpl3j+zVc2y1l4wcX2mbTZYPpqN8lu7bGKo9SAlXm0EpLkni1Iwa1WcPElRo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639836; c=relaxed/simple; bh=2lTtUhy8NY0Kb0Je8lGpuIe60RILdhnqU96HnhHFLoI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GOj2tKTYjM4Oo/tR15+jb1D2OoONWAJbSXWR5rdFmsjjxb4y76ySoo6Nq+0V2cVjoqpS5yCn++z6kNwBJO5Rbip4EG7iJBJK23Mf1NJRp7p2sQ1u440H2zL5Y1+I6piXgmm0q6050UHH/OlWDVCc9oLSS8EJhZslCKEzEK5HsgI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GNZ7iUYx; arc=none smtp.client-ip=209.85.216.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2b387e2e355so476896a91.3; Thu, 02 May 2024 01:50:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714639835; x=1715244635; darn=vger.kernel.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=GNZ7iUYx/MScLaN/taj5dbKE1Lf/YojN31fX6e1M6nLIOFM+Do6WuRW/0lbuVQJS28 XHnguTT+w/LMUt9RM8BmSFKoBDHGlVwX5crWokMYM+QL4GfRL6dcYj2z3LGOIRGdNxj0 0xyJ7lM/0Hczly2y7RRHmWP/y2/GLzAh5TCrRv8GTjL8D66Rr4GH+ryXkT2BH7OLKi3g 67gAhA4Gq1eKihJxXttReJ/lajRIdzgChDIAtXY3aFPjMIBmcxnmDfV+HoO8eK17YrBY x8Mfx6MJR4PKhuyob9H4LALcRb8TseXTxbhIFdK7mZW7jhFKFGxDroGJeo6NowtDUk3P MPQQ== 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=v+eBRrQ2sCWtHsH+LLPg8eyZ51f2QKCMk1ujs0wBEeO/0v3mXyrMAkDLRn1+sjHTs3 wHALrPqsE+OV0M2b/0aFhyCnT2nfl7Gg9en/mbmAUwZ2518DVuMCB800ybEzepQGHAEC ikM4nGgHcDCuyvbCDdubgN2Fi/O9pVIa882Ol5twzVkFjX4wrGvjyI2736MVX42eNz2G qTtFkVCqZGhGHS4uZhIn8XiV/FVGefFy9gnirrengkk33UH2vigrMEqb/lGCWwsM7TG4 J0nmlGAIg8LzCflVxyQfgkumKBIM0K0WibyMYz3prOHmPz8k0KrLzk3ms5lK5uIHqQ+m iLPA== X-Forwarded-Encrypted: i=1; AJvYcCVkeVJHZDc5nijMk46wx5uOL7bxQmmtquOimA3wuGDcWvg2OIz/q09ajVd8PxXGq3+tBHFxKlUVlGigoX5Ee6BpENOYtnSUkh8jUfqPAgTJWidm+DwsQhQoR8ZHf6kgUqGbQtPwgue/le7TTg== X-Gm-Message-State: AOJu0YxNm5TkK8dFIbMznyboipftUBOUp3YnfiHoamMU5hw+2yJS41hH G+EVxLOJvA11uhIaU7swO8QpttZCTPrqbe9vf4s1XYO6onaSZNCS 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 -- 2.44.0