Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp1204257lqb; Thu, 18 Apr 2024 03:20:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX0VMKLQHOxfYDU7oQV2KuqtN7hqH3GYLKHe+C4gWR14f/QxyvJbBDHP2EeyD3bxKni55NAey1xczjWA86A4nlkLF4twOBT53ZGH9fHHA== X-Google-Smtp-Source: AGHT+IGFfYdmIMGzkwTqCo8LzRQXqZzdcWC6k4nKFUYaO43Xs5HAUEjjPl5FGP0Luyu3FECAqM+T X-Received: by 2002:a05:6808:1a0e:b0:3c7:30f5:9466 with SMTP id bk14-20020a0568081a0e00b003c730f59466mr3209321oib.45.1713435639362; Thu, 18 Apr 2024 03:20:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713435639; cv=pass; d=google.com; s=arc-20160816; b=hmCipGTrd+xEgQV20JN8GOf2VWbGv+m4ge8e/71ifCyDTq8JtMFYn3T6WQCnYH9C+f WWj9kr35lKrycvghLG8H+3Z2mz44QqfucR9X/qdgJN0T9/Ls1B1WaVDB76N6Wp8lK0lA UdSnafcGWIyMpWEkxUcKgRBftVKFPV/5erSAUuFlB7xgmiy/Jkqf0LbNd1f7P5RY2RU+ jMhQm/FlvSOEt0tJl5SrhSL8iJlQbSbKF1Te9Mwp8o9Kg2IbjIv821R5aJWgXwnqqv1f AdjqIg2eBdP8c3BrQGC8vKKGGuT7Bz5ABqDFYKG1Be+hg4Q8hBkab5o358usiqYRL0VF 8oqQ== 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=7QuOPPA02NXP13o7JH32iH/XYg33BypsERiunyF7/0U=; fh=oecKYYk35zjhCh+QG1LQ7YdKKVqND+53f7J1hdmmOx4=; b=ZCr1+ktG8dxal52IefYNOtVSeMmQSA/yx+szvggcWkhwhqWAwLFbFBJ6AqmvUPIR33 nsdST8q2P8ssvEpWOY3eh+pcd4xzpmE4AoMxiqcN3oxB/4RDf1+11Qen2GzdjyQXMlUk 7BF8BBwid3OFgbPl6XR+UHfhP6R+Yx+kuq2p1/WvKExwUA4vmNtQ4xCXQ1dYLJXf39T3 vsZXMJNLUj8+O3Mezap6wSp8KzBvOu9Vxep/3JxUng3ttF5SoFWn2ogojf4ycYCBzuY1 rHtUY7brIcqeJfJ9wQVvhQmqCn7VeTsli2wcf4kv4rgK2xpC9FPeXatcUBSUeFxIaESK dezQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Z3MNcWQS; 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-kernel+bounces-149869-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149869-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id f6-20020a635106000000b005d8e221d9f4si1102438pgb.77.2024.04.18.03.20.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 03:20:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-149869-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Z3MNcWQS; 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-kernel+bounces-149869-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149869-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 8A752B226AC for ; Thu, 18 Apr 2024 10:19:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 879F315B97D; Thu, 18 Apr 2024 10:19:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z3MNcWQS" Received: from mail-vk1-f170.google.com (mail-vk1-f170.google.com [209.85.221.170]) (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 3AC1315AD8E; Thu, 18 Apr 2024 10:19:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713435556; cv=none; b=hkYV8Q6QcaABz8KNeT5cdghDLhuULlHV0KzQdGkB6Qu0fu7+RY+cJPOYmvHrO2e7qBuoe/BNtcdyKVzrFEWQ0mVnqcyTAPCznnCDCO3zrB6gqFqln4vUhFV2C47gfp1MviW7KapkRYFdlQzPJzbmuTkFC9psqz9vvhuO2QGfwvw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713435556; c=relaxed/simple; bh=VL6pJSQmGCfJDVOYa1cGphoXn4BaHMl8XQjHe6z0SE0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=IkaPwxQn4dnApK3/IiAK3QfRaF/1M8ZW78gjUzT2HyWIoYx4fR4SQqOZUcvSOA9WrEog97L3SNRLdiSMqKI8G01ftebutR2KXVO8psz1+IaWj7zh8bDeqVEr27OxxG1PSFpYVEyaUTC6uGXKfnL6/kOYV3Is/0BtlgpxiSOsPSs= 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=Z3MNcWQS; arc=none smtp.client-ip=209.85.221.170 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-vk1-f170.google.com with SMTP id 71dfb90a1353d-4dac92abe71so179181e0c.2; Thu, 18 Apr 2024 03:19:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713435554; x=1714040354; 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=7QuOPPA02NXP13o7JH32iH/XYg33BypsERiunyF7/0U=; b=Z3MNcWQS7uQZhyRM/fbKnZX7Js9mX7nCX2zyPrL+AKu6aLeC7a0V0A8xz2I8lpzzdn fnzyn11LBxvwCMy8DXP1wND7b7WbHodOHDFlWDeolZ7cZy2okhmuFczGUMq/p8hf1aOn 0hvzs+xEnP2JgBVIsiGcE5CSZL1U1wqBd7ngQwPwWGbLokZ/0HNGCiSmcV8/ch9T9A/s RbqqzCw/ltdo4KoplEPfn/dIPmOdjw2MAhdqrbuXLHb8gP1pWpKApIwZ0lYHTHWeOETk gTht+EVMQdZmIFyyIT4VAXWuPTCrp0RW/IG3S89Fx+H0ePdVuD1k9ks5wEI0Dvw+EWSZ A78w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713435554; x=1714040354; 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=7QuOPPA02NXP13o7JH32iH/XYg33BypsERiunyF7/0U=; b=qAWk8FdSPdhyQsRR3Jk3N/q9sU5xlX9Mk/U+UFhyezTtIylvacQ0+HHEBzTCb3Rq/w wMlXE7Y+R6m50RzD7ntN6RpnoIbrPgEVBWECWjvO9+wtADWfAep4smh8h++GPpLW9Yno W8+ibU92xg+QgArThZmJPTZLXR3K9rYQwhbhDgZKzbZq78NDGdiveJ1MDyoXPglw3Puk NoMPs8M1j5wCqngB8wcq1VYAsLPcyCV8yaiLSs6vBL1OR/2E7vJ7qrjH/NJfMGEGFJAz 99s7mojCY55zsYxrjsEv7zUUAkMXtnVCGIsbtUrUI6mnxjFNI998/wKoL7g2Q5OyhKtq sdnw== X-Forwarded-Encrypted: i=1; AJvYcCWIS2ioyk6+85frfLm77fvSvqvoLMreSA6FlKWp4kmXJMFCwzLOcE2jF3o3K+ZcB3qvW4ex0n3EfwUgMXneIrUMRFfrf52v3f2dg6zvu8L7XqLsZlzVIMc+vuDJVH7Nzh+jlbf5rHVRZOki3Q== X-Gm-Message-State: AOJu0YyRusVff8by/gIsBv2ExVjhPA5iMnNwYF03NCon22NyXrH0KO5R liwr6MjzZ8zpuZpwB3cSIXsY3uI89eHSpjZWxGefvyItHoXcZUsqOnvHNYntbyVMwZJQdqKRqZT TsFsTtLsJokbDTjRgp16gI8vRF80= X-Received: by 2002:a05:6122:550:b0:4c0:9ed8:57b3 with SMTP id y16-20020a056122055000b004c09ed857b3mr2912649vko.1.1713435554013; Thu, 18 Apr 2024 03:19:14 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240417160842.76665-1-ryncsn@gmail.com> <20240417160842.76665-8-ryncsn@gmail.com> In-Reply-To: From: Barry Song <21cnbao@gmail.com> Date: Thu, 18 Apr 2024 22:19:02 +1200 Message-ID: Subject: Re: [PATCH 7/8] mm: drop page_index/page_file_offset and convert swap helpers to use folio To: Kairui Song Cc: linux-mm@kvack.org, Andrew Morton , "Huang, Ying" , Matthew Wilcox , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Apr 18, 2024 at 2:42=E2=80=AFPM Kairui Song wrot= e: > > On Thu, Apr 18, 2024 at 9:55=E2=80=AFAM Barry Song <21cnbao@gmail.com> wr= ote: > > > > On Thu, Apr 18, 2024 at 4:12=E2=80=AFAM Kairui Song = wrote: > > > > > > From: Kairui Song > > > > > > When applied on swap cache pages, page_index / page_file_offset was u= sed > > > to retrieve the swap cache index or swap file offset of a page, and t= hey > > > have their folio equivalence version: folio_index / folio_file_pos. > > > > > > We have eliminated all users for page_index / page_file_offset, every= thing > > > is using folio_index / folio_file_pos now, so remove the old helpers. > > > > > > Then convert the implementation of folio_index / folio_file_pos to > > > to use folio natively. > > > > > > After this commit, all users that might encounter mixed usage of swap > > > cache and page cache will only use following two helpers: > > > > > > folio_index (calls __folio_swap_cache_index) > > > folio_file_pos (calls __folio_swap_file_pos) > > > > > > The offset in swap file and index in swap cache is still basically th= e > > > same thing at this moment, but will be different in following commits= . > > > > > > Signed-off-by: Kairui Song > > > > Hi Kairui, thanks ! > > > > I also find it rather odd that folio_file_page() is utilized for both > > swp and file. > > > > mm/memory.c <> > > page =3D folio_file_page(folio, swp_offset(entry)); > > mm/swap_state.c <> > > return folio_file_page(folio, swp_offset(entry)); > > mm/swapfile.c <> > > page =3D folio_file_page(folio, swp_offset(entry)); > > > > Do you believe it's worthwhile to tidy up? > > > > Hi Barry, > > I'm not sure about this. Using folio_file_page doesn't look too bad, > and it will be gone once we convert them to always use folio, this > shouldn't take too long. HI Kairui, I am not quite sure this is going to be quite soon. our swap-in large folios refault still have corner cases which can't map large folios even we hit large folios in swapcache [1]. personally, i feel do_swap_page() isn't handling file, and those pages are anon but not file. so a separate helper taking folio and entry as arguments seem more readable as Chris even wants to remove the assumption large folios have been to swapped to contiguous swap offsets. anyway, it is just me :-=EF=BC=89 [1] https://lore.kernel.org/linux-mm/20240409082631.187483-1-21cnbao@gmail.= com/