From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5433CC4345F for ; Wed, 24 Apr 2024 04:06:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C85396B01F9; Wed, 24 Apr 2024 00:06:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C330E6B01FA; Wed, 24 Apr 2024 00:06:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B23A56B01FB; Wed, 24 Apr 2024 00:06:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 9556C6B01F9 for ; Wed, 24 Apr 2024 00:06:09 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3D3311603FF for ; Wed, 24 Apr 2024 04:06:09 +0000 (UTC) X-FDA: 82043087658.11.8630DFF Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf13.hostedemail.com (Postfix) with ESMTP id 3A3FC2001B for ; Wed, 24 Apr 2024 04:06:05 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=h4Fe0VR3; dmarc=none; spf=none (imf13.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713931567; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EuETJtGZxu1owesI989Ljeb319SuE+6AMj187CcAyGU=; b=cTWup8Wn7kDapWvSkcpewn/DU/Qj7GCP+cetA/AcI1JUucEOg1zjS4tylwoin+JJxhD4r6 lD+arlkepdbjDoaf1bF6M2LMq6dhJqvrFjOnurMCXoTvs2zl0mUvQA10StSh8vdiTkxClj Y94T5CaQCVf83A82zwhP7o7PZXs4Edg= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=h4Fe0VR3; dmarc=none; spf=none (imf13.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713931567; a=rsa-sha256; cv=none; b=5RmFdhziqIRUL/p9oGV6qwgXNAR30by5IIUidcOWNukw0RXWMZ4985TwrI86/hrJn1QA9U phbSZ6UK/doo4RmTCWyRSu8N4JUpHtAqI+HSj8ReASZcbxqbVmUQ7FivOll92fXntwkI0W 6tkI0dfCgx4Pp/lxDzxasI9G9dTH0zM= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=EuETJtGZxu1owesI989Ljeb319SuE+6AMj187CcAyGU=; b=h4Fe0VR3cSeC3HLANTcVKxyO/i B06vSJffXjewy57PoJgnUcyyBRkwUMt8vwuZzwXPAPX/udjrDvsPCNFQzhONrXdtyLHXfbOJ3B19K G4cRQtmYMqTvPrqT5/VHDUveVUmupBCQy1DVO5WfA8wGGpm8/ic5HV0FkHTTDKg3mdgmo9HuGlteL dcOe9STGScruYnrnJTVB/SzBLNbp4V+Ao8QGX2RO3DBO9G8mERgnhc1SvA84Cy+T4EM6m+089hhc3 ZvygtNcQZxBN46XczDC7C/g2Bhq+rZtbyN6BQWKKWNsoskDTrqwacWtSXRrdNeiFV+92BjMO6/pnQ x1RO0NIA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzTtG-00000000894-0JOS; Wed, 24 Apr 2024 04:05:50 +0000 Date: Wed, 24 Apr 2024 05:05:49 +0100 From: Matthew Wilcox To: "Huang, Ying" Cc: Kairui Song , linux-mm@kvack.org, Kairui Song , Andrew Morton , 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, linux-nfs@vger.kernel.org, Trond Myklebust , Anna Schumaker , linux-afs@lists.infradead.org, David Howells , Marc Dionne Subject: Re: [PATCH v2 7/8] mm: drop page_index/page_file_offset and convert swap helpers to use folio Message-ID: References: <20240423170339.54131-1-ryncsn@gmail.com> <20240423170339.54131-8-ryncsn@gmail.com> <87sezbsdwf.fsf@yhuang6-desk2.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87sezbsdwf.fsf@yhuang6-desk2.ccr.corp.intel.com> X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 3A3FC2001B X-Stat-Signature: ek9wf49xqg91szdh8unrihhhxxo7ad44 X-HE-Tag: 1713931565-209009 X-HE-Meta: U2FsdGVkX190AQlCfyd5MO2PRx6BMMajIJZLhcgi7OS6WMl8VVWSQ8TWk52GjlxpO0PueUyNWp/shvCtMV7n+LMq3u/fmul3UYxFWd/ZicYPovv3JOKj3f9qAiGrpzKFxwiR0nFREB7Iea3hWmSu1ZfH2NXjtoexkgFsOgeWvzgfjCZbdaRz/bGVI/VeNls97xbn9UQJGGx6/KDEUOhLtdA1IJrdrVDb4/1bPdBovN9NAVvqCMjdbCLoDWzEeyzIbqExT+tUzHrrZNxzvsBMCdYLl7guMkh9hFwPU6LADCAndzbWUrHytbLUHYS5fFG7Om391RyymL4wXc3tt8n5asrB58Bvm9PWNkwwjxszIWCjxZbK+JAy3jFpBGqQQ8YlrSD9PEoDdLBoGJOq1j6Mw8hWsVQRKMWhrh4BpKBLhB05/M1mxRRSNe+688QPMskCHWiZFJHN6Oxs4kNu7uZxOuvHUAMo/e9Of/6W0MGgBcheSaG3SfrEyj1+TV4NRzu+AEg2PkOUKOxkeXYY6UnAD/LoeYkyewJdtx897tHOyNzR9kbgNnYf0zVFomtBItihefzffZ4XNQBCmLiEUF2wsFQyDnQ/CcwlvbOXlFpVD3Cw5kIZr4laFSjEIps/u8XUyjetWxYmywetutBoYZ60f3KivVMj/exnwWgBeBDKP2Z8iV+dPKsV3aFFcNHJx/3TlD53SBniK6RkcLUkPdKOvvoaX25BgpWlHIinv9s62AAYAe++XpI5EKqnoQC6VNgdBafnnNju1IZDno42bSUyOEYL/DK5WzLNyCf/cTTOz9RsZ1WuhxG7BGKbJQ5H30rE5AHHf2czQvK7EyfWmYVPtUr5X62yPjDyC3J3uZaYaIWksSvKa7Glj2EeUa7pQV5iJJ4z2QeJqmEe7ksh1iX9n7rM8NP+9xnWoiPTeVoENbrOeO3O4W11BmPEwvWy/jBReOslNeubs3AUfV4sYLw m3jwy/u9 WivsYJVhXJfW7hXAoyQ/W3ghlSR9RuL+/nvTdjulAiosN7Mhml2kRKPwR2vu90rbkiGtyRzCvigvlbhm7WRWL9cS6CHYdCuWvN8QKDwjekp2OV3MC1fS9/OEgGOxMiloMFBo90eJAz0BUA19aWBD54a1k7SDskrfPej7ASLrznY0zoaK07+TmD+eOI9QpS+0x9AYePF/f94L352A= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Apr 24, 2024 at 10:17:04AM +0800, Huang, Ying wrote: > Kairui Song writes: > > static inline loff_t folio_file_pos(struct folio *folio) > > { > > - return page_file_offset(&folio->page); > > + if (unlikely(folio_test_swapcache(folio))) > > + return __folio_swap_dev_pos(folio); > > + return ((loff_t)folio->index << PAGE_SHIFT); > > This still looks confusing for me. The function returns the byte > position of the folio in its file. But we returns the swap device > position of the folio. > > Tried to search folio_file_pos() usage. The 2 usage in page_io.c is > swap specific, we can use swap_dev_pos() directly. > > There are also other file system users (NFS and AFS) of > folio_file_pos(), I don't know why they need to work with swap > cache. Cced file system maintainers for help. Time for a history lesson! In d56b4ddf7781 (2012) we introduced page_file_index() and page_file_mapping() to support swap-over-NFS. Writes to the swapfile went through ->direct_IO but reads went through ->readpage. So NFS was changed to remove direct references to page->mapping and page->index because those aren't right for anon pages (or shmem pages being swapped out). In e1209d3a7a67 (2022), we stopped using ->readpage in favour of using ->swap_rw. Now we don't need to use page_file_*(); we get the swap_file and ki_pos directly in the swap_iocb. But there are still relics in NFS that nobody has dared rip out. And there are all the copy-and-pasted filesystems that use page_file_* because they don't know any better. We should delete page_file_*() and folio_file_*(). They shouldn't be needed any more.