Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp267498lqd; Wed, 24 Apr 2024 01:22:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXWrX6mBMM/d1GVTTBs7VFUQ6nP9jmTqE2VOjkZimx08KdbbmYUpZxZvnJTOMHD2j//w4WrrMttia4fuKnQpFjgZseooX00iMFgDWiqeA== X-Google-Smtp-Source: AGHT+IGDF2WXeKYg022YOUyLWQ/GbB4p4bHRkLzQeB9UegzWNLFG+N7A15SuT0KykKBZQtyXq51n X-Received: by 2002:a05:6a20:c21d:b0:1a7:bb6d:6589 with SMTP id bt29-20020a056a20c21d00b001a7bb6d6589mr1463476pzb.29.1713946939667; Wed, 24 Apr 2024 01:22:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713946939; cv=pass; d=google.com; s=arc-20160816; b=UL+AKEoAkjqwx+vbg8SrjsyVgl6qY7V59EiaEQFdb87TP8W23Gbf9AQCQHceQ6OuOV WX9r8NmQVQNlVscibrvySOx7i70rgz16jtgyjZK6gLgQtQ6pxDOPAxYGBIfX3Zs/HtSF RXeaXBB3mYsioHi40rj32ahmZvx+LHC08/+0APhUWvQ3ZRJ4CbWIIpx3qsbFRRx79Fib d9rrxM+bizCVEuuB/ubG3t16cPJAYndEnGOXT5/wMUVV9w2NERAZ8q4jImA9f/hYIHS0 6WcTx1IBNCuXlA2UvWljPc9Baf8YZCFJgF6DtOaXl2CKBgZImUHh8qpX/zKOahq2ToVh BAuQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=EuETJtGZxu1owesI989Ljeb319SuE+6AMj187CcAyGU=; fh=f2rbTbKv14qRC5lgfmGPtJh7EnASW/olV72oJdtwh/U=; b=a2nUFc/R2G5kxwOSuerA2SUDQwcQqlwEGM2vfFeoV67TgumlCt9X+OWB+VlNTuTqsv aHZHspu3gXH/WSqNhW87gxUkjWHEyQ+4czHek3K/Hktulm0jTFfG0j+nDSgsPK1R1a8U 3OAmxpcGB8Ic63ibvrjUTVLoZ1yAjUF47Tk8/+OIWi5IXIKdZrkM8wEft5ufkypJ8+bm 4MBpSQQ9Mqc2VQ40/d6kPIFaBEC3OR4u6dNEGttpWvrY/wdyijho5amatsPGFUfHGG9A rp/Fbmu0cOvOGW12K4brAlZXLDEbIvruXXOdc8spcBi7SsxSLur6XyyBHfmE0P5+5j7V o9Gw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=h4Fe0VR3; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-156257-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156257-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id o5-20020a17090ac70500b002ab363e2fdesi12725492pjt.99.2024.04.24.01.22.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 01:22:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156257-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=h4Fe0VR3; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-156257-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156257-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5F8E2286A55 for ; Wed, 24 Apr 2024 04:07:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 10FEA1448C8; Wed, 24 Apr 2024 04:06:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="h4Fe0VR3" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 969C0142E9D; Wed, 24 Apr 2024 04:06:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713931576; cv=none; b=VFt+KCSS4rWeOGcnvLle41O+HK/Vt6AHdQLTe+p+pmNv9ikrKamhzBrMdmKEKEuvYBkZjq27uV03zxyKjoAYPlIOnAmMmVa8AujcWejmuwGjd2yw6K9+dymRfEmcS3SgLYuOZTbRTnpfdxjP2t7gpODfgj6cHrBFONdi4bDaaJI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713931576; c=relaxed/simple; bh=uQR45cFMjtlCHmxT79KIysG9mZOqnQ9+qd3qqsml7x0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fz7gEAe67xHxj3g9p0sWBG4FvKpajdh9xoDU0ugtEk8Vfh/7Ti/78sjbeuu55oqcb7feTVeZFOslpvTnY5PewoXamn11bbd2xbTpSfIy1ml78zZW1QcaHCIlPvGkOY0LBAv09SCrSFFTo9GdsuADQnjBEqd+ZUcKEHghlRoAQKc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=h4Fe0VR3; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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> 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.