From nobody Fri Dec 19 04:00:45 2025 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 37E341AF0D0; Sun, 27 Apr 2025 19:00:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745780417; cv=none; b=N5vJjnamTgJi7P8G1vPdit1t35gRd9TiSIgVDLjvtu5ttZP4j5eShIYHNgAL0EuwPBiwCzJxoLSn6/02NvWplCvSkFnvHrmvPH6bMwtV1OXLCBbe2Vp6AHYRjEHr2TicXyrCdni9wiWik16sW74GcFFNfMYW/+/XoO1xgciCilI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745780417; c=relaxed/simple; bh=2MeVGcC/JbBXjj6Z9aXrANwGElZGb7UdYFZ3+Z4IcYQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TOROjzERj72rTciiUguhv7iRiuUQgW/pBy+1MN2CxI1JNdCMntQJaKnIZZOEksS8qeAEYLplXVH0t3lGtjx8ckVyeeGH/Bg4v7vzC9JYfAgacAo7jfFbVeKV6SSAQRmTfh8lDK2BJbQGUK6bfZI19yIkK2PLU50oyHUYMPjqfHY= 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=POny5gUV; arc=none smtp.client-ip=209.85.210.174 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="POny5gUV" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-736dd9c4b40so4428332b3a.0; Sun, 27 Apr 2025 12:00:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745780409; x=1746385209; 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=jHQnw9mBKPJvkNcz1FYOPZlxw2bb5IcvypIEEOwJyYI=; b=POny5gUV0llVGcO5W+bgyWbW+NI2OZD3i/IpuW+hsp+9T35JdDF8rm/bRfWQQmg3ZF NpPGLgJN/UHGMtQuZEdiLMtmjMi6wbxQYStTIt0i6IDaLkqMjfotsnpgRCigFnpFJQ3P QbJ3qY43SC/9bTldeIF5san8bpxix03G/xOM3gDafsE5qIUUyvWpKLIulqgxhppXOtP6 iw4GtwCv2UA1/1pFykWlJVFKP0kh9Vt4YNPWhbsbhqVVPMXdTYmCLf82HmyrpNUFsuif eVvTEm+R5Av5ECUC+g8d2GSMLfzjlXWJfTQXg/lf76St3WEYzKTsdhU0/vd/c1/zZek7 8LOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745780409; x=1746385209; 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=jHQnw9mBKPJvkNcz1FYOPZlxw2bb5IcvypIEEOwJyYI=; b=i4LrYRNXiSoXLS4M/XkJYKF+W+WWDhN847inaOWg2ZBYsx+gSorE4c0/B59Dm1aGgq /mAW/vCl88fyNiyVZJMxyVnEzLMrOwwGCMihG0lgGAH1YEsnNQ50fOPvu9nveNkmCdz+ LZb8eineFeoqo7lQ97y3AUf391WQJtaGfPuVlBnrEY/P1gGGfRvDxqEjyWlqmBahEZKK 3cxqNGf6ht3mjFOPaSZgTyvlZghRGBFZ9G/i7atzdAiZJ84N1x4+cbuwC38XfZ2vbzBR 9Dzo5l5VMvNpZ049c1mpHyAKZk2Co81QVMc11/mWhUtouPPNR5SVVExT+Y8d4ifYCVgL rRkg== X-Forwarded-Encrypted: i=1; AJvYcCUTYgQndq1x/lC/GGODkCT2Jh7EWjOVwnnqeK+oW5aROG/VfZVl5gt6M5PwsnoBfBK51K5oJUOxrmE2yshp@vger.kernel.org, AJvYcCWpNdKQEsxPqmMzhrNpfjtq3dDv81x5KyF73+a24nmaGJFSWy+H1Np04kgk6TKnmrPXZVw4E4Xk4OwEVQbM@vger.kernel.org X-Gm-Message-State: AOJu0YzqVKFZnbJaR9Wo+1Cf+srHxa0WeEDHow9HpXJ7tzkLqCaNlMbs VHDrEOWbklpEGAq8dEFMVtNv0JAAxqlId1i78WjZYKxHlY08OgUTuRyIZEdhNnE= X-Gm-Gg: ASbGnctMPTXAPFYSnUoHXB6bPoaybYBboNHrF3KjVukW8a/3OERsptaC0i7uRxwhO0+ gyOoQoFJ24Swqd294IDPCN4PlmWmLWxkLDBqwqtb3XWyph6wpLj//IjsaUSiTOQVtglHLuhhYz9 UnlSvcC8AeEAlCqjpaKdb3g7ep+r7fHFzEfqVM502NFZE17gFwL/ST4yuMsoMFRpagRZ3KTbwQg t/7GrSgUh7anQmDT8Pt7dSH1GxoesrXE/5MrswxdcjIvWYBpxBh2mx3IZLeZwafSVyao3bN/3NB gB9frLwoQEEdY8cyc1kgYBNtXnB7CFiRtbQ/md6Ookcg6pTVfJA4UiJSAvN0MQ== X-Google-Smtp-Source: AGHT+IFFL5uf7jvIZwZoQNOWOpv1lhMyIRa7HYcY56NDs4Zz2MFGHKVsUV9AK/hefFCN4GDGqPUEyQ== X-Received: by 2002:a05:6a20:d709:b0:1ee:c830:abdc with SMTP id adf61e73a8af0-20445fb971dmr17217657637.15.1745780409348; Sun, 27 Apr 2025 12:00:09 -0700 (PDT) Received: from KASONG-MC4.tencent.com ([115.171.40.102]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-b15faded554sm5862153a12.72.2025.04.27.12.00.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 27 Apr 2025 12:00:08 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , David Hildenbrand , Hugh Dickins , Chris Li , 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 1/6] fuse: drop usage of folio_index Date: Mon, 28 Apr 2025 02:59:03 +0800 Message-ID: <20250427185908.90450-2-ryncsn@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250427185908.90450-1-ryncsn@gmail.com> References: <20250427185908.90450-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` and that is not supported for fuse. So just drop it and use folio->index instead. uigned-off-by: Kairui Song Cc: Miklos Szeredi Cc: Joanne Koong Cc: Josef Bacik Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Kairui Song Reviewed-by: Matthew Wilcox (Oracle) --- 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 Fri Dec 19 04:00:45 2025 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (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 79BB81EB194; Sun, 27 Apr 2025 19:00:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745780418; cv=none; b=LRlAAfF1OMDcmyVb4wjxqtvyoYlHvDkvJY/3rnH5ZWQVSQ5AGviFNPYdepbSXRRmmRgHcLngBibQSmANW5j9GWrJyVYmeuSjjwqynxSYU5nBmcKeR6rCXmxQCfrvk58tH1s9Hk5RNA5AZFhTXP0y/n39LhZI9aYqWHpSKLEPfeI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745780418; c=relaxed/simple; bh=IcZsI7Oroz0kOLntXx2TPdJDuzwG+IXq5Cx1/e3EwgA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UKL3Wb3dmY3RoBHly+OefwpVWTh2QhDrI/FEVGemmoengH5p3gkNaSLADYtEwtUICj1wSNBAcsqe6uGiLZ2KaLM9fJvZNXtH75THYxI9AYPMxh2AXz5Gtxk4+Ci44IZKiiElNU15Gy3EwTGi5jDd5Utzoy+fFQp2phQyEkFQlNw= 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=cJ7LU+Os; arc=none smtp.client-ip=209.85.210.178 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="cJ7LU+Os" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-73972a54919so3292805b3a.3; Sun, 27 Apr 2025 12:00:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745780414; x=1746385214; 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=sjYvr+yA+zdWfNHFdWRXavur5ow2fufmvm69FNNW48U=; b=cJ7LU+Os2NjorFdoPl+/NkAUe/wEzTFZlmYLyB4tVNzMYz+IIMohyAOM8jJjPRgCEZ SxLuliee2iM0zMUeHYbblJWwcjahMQ7woSRw0iEoUPhP+7GMbrs8GDATvAGEgUMCyRGJ rEKwi/Lf4kqu5wH3R3Cb4wcbbJYPjH49pX1FqXXYVml93ztL2dpXacTPMncec9NNOHhp fS1mWqD3AxTggXgYhGcPqOu/i5RUV64Xd8X/tD7hs2Xh0gvCAcR/5kRHe173ZReKR5TM 9No/L74VqHNVX8+3ucumnRDp/e13ztSV1bKKd40EdFJQlHIcwHEWTdjNF5rw5d9zhGcR +wvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745780414; x=1746385214; 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=sjYvr+yA+zdWfNHFdWRXavur5ow2fufmvm69FNNW48U=; b=DMSZGZIOD4CLsQ6tG6otUw7D3pKayNZXNadVmf8fNx8UNAEep1Bebx+t4C8DKwFP2o wBnmQPVxMExauAfsHvo8zQlNOuaEtjtgQzG3uGE0h8qBKY3G+KC0ynJdkc9k8dGNbOdj fSR3KNkbc3yvkiCvPpeWZ9nGoN3le0lnPXRGBSL7ltVuZZ8tJubVmMF3AUNm4jouHIyE Ud+1SF9im1zRpHzVe+5fPcaCoKtBvQq1B3I0YKFW3YzYysS5NDE2+XWLq4+E2tHMD0OQ wWkAMrmegKoS3hIIXS5j3+6lLsiSrCmqYvRLtPlsf369K3XpVkSHZJx3MeDjZSd/BL3U LRGA== X-Forwarded-Encrypted: i=1; AJvYcCWi2kNW+KHirxGZotUZ0lTznAfozh6OUoj3226sOu8w3kujHiztj2KgCmdJD5VXUa0B2F1RiEJ5+Ola2g==@vger.kernel.org, AJvYcCWqCscYfmjsu7DNbOiEA9mQulkF25skOYMv7E4CmxV043pt7UG/yO1rtljl4DRrSzxS09MELasCFpH/b2n7@vger.kernel.org X-Gm-Message-State: AOJu0YzrlkZt1VQsUlojrfzKBLjTW8Sw3n4+PfS4Yos5byrklE6L+Fwq ovJ/pA9cZ4tkyh0/04Zx0l30RadPhsKHX7YSPeYwuNesFgENw4en X-Gm-Gg: ASbGncuAjZwHn+pKyC3KERhR+W3QBwBCaauLeDrYzuxreKymKIvCahJkcRmNkEpxrRc Puv+CM8Sf2fBUoI3v+yfRkhXT54yDuXtaFkkaVgwAAtbp4sh1s1KKth0R13yiKO83zYSLFLqs0A XePh5Atl36j+kVT0F0oy1lmCG+DUZNRaXG+ncX1jrnXvpuPajmy/mTsJ5okQwGDf50ZKNm8USEq +UJKArYRcVvaE6hxy6uwOFMMwoNNGGqYqQZqx2f7LYraf+trXM/bazrhcfEwM8lyrTPJt5mta2x EUVdvKBcI2GLJjFb5RUIc2dH0SmjHH/4WFQmgebBq/KFCE8hMviRizRWyDK2MEkFAa8EL2Cc X-Google-Smtp-Source: AGHT+IGqp/hwdsuDHXNECCCGo0RS9+jH9xdWghKghtAN8mLfYvPhaOhox/tezpC0KBjUwj380xdEDw== X-Received: by 2002:a05:6a20:d817:b0:1f5:839e:ecdd with SMTP id adf61e73a8af0-2045b6960e9mr12016852637.9.1745780413622; Sun, 27 Apr 2025 12:00:13 -0700 (PDT) Received: from KASONG-MC4.tencent.com ([115.171.40.102]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-b15faded554sm5862153a12.72.2025.04.27.12.00.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 27 Apr 2025 12:00:12 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , David Hildenbrand , Hugh Dickins , Chris Li , 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 Subject: [PATCH 2/6] btrfs: drop usage of folio_index Date: Mon, 28 Apr 2025 02:59:04 +0800 Message-ID: <20250427185908.90450-3-ryncsn@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250427185908.90450-1-ryncsn@gmail.com> References: <20250427185908.90450-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` and that is not supported for btrfs. So just drop it and use folio->index instead. 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) Signed-off-by: Kairui Song Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Qu Wenruo --- 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 Fri Dec 19 04:00:45 2025 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 858F18BE7 for ; Sun, 27 Apr 2025 19:00:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745780420; cv=none; b=A/QC4+jSKeyNryJUznMjTamTUL8CZEmEIuUi6YjywLj0cypcOY3B7mcoLbPm+ubhhgsSpD+DfdpmrT8F1KiemodX70WSaOCbiKbT/9alp7rWtqU26+SRsPW0vAqrr9+eJBRXk6LrYYRirFVwFUxgx6TAIEdBOZLlbOzgSoyeql8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745780420; c=relaxed/simple; bh=wM68GCXbiSerHyiJjiF8qiDn6ozAYSo+GCvSaYYs5yM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bdwdbclsyPZE6icd8Cmjz+il0SbUCiXhQfmT1V4v/SDZt9rtqdlOYczuo5B1Wkzv2g8VW34vfDL7T13gi7ud/Mk/9VwpqwmWXVeINCqf+CZH+K66SYFO/P11IEFzeVeoD1FseDlwBIhpFh7e1kf68FOwh5NwXy4d+/HyHwDNqws= 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=b6R6x2TO; arc=none smtp.client-ip=209.85.214.174 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="b6R6x2TO" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-224100e9a5cso47271285ad.2 for ; Sun, 27 Apr 2025 12:00:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745780418; x=1746385218; 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=kiHWomkf3wcsR+tvD4RLDrQZNUBMxVnHVwy9itXWJo8=; b=b6R6x2TOsC/XjdHalNJmC/IDLJbtwvbNOleFrCmpwRlKaTauJVFllD0mIfWkvKGLwi 2sJIIb7HlV088hVsJPFTbWfCbrB9u7ajgZdNk+udE1SDZlq2DeEf/MU/TtwO8qUBH4Md svE3X61i5lwlCg7B+ordVHxDUjzl6nWQFcQa48RetFRMngRMtBecMKJi0aotNhEU+Fh3 6m6O7vZHmV8z/2E6PEt4nR9x6XtCNIL9Soh06FbEFhCsWzlpFsq+/N9cws+yDuFS31wi SpBT6AvKZ84S1BCLIw1aEAAucH42etqYxgDASKp5jgeD/vK/fTtd5zUwru7EqtjIn25i bqsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745780418; x=1746385218; 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=kiHWomkf3wcsR+tvD4RLDrQZNUBMxVnHVwy9itXWJo8=; b=aO/RV6XeZD50JPfekUArexX8IIIU08ptsetXiZ7z6p7EhxEG0iU6gTbfZ1gUeCY+es F+qeQK1Aj/ZitcVXkbJH6g//W+kIQ5ONxLv074TVjvP9vMzb7MqSjf2RvfZRHibLuNij 9142Pg+IG78dsrfcsaCvibl/iSfrJ0riBzhtc/IbnYyZFYBp3p7QtSMyHgTJjKhEJwts g8x5PQt13AHKMJM4NzdMG+7aU7we3RbjbDQMLdvHexKep1YL89H/rszvmxaB1mT/MJsk +JvJw/5hi3U1DLtn24fJjAIpIlK1q0AmsmbaNHot3PoLwkCXasa3K1Oiv5KeRj6QZ9IH 6mDQ== X-Forwarded-Encrypted: i=1; AJvYcCUfXTm3L9C41uyyTMbqvUWtCTrnzb45X+L1d3XDYIhnmjF5GF+NuKtsIo2OTw/stoapImOWkGpwa4o3DPg=@vger.kernel.org X-Gm-Message-State: AOJu0Yw64HzeyUN4KuKIrSbFwRRtHHsNm1BXyiaO1hAarzyXBcjD9VeR s/G8/VTk4s14I/3ea6fuNwagOVRcuJ/z33DcfsLI8jOwLOWURsGX X-Gm-Gg: ASbGncsqQ/mp3wjkowAAqboriPJ1mnZvcLB1e0IeFiLT7Fd8dizdnsJS4XVIdxhZb9+ 8y8A8/tfMgqpQEQdN6Qzbmnl+FxZVeebgVux9J4rCQpGcW6hNvMcID6BKHh6SEyB0mJ3p2XBs3x bEXjRYpaZmO+DKKFSFeQfoF6Vfkc3U7zxR5oFTj+KfViC93QXjOcBOmMtEgRDuMsVRkMY6IPoB2 ka+2IwgmGi1n/AeYdEdDDZdAkwYWzzcRVtCs+Ri/m3tio9weSx95aOyw9XiikomZSz20Omkh1Ib hJLMajEay6db09K43amkmjb5FxntWkxtzYMjr/seSUi/e2r/kBSb+tS2fVS2vg== X-Google-Smtp-Source: AGHT+IFUylfVVyaQkdTj7G9SXw4aWzBB2+YYrPKPSQjJoZLloI+KVj4P63eCYK2iieWNVOo68Fjdwg== X-Received: by 2002:a17:902:e18c:b0:22d:c605:a30c with SMTP id d9443c01a7336-22dc605a33bmr81867745ad.11.1745780417680; Sun, 27 Apr 2025 12:00:17 -0700 (PDT) Received: from KASONG-MC4.tencent.com ([115.171.40.102]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-b15faded554sm5862153a12.72.2025.04.27.12.00.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 27 Apr 2025 12:00:17 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , David Hildenbrand , Hugh Dickins , Chris Li , 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 3/6] f2fs: drop usage of folio_index Date: Mon, 28 Apr 2025 02:59:05 +0800 Message-ID: <20250427185908.90450-4-ryncsn@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250427185908.90450-1-ryncsn@gmail.com> References: <20250427185908.90450-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` and that is not supported for f2fs. So just drop it and use folio->index instead. 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) Signed-off-by: Kairui Song Reviewed-by: Matthew Wilcox (Oracle) --- 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 Fri Dec 19 04:00:45 2025 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 0DD8D1FDE33 for ; Sun, 27 Apr 2025 19:00:21 +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=1745780423; cv=none; b=pnSHaN7uw/paE6ePr6vSVmDRdE4UH0WZU+y0V+YybbmB/D8BKjwx8j9PWJofoh6b9poAIl+G4zhNZLB7YwYtFaVoeE+X7uo5XCBcuxMypQ49r5GLdeIol1aYP1B+xJBNtaJw1MA0r0gT8jKD4qF6U/Q5HOKzHbUOog9egMqdZnE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745780423; c=relaxed/simple; bh=YAPaKQufsSkymYOV0BNJBbozknIm7Gc106mHlRJF3Ug=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jObr3y4n7VhVooSgOfVdnOX6YuSKdQ2WCiuqSDYprqnkfvYM3yuMAnRrXZ3hvAPiudl6vdTLyhzNYfDhn5jxpf1lrub1yEwPtRVpgPK6Ahxdn5uHxhEoio8UO8KHIDK88AKkSv4xxDY89zds36dc91LOrPEIF52gfArJrRpYLIc= 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=NLNMrh8/; 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="NLNMrh8/" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-73bf1cef6ceso3950670b3a.0 for ; Sun, 27 Apr 2025 12:00:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745780421; x=1746385221; 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=mCqwAYZCSc0dh66qfmmYusnvvBLoAOnre8x5oj+2T0I=; b=NLNMrh8/etIHeVMpFTUNOcZ2j0K5Z3FG56zzDZnANZhNXtHnGo9HJ5mEGUT0h/H7pl 1X7r3PgLAN/OGJozZQVqJhYKwr1JDvItJX2O4/m4jFG/1+aMYeE/pSxtpBq3yKeNpD/x M/HxZzlRXRnbm9IhZ81KTEqSaVl/UDlzvfS52NAt3UdA3DB8emI66mhR4Druhupsi9kX UYJCxn5s8NzmPXecXXUbXh5NPZWHIcg5pjFFkdWrBMr3rRnXy7LXZBP1Cit479mbxpSR HCE5WGP1mRJqQyr7pTYrJcKmHrz3q4hRBertFL0cNEunxmztfzX8FBybtSIxMdJwpbhx YG2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745780421; x=1746385221; 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=mCqwAYZCSc0dh66qfmmYusnvvBLoAOnre8x5oj+2T0I=; b=H9WiQ8PYd8TRhYzgzmB/Bw82euiK7cHOZM5S7uvYuj2Hys8q+A4ZXX5kBkmOaCRSId MNArjvqi1DRlhYaMPFi7l3LmvE8ZfgocfwTkqEsbH7VXiP1sViyvogmxM5hZDYDORN9m ahOG6bc/Nc7Rb4aHaMwGDOBMrKHzdThfXkeXXPwo0caXcCZtsBXOA3vDEJTPKUyHTa6F MUry5W6ua87EwfUDf0O1MPSTgAjpbDD7eo18a/bRjeQebsQOH+OzUTu6eT0LYaFbpaG9 kSbtxBBnTCDWDzdb7cHmuWtdCgmIXF7JFUF6TUqbAbOiIXczlsmLD7+GxhfMgoXfWU93 E/3w== X-Forwarded-Encrypted: i=1; AJvYcCXfHHbqyETmcOZOqcLZAY7hnIBDGQ4YCtd5hUh1Cc440M0lPWQ9W49J95E6svOnj/DOCxIDKq3co1KO3eM=@vger.kernel.org X-Gm-Message-State: AOJu0Yz1pkxJzXdGndiOiJGiZ3W+ulUWIqZ9g2CCjEQha14HFLgUvs6P ilTRLQq0UjKCxpZMlphJjGlKQACsXbs6AUDoy/lBMcjYE3p93Cja X-Gm-Gg: ASbGncsNsKQDISkNFB7Iotllp/OE30AC5ZzVpL5JeSiox2V1IFHouBkqoMZ7AuenQRR 7XVicJxreyYWV63KQpxjz3xOLQFZOJ1HZh6DwIUPOddGOAMT5pAGgwBHfNLH7MppcFxjD+0KCSa Jlp+fiDK/mu/7/ahVP/kqctP3A/Ye69337YR/uoEFhZV/533k7DNUBNpxrJkzLHnJyeU5syFLJy K1AjPeKij+weHlTgZRACW6LfSUTusRB9QEAd+R8oY8mtpjHxEuFUV1EILb+Y0BEKso/5Rlf4XE8 D2RsDN4Rx22jdYEpPTedEJczmyATEfU7ycKUUnR0Gxx22B9K4oLI+f1T8A+ABQ== X-Google-Smtp-Source: AGHT+IHnhP8OfwmNTbj23T0LsccS6Liv4VufDh0OTB4zjqyQzJVvlOs0vxIfu0mxzqpCysWHijiiWg== X-Received: by 2002:a05:6a21:9004:b0:1f5:535c:82dc with SMTP id adf61e73a8af0-2046a74a4d9mr7876792637.42.1745780421233; Sun, 27 Apr 2025 12:00:21 -0700 (PDT) Received: from KASONG-MC4.tencent.com ([115.171.40.102]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-b15faded554sm5862153a12.72.2025.04.27.12.00.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 27 Apr 2025 12:00:20 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , David Hildenbrand , Hugh Dickins , Chris Li , Yosry Ahmed , "Huang, Ying" , Nhat Pham , Johannes Weiner , linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH 4/6] filemap: do not use folio_contains for swap cache folios Date: Mon, 28 Apr 2025 02:59:06 +0800 Message-ID: <20250427185908.90450-5-ryncsn@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250427185908.90450-1-ryncsn@gmail.com> References: <20250427185908.90450-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 will 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 managemen= t. Shmem won't interact with these sanity checks either unless thing went wrong, it would directly trigger a BUG, because swap cache index are unrelated to shmem index, and would almost certainly mismatch (unless on collide). While some filemap helpers works for swap cache space, the swap cache is different from the page cache in many ways. So this 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 and remove the folio_index usage here. Signed-off-by: Kairui Song --- 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..a0bed4568c66 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 ensure folio->index is stable and it's + * not added 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_BUG_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 Fri Dec 19 04:00:45 2025 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (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 B119A202969 for ; Sun, 27 Apr 2025 19:00:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745780427; cv=none; b=XAngmS0aCH35L8zaRbWi4gDPWKGtMFsEsqHbbF+lCFYRmSpI5S6c724uPcE7YeTGP7ZZUjzlBPz3SMQTkkiSiPG7LXwGzdG1m7fjC6wx/bm49P+E6PkePSbSSjJ9ry2lFj9I43dw44+uNfDKGKvgXJYRYxPBEsPRVASuU+0+Jt0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745780427; c=relaxed/simple; bh=4nwoiXMW5Nhzqq1c47JZh0IYqvoVqtn+nAhCq+bVGLk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Km7DIhLyk3Y3OxUlNuViaXlHCID0RiLk0v9BXjgmwDTZMEOOu6xsN+Hhu62NxsRt7xg/KFGYVuq4wZwmqLqYgdv8WMqQynO5ptkEOYX/vIZxfp2vJcjbZy2J8X9/eHvwy7f2sj328Inxg4++0fYZpFNR5GBO+RLWOoeyOP4dLNI= 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=BkvthYyZ; arc=none smtp.client-ip=209.85.210.169 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="BkvthYyZ" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-736c277331eso4751502b3a.1 for ; Sun, 27 Apr 2025 12:00:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745780425; x=1746385225; 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=IDmeL4hx/iVNmF7D4U//Rj1ZUKsUj7xb6gC03dWplSo=; b=BkvthYyZ072AI+CtMlhEieWjsmrWEILvu42M9EIPFDyro3t6NxxDj/sMgdFPQaE5m1 9l0A5nXPOGNaMrNF8yDkQzb7XBuaMpc2RreJPBEnHrvSdtw/eaUjbAK9a3k7bxz1xMq4 pHBdGE7stqQ7dU0HYQZ8cd5mwS6be2lz60/gqrdmVoIqpDeqgYLmqkgcuO21pXE2J5Cg mfo2y1CHbJmF7cAPpxigB8c6GyTJrzzvRp8hsCTQHtPNZGne9Pugy4MJQq/Cik8Iugre 6rW3REN72Vs47DBGYDGp1d+WzLAPLxeVAfWGHTp9UOzRtNllVGFJ9bG2mrHb+L8FOPpD cvpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745780425; x=1746385225; 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=IDmeL4hx/iVNmF7D4U//Rj1ZUKsUj7xb6gC03dWplSo=; b=CM/itR+U+7VQagmz736aaBwEiHOglVlNoyuGngG1HxMI7ou0fYIUzX2QIm+qzD3nSC QABMTsQBrTIvO7OgTcbd4GQDqLAaJTBPsJqaJqDjrcAC/P53kXIcFnaYG5aW38+/Se2G b6yXxpYnZUmAcfWYqGWeJk3VFcI8ualbKOgPVIE0HFqwM0aKwwWBz6FIHIk0QhfMyXMf Xl6FxL/wNXceMGu/xIQCzr+tlMghhB5TnPdYbFqDDi7EgB3R20pPUT6m6ozReMlJOU1r wD54zB9vWa864Mf5D2lE6kYTvwma5UPasCok7AeLi96JvtFT8mh6yX+iPlVlFR+WXx9j Dgaw== X-Forwarded-Encrypted: i=1; AJvYcCXN42WD9klPFM0kr2OrRzQIEfdsmccC6s5nFyCvA1c+T9V+30pGXaGkeRtcSn4FNItvD/Kduy+zfgjoH+o=@vger.kernel.org X-Gm-Message-State: AOJu0Yyfxaps8z+ZWtZCK+2AfPT0o6aFvJktAUpst+XGuzFEpwl9stpN 2h0nAaUZ50CWhCsuJZPL3WAhh9O4Tv8Hj1tjqmlONtG/naYJD0Mr X-Gm-Gg: ASbGnctkoawZVsBRy+KGeTmULCyFTRi756fdb0mTwa+lxUvbPQ1iTPHgRqeCuVFS5bY MRRtJa00MQILXA30xYaOTCe87P/LJJalEYXZu3VGnSwMZqfcuJ/K4ff3gniUMBK5sFqpmHW2tI3 Al5lIIlsEEkw6epw14TJdickvWjSeTEHaRqoGT90q6zME9G8xuvIR9B+tFKKr6md/rkYstm4FSY QL5CtnfLCONSDNty+OknouLNcnSKM6YYd95tI6a4CzVh4xpWUhd0rHw/4Ljo6Zr8z9VfiIquEmU bWKMNXKnUw2Llhqa8Ix2mTNqAveWCO/pqgKED6iA+3pHqtPk4MygAGrcZ3AZUA== X-Google-Smtp-Source: AGHT+IFmqHyI30cpvwrLTTi9PNKbANg/76Q7YdrGeP4dTjEc5/oTjQAc7FEio1Ywcx1BN3zSAl8SqA== X-Received: by 2002:a05:6a21:6d84:b0:1f0:e6db:b382 with SMTP id adf61e73a8af0-20445d6f33amr19304516637.8.1745780424787; Sun, 27 Apr 2025 12:00:24 -0700 (PDT) Received: from KASONG-MC4.tencent.com ([115.171.40.102]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-b15faded554sm5862153a12.72.2025.04.27.12.00.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 27 Apr 2025 12:00:24 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , David Hildenbrand , Hugh Dickins , Chris Li , Yosry Ahmed , "Huang, Ying" , Nhat Pham , Johannes Weiner , linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH 5/6] mm: move folio_index to mm/swap.h and remove no longer needed helper Date: Mon, 28 Apr 2025 02:59:07 +0800 Message-ID: <20250427185908.90450-6-ryncsn@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250427185908.90450-1-ryncsn@gmail.com> References: <20250427185908.90450-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 --- include/linux/pagemap.h | 20 -------------------- mm/memfd.c | 1 + mm/migrate.c | 1 + mm/swap.h | 18 ++++++++++++++++++ mm/swapfile.c | 6 ------ 5 files changed, 20 insertions(+), 26 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index a0bed4568c66..f61fdb8e165d 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/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/swap.h b/mm/swap.h index 6f4a3f927edb..2f18d21c17fb 100644 --- a/mm/swap.h +++ b/mm/swap.h @@ -50,6 +50,24 @@ static inline pgoff_t swap_cache_index(swp_entry_t entry) return swp_offset(entry) & SWAP_ADDRESS_SPACE_MASK; } =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 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 swap_cache_index(folio->swap); + return folio->index; +} + void show_swap_cache_info(void); void *get_shadow_from_swap_cache(swp_entry_t entry); int add_to_swap_cache(struct folio *folio, swp_entry_t entry, diff --git a/mm/swapfile.c b/mm/swapfile.c index e727021b8e2c..bf6c98009909 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -3662,12 +3662,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 Fri Dec 19 04:00:45 2025 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 15C411DED7C for ; Sun, 27 Apr 2025 19:00:28 +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=1745780430; cv=none; b=d2ispNYZAgfjRpG+9KXqYhFRCKZqnOktUXkfqucv7LV10MS0dn9gxYg3L6hzhanUIV8rVrV9x6Z9cwNu4iAjzs3RySaHBUlHbsLzvwpJE/NXwTA0PjAr7IuVlR39YOGqmL8Tnw7JubwUlqC2YT0VFxSmaoBbvBTQ4jLeewA56QA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745780430; c=relaxed/simple; bh=6tQrn9+xTH3Ch7ph4D4tcGbekDLbNeUvvmLN+sNTBZA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H+m7o9ZF/jiGIg34O66lzjl8lHBb31o2YStg1pEgnZVxsVFHDi5falqnoZbz+7JcfnmF5ZOl8OLsQBnzpbey5gSJG/aJ/aZtyBfPrjR02QfTlWkyWCmgXfxtAtelqWaEwyy+mBpj75mEelcrNx5XwLd26z31iNre1v7AnJ/oN28= 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=NWeIh340; 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="NWeIh340" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-736a7e126c7so3716932b3a.3 for ; Sun, 27 Apr 2025 12:00:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745780428; x=1746385228; 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=f4lipydBuOubJubR5kmo9nNBPLmCY7qckq6Qt0Bh+qw=; b=NWeIh340zRY5E01So6fXRCaAamZ5u9BtILmD1ih+8PpNNji2OJ/4NCX6jK/iqDa60G xMLKFZwuFjyKyXujPXuupWmRYfGlR/7ugBDvGw+Wykp4HIILDX2bRLmCg041JeRbliEe uAa4/CyA+/OUPOscLH9FDsWnKuNuisVAQ6G7qksIElCxIR9TZJv9WBIVSvpBxn6L8Ut4 LXZPZpbATsyPn6657Dk0QpD+/IQDRCGZj2Wp9APprfbzRF6XJJ2FeKkaG1M7wBd0hHAZ rKh6Np5b6AjZMsM78OnNI8VFtTgyRyE7p82xNCWBTen41S7xtWcJLgsOEpGoxtIzoKsM DNXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745780428; x=1746385228; 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=f4lipydBuOubJubR5kmo9nNBPLmCY7qckq6Qt0Bh+qw=; b=a9XUkrgz5vyM6ME05s23TJRuXPltJc1g2mbw3oCHxv1xUqL47VcebwnFS4JCSzZ5kn TU3r2JeVpyVnmxBmUkNVs18CzOSzsYVc5Wq+faZGdkD/xYKHGipMqvBGa/8elO+OKP0V oS5JRKRkY9Aafn5LzYIs8DrlfzMYRMJJfZXQ8f6zY/4q/sjKUzI26DRD55w3Fhv+VX6z nQ2YHfDLP/AhmxoU+g97Xymhrior1ySZc5kWTW+2Jm8CaZjAbJyAX/wVjo8anP1Giz8d kMnd5JrRR46G1pbKv1jTzuZ6pmLiUVkAHFlOOdV6e/PYX29XXBxWc8t6RVByHx1xExRy xnWg== X-Forwarded-Encrypted: i=1; AJvYcCVEMEY07Zyoa7qSUwQYnVywdW+GO/RZ7VLA1GNF6KFA7QskPezBMpYNXL7W7I8pyXWawWH132CWfhpgkfM=@vger.kernel.org X-Gm-Message-State: AOJu0Yylr+rmgD5FF9uDFTcc154W6oSuXIVEQWMc7FfApN3Eye4b/oHC r+DKAqII6qTrxdHRmoF82i4vNMGvtWuItBqSZugRUuMT5MIskhx2R3aGgjRKoz8= X-Gm-Gg: ASbGncuf2bZpM4zEH757/ZMvP77uiP77Lumi8LoTUHriIEXjhqfNQjTRY2K5kbp7eDd 4KiRYdVquMC2CNBl1M6J0+yjt5MBOxODg79oODYKxLMAM8ejzxwOfJ8AbWyVe55zgpDi3AiRdWz zKSffpce4YOjzSaiUlULq7crVaXIaaHh12pNG+iEh3My3wBK+tZOBR7HQ/8ioDyDLeTpmjcQhK4 Li3fCRJum/q0OomLws7TW7GfWljIAKIVuzV2HVpKv7AVLJaNTuX9+OeLpAnqBgOFAkMKecbXjPI mKbRo/sDEceRD9OQBofIstbRYQSu7Ei+QKlX2fZz6TfUpm/EQyw3USh66/KrHIXOPfF0qV9n X-Google-Smtp-Source: AGHT+IEojAV7wyacxqGiE1y25FLFORF046WjhVqXTWNSq4957oQpkciYstlz2WCGKQpwjcRVUqRcnw== X-Received: by 2002:a05:6a20:9d93:b0:1f5:8221:d68c with SMTP id adf61e73a8af0-2046a3eef47mr7803932637.3.1745780428327; Sun, 27 Apr 2025 12:00:28 -0700 (PDT) Received: from KASONG-MC4.tencent.com ([115.171.40.102]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-b15faded554sm5862153a12.72.2025.04.27.12.00.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 27 Apr 2025 12:00:27 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , David Hildenbrand , Hugh Dickins , Chris Li , Yosry Ahmed , "Huang, Ying" , Nhat Pham , Johannes Weiner , linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH 6/6] mm, swap: remove no longer used swap mapping helper Date: Mon, 28 Apr 2025 02:59:08 +0800 Message-ID: <20250427185908.90450-7-ryncsn@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250427185908.90450-1-ryncsn@gmail.com> References: <20250427185908.90450-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, so remove it. Signed-off-by: Kairui Song Reviewed-by: Matthew Wilcox (Oracle) --- 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 f61fdb8e165d..b27e369d8bd7 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 bf6c98009909..1a36e1f4f198 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -3653,15 +3653,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