Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp277443lqd; Wed, 24 Apr 2024 01:49:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW08r6LfcrjZaB16WZVDa00uaYrf7YRmn9C724cioK9q1ls5Kggi7QEnhtKGK8Gy0P16cWda97xLe7Pb1+4E+8DcRW0GL6LjQi/x+fbYQ== X-Google-Smtp-Source: AGHT+IFbgXpspBbMpUGI7YjPOErchDUwGhEpxqo1II7EGc6kjFR4Ty9H7vDyUe61Y1Frx68sbwlf X-Received: by 2002:a05:622a:d1:b0:43a:1414:b94a with SMTP id p17-20020a05622a00d100b0043a1414b94amr2746985qtw.5.1713948552159; Wed, 24 Apr 2024 01:49:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713948552; cv=pass; d=google.com; s=arc-20160816; b=DQwM7ztV6ebbbrnh5P2us+hm7sa3ip0iLOX1mv1sbdEvGIC7LCL1utaSCMA5GBHftd 1Qq7nKij/b2nZWzp9sbE3BYFYEtbr89V/ME0VzImHwrimwY++l/6fQTA5pMOuDpgqJ7Y +kNB82LNubsavDKxoMtMGEm1R+AFyro256zEHlFmMFUMRZPT+jLNxXfyj9X+wvNb+Xlw qtdtgWvcpj2reHkf7bX8K3MpYsTv8tZgmZsdXJD3NTpb9BjqHJl8fK5SJGbJskE6yr4Z EIhYVtzRPk3t/S1+tliKP8rIg3fKMaH3dtNFW1c14XGfC5LLEw/0O0rxvx6t0Bft1S0Q JopQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=/kFQR8E+rQp7uC9yW6Ow4kuJJBmzBQxe59gx0jzroTg=; fh=U/3Hm0gOXDADmM8adc39NHh4lyMyZ1JiQCEkatPSLb4=; b=xB4eSvOiMGRhP3iYUhg3vIg+Vijlhr+TI91vCwsLTQGepNhs+ejG/LkZearBfOC7+R 2tM5QEIhZ7eahCtNM/VKLInfa6xbyGI3MBjuAcqIa1Yh7w0s01+Ej3K5t849Wujw1MKp VgmgHBQNfmmDuvyz2p2qUyJfQ/1nWFipI31TXFEbkedx11ssW48q1+EgcTkpW/ygwqmh FCMcSqCdIYfJxzWeCJbZNBDG2XyWi+fNnfmYYxFF1uiaNaZSls7zrcrX8t8arpF4TOhZ rSpsgVCd/T8P3DL0Nz984wuS920kFdLHaX9rh8xOQrHK/e3Hk1O7fD2198UH21/jpQ0j eRPg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=J2NwAL2I; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-nfs+bounces-2980-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-nfs+bounces-2980-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ey23-20020a05622a4c1700b00439bb06779csi7058653qtb.331.2024.04.24.01.49.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 01:49:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-2980-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=J2NwAL2I; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-nfs+bounces-2980-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-nfs+bounces-2980-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 924381C22747 for ; Wed, 24 Apr 2024 08:49:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B8D40158872; Wed, 24 Apr 2024 08:49:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="J2NwAL2I" X-Original-To: linux-nfs@vger.kernel.org Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.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 27DE3D29E; Wed, 24 Apr 2024 08:49:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713948546; cv=none; b=eg9oNKez8vw5UKjMxhmDL1efWhMox1hNlRcOu/m2NZCHm7PHX8tDwnqr0LyRGL4DB1aJkw6uv+XbMWgFb/MIdWAZQ0WF88PQ0NOCZrxexenV/MJBYp4rAOTV9El6yXl0nFkNJrSkPGFKt2VU58il4s5JAFzgGuyGuoNWTxxYvoI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713948546; c=relaxed/simple; bh=Xm6NxcEd3ZnINqVPRreRGDQC7HahRju6fclnxD6CacM=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=hjoBwVNNH2qujTnA+4Kc86f70rgcbFSgqm4PtGKkxQLnEwuENAcPXsXnUYaCS5GyasyapCRNATURy3QjNLYp2NODQNrkx9qt7F6Ymo5f4b+EZWqkoPBgr4crDiUqT9KER9gKgJaqnidFwxmEEYpoRemIQTJ5BmTrchVu0+84ROY= 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=J2NwAL2I; arc=none smtp.client-ip=209.85.208.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 Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2db6f5977e1so86973121fa.2; Wed, 24 Apr 2024 01:49:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713948543; x=1714553343; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=/kFQR8E+rQp7uC9yW6Ow4kuJJBmzBQxe59gx0jzroTg=; b=J2NwAL2IXzafeNEeZfNuHkYmff6fq82dIPFvHh31C19LgwZhSCI1I65otlzlQMhGst uWNTwuN9osJ0lTyr9KpwrUltg510uX7Q4AjORJUCCOfQmUIanBLiWVAijQuHv4KsFZBv VsnSB1ocGPwyOuEo+7TwCFM25y4d9JWM+J7JPbB3TFIkjzU5w+OKNH74lAC+3wIcYU9E 0NFsfMRZKUhjLfzAbQ9JRAGzrnQAVNlTvAhGR0cKYmn0iUZpMkTEp1sdDgVVpcOeQ0IS J/hjevR3Y2nu6a+zVqeno72OjEEVjT37RCQvH0RjEGmsmvW5vcejepJf0Vgl6jQAI06M +oqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713948543; x=1714553343; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/kFQR8E+rQp7uC9yW6Ow4kuJJBmzBQxe59gx0jzroTg=; b=kh9GM9Bd6Lj5FygFbl4/7nmP6v/sYrUZIty0N0ACgJdO5QdKQup8S10duj/xwwJ9fB /j37u3xHdX+SWDR9qY6KAKYdFXCQHzH2R47A3c6XTmxdTWQ9mCMkf6Ren0mK6EDiH/oC r2PUsaYqqWNVK6lZKfBxc9wMKvWW8U3e72UfhL0KnWgDeXUy+W/FgRUQqMGOONIqFA0L kXbZUL4DaMl9vbafr1Hj8k4jej2/85W2KXnndLs+BxWnlIhZ0XejodzJTTR26R2cRXuU M3yc0WH4/K78p23vRxc0/3e5VvJuclbTfNS85bLBaEE8C5YVEjLXv2LaGFMKQMlCJeF+ Jnmw== X-Forwarded-Encrypted: i=1; AJvYcCXpSAoFsx0M+D/5Gcv1E/NGT54GwqB4/joAxzf3CMbxpvMAxSTwK1Xs0+Z2DckS6ncu/m1KrB2JG52kPS9VM5iOiMO+JGMbq7dHzeCTBWnAeEJs7SP0etVTRylfsDU8u17WUQ6YKNOIxn67jRdNTCebxxCEf0g/LnLnuVFlr52pE/8I4O+N9g== X-Gm-Message-State: AOJu0YzyfLy8u/ZZCK5Tu1q6hZTDgqNN52lm3erj2h7ZCS+mIJ/O9FST OP/vTvUfdaClaT1sdpKuoIKvDahJ7BKlMNfq3qhnE+761GXHB7HZu8hcIgf9enbH/n9JfZWDihQ wf4meYSzkZ98iHY22GOVejSgZFv0= X-Received: by 2002:a05:651c:49d:b0:2d8:3d69:b066 with SMTP id s29-20020a05651c049d00b002d83d69b066mr978648ljc.7.1713948543126; Wed, 24 Apr 2024 01:49:03 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240423170339.54131-1-ryncsn@gmail.com> <20240423170339.54131-8-ryncsn@gmail.com> <87sezbsdwf.fsf@yhuang6-desk2.ccr.corp.intel.com> In-Reply-To: From: Kairui Song Date: Wed, 24 Apr 2024 16:48:46 +0800 Message-ID: Subject: Re: [PATCH v2 7/8] mm: drop page_index/page_file_offset and convert swap helpers to use folio To: Matthew Wilcox Cc: "Huang, Ying" , linux-mm@kvack.org, 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Apr 24, 2024 at 12:06=E2=80=AFPM Matthew Wilcox wrote: > > 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 wen= t > through ->direct_IO but reads went through ->readpage. So NFS was change= d > 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. Thanks for the explanation! I'll update the series, and just delete paeg_file_offset and folio_file_pos with more auditing, to make the code cleaner. Should I add a suggest-by for the removal?