From nobody Sat Feb 7 16:13:47 2026 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 4FB06270578; Wed, 30 Apr 2025 18:11:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746036669; cv=none; b=HsHzvYbNsPT/m267O4rqO9oBlSmEIU4C5kkGIWyhtjzXuQss7CqbzKrssQW6YePIznvO+XVlNHHWUzuGCmjAvc6VoZjjTtFtXq0sXX7qij3g3Y81eHaLkXbRAsb7nfTHinjvEdYnAgU+S6FXGwW0vXZ938ocayBBCeCoGMLl3iw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746036669; c=relaxed/simple; bh=uKkWq78XfYV8C1wGjeLxUClR6JZktKdqmRzCLRPiniM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=beY816YOwo2dS9A2YUT4EqWVHfNZqyL0CrbuUNVVHxwz60WQXPOWNgfLtQRcelnxPtaPg7FZ+lYI+3SvOf3So4I+7TDHIYhKvJTPBTxV/nJFdlRsGH3DsxJQphLkWH7JJvvpdKdlKKaDOt6FbfCd3xV5xQikHDqekv7BbHeR1is= 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=LDRoUlFl; arc=none smtp.client-ip=209.85.210.171 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LDRoUlFl" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-73bf1cef6ceso280641b3a.0; Wed, 30 Apr 2025 11:11:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746036667; x=1746641467; 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=rWrdBEdzmL3R/kfX7rqlGT9fsre+XXLU7YQDNncr/vk=; b=LDRoUlFlQPkVRrLEixPf8YnIJbnSTGunj5E9QMx5Ns3tbwn/gUmSBxynpVp5yEVwvE zhobKS63DUh31l0LwTzWiWueAi0eF+UkJtFJ1Un2YkTy3PROmtMBdJVX5Dxprnwt9Oj5 A1X9swcuukrcpk+RlgYKXr9I8GxK/+Xj1oGQc7amNj7S6ijhWRgaqwaVL2uWkcAgfJd/ ha2MJG7m2tRjN+EykqXHLF0pNoWg3iRMWXGYYrkneK9St8F5ZgeEuPEK94U7GhI8vZmt H45xUZVXIfHkOOmCczYj1RsHswL8rTr0cR9J+Zx+dhKrj5Wmm+65P8CDZrfGebYo8EI/ 6cGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746036667; x=1746641467; 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=rWrdBEdzmL3R/kfX7rqlGT9fsre+XXLU7YQDNncr/vk=; b=I4QZkPYO8fPWBpoKVyAWArmBLWdeU9XSBmrMJPMCShOWL4ROMF4LmjBVzseazN0yFH CIrQ+zKV5AbAIxTI9sM/+qxjFfuB6UDwpSmvejyRxHq//IoEUOYQI0UHb8X8BvXoQmsX Ab9wL0ZyoWbmpmUdo5Yr2JNrg2qTHw5p0XYl8WUPadXicRfFHlDbzHp/L+ooQeAnrLQL ci+Qecg4nWsb4/xOWB54PMGYZ4+rApCznXzxbWR2Q9E2cjKL5p/Jrgro88FMx0Kgl6WT P9ac2MRenVvnb4/gPgCC71DaakD4MAD0z68JmsOMpXqCkFjkW8WheRZ+mb3O3KqZgrRI T3vQ== X-Forwarded-Encrypted: i=1; AJvYcCU5oa7+3bWuxgz/5YjXdbPKLRn2taRzzeWBKay3rqIINKgLNqMjm73zlEKXR9ZztR9oU0hu3+EFxFJA3viH@vger.kernel.org, AJvYcCVtiU53SwwwnHPF5HAaVeikFAZf4c97r+ym6NvkHcYsFJRVUxsVNKsChig2QrSDql/ZFRf127DnQWt4TyTq@vger.kernel.org X-Gm-Message-State: AOJu0Yx+GLF6pEcB6wFUocYo2GZxJYvkGdaPEGgsORQM9fj6wuWL0BJH ncxkD4XITEqxpq1NHSDxdEzp+SsvYCSRXZAlcExUwvcqbsXTY8UK X-Gm-Gg: ASbGnctSa0AaXdtbF6cyDNG/hCeCtvmGSllxPQj7x5NNwUbKxE+yMyGiXJeEyhCpBCe siwd77l9G1kGYhjVYZ1WEUwIxvPAjmRXYisBxTxR84BGmffTfPIeUviOL7NI2zRaN+tzSn2jwcG vh4Dwnt7cIGxL0PWfUbUGfdCg7aKb7PrKV5oNOpDSMceYoQeNJRAufH1XdMeRLg8n8gcTU8zv2d CaPJ3wQkP87ijDYcYMtVMYpQsKFY1pB8kS5XUSHFIorU1wzTlvpgh9ZlkryZlDV1OOuWMDpJ6Pq mO1w+0q080ZNPO4TiiYE0oi9ap4yRudDR7HvdGd4qby9T4jzztm9x6GAdnx4Kg== X-Google-Smtp-Source: AGHT+IF9cU95gPYlg/+BueaWtgjVYu+duwRSmPeVQaR4peuDgpv89pIl+iXc0sQ4jiHvcfNXy2gTMg== X-Received: by 2002:a05:6a00:4651:b0:736:9f20:a175 with SMTP id d2e1a72fcca58-7403a75be24mr5326968b3a.2.1746036667491; Wed, 30 Apr 2025 11:11:07 -0700 (PDT) Received: from KASONG-MC4.tencent.com ([106.37.122.198]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-74039947976sm1983822b3a.84.2025.04.30.11.11.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 30 Apr 2025 11:11:06 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , Hugh Dickins , Chris Li , David Hildenbrand , Yosry Ahmed , "Huang, Ying" , Nhat Pham , Johannes Weiner , linux-kernel@vger.kernel.org, Kairui Song , Miklos Szeredi , Joanne Koong , Josef Bacik , linux-fsdevel@vger.kernel.org Subject: [PATCH v3 1/6] fuse: drop usage of folio_index Date: Thu, 1 May 2025 02:10:47 +0800 Message-ID: <20250430181052.55698-2-ryncsn@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250430181052.55698-1-ryncsn@gmail.com> References: <20250430181052.55698-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: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kairui Song folio_index is only needed for mixed usage of page cache and swap cache, for pure page cache usage, the caller can just use folio->index instead. It can't be a swap cache folio here. Swap mapping may only call into fs through `swap_rw` but fuse does not use that method for SWAP. Signed-off-by: Kairui Song Cc: Miklos Szeredi Cc: Joanne Koong Cc: Josef Bacik Cc: linux-fsdevel@vger.kernel.org Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: David Hildenbrand --- fs/fuse/file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 754378dd9f71..6f19a4daa559 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -487,7 +487,7 @@ static inline bool fuse_folio_is_writeback(struct inode= *inode, struct folio *folio) { pgoff_t last =3D folio_next_index(folio) - 1; - return fuse_range_is_writeback(inode, folio_index(folio), last); + return fuse_range_is_writeback(inode, folio->index, last); } =20 static void fuse_wait_on_folio_writeback(struct inode *inode, @@ -2349,7 +2349,7 @@ static bool fuse_writepage_need_send(struct fuse_conn= *fc, struct folio *folio, return true; =20 /* Discontinuity */ - if (data->orig_folios[ap->num_folios - 1]->index + 1 !=3D folio_index(fol= io)) + if (data->orig_folios[ap->num_folios - 1]->index + 1 !=3D folio->index) return true; =20 /* Need to grow the pages array? If so, did the expansion fail? */ --=20 2.49.0 From nobody Sat Feb 7 16:13:47 2026 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 5E186279904; Wed, 30 Apr 2025 18:11:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746036674; cv=none; b=Ic7SusCfHJJUNr73VO77fDK5o6id80a/JjYEfS+j0+bKqDbgtrIl9TqbWLy7NX72/yP3IYsalugRoSicUQ1Eq6SKxkIvxSjMGVnbUEyjzpXTYNPgWhEnPL1U/GKY932Pg20rKDgU+MT4Ej/+eCLvC33DhXA41vHUH3LGBpul2Zw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746036674; c=relaxed/simple; bh=bjClv6BryTyDpGkWdfsiI+95q6D8k7MY583X7jPAQJk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gbhC4XOQ+vj1sM74FVHFFIEUOJ2puv2yPByhiE8oVQLGeVmaZXJS0bUOIlNAeSot1+wJqBwE801ldRYWUR/bjzUtkHf3NU55kTKCkj8LiVbvS44VOlun2VBPIil9+DJ6ByK7t0/94zRpneUaZbAGWDvQDr+KplbLu2pAA8XM2Qc= 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=Xyo+JaDQ; arc=none smtp.client-ip=209.85.210.177 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Xyo+JaDQ" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-739b3fe7ce8so283326b3a.0; Wed, 30 Apr 2025 11:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746036672; x=1746641472; 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=tq3nEj4DUSPSU3dXBHWbYOiByd1+bRHGbfykzSesdrc=; b=Xyo+JaDQ9INLleVptVhRQpYuGrBchG8Y8HjZbttORjNEJU+wmOKPtumtPLIhZK2SNw HCp36kmei8v7Ng4kJG6W76qpJJ/8ZpJEr23pQ26K55Bzw0KLFL+KwGOwVJpnBaLsujyO vTginbmmwzUiYsJAzVXabU/gaHoJwV88FbxLd3gTSs2OUgsO/sBglMESAmCvYT3GhOiZ 4zrnntzsEPLNZ5fWhT3P1DMslc4HOm/abqONAGsgmVgwK7eNOkqHbCZR7Ker/CGmeTM8 WynijBqkyQILuJ46IJJrnLBGN1UWydnN0DNKN6mZZRz1m+qPApyNlfBBnRzbkgvDtfay 8w3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746036672; x=1746641472; 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=tq3nEj4DUSPSU3dXBHWbYOiByd1+bRHGbfykzSesdrc=; b=xKnRe/WU/xRnGeJuszENZkkQaocUCgFTwVTS6H9WT9zyAwBlNaHqMadDTIGzIu8iTj 008xozXxgbOaCVKkBBeFq1zF2w+g2yGFITZZmqUeNhc1t0cI777fCZDvsVe0eNwa709t PwV3BCRbqHXlJB1MCm5qrfBQ6+FwqsbU/erOVWcaCzr3Z9r5szFaKr0WgimY54hnG/9S 7mE+eZqB7YzlMzfX5TJruUG2Pq05I0ZtMAB9XKpX1KhMXX+aLU6rslNgEPay/KHSRKiY pD5uET6pcVJlEEDa4p7kXBZaQzGz+QCjo6kNhxktwaCA93wQTeHCtOvJf/N3vSVU86sA BkYA== X-Forwarded-Encrypted: i=1; AJvYcCUl36umNva4a++R9DowvZckZyCMVt7smYOPxWZTlcfOPwdTsKZI2t+BZh8e1AXFFTQKcoNPhQoG4Km+YhZf@vger.kernel.org, AJvYcCWv/XYj0iwn/KzfOcugGTLaOoMP9YRjWVmwuy+09rRam+8O+ZKsWzIsLNaeCExMA76qCRsKNnSo0RqX9Q==@vger.kernel.org X-Gm-Message-State: AOJu0Yxu6MiOtRExZuz7zwxYmuRNfm4/0RnGcabKhURciy7fG1QXhfG8 JZpky7ihTGojYsbvELTxZ7uNhBkwHH3eP688cKd4DucXNn3nldHGj7A98meUfJ3ngQ== X-Gm-Gg: ASbGncu/YsGOXdeG+ZxyoeYyxm9TeU/0Dm0kfVZOLQWhiB+QNlZMHF/tEKCWEgXq7uf W9CoI8GWvDlmpYI3LKxTpjwAtQlcFFRbcXyChFZiuIy4ikjdqE36ClYYUB9wiE2LEvlBECPNR+V AjnKw4V6zCHC3jAUmqYeIQ5TJRBioQG1jPFC0nOvdZmmMigAipuRoVhMuvPAQuewPnVcrC6Zk+A Ubb2LoNeYUzVvtlwrELRZqhgx/ebrstRf90cdSaIf/w/NmURwxJZXq6iONK023Zi7jRQgJosBje tct36YmRvNsQBIqeF5z9TlVRhPbnICyAhphr+aKgHaYVgJKAD1wAQ1nflvX8Rg== X-Google-Smtp-Source: AGHT+IGPmIR52RvLNc4qp7jBDc7epoAkUWjSXFVEqnCRZkqTXLMSG6UyM8sVIbiZ/MbiNgWOBB70hw== X-Received: by 2002:a05:6a20:7f81:b0:1ee:d8c8:4b82 with SMTP id adf61e73a8af0-20a89419b37mr6855342637.31.1746036672506; Wed, 30 Apr 2025 11:11:12 -0700 (PDT) Received: from KASONG-MC4.tencent.com ([106.37.122.198]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-74039947976sm1983822b3a.84.2025.04.30.11.11.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 30 Apr 2025 11:11:11 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , Hugh Dickins , Chris Li , David Hildenbrand , Yosry Ahmed , "Huang, Ying" , Nhat Pham , Johannes Weiner , linux-kernel@vger.kernel.org, Kairui Song , Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, Qu Wenruo Subject: [PATCH v3 2/6] btrfs: drop usage of folio_index Date: Thu, 1 May 2025 02:10:48 +0800 Message-ID: <20250430181052.55698-3-ryncsn@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250430181052.55698-1-ryncsn@gmail.com> References: <20250430181052.55698-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: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kairui Song folio_index is only needed for mixed usage of page cache and swap cache, for pure page cache usage, the caller can just use folio->index instead. It can't be a swap cache folio here. Swap mapping may only call into fs through `swap_rw` but btrfs does not use that method for swap. Signed-off-by: Kairui Song Cc: Chris Mason (maintainer:BTRFS FILE SYSTEM) Cc: Josef Bacik (maintainer:BTRFS FILE SYSTEM) Cc: David Sterba (maintainer:BTRFS FILE SYSTEM) Cc: linux-btrfs@vger.kernel.org (open list:BTRFS FILE SYSTEM) Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Qu Wenruo Reviewed-by: David Hildenbrand --- fs/btrfs/extent_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 197f5e51c474..e08b50504d13 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3509,7 +3509,7 @@ static void btree_clear_folio_dirty_tag(struct folio = *folio) xa_lock_irq(&folio->mapping->i_pages); if (!folio_test_dirty(folio)) __xa_clear_mark(&folio->mapping->i_pages, - folio_index(folio), PAGECACHE_TAG_DIRTY); + folio->index, PAGECACHE_TAG_DIRTY); xa_unlock_irq(&folio->mapping->i_pages); } =20 --=20 2.49.0 From nobody Sat Feb 7 16:13:47 2026 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (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 29AD927E7CB for ; Wed, 30 Apr 2025 18:11:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746036680; cv=none; b=m01An2X1uAl1R04VGYdnMZ5bvyGMXjStLJT/FWGynMap4EICF/EqOEeGbxJFQYRIEFrJkvaMN93UoCT16cWdghKhi/a+iZ+dvtHk6fkN1o8s5ZSODADCduuSvfbVzLRiV2KHxb8+a9GO5MaytMr7QlKDY6LaqV6p22gX2h1Gicg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746036680; c=relaxed/simple; bh=2+zHp3o6v4QSVzp94ClonbDqg/k5+dUzGUoCLjRAKLo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZX2xZlPXJ+gn2Tz822gL+VoyHkhSI3BbNsUFneOYYB7bepoDreLNeCv01koqYKfpiCH2bl/w8++nEj63uCw+UqeoTJncVI8vGSsbEI/s0IJe6RrLO66dZ+ViwyTsiN0o21XZwNQAEptIc/HCicnKvnp112/eeYrnWt0Ithb5wgQ= 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=bLUNb8lP; arc=none smtp.client-ip=209.85.210.176 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bLUNb8lP" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-7399838db7fso283274b3a.0 for ; Wed, 30 Apr 2025 11:11:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746036677; x=1746641477; 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=NRi4DVQ4l2yFg1fX4IS9tDs6tW+LC63jcXq9t1eYUbg=; b=bLUNb8lPgIAbQivTjoIOxkLs/now8WOA0BvdAysge4hMXIsMoaIkcV3aMmSIM0NOEE P5YjqTWb7mlpPizxY+y2GQxTXgrjgXpD7UZ5sOIzhTHzH5EY0ShLUSYXGQEYL5keWoRp A6mcYIEz6tom0FPYHdAIPzY6XeSvCQ7DaOexCTgEbsbH+qIsz6dOenyqPMdFr1L193LV pouOUlxeTcs3FYueGM45FTSdvDJFQFt6gkcFWNzouuv2RgP3zEtWpeaCbcGhC+R1hkyw sNWoEyNwZvwYtn8W5gabUP4OQLmjq4k+F53G1U+cxq2DiB32uALJWPko+IYWK7K/MNfB PEaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746036677; x=1746641477; 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=NRi4DVQ4l2yFg1fX4IS9tDs6tW+LC63jcXq9t1eYUbg=; b=IR1fnLT813fBMRGgkDEB0FiIl3Euc4xyhA3plbaFG1P3BcZWG2BiuyB97LWDfcp4lL c8ebMiyRZPBPX5XMUkgLNsgiF6UuM2naVlwPMfxe8A/XdoygOlFLUZqs9vIB6ZxrAqLW +KoNzjvHjZjYHSLqFI0vQbQH7GwfrU9NB1ICHN3ZUoqRK67CX7D2bpISy8se+VCXdEes pi7xAMNs8OGyB7CgXFxJ11cx7fKK1KUfngWZ4ckqGXJRgOiD+DDL5XeVfum2SzhvCV/p 2eBDXFCThWYgac1Iah5X+qpPLX0PUeLk08zRD/MtKC6nF17n0hOmXA6kXBlVyQdh1y2n ymJg== X-Forwarded-Encrypted: i=1; AJvYcCUGRHLS2DK78+T7qhwzU13DwTVor3w5MEjWkAC9yEJmP3xksISieH2W/F6do0Jkh6IUeZF4+pv60jxMXY0=@vger.kernel.org X-Gm-Message-State: AOJu0YwfYUC6PSWxIFR23WxJpt8tFZ9mPfCkIY+8aBfYRDY0mCBJMVKp d0kZWbrRhdosFyA9KKqkd6VYNC9jxmkJBj76TXQ7X9ve4m/MOgG2 X-Gm-Gg: ASbGncshu5sPAPJMA+DT1iWCFSbKEJkdm0siV3uelGoUXxHIqFny+XIhGHV4BL71Adj tOwek5sMUsmrFSDgiVibA4Kl67Ai2kjZONaieqf9+ppxJ6GkF9sAEQjdHceSYP45TlOBdgGiSyt AXwGr1BBvC/Ci8jTngBctbSs4b65Nbc61626WoTiLizhA17DY9Z4WfxtFIM+SNSnc8AHbAcuY/K MUJ3QB6piazNGY7RkCJrs4QHwShtobygbFJCr48cqmc+ch96r3hCP4QSnfk9z24WQymclhsfYWq L0ln1vkGEDh0gngvBfndIE5pW428wB8yrAAuaUcMZINRAS/VHp0xR/Ty7Yv9nA== X-Google-Smtp-Source: AGHT+IFui7W32qe/7oFPxgXqGuD21PFMOpd9VG8chpu1c5yNXFW+POaOkysCOWvmg5iIKChIBFoOWg== X-Received: by 2002:a05:6a00:391b:b0:736:3ea8:4813 with SMTP id d2e1a72fcca58-7404613f584mr699444b3a.2.1746036677129; Wed, 30 Apr 2025 11:11:17 -0700 (PDT) Received: from KASONG-MC4.tencent.com ([106.37.122.198]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-74039947976sm1983822b3a.84.2025.04.30.11.11.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 30 Apr 2025 11:11:16 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , Hugh Dickins , Chris Li , David Hildenbrand , Yosry Ahmed , "Huang, Ying" , Nhat Pham , Johannes Weiner , linux-kernel@vger.kernel.org, Kairui Song , Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH v3 3/6] f2fs: drop usage of folio_index Date: Thu, 1 May 2025 02:10:49 +0800 Message-ID: <20250430181052.55698-4-ryncsn@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250430181052.55698-1-ryncsn@gmail.com> References: <20250430181052.55698-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: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kairui Song folio_index is only needed for mixed usage of page cache and swap cache, for pure page cache usage, the caller can just use folio->index instead. It can't be a swap cache folio here. Swap mapping may only call into fs through `swap_rw` but f2fs does not use that method for swap. Signed-off-by: Kairui Song Cc: Jaegeuk Kim (maintainer:F2FS FILE SYSTEM) Cc: Chao Yu (maintainer:F2FS FILE SYSTEM) Cc: linux-f2fs-devel@lists.sourceforge.net (open list:F2FS FILE SYSTEM) Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Chao Yu Reviewed-by: David Hildenbrand --- fs/f2fs/data.c | 4 ++-- fs/f2fs/inline.c | 4 ++-- fs/f2fs/super.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 54f89f0ee69b..5745b97ca1f0 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2077,7 +2077,7 @@ static int f2fs_read_single_page(struct inode *inode,= struct folio *folio, sector_t last_block; sector_t last_block_in_file; sector_t block_nr; - pgoff_t index =3D folio_index(folio); + pgoff_t index =3D folio->index; int ret =3D 0; =20 block_in_file =3D (sector_t)index; @@ -2392,7 +2392,7 @@ static int f2fs_mpage_readpages(struct inode *inode, } =20 #ifdef CONFIG_F2FS_FS_COMPRESSION - index =3D folio_index(folio); + index =3D folio->index; =20 if (!f2fs_compressed_file(inode)) goto read_single_page; diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c index ad92e9008781..aaaec3206538 100644 --- a/fs/f2fs/inline.c +++ b/fs/f2fs/inline.c @@ -86,7 +86,7 @@ void f2fs_do_read_inline_data(struct folio *folio, struct= page *ipage) if (folio_test_uptodate(folio)) return; =20 - f2fs_bug_on(F2FS_I_SB(inode), folio_index(folio)); + f2fs_bug_on(F2FS_I_SB(inode), folio->index); =20 folio_zero_segment(folio, MAX_INLINE_DATA(inode), folio_size(folio)); =20 @@ -130,7 +130,7 @@ int f2fs_read_inline_data(struct inode *inode, struct f= olio *folio) return -EAGAIN; } =20 - if (folio_index(folio)) + if (folio->index) folio_zero_segment(folio, 0, folio_size(folio)); else f2fs_do_read_inline_data(folio, ipage); diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index f087b2b71c89..eac1dcb44637 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -3432,7 +3432,7 @@ static int __f2fs_commit_super(struct f2fs_sb_info *s= bi, struct folio *folio, bio =3D bio_alloc(sbi->sb->s_bdev, 1, opf, GFP_NOFS); =20 /* it doesn't need to set crypto context for superblock update */ - bio->bi_iter.bi_sector =3D SECTOR_FROM_BLOCK(folio_index(folio)); + bio->bi_iter.bi_sector =3D SECTOR_FROM_BLOCK(folio->index); =20 if (!bio_add_folio(bio, folio, folio_size(folio), 0)) f2fs_bug_on(sbi, 1); --=20 2.49.0 From nobody Sat Feb 7 16:13:47 2026 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) (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 EE7A62749CA for ; Wed, 30 Apr 2025 18:11:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746036683; cv=none; b=pWS8/HaZmSR7hw9VxRs27wxONUrqZkFRSaPm7DULONttTGEn5iCDUFvrCj+Ra8GjrsEER6No+6QEdsh/MIhqYmjxsTBEO2mqz9/rPt1LcnaP4mmIi+X3jsk+/0rXRgDBEktKOVpeqw3YfE/kI1wVh+vKdcMbR3N2ejY/EeMQ3lI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746036683; c=relaxed/simple; bh=We8Dff6Q27N+5ZEddI/zKbc2E8guH42H5LUvj7Sdpas=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MThNKVcKjvtLpVT3gdUnHGW+GHbVfO6YpSQgRxEzC1FSzmQP4M8gY4PAHuimtI+AbnVf6UTKoyKKTxNp1dd12VOYvbHqTH4S0vR1ZbPdCUzUu+b9ZUXRFx8DiR0qskZnmTqy5otjAfCTkq/8N1nMpi58Ew52ARWkC9cTw3HOfPI= 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=JkDTCbkQ; arc=none smtp.client-ip=209.85.215.176 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JkDTCbkQ" Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-7fd581c2bf4so127183a12.3 for ; Wed, 30 Apr 2025 11:11:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746036681; x=1746641481; 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=9qHFF/xTlBQeExdAl4eX04pdKCEarK6ESk+cMoKBj4E=; b=JkDTCbkQJgRwHu+zzA91fpv26bj7Z1q5hoo4d6q0k2z6cGSdH77MSQi4/k3ZH6dmpc +rtzEpPZwhTC93iDnwFuifFHi8zGyNS5BDDNflcyfqzVrEXbmipJYwfG/GXM0YDtq4Pc gy98cnIrIBB5CGISeLsYqKp1AKkeIgLMtw2SMjW/foSZ9IbwAAokFt7EwFIrWC/wi0VU 7a2UMSN7jXkw6jNgdgrG9VWAJF9V7m14rrMi6D/4wVowUWy53ByFBmFOyiuWh+CTTEQ0 cHdFRyGju4ZZS/VSDRugs2+bczYyR+zQJZDdraQqgODxviUsUbMGv7T4Jjmv7N8Yr0po IkgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746036681; x=1746641481; 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=9qHFF/xTlBQeExdAl4eX04pdKCEarK6ESk+cMoKBj4E=; b=eUwgjnydB14HRc6Yko0VqVmIFPfVkMd6mKfyxCffDFjDkxeEYQJgJK+J8x4a0u+qiD 33RitCyTsaaD4Fkay5Q2k4HrvG5rzT44i4Fe/Lmt6mhqYxoM9MTE7XwKWFDODJeuD3TU Ef5VB2dDkH1Mb7zjLhNA11MbDWyt098+28S8LJx9zEDZvT35NgtdrhJPnDy4IUEmhALe yxZZGGzDnRm1/BHegVCKnZeDjfYbu6Nfa7EdmUsF6fvGiYxSm0kvZ/i0UjFrMow2VaFI CUejvfBt5kNBi56yT+hVhhMtE65cgl24it5ZIoHeKL9uMidaEt2vOpcd1hwqb2gr7iVH XJBg== X-Forwarded-Encrypted: i=1; AJvYcCV/q+gX5ILZ1H9I6vRB5GF3nwC3JNowtdpAjsymjCcD73avM0paHs74cKVTfgYn2RrekeiQGXLVauHG4tA=@vger.kernel.org X-Gm-Message-State: AOJu0YzTvTcgdqOnvdVUWECqj3mIrF5RBXzpcKf2Je8jRgqJOina8XSH sX8jEM3hdeMDUTMpIcUxgxr8X5nO/ovKOzFF65NEZnbNgDpuJ7Hn X-Gm-Gg: ASbGncvhTj+61BbiupdqJDVcCeY671fgvUKLcHjH4qHS0v9wF6SgdAZwF0YjuD7iyx1 kbS2IsSbg2th5LKnuDxDEbgkdcDx6YRfVyT76aymJf8x7Y1mPMX/NX2+jm3mi3En0EDndOsynrT Vn9cY1OCVq19/yR1DbM0A0ok+7GTvFeo5zReEWfulUaJ6d3EBfKN0qh7cQv7aMDuK/uxSuf7ERz ub93sqOHmo4k0cAIMNjBqHDnTWt9+zjErZzaWFM6ckZwgFStbkkUD1UIN1rdU3Q+kzCcv7bqXiv V2zWeoeKRht9BAXjD997hRozr6ZZf4ncp8VdZNQrtvuqxxycILLW6IprMmUo4aJsiuOCO3Va X-Google-Smtp-Source: AGHT+IHF5M1/PXpGFD3JmmxbamN2ef4frqiiXFLFq0XpOZjSrO3NxaTlgM0tiao5ZAJP8qQkb0DMiw== X-Received: by 2002:a05:6a20:9f8a:b0:1f5:8da5:ffe9 with SMTP id adf61e73a8af0-20a87741099mr6125077637.12.1746036681106; Wed, 30 Apr 2025 11:11:21 -0700 (PDT) Received: from KASONG-MC4.tencent.com ([106.37.122.198]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-74039947976sm1983822b3a.84.2025.04.30.11.11.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 30 Apr 2025 11:11:20 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , Hugh Dickins , Chris Li , David Hildenbrand , Yosry Ahmed , "Huang, Ying" , Nhat Pham , Johannes Weiner , linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH v3 4/6] filemap: do not use folio_contains for swap cache folios Date: Thu, 1 May 2025 02:10:50 +0800 Message-ID: <20250430181052.55698-5-ryncsn@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250430181052.55698-1-ryncsn@gmail.com> References: <20250430181052.55698-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: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kairui Song Currently, none of the folio_contains callers should encounter swap cache folios. For fs/ callers, swap cache folios are never part of their workflow. For filemap and truncate, folio_contains is only used for sanity checks to verify the folio index matches the expected lookup / invalidation target. The swap cache does not utilize filemap or truncate helpers in ways that would trigger these checks, as it mostly implements its own cache management. Shmem won't trigger these sanity checks either unless thing went wrong, as it would directly trigger a BUG because swap cache index are unrelated and almost never matches shmem index. Shmem have to handle mixed values of folios, shadows, and swap entries, so it has its own way of handling the mapping. While some filemap helpers works for swap cache space, the swap cache is different from the page cache in many ways. So this particular helper will unlikely to work in a helpful way for swap cache folios. So make it explicit here that folio_contains should not be used for swap cache folios. This helps to avoid misuse, make swap cache less exposed and remove the folio_index usage here. Signed-off-by: Kairui Song Acked-by: David Hildenbrand --- include/linux/pagemap.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index af25fb640463..0c9aff5ec77f 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -935,14 +935,14 @@ static inline struct page *folio_file_page(struct fol= io *folio, pgoff_t index) * @folio: The folio. * @index: The page index within the file. * - * Context: The caller should have the page locked in order to prevent - * (eg) shmem from moving the page between the page cache and swap cache - * and changing its index in the middle of the operation. + * Context: The caller should have the folio locked and ensure + * e.g., shmem did not move this folio to the swap cache. * Return: true or false. */ static inline bool folio_contains(struct folio *folio, pgoff_t index) { - return index - folio_index(folio) < folio_nr_pages(folio); + VM_WARN_ON_FOLIO(folio_test_swapcache(folio), folio); + return index - folio->index < folio_nr_pages(folio); } =20 unsigned filemap_get_folios(struct address_space *mapping, pgoff_t *start, --=20 2.49.0 From nobody Sat Feb 7 16:13:48 2026 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (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 0B23326656F for ; Wed, 30 Apr 2025 18:11:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746036687; cv=none; b=h2zNMnhw3/XyA3nse4S4Dfc8LvaElBIdYH1uyFQGtQpS9Y+zcT1c5l9nIu0jNhNuMk3Da1nvxYutdO8arUpHt8blpCtBClTcJfy1Rgq8I35IozfyQY4BI/cfsHvHjUrW8y75GkJkvPSjoNjiSpPm/O39VlRuEsw3zpIizbHtNBE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746036687; c=relaxed/simple; bh=CQu6NY+XXCjQ0pDoxIrTBz6qrVh4Glx1z3jLOwt79bY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q0C2gnNC6PpQWjH71bKEMJpBLD9Ft4gOeeHLxBSg5Oz+bPgQYmzGi6sWvAdU1dlG/FXgHzNfa8S/gJcO5z9hYBt35jddtXPnZbp67Ce4IUpJn9vfB/2+nyR5wzT6plei4R0+gM7F0iyQBi01dPoNAoDqUZ5ayhqotP+wMc+ldB0= 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=VLnpInnA; arc=none smtp.client-ip=209.85.215.172 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VLnpInnA" Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-b0b2d1f2845so107889a12.3 for ; Wed, 30 Apr 2025 11:11:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746036685; x=1746641485; 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=ABVuvP5TNG4tVYGMuC//l3k1Ki5yFOjDY70WGpcFOzo=; b=VLnpInnAmXiY75sDp4x75brDKpRp/VGCeuXCb3IeAjhh/V67LOb8l18bihH1iKpEco flNbfgGzco2Ekgw+2mpkIv8PLoDEeXwxYCVg37JyBUPhpfH1U+jlBfNkOwmGbnyLelzb u/K1W/66z76c9ZbuE+DNdGiTRcLbKi9kzNM9tHPAuFVgNiJQdJ8KTNJ8WukGyVt7TYMF oy5NXkjcIFzvle2WO5CmN7glrhzBlrBNudelnDjEIRpv/Z1abyoNTzapY9ukt7OcFR5w QL684UTmmo4bBFWOTiqoF+No9Cttf5vfg0bNHNXRa4O2L9zwckt8V22D7eQ07IHZgV0V ZSSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746036685; x=1746641485; 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=ABVuvP5TNG4tVYGMuC//l3k1Ki5yFOjDY70WGpcFOzo=; b=M3hRi3F9Yh8064hEGD5myNuFjJq0H+o3fPPIdAr9zaczSVTH7f1GA74UAjJz/GKNPR cUEWjyO411B9yqNwEbq5vuhQFs8JG7aVY408SuSzONcKKmHMddtakfBzCADV/mq+dWn5 7T6KBVLsY+cSxzsolfXDsXK8hBQq3rhcMg5BO98PCOwSFPUs6/E3zpq37sAvEa10eAgT UbISXV78peOvVQdT8ZgSHL++pxRw2VvBEypu2SwKNzEHNzvHrjjp2OCQDV91BbcEHm3R sqd15AHuqxGFMgwTK5C4TgBltgxA9rKNQOOGq0TACgtHq10WeSi7J1zNujM7krG/ebN3 E4Yg== X-Forwarded-Encrypted: i=1; AJvYcCWexNsuIOiW+BDTc5QqliUa+2vcAbtR6/5i0e5nVcmWIaj8iKiAx79tbh5VgOVHbkkR7qT4xrbHm6sJ9/s=@vger.kernel.org X-Gm-Message-State: AOJu0YyZnf0LBeMyrSfbyYc6TOSqGaZQe79Z3xmWMfTKNJ38pzc/T9SS zXifhZPjCuGPABSosv0lVi64cjPqusCkjaJrtkombxYr/ka1pTM8 X-Gm-Gg: ASbGncvArXKga33eHe/dULns1k1wOz0jM+q3I0WNXC37fwlijaLziteiQTPt9a+wi3q 0qXefaHFb1M8aP1LqLakenye26x00LPLJ7j+hMPFgtB0XDSaHj+UGsWn25O9GSmFCLTvoA/JP85 mVnlRvMNeTUE+FcLLqZ2zES6o+7s3cdjYgitc5veV5M2UyXcMBeG/jyJ0kpGh4WOfOlRhyWXl1P OmgzS0YlmcETD22H/sDoAQCH/EP9JSqPZA3qCBCVr/AFxIUWu4CGYQCfVf3yPo4qNXgoi3U+4lz yAlpbGkXNDpvHYmXRbNozBPP6p8ZPsow2NMeAHUwR18SDJox6modvUwWto9Ayw== X-Google-Smtp-Source: AGHT+IGvk0oJWttNM6c0zFmz2EsnDvT1Lr3GHsue6PfHLv/bA327BK4ptz41QX/l91eCNpM4QRO2Ag== X-Received: by 2002:a05:6a21:1583:b0:1f5:6d00:ba05 with SMTP id adf61e73a8af0-20a89a012bcmr5766473637.38.1746036685092; Wed, 30 Apr 2025 11:11:25 -0700 (PDT) Received: from KASONG-MC4.tencent.com ([106.37.122.198]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-74039947976sm1983822b3a.84.2025.04.30.11.11.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 30 Apr 2025 11:11:24 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , Hugh Dickins , Chris Li , David Hildenbrand , Yosry Ahmed , "Huang, Ying" , Nhat Pham , Johannes Weiner , linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH v3 5/6] mm: move folio_index to mm/swap.h and remove no longer needed helper Date: Thu, 1 May 2025 02:10:51 +0800 Message-ID: <20250430181052.55698-6-ryncsn@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250430181052.55698-1-ryncsn@gmail.com> References: <20250430181052.55698-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: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kairui Song There are no remaining users of folio_index() outside the mm subsystem. Move it to mm/swap.h to co-locate it with swap_cache_index(), eliminating a forward declaration, and a function call overhead. Also remove the helper that was used to fix circular header dependency issue. Signed-off-by: Kairui Song Acked-by: David Hildenbrand --- include/linux/pagemap.h | 20 -------------------- mm/gup.c | 1 + mm/memfd.c | 1 + mm/migrate.c | 1 + mm/page-writeback.c | 1 + mm/swap.h | 18 ++++++++++++++++++ mm/swapfile.c | 6 ------ 7 files changed, 22 insertions(+), 26 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 0c9aff5ec77f..627cb0338e5d 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -884,26 +884,6 @@ static inline struct page *grab_cache_page_nowait(stru= ct address_space *mapping, mapping_gfp_mask(mapping)); } =20 -extern pgoff_t __folio_swap_cache_index(struct folio *folio); - -/** - * folio_index - File index of a folio. - * @folio: The folio. - * - * For a folio which is either in the page cache or the swap cache, - * return its index within the address_space it belongs to. If you know - * the page is definitely in the page cache, you can look at the folio's - * index directly. - * - * Return: The index (offset in units of pages) of a folio in its file. - */ -static inline pgoff_t folio_index(struct folio *folio) -{ - if (unlikely(folio_test_swapcache(folio))) - return __folio_swap_cache_index(folio); - return folio->index; -} - /** * folio_next_index - Get the index of the next folio. * @folio: The current folio. diff --git a/mm/gup.c b/mm/gup.c index f32168339390..91bbf57579f0 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -26,6 +26,7 @@ #include =20 #include "internal.h" +#include "swap.h" =20 struct follow_page_context { struct dev_pagemap *pgmap; diff --git a/mm/memfd.c b/mm/memfd.c index c64df1343059..ab367e61553d 100644 --- a/mm/memfd.c +++ b/mm/memfd.c @@ -20,6 +20,7 @@ #include #include #include +#include "swap.h" =20 /* * We need a tag: a new tag would expand every xa_node by 8 bytes, diff --git a/mm/migrate.c b/mm/migrate.c index f3ee6d8d5e2e..662e5dc44b33 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -50,6 +50,7 @@ #include =20 #include "internal.h" +#include "swap.h" =20 bool isolate_movable_page(struct page *page, isolate_mode_t mode) { diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 20e1d76f1eba..9ff44b64d3d6 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -41,6 +41,7 @@ #include =20 #include "internal.h" +#include "swap.h" =20 /* * Sleep at most 200ms at a time in balance_dirty_pages(). diff --git a/mm/swap.h b/mm/swap.h index 6f4a3f927edb..521bf510ec75 100644 --- a/mm/swap.h +++ b/mm/swap.h @@ -201,4 +201,22 @@ static inline int swap_zeromap_batch(swp_entry_t entry= , int max_nr, =20 #endif /* CONFIG_SWAP */ =20 +/** + * folio_index - File index of a folio. + * @folio: The folio. + * + * For a folio which is either in the page cache or the swap cache, + * return its index within the address_space it belongs to. If you know + * the folio is definitely in the page cache, you can look at the folio's + * index directly. + * + * Return: The index (offset in units of pages) of a folio in its file. + */ +static inline pgoff_t folio_index(struct folio *folio) +{ + if (unlikely(folio_test_swapcache(folio))) + return swap_cache_index(folio->swap); + return folio->index; +} + #endif /* _MM_SWAP_H */ diff --git a/mm/swapfile.c b/mm/swapfile.c index b86637cfb17a..9fe58284079d 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -3671,12 +3671,6 @@ struct address_space *swapcache_mapping(struct folio= *folio) } EXPORT_SYMBOL_GPL(swapcache_mapping); =20 -pgoff_t __folio_swap_cache_index(struct folio *folio) -{ - return swap_cache_index(folio->swap); -} -EXPORT_SYMBOL_GPL(__folio_swap_cache_index); - /* * add_swap_count_continuation - called when a swap count is duplicated * beyond SWAP_MAP_MAX, it allocates a new page and links that to the entr= y's --=20 2.49.0 From nobody Sat Feb 7 16:13:48 2026 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (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 F2C142882BD for ; Wed, 30 Apr 2025 18:11:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746036691; cv=none; b=RUCH+ZG1HVG38XW6Hnj9FIqiCYjniOCT8QoX5yXKnTOAhtGTkJbR9JD+HotzS7aKCIvwy8N0gMKH5QI3T9aIGwsqQC5kTLvNbzcKUKdWj6iBzsc7BztdHVqQ/tU+zYu4yBvdTP7Ibcm/2IlXn/W61iJ++NJQMFU4lZPJ5RdoyiI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746036691; c=relaxed/simple; bh=j4nly31GVjWEhbgTSOnyZr5LFHdDhJ/vcbZlEmbkTs8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ut44zsUctlYkEgIziDBEmD71A+WdSPFAPFdZnOYcKPH2jcVc79isZ2xX2sYBVOtPFdqR/yei7+NDcxfes1ps9wc0v/leFSlcLKD1wdaOw+CJ1KVVg3YJwUIas+HXdC47FgIDeu+mQ5Ik98GwMGrdj9EDBN36BXtF7/9mFinAiIs= 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=WjHvu0/A; arc=none smtp.client-ip=209.85.210.180 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WjHvu0/A" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-736c3e7b390so241512b3a.2 for ; Wed, 30 Apr 2025 11:11:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746036689; x=1746641489; 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=YPYU8xo1mzMVuKzjJlWPb2a6nMmELwwkYyTRspWFm2c=; b=WjHvu0/AFF1rH0k3CnD3JPsA4kwk6gkQY0IvAyuOe66KEKXJjwQO1AWsO1eRbUbfGJ 2T6hBs355pux7+6pHurfDhhbRMo0rmFUtU3p2iBMmN/vWU/5VlN/fNkFcDNfjfdxOxti GXRW3nNXTShIVDxPR9tJ9CgBa/B30/NsIWOimjEvnzJJ+kAPkeNw0mV4AxUWb4gnCcT/ G1NOKgP0B82BnE/ZZiQNCpxaJlpij2ZSVf45vqu9Z6zW3G8JpO311yVA+jV9XiRa069O F2N73IYjWEt1Wfrkfgi/LxPO9vICScqZaOyIZdSFlTHkEgduilg5bR01Zsxw70+UOWxp anCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746036689; x=1746641489; 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=YPYU8xo1mzMVuKzjJlWPb2a6nMmELwwkYyTRspWFm2c=; b=voW4TtPdOuomkarLHmD1vTIpJZBxArWynSKxtOFKjL02h18Xx2I5SFObVrqCrb3HC6 HpRxwtfL3TwT3Nh1qQ4i74b6KBgNIK2jbMLP5qom3bVE3xjALoU869cZw2RAC4Bgzjhq ZjnoE+QZ1OuDD9TvtmyOF9R/m+ABEoLcLa19QlaPS8gifYhVq8Y/n7Ggt66Xes+D6aaE w1zLOu2r2ORpKBicK2S5RRbeG1AxZ/zsQIy9B8/STTV8ERvhO4RyklWiQ7WUyIsfftXy U33aLeS1NFDNFix/L4J8TvsMaE2GTZMHjUavY6WSzcfW7gFjqUibQxROydfcT30xTKKX C7Eg== X-Forwarded-Encrypted: i=1; AJvYcCVKlAqFQUXxlPkIYANh6m+gEfAr/B1IIeYbHLfABOx+JrtXGlaNnZzmW3622Fko7FmJ2uyvRm1aLNgB2fI=@vger.kernel.org X-Gm-Message-State: AOJu0YxhqG4mhqoogc5J+tgF+xw9pIiS3T7fb8g4algIYInCOL0Ej07y 0KZfsD9pHsqUI1oiD7YYDKjXzUmAMJtDhitE8PfCUrc/0TIQ/2mi X-Gm-Gg: ASbGncvKiddWnK0wHHHiT09OhL9Rc5LSkz/jt4SACTekrsin0zIvtiAcIG+WCdbpPXh JE6fRXSXKcOinKZrI1oyg6SbClvK7WyiqvFcsUJpMuVfHwqjyv32RWg2lDld8aJjYHCnzEv4cI3 yrJBe/eQSHZBzqoRWZ0+XHvWLt83vVrzw6yQRFYykWxebaCfwfymfS/crU41ZSrEKmXzdeCcY5a KmYJjejMFGnwdbek5u2nx8MLiafYKTOIZWcJhlhG/yi0JseZF+L8LW053k+WBOnOvgEcHck55Gx y3XOqsQG7FKvay9/LQZtcTkz6QB+rf3aeqJdgdf41DoPxMGI7reYF+8e9wmLwA== X-Google-Smtp-Source: AGHT+IEizwJh83fKA4GblxYQufq8IOSE9ngbKGJYIoIhX0XYft1sNuqLkCRCPDpZGvKkBh5oDGgu7w== X-Received: by 2002:a05:6a00:18a6:b0:736:d297:164 with SMTP id d2e1a72fcca58-7403897a50dmr5522387b3a.1.1746036689082; Wed, 30 Apr 2025 11:11:29 -0700 (PDT) Received: from KASONG-MC4.tencent.com ([106.37.122.198]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-74039947976sm1983822b3a.84.2025.04.30.11.11.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 30 Apr 2025 11:11:28 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , Hugh Dickins , Chris Li , David Hildenbrand , Yosry Ahmed , "Huang, Ying" , Nhat Pham , Johannes Weiner , linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH v3 6/6] mm, swap: remove no longer used swap mapping helper Date: Thu, 1 May 2025 02:10:52 +0800 Message-ID: <20250430181052.55698-7-ryncsn@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250430181052.55698-1-ryncsn@gmail.com> References: <20250430181052.55698-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: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kairui Song This helper existed to fix the circular header dependency issue but it is no longer used since commit 0d40cfe63a2f ("fs: remove folio_file_mapping()"), remove it. Signed-off-by: Kairui Song Reviewed-by: Matthew Wilcox (Oracle) Acked-by: David Hildenbrand --- include/linux/pagemap.h | 1 - mm/swapfile.c | 9 --------- 2 files changed, 10 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 627cb0338e5d..8c6894d0ac27 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -533,7 +533,6 @@ static inline void filemap_nr_thps_dec(struct address_s= pace *mapping) } =20 struct address_space *folio_mapping(struct folio *); -struct address_space *swapcache_mapping(struct folio *); =20 /** * folio_flush_mapping - Find the file mapping this folio belongs to. diff --git a/mm/swapfile.c b/mm/swapfile.c index 9fe58284079d..026090bf3efe 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -3662,15 +3662,6 @@ struct swap_info_struct *swp_swap_info(swp_entry_t e= ntry) return swap_type_to_swap_info(swp_type(entry)); } =20 -/* - * out-of-line methods to avoid include hell. - */ -struct address_space *swapcache_mapping(struct folio *folio) -{ - return swp_swap_info(folio->swap)->swap_file->f_mapping; -} -EXPORT_SYMBOL_GPL(swapcache_mapping); - /* * add_swap_count_continuation - called when a swap count is duplicated * beyond SWAP_MAP_MAX, it allocates a new page and links that to the entr= y's --=20 2.49.0