From patchwork Wed Apr 17 16:08:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13633555 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (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 2249E148FEA; Wed, 17 Apr 2024 16:09:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713370184; cv=none; b=i9tDLQIqkmLCulcxFh8FGF7Ga/SjU8Fm9wRtLjLBWzFYB622Uvj5F+g5OUG6wJSWH6qtU2b3Y9CkFaUF27IahrIW4k6RgDreqvbaSX/BeaZ3BIbp29E9uPA+cB2Xv86m7MrTQu6n3eOmXj/JabGZC9PXHWKsgLJe2bsrcNH1YHc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713370184; c=relaxed/simple; bh=pMXBuRSYRvxJ/Pm5/D0Ih9VGkrkcDFfmsJy8ADz5Yxg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l/1f1JRwkjgevD0IG2ZYOr6sRdU/t4HW+Z6x7ihy77WZvDEqRedL4V8MP90W+Vuw7zeZs0ecFLguLauEu4/YOJkHbuPglWGn7yp+2OHsHEDLySHsDpI75Ay6vQbv7NI98FN4LIXnw4WNPKuwMSk6x+1l2ofIZrrvZ4w3oPw79e4= 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=DxnuBve+; arc=none smtp.client-ip=209.85.210.179 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="DxnuBve+" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-6ecf1bb7f38so5305241b3a.0; Wed, 17 Apr 2024 09:09:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713370182; x=1713974982; 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=BixicrujN2w/NN7W8Yk1bOtYDD16jf87ysiCrI+mjZw=; b=DxnuBve+OgB7iTJSOkoYbkli5a7MkAcAS8KAGlIBhAYS/qasj9afZQqCR/uejQNtQU BFuUzTR6YDIun78IZCZ8Wls9hDW3CaoPdzB0qvc6dy1vRmgd4mhKDftzHbh8V/bW9w3u e46dEVZjkcJD7kTfi4VipDT8VWpU3FUiz4Ro5fhFcON1PN4zdWfIFe9IN/jkLSjzEGmN fZR7Q1zye9yASeq/oWLgKJgoy2km03ZJlK37dxNeACeWVcNI8/dmuujSCaiMvYXeMjAJ OYlHVwd2lLxsFFfXeeVDkk0YAlwxDV4K5/rTZeVJKyoN5cIfXdx7ePPKlwBffLrM3hQz lecA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713370182; x=1713974982; 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=BixicrujN2w/NN7W8Yk1bOtYDD16jf87ysiCrI+mjZw=; b=LR4JRQOxnqnOXvr0oMYQz3Lyy5gU/wKqpH8g9ux4t1QH4sRGnyOwc/s+jKxwFI+Jrd dwo7PqcQDsIetlnj5GSSoxVehh0oHAGn3XpT0y0LAOsCZT2K6oOkqzVLsxEMaFOMJgHj zs25IxHiw2ZDWsmH6YilyLP2lyfAHYTujyKBy1lorhnKyJEf+1wK+eakjqZ6XelCy1to HXCAxzEa3f+SfOpnYwYPo+NHnExi7clQbyrjooIGrUXRK+q0qmqxY34RkI4EZj97/p3W 5ZOPtpkHp8jzJ8A5NGg4nTekk+T4JMG9C3PrQ3Uqt7Eu/YwzlefUvlyUL8n6kc0ahue/ vpbw== X-Forwarded-Encrypted: i=1; AJvYcCU6a4LCmttOa9B5v4Vza1gk95AkXZvRB2MGeGCy5Gm/P7dx8ex1FfC+LKA7w0Ha5hNiyIquYlhzEr4IrJmnfhP4vsbOd/HkwVEPrYZSlhNYc56BXUNIUJXUyYl2p+LR8yubqFdgr3Hmqxng3M6yD/ix7Ip3IL+E14ibgR2JcF6+cTs+rO37oQ== X-Gm-Message-State: AOJu0YzkpWdWRTDnFY/X81rJW3PZ2E+QdJgHnZXl+m+xGMQbfWGExaP3 vrWQqvsGwmOszMTC/bzT3s1tQUD0bB/EWixOgoMh/28NBg78rT1o X-Google-Smtp-Source: AGHT+IHADX305+lhsZl65TBVJfwFNnUajwhJ6mgc1Rrgzv/e0DGcheSabgx4i4+AnxNft/shYQftQw== X-Received: by 2002:a05:6a20:dd88:b0:1a5:6a85:8ce9 with SMTP id kw8-20020a056a20dd8800b001a56a858ce9mr71965pzb.12.1713370182271; Wed, 17 Apr 2024 09:09:42 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([115.171.40.106]) by smtp.gmail.com with ESMTPSA id h189-20020a6383c6000000b005f75cf4db92sm5708366pge.82.2024.04.17.09.09.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 17 Apr 2024 09:09:41 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: 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, Kairui Song , Trond Myklebust , Anna Schumaker , linux-nfs@vger.kernel.org Subject: [PATCH 1/8] NFS: remove nfs_page_lengthg and usage of page_index Date: Thu, 18 Apr 2024 00:08:35 +0800 Message-ID: <20240417160842.76665-2-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240417160842.76665-1-ryncsn@gmail.com> References: <20240417160842.76665-1-ryncsn@gmail.com> Reply-To: Kairui Song Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Kairui Song This function is no longer used after commit 4fa7a717b432 ("NFS: Fix up nfs_vm_page_mkwrite() for folios"), all users have been converted to use folio instead, just delete it to remove usage of page_index. Signed-off-by: Kairui Song Cc: Trond Myklebust Cc: Anna Schumaker Cc: linux-nfs@vger.kernel.org --- fs/nfs/internal.h | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 06253695fe53..deac98dce6ac 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -790,25 +790,6 @@ static inline void nfs_folio_mark_unstable(struct folio *folio, } } -/* - * Determine the number of bytes of data the page contains - */ -static inline -unsigned int nfs_page_length(struct page *page) -{ - loff_t i_size = i_size_read(page_file_mapping(page)->host); - - if (i_size > 0) { - pgoff_t index = page_index(page); - pgoff_t end_index = (i_size - 1) >> PAGE_SHIFT; - if (index < end_index) - return PAGE_SIZE; - if (index == end_index) - return ((i_size - 1) & ~PAGE_MASK) + 1; - } - return 0; -} - /* * Determine the number of bytes of data the page contains */ From patchwork Wed Apr 17 16:08:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13633556 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (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 8C75815252D; Wed, 17 Apr 2024 16:09:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713370188; cv=none; b=BCRted07gp2eU6fH3pC6yJOmCNWA5s6DkGq54NdN7erLOiQnaVmjt857xWD9GKPt6vbfR5MqFO1PEF/y7uBZjuiJxLnIovQpzbSnZLOf5Ry9nQJiDIUeyRZZLO4pUS9qSAWhcDCjtlQln4Pn0/dAmo6mSvSrk2xUmfDYcdTznhk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713370188; c=relaxed/simple; bh=CGj+WNrIUV3l61RyE0q4VlcKcvdYqAZ7eo8PGn+yS3o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Hd0HtJGdwuuAQHFah2BtoycuopMwyHkcrY/jpZn7E0VWVItpd1ghULB6KbjUv6TdPOob5O0ysSEDVue1FALUrrGt5PcVicWjTspldsM6T1T9ImY1WM35CfwPEmrr2QJV5g8c+szkFn6MB5qSRaFRaZyclxKNBYIGV1wxrgmA85g= 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=B0lTodGu; arc=none smtp.client-ip=209.85.210.173 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="B0lTodGu" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6ecf406551aso4776285b3a.2; Wed, 17 Apr 2024 09:09:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713370187; x=1713974987; 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=EKBCpzMJJOybw3E+mN0Qu57krGqjseTa24mZvlKHSk4=; b=B0lTodGucJ5UnljoLMZJ6r8QsKpHWUvZTtaIL9NZ52ZDvK5DVYxfzwgiAUyNHcMfsY iHjL3AH2T9SXosi9aiQmiXv7QnW7lRR0iYTQGjN6/ERo8GmrDF8bEUHTXJNbgCuVgGeI 5ykzPvqlwvuFOgU/DA2vwtBL5qUILsw53Zj0U/VxlCL86sr100pF7zNrgi06Vx23fAyY IXaaX+M34nMIhAhV/sJ11FHXbaAaGD5BNODV53uvtv1UBrKpvBis7m3T4pmEmQ4nFyhS e43ZY/Ti+WP6+qQyDTYEf9AleVfedKrASKycPcSA6j6pzHHbzbkq/lqHRl8LzHXC9nXj ITNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713370187; x=1713974987; 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=EKBCpzMJJOybw3E+mN0Qu57krGqjseTa24mZvlKHSk4=; b=C2233+fFGN1LF0ZNQBDPZm41ELsb6Vl5IeDBezhZJPz+MyZSqyXL2fjwRKKjyapKRh UQzhvmVN2kOpgAM3wXrFp9lbGxb9kNIGmzEX7DYEj1vVecX2jCUU4uUlm0gP5pzuleI5 lNzx9eF2+ysBkV+xf0Vooalf96d6lXysiyS1arUkEe56UGh0yXtIOQ76CA3dv0B6W0ML dqXmUVZL68bIatEZBBjKQ1dQyThe5U+wljNWtq9u12GZ7x2qzstbNAgtodUQGaRQCVao l4xwbHvJPHxYUn8bkFDXozemuW32sYZD7F8VbhFQ4PNDkPCSkzfb/YD6lqRENAWNvnaf +OqQ== X-Forwarded-Encrypted: i=1; AJvYcCVQX8JuMIOQKUjS9+EhdQ8B5rfvLs41f0LkBSUyyCc0aK21xoNhr4NKRXMh4w6xSqUqLM9aZ5ypdQU4EqeSLK26Iq6hDtehfqOvCoA7RGTBN0E91Ko3xlLA48aak5gWt/NULHOJhpxgUVk5xcl/zhaHN0ZISwGC1lXJCowkR4JQzDYJvQgGmOdz X-Gm-Message-State: AOJu0YzTV9kZ1zMBoSi9WgQ67SIiBShmPz1rZ909XQeF9qxvWFGFg8mp y2dWAXtaododZSOrTtckepTclZZvwKefglbQgIGMmyprG2Y1CS7u X-Google-Smtp-Source: AGHT+IEUIsD2UfwALUBzZ9zgNwZkhBtp79KdHPB59HWhpiWeEDWZ5TAduyfuawXCnxiRfUFyeMAZ7g== X-Received: by 2002:a05:6a20:1042:b0:1a7:a21b:66f9 with SMTP id gt2-20020a056a20104200b001a7a21b66f9mr48906pzc.43.1713370186696; Wed, 17 Apr 2024 09:09:46 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([115.171.40.106]) by smtp.gmail.com with ESMTPSA id h189-20020a6383c6000000b005f75cf4db92sm5708366pge.82.2024.04.17.09.09.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 17 Apr 2024 09:09:46 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: 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, Kairui Song , Ryusuke Konishi , linux-nilfs@vger.kernel.org Subject: [PATCH 2/8] nilfs2: drop usage of page_index Date: Thu, 18 Apr 2024 00:08:36 +0800 Message-ID: <20240417160842.76665-3-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240417160842.76665-1-ryncsn@gmail.com> References: <20240417160842.76665-1-ryncsn@gmail.com> Reply-To: Kairui Song Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Kairui Song page_index is only for mixed usage of page cache and swap cache, for pure page cache usage, the caller can just use page->index instead. It can't be a swap cache page here (being part of buffer head), so just drop it. Signed-off-by: Kairui Song Cc: Ryusuke Konishi Cc: linux-nilfs@vger.kernel.org --- fs/nilfs2/bmap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c index 383f0afa2cea..4594a4459862 100644 --- a/fs/nilfs2/bmap.c +++ b/fs/nilfs2/bmap.c @@ -453,8 +453,7 @@ __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap, struct buffer_head *pbh; __u64 key; - key = page_index(bh->b_page) << (PAGE_SHIFT - - bmap->b_inode->i_blkbits); + key = bh->b_page->index << (PAGE_SHIFT - bmap->b_inode->i_blkbits); for (pbh = page_buffers(bh->b_page); pbh != bh; pbh = pbh->b_this_page) key++; From patchwork Wed Apr 17 16:08:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13633557 Received: from mail-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) (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 65FE2148821; Wed, 17 Apr 2024 16:09:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713370194; cv=none; b=UOIN4ki9D5x22TibDaUrRQ86BmbUPggo1Tr1STsU1I4wOw65ou7PfgLzDehUwZeblDf6VWOgJjo3i4DEcKO8P+TCBVfBcdzrYYsMiLlaYw/+qxtsBVwgi3+GdTAuv21eTlgZOBIH9JoO1K52tgZsjA5J4PXtaTkAw3RTlF1D6L0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713370194; c=relaxed/simple; bh=UaTaQyDAPYJXzxuGE+S2wWuP7fLVM+PYcfLn2sBx5RA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hlTPIxve2ItD0jWT/DOnbbKOmNBr0DrIVPk5vM5OSWK7jzhKskpOjP8fLczpFmndMR2hcdgAoVkyIs4/Y5fGt9hmkihX7lYbCIcrYfOLQMW9Mz3ZA0o1zIfrhcK0QOJyIja2WaO7M9W6yoQSIAto1FQ7taVZQmkYGqzBu/JjkWw= 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=g97zxKK1; arc=none smtp.client-ip=209.85.166.45 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="g97zxKK1" Received: by mail-io1-f45.google.com with SMTP id ca18e2360f4ac-7d5e27eca85so260990639f.3; Wed, 17 Apr 2024 09:09:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713370192; x=1713974992; 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=ccxP7TY1LZd03lAzTUSjd/WMiiw2l1TFGZjibmTvaRo=; b=g97zxKK1wtWoSsmpHyXzBUATjRO3qORf+hY5Ih9b4KYbLmH+NdlQWIXXkVan3R1Btu 4FIktFcJl4AZDeeM014EY+uvUJtlVyG4XaBby+5Ieb2mfS81zFq052EqOcSTcnrJjUyK dAAAMfOvFnd84o+mI5eV9JUcS+V+svcYntAqauy9RmVIX5wqptBuAo0lC6msdJQeKdnc XyCsG2RAeAMkBDqlWQwzgLKiJXLM3Wq72lpMhpBQV7gRStarobJYR8eGmivI0lylPQKL L3nZF3GJySzAJ2zTf2YWL0VjxOA3AOm4nyhK/Yow+M1UbJnCEGMoSBDpEZlX+WN0RHxy Y80Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713370192; x=1713974992; 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=ccxP7TY1LZd03lAzTUSjd/WMiiw2l1TFGZjibmTvaRo=; b=YoKOfd4Yzz2yuKyTSh3dKS10dx62NQCP4nTgf/Cjh6EmPdnP0piSEryAIgGgINMRIA nNWK/Vp2zXFQaQQrNuPV32v2lxfKnTA8smCY3JdhTnxI6P7BLUAEFFMgyww3aN7cl75B nCtDL56VYTkx5ZXn2JIyENokGxzEowKWQyMVhOv5msDRQtRi86B4cR9dYk5VwEyhdNWB WvwmCVj60WgjvLDtGwX8QFKz+axaHVqSkH+BYXRYqR8UM3gW4sGnB/vzd7cNeOgbbffB S7U2e8Iyj3a2f70nwpeSCNxbKYmXmxSZhBqfuqQrJkyW9Gkq4yFAnsUtVCC8W6lRr3nL AhtA== X-Forwarded-Encrypted: i=1; AJvYcCXHLAZH5SgMwONWkVFE1guPAN9uy6PxkQsPZt2yQEqEi6Db9Vu7YDl7nw1lNEbKl6zUlSRT1NJAx548ZRDUeD+y6bCaBmWkmpX/uoyRw5n7/2N3u9dT37Q5DfJzuIth6+YpKCcSfkwTln+3IQ== X-Gm-Message-State: AOJu0YxVqaprX5cOj3ZSm1X093oEXhVU31zsoZLm2zlIBTrM1VN/1f8o bHXwuVy5gtdVpOaxVRchOmAk6gU5e/ReUk/en2tXU272rUyDIlWw X-Google-Smtp-Source: AGHT+IEpyaQ2B9laiL5Qz3xq+OgAsfHl508IHieRw4jQK+zsxfoW9aDncD8KQfXYdlyhnJK/CywmIw== X-Received: by 2002:a05:6e02:12e1:b0:36a:1e27:1708 with SMTP id l1-20020a056e0212e100b0036a1e271708mr18563457iln.25.1713370192373; Wed, 17 Apr 2024 09:09:52 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([115.171.40.106]) by smtp.gmail.com with ESMTPSA id h189-20020a6383c6000000b005f75cf4db92sm5708366pge.82.2024.04.17.09.09.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 17 Apr 2024 09:09:50 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: 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, Kairui Song , Chao Yu , Jaegeuk Kim , linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH 3/8] f2fs: drop usage of page_index Date: Thu, 18 Apr 2024 00:08:37 +0800 Message-ID: <20240417160842.76665-4-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240417160842.76665-1-ryncsn@gmail.com> References: <20240417160842.76665-1-ryncsn@gmail.com> Reply-To: Kairui Song Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Kairui Song page_index is needed for mixed usage of page cache and swap cache, for pure page cache usage, the caller can just use page->index instead. It can't be a swap cache page here, so just drop it. Signed-off-by: Kairui Song Cc: Chao Yu Cc: Jaegeuk Kim Cc: linux-f2fs-devel@lists.sourceforge.net --- fs/f2fs/data.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index d9494b5fc7c1..12d5bbd18755 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2057,7 +2057,7 @@ static int f2fs_read_single_page(struct inode *inode, struct page *page, sector_t block_nr; int ret = 0; - block_in_file = (sector_t)page_index(page); + block_in_file = (sector_t)page->index; last_block = block_in_file + nr_pages; last_block_in_file = bytes_to_blks(inode, f2fs_readpage_limit(inode) + blocksize - 1); @@ -4086,8 +4086,7 @@ void f2fs_clear_page_cache_dirty_tag(struct page *page) unsigned long flags; xa_lock_irqsave(&mapping->i_pages, flags); - __xa_clear_mark(&mapping->i_pages, page_index(page), - PAGECACHE_TAG_DIRTY); + __xa_clear_mark(&mapping->i_pages, page->index, PAGECACHE_TAG_DIRTY); xa_unlock_irqrestore(&mapping->i_pages, flags); } From patchwork Wed Apr 17 16:08:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13633558 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 29CC7148821; Wed, 17 Apr 2024 16:09:58 +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=1713370199; cv=none; b=p84QLicbpNi11nFo+15NPn06Ze+xf+yv7jSMfgExFqQsb2limxQNT77ZEkjwGLEAFsDboCC8HTXBlxNA4b9PZozvpiZPvFnGs1D0sx+8vDt/2vNMLBhJs9bj5kemSMn+sNESMJDGA0AupVw5K7p7CAL9PeL9gmEtRocfxCcymdU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713370199; c=relaxed/simple; bh=gNeowpHLn3XanGMjOPlcSsZZHe5AP0lM6lADWQVCs4I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JHqkusRoblLdQ4xi6f6MX9Rj5ugVY+5rJnzYUCC96sMvIuT6OGZEt0/zPrMyqQuvHVaiJQZtT0odYboUZ3PgoanBRlSnFhD/UwWJAeXs4cH4ctFPywItmZj0Kb4eIgAp5A02Nrv40env9J81UzqJsqd5OZykXk4RQZPco9SlUcE= 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=CW65eJsw; 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="CW65eJsw" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-6ecf406551aso4776595b3a.2; Wed, 17 Apr 2024 09:09:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713370197; x=1713974997; 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=5+IkB3+J9K42d+V5Wi+AdhWpwnXMtEpYhZXm/5fw+dM=; b=CW65eJswhXnaDYbGXb9KQc7uhrTdxxq81xyfc3OYHNAHG8RoikTuX/UPK9TAN7BlaR 54spxgVRE0IuFkurhOuVKyy0dZ3LOnIBw4hhq88pRHGAjLCf2l9IBXjjvDq+HFpB8+Hr 0sgJS2JLmBXzJzRr+qCgu7inn5mCCKjdwl6FdeRBS4vW5ZlgReliy8c+NkhbqTFqxgjv Zgl5nPJe4Q4qJXuldEMPxt1xeLNVLcZWfaoLGmrk5Mh34kd0cy6azaOTW64IU4VKVY5k pG2JcalVbJgT0te5ZCkjICjscFN0+G/a64CSMFPCksZNJajY8k+jicMy/L11f+Gh56ME 8gaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713370197; x=1713974997; 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=5+IkB3+J9K42d+V5Wi+AdhWpwnXMtEpYhZXm/5fw+dM=; b=lEDo3+Je8eINE2SgUJAINFTsh7jeD03wbKupOIt4OEHfC/opjwBaEH+vesUzZVUd3M Ev5VXhw5IwRWCUaFm/T2mDgGjaFFfkPDKMizsNZKqTbSGMCrfY+SLpt2XKe/HDMKO0jn m091aEp+JXewElOrjWaSx8XkjjK/8W1meHDpF2RgMr/OzHEdvfMRiIuvz7yzNiCja4kC 2oLzDu2la6OVmfs0oECDFOnouXZT3euvaZe5kKiZHrGp6V4CKAvsCNW8NQGceaOXyXfW +wN42Kf99FEXI397fqtRFdLTelLfrQs3UdvpM7yp/rBi2jY+poVzLmRPII/s/FwwYrW5 lUBw== X-Forwarded-Encrypted: i=1; AJvYcCXV96KOSvSNkBFfxAGDD4f8GIjl6lVivoZj2z+PEdHCEymNg7TwslJMZ2T/BPI+GBGiSjxDwLIwZ7Oo88zCUimQ378ppNcC2ijAgKzhv9LN2VvEBx4GXbVHlGqmgFokvd8/UwVJQ9xZF/dJgtChQ8Shik69zxfS/eb7sSaH8VLkeMDynGH0uWM= X-Gm-Message-State: AOJu0YwVmTIOi0tc/0MpQcxghLb6Vr0YMKqSA0uQZqhq8mdkUyFu857i Y2y7VXWbHzNgCgDuvEd3nEQ9W8ImzsDEB4uaR8EFU/5GXEcAcuAa X-Google-Smtp-Source: AGHT+IF89lpxIREGckNZOeGWJiBxfqA/7WGCBHYUpnctYHo1cbqQfhXPRXtCnH1w7NEcZKTHHIsNPw== X-Received: by 2002:a05:6a21:2709:b0:1a9:eeef:f6b3 with SMTP id rm9-20020a056a21270900b001a9eeeff6b3mr63326pzb.53.1713370197257; Wed, 17 Apr 2024 09:09:57 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([115.171.40.106]) by smtp.gmail.com with ESMTPSA id h189-20020a6383c6000000b005f75cf4db92sm5708366pge.82.2024.04.17.09.09.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 17 Apr 2024 09:09:56 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: 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, Kairui Song , Xiubo Li , Ilya Dryomov , Jeff Layton , ceph-devel@vger.kernel.org Subject: [PATCH 4/8] ceph: drop usage of page_index Date: Thu, 18 Apr 2024 00:08:38 +0800 Message-ID: <20240417160842.76665-5-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240417160842.76665-1-ryncsn@gmail.com> References: <20240417160842.76665-1-ryncsn@gmail.com> Reply-To: Kairui Song Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Kairui Song page_index is needed for mixed usage of page cache and swap cache, for pure page cache usage, the caller can just use page->index instead. It can't be a swap cache page here, so just drop it. Signed-off-by: Kairui Song Cc: Xiubo Li Cc: Ilya Dryomov Cc: Jeff Layton Cc: ceph-devel@vger.kernel.org --- fs/ceph/dir.c | 2 +- fs/ceph/inode.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 0e9f56eaba1e..570a9d634cc5 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -141,7 +141,7 @@ __dcache_find_get_entry(struct dentry *parent, u64 idx, if (ptr_pos >= i_size_read(dir)) return NULL; - if (!cache_ctl->page || ptr_pgoff != page_index(cache_ctl->page)) { + if (!cache_ctl->page || ptr_pgoff != cache_ctl->page->index) { ceph_readdir_cache_release(cache_ctl); cache_ctl->page = find_lock_page(&dir->i_data, ptr_pgoff); if (!cache_ctl->page) { diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 7b2e77517f23..1f92d3faaa6b 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -1861,7 +1861,7 @@ static int fill_readdir_cache(struct inode *dir, struct dentry *dn, unsigned idx = ctl->index % nsize; pgoff_t pgoff = ctl->index / nsize; - if (!ctl->page || pgoff != page_index(ctl->page)) { + if (!ctl->page || pgoff != ctl->page->index) { ceph_readdir_cache_release(ctl); if (idx == 0) ctl->page = grab_cache_page(&dir->i_data, pgoff); From patchwork Wed Apr 17 16:08:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13633559 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 CCAD715DBBC; Wed, 17 Apr 2024 16:10:03 +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=1713370205; cv=none; b=qlxCv6ealdAyXzinLY6URJhSztTPLGUlAx+9BUuk56op7Nkg+kwTCEk8Cvm08tL8q4Tt4uOyB0l+xgS01ZUtDTqdYvSdVZQ5E5U6pt7vNLXNqPOklJp/SQjdj9iF3n+I7a3jR6Z8xwkzyVgnXCJmjNNGpFluZb5ouxgsLwyHSD4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713370205; c=relaxed/simple; bh=lRmS0vfrkRgKu2V0vYqMI+J5yAkmvRW6Rx0XntA+fCg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p41E0ihp1WrSd1yYAvH5WhdUGhuyG+2zpWnnCrA8zX0+HVyx+h+DuJ5xwHYylo685lvHDR7Tqi0j6w8lVilAOU6WcUW4bw36OCwibcAhOVj1zsqaHAPeSlFxOLaFV79DuO0SZzr1w+32mXeqnwNPpTLcR1kKtdNRg29MT78iHjM= 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=PBq+XjkA; 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="PBq+XjkA" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6ed11782727so4971254b3a.1; Wed, 17 Apr 2024 09:10:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713370203; x=1713975003; 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=QKsmOxPUvJ8jFqBm63ArqbRFjM5INLEtk88J9DbM67E=; b=PBq+XjkAZNsNqLL3kptoBsgjyTBVKvmWpyas6Rez1zBGm2ttk5bUjJu77Rt88CFXAm jD1he8mhheKxweCR09JezTPnXszkUdWOpuua1pJvBjq0gEMD1PW5u7Hv3tR9+VTJcFVX 2voGQhPbKbNd5KOd6MHeZljRx9T1RrfDRa6PQV7y2elsNNYXYkmm4cSComk8UUQdtQIB LLhsZBiwhVUn32LgHS0qs3kNrpMAOpLIowSgNCc3rOw2co6gvPS+Jc2VD/BeiABuSWid Fiz88PW1GlZrukGv9DMyX1M7Nuv47zti+kXRugiBu52fhXFgyPaaYgsAYmUp+6TVN18F Xnkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713370203; x=1713975003; 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=QKsmOxPUvJ8jFqBm63ArqbRFjM5INLEtk88J9DbM67E=; b=petvuo8c3apcCjWornrRO1+4u+5mkjZgtqeyTASohLvisFL9xz8mNpFNQlmbxLLNlW ULfdl7Qx0tlcymHjWA2+wx7XAWS+jLElF4TiZi8EVUmG4xaMlWdh37dnEph/Ddpu+eKf 8mnlLUGH+51ZHVb+IkGpTZxjCFTxOj17xVi90xPuYgGjpCYwIIKc0T79SV1vKkApeY1d ADgGDJ4IZw9kfaiKReAbE41RVYsYhgbZJEAv9BKDrWQLmAkHWLzw7OkzcgLpGpfLMPuu lN6jZSjQi5grVRyRmWMePujSrhPNYDvbdoA3B3A8l46KIsJ+1exJh5bPpLY1gIrp8xH8 k1oQ== X-Forwarded-Encrypted: i=1; AJvYcCWExE4FcJJJJgfnXtoVpuiydkMSpbu18ZvEILoZropgP7DdbdP8XkYbeD80WfsX97nscZorZv1Lo7GQmqltkSrbd2xXSzYgz5gY91obWcNY3w6/4E6ep7ARdVzWUak7J4gzXLeNcI20LGyG7Q== X-Gm-Message-State: AOJu0YyWLZqWGRokLo+JtBncIxk1MerPZIe8Or9OYt0RTBU2TAXvcBRL UcZl77PX7k14+2ObV6xz3pee3w4SpxBys9Tfs3X7eRFe+jRhZmjW X-Google-Smtp-Source: AGHT+IFJeyb4K3TlyeiLY9c8kwF5soNMLS4dioE3GGli82q9k0eqDSGM6THIcyA7JEE4hz8B0VjGpg== X-Received: by 2002:a05:6a21:8189:b0:1aa:58d9:1825 with SMTP id pd9-20020a056a21818900b001aa58d91825mr83965pzb.3.1713370203077; Wed, 17 Apr 2024 09:10:03 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([115.171.40.106]) by smtp.gmail.com with ESMTPSA id h189-20020a6383c6000000b005f75cf4db92sm5708366pge.82.2024.04.17.09.09.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 17 Apr 2024 09:10:01 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: 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, Kairui Song , Steve French , Namjae Jeon , Paulo Alcantara , Shyam Prasad N , Bharath SM Subject: [PATCH 5/8] cifs: drop usage of page_file_offset Date: Thu, 18 Apr 2024 00:08:39 +0800 Message-ID: <20240417160842.76665-6-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240417160842.76665-1-ryncsn@gmail.com> References: <20240417160842.76665-1-ryncsn@gmail.com> Reply-To: Kairui Song Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Kairui Song page_file_offset is only needed for mixed usage of page cache and swap cache, for pure page cache usage, the caller can just use page_offset instead. It can't be a swap cache page here, so just drop it. Signed-off-by: Kairui Song Cc: Steve French Cc: Namjae Jeon Cc: Paulo Alcantara Cc: Shyam Prasad N Cc: Bharath SM --- fs/smb/client/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index 16aadce492b2..73bbd761bf32 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -4749,7 +4749,7 @@ static int cifs_readpage_worker(struct file *file, struct page *page, static int cifs_read_folio(struct file *file, struct folio *folio) { struct page *page = &folio->page; - loff_t offset = page_file_offset(page); + loff_t offset = page_offset(page); int rc = -EACCES; unsigned int xid; From patchwork Wed Apr 17 16:08:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13633560 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 0A10B15E200; Wed, 17 Apr 2024 16:10:07 +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=1713370209; cv=none; b=GkAvRT+/+BxHtML5IHEi3XkF28IrFyVD6fWmLXIW26YaWyyZt1d+D88syOuhOUalyBKon2Bd9gNFRzVspdb0wPSpD+Mam1wZhfI8/tOP9F33nOvq/LuM+bu5bUQaJ7lOtFrP1UQyqiVN18IJP8jN2bZXgZeZZWwW0oa35CUDiRo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713370209; c=relaxed/simple; bh=Z6E2pCl6gh7/PPQWEZWXuOAcVWTT82yYaNSwyTRO5yg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AXqif7ruL/oEutgjEkgcf4RGMGpEAbfwh7LNhSMEskEWpgFzOj5aVu0YsbnqdUvMyDKrVBRoMEiuS914oYQdRpzSu7RqwGLcuQGl/IhehFFUUJqJ/pHbHhJEvAtGqTiSB6vRHCgQ06d91N5xSXkgdA2/txjGznumhkAdzv45YOQ= 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=aowM79hZ; 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="aowM79hZ" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6ead4093f85so4895104b3a.3; Wed, 17 Apr 2024 09:10:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713370207; x=1713975007; 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=Srg4dA9RNSDxQazS93yF50nbI2bCxfJ5XfNZ+0IFk1c=; b=aowM79hZL9Ruw+wtsOLqgQPAhm4DjRKPKSwAhaHaMJzDnNWVyyQyAcnhXEQo8bDP9v sOKFhgllOodLknAFGJjEuprMnW8IlfpzybMwPrzvuQSL0ww3wgOuh1Rt8H4xmjFkFWfk WMn9RDotpQ8gonm3ArqVn2M97R4wGL8/ISE5GBp16nxtW9nOnE0y2OAeYkLGlElYtmru uJoUUGqnmoEJXFy3NdPPFRG1swlY/XYLGhduMFrfjrwwpm1FG8wVo+s6ASN8rUvy69Vf voEdPNj0JhwV4uNtjpULgWDafF/2spBjuoxm64lX/u+QxEc/637hQl5lP45dpXh95/nA lxTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713370207; x=1713975007; 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=Srg4dA9RNSDxQazS93yF50nbI2bCxfJ5XfNZ+0IFk1c=; b=bQKTN38OyqV7NyvR3FKSa0or3LwsP9jTrhUfz3Wqgl8WHDGNnj5NuQmNvxBLOLmZea sSh0Xx3GCtFCpeptcz+sXnXbDojMmUpn/nvXCu4c/sD0hyOfofTtqGuyqn/6QCe1sPMt igQPBz7IVwGw/rNw0gYCkCmas8xCou3h8oGOeZWJFcRZlvFlzESt1Aa80dwsMke8zTqh YAnUDYqnJq49umB+0lNDBQ7DdFxdayhE4WBsx5ermpZifPp1pEo1OTWFEkJMy7Iqz3vr yAcrrTW5/0Dm7BkeLnXB0vQvrU7DVaweQ3c6W6YU3lbW7eOsCSB1fKM+fHHvLWKmIk/e yNIA== X-Forwarded-Encrypted: i=1; AJvYcCVGymZQd9t7MKzwyWaDArZ0KY3/l31ZN1EYfTf8f9Y8ZtSR9K6rnCvDa0gkcTRbR7jrKnBNtd+/vzhVqDnqQ30TmAtxiVDlUtK2lQJik5zVSM1fq07SQS9Q9zRDvteSou8YjriLYuLWxyXGYA== X-Gm-Message-State: AOJu0YzJbwV1SlX/45pxCzMcoQCHXizoFDw2kI5e27X6WTJ02hc9hgJh MMnjzCOxvD+a2HJJEL2CJMvq8VtbT1EDWYivBC75wME+30IsrYNm X-Google-Smtp-Source: AGHT+IE91IYOeoH7Co4FQPgzNtFkiFYWeecE7d0F5J2GxZaKlBCPwnRQBB9VWoRDd1SCyPSrNH5WaQ== X-Received: by 2002:a05:6a20:3ca4:b0:1a8:2cd1:e437 with SMTP id b36-20020a056a203ca400b001a82cd1e437mr102832pzj.11.1713370207249; Wed, 17 Apr 2024 09:10:07 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([115.171.40.106]) by smtp.gmail.com with ESMTPSA id h189-20020a6383c6000000b005f75cf4db92sm5708366pge.82.2024.04.17.09.10.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 17 Apr 2024 09:10:06 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: 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, Kairui Song Subject: [PATCH 6/8] mm/swap: get the swap file offset directly Date: Thu, 18 Apr 2024 00:08:40 +0800 Message-ID: <20240417160842.76665-7-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240417160842.76665-1-ryncsn@gmail.com> References: <20240417160842.76665-1-ryncsn@gmail.com> Reply-To: Kairui Song Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Kairui Song folio_file_pos and page_file_offset are for mixed usage of swap cache and page cache, it can't be page cache here, so introduce a new helper to get the swap offset in swap file directly. Signed-off-by: Kairui Song --- mm/page_io.c | 6 +++--- mm/swap.h | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/mm/page_io.c b/mm/page_io.c index ae2b49055e43..93de5aadb438 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -279,7 +279,7 @@ static void sio_write_complete(struct kiocb *iocb, long ret) * be temporary. */ pr_err_ratelimited("Write error %ld on dio swapfile (%llu)\n", - ret, page_file_offset(page)); + ret, swap_file_pos(page_swap_entry(page))); for (p = 0; p < sio->pages; p++) { page = sio->bvec[p].bv_page; set_page_dirty(page); @@ -298,7 +298,7 @@ static void swap_writepage_fs(struct folio *folio, struct writeback_control *wbc struct swap_iocb *sio = NULL; struct swap_info_struct *sis = swp_swap_info(folio->swap); struct file *swap_file = sis->swap_file; - loff_t pos = folio_file_pos(folio); + loff_t pos = swap_file_pos(folio->swap); count_swpout_vm_event(folio); folio_start_writeback(folio); @@ -429,7 +429,7 @@ static void swap_read_folio_fs(struct folio *folio, struct swap_iocb **plug) { struct swap_info_struct *sis = swp_swap_info(folio->swap); struct swap_iocb *sio = NULL; - loff_t pos = folio_file_pos(folio); + loff_t pos = swap_file_pos(folio->swap); if (plug) sio = *plug; diff --git a/mm/swap.h b/mm/swap.h index fc2f6ade7f80..2de83729aaa8 100644 --- a/mm/swap.h +++ b/mm/swap.h @@ -7,6 +7,11 @@ struct mempolicy; #ifdef CONFIG_SWAP #include /* for bio_end_io_t */ +static inline loff_t swap_file_pos(swp_entry_t entry) +{ + return ((loff_t)swp_offset(entry)) << PAGE_SHIFT; +} + /* linux/mm/page_io.c */ int sio_pool_init(void); struct swap_iocb; From patchwork Wed Apr 17 16:08:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13633561 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (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 297BF14901F; Wed, 17 Apr 2024 16:10:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713370213; cv=none; b=h1n7KJrIQlKoQ7DMlQIlBnux+SyKD0LUP6U8gWmK3YhF8q5WlMXaxirUr8hKG/Diog/7pdEn8Uolesry/K2kSlAF5e+UWmnQR4oGgjtro2RlA75E/atu2Ib1u0MaV2hg2woMUFhoZMapnamoKoEtPisRlKMzy4KNPijOgIIqeEc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713370213; c=relaxed/simple; bh=5jEmnmpH4K1VGhhKveCTQ+ItuA927FSFJoiRaE+xlvY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hfGj7U6BniefFOuFCVr5WsMTGEx69xjmX3pySP9YfYfNl1eJonGQo6JvTDAiEpf2nV0fn41GFz/uFMLthmcOEMSEzLcDyOyA2ftEdf04v5BzLR/bnhTV7aub1KBSt4FFRnRnGEbO/owEbzYLt6dglIHbcnTCW2J63IvOdGndim0= 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=WCyYBqVA; arc=none smtp.client-ip=209.85.216.41 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="WCyYBqVA" Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-2a87bd53dc3so2895501a91.2; Wed, 17 Apr 2024 09:10:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713370211; x=1713975011; 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=yWtogKRbykZjVeWYRJzwDv6D8U3YfbstN+EZdpM/Zng=; b=WCyYBqVAM45DFZ74CCmCuPWB99FgBK+RwYmeOn8DcD5FEXEFRsxZAAr17nnWSswYGQ pLeDa9jAhxTA7LkGiTU2BhNRP5Oeg8RPJs4RPZdJQW3vbDaFmVLQMCGHzuV+ppnXu1xx UlQTTVh0/+rL5SssAiTZ4mIirGF3D6KsA0/f7FTgnAGtdNsa3rNZGJyT0M1AauH8N+vZ DXWk3JZ7AvHSfvrbcpnaq9drLLrkCaSFqqoDiMRFnI2Ws8Eq1OEFVumrBE0FyJyoomXL P/SZpyxnkHvuUQHzP6m5QTRLYR/iMRL+TEWuMOIzxDHrZnNsdlPJecaZ3Ckps44qk3c3 zI1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713370211; x=1713975011; 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=yWtogKRbykZjVeWYRJzwDv6D8U3YfbstN+EZdpM/Zng=; b=bcBTMtqSiaNcUzSQtICPPqi7rJeSFb59KkwFLOB9Te7NjbsreQhx8VItHGH8nk3+Mw jYAjg6pxO4YaRt+wKZZekZlDVL2elEg7CS3x+8T8gXhZBhz6tyFW4JhDF9k+oU2Q0+Bm 9dK3lSOqhX4dNqN20Fma4+8Yumr7o1f/BLPM+qL6q5411vDU1WeR1XfQVoJl0CE4RuTv atuLtmP3BAuxAOQhq9uXcI9bXyg2kfL6qNX3PQujBFrs9nHxr+1NAW3MeBnSe9fKj2da 0u1nxaI0Rq31XMWUrpvHUNrNVupY86CQNW9is3e7Quab6Wm/WN++KO9n8nC3xg2P1oWA 4cJg== X-Forwarded-Encrypted: i=1; AJvYcCXySZdsLEBUoXGz5zn3oPX310kI22t1knfzdgd0J8VnwkmM4qs4Rwd+szxpEVuw/wctwrMSnEfppteKRAGYuG4wL1T47CL1/D8OtZgS6lUWrkjYftYlwpBDX7xt40N2bHPMW+VrymxSVcqBBA== X-Gm-Message-State: AOJu0YzSlqeiKSYqwTg4c7wrYLL6HIwHtgveC+oygJcdWytlyIOi5GBl Rk9n2MynHCSwbJ/3ybv0QIrsV91KT55lkKvx8qTgbHX4ysJgJScH X-Google-Smtp-Source: AGHT+IG64Mg+h0HLvsWvmsefrKZFQIaXKNBvLrGP2U2HIqBvzsee7fMoaAAuubQ+ziUMJdC/6NC8Ug== X-Received: by 2002:a17:90a:128d:b0:2a5:492b:847e with SMTP id g13-20020a17090a128d00b002a5492b847emr13549505pja.1.1713370211442; Wed, 17 Apr 2024 09:10:11 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([115.171.40.106]) by smtp.gmail.com with ESMTPSA id h189-20020a6383c6000000b005f75cf4db92sm5708366pge.82.2024.04.17.09.10.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 17 Apr 2024 09:10:10 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: 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, Kairui Song Subject: [PATCH 7/8] mm: drop page_index/page_file_offset and convert swap helpers to use folio Date: Thu, 18 Apr 2024 00:08:41 +0800 Message-ID: <20240417160842.76665-8-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240417160842.76665-1-ryncsn@gmail.com> References: <20240417160842.76665-1-ryncsn@gmail.com> Reply-To: Kairui Song Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Kairui Song When applied on swap cache pages, page_index / page_file_offset was used to retrieve the swap cache index or swap file offset of a page, and they have their folio equivalence version: folio_index / folio_file_pos. We have eliminated all users for page_index / page_file_offset, everything 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 the same thing at this moment, but will be different in following commits. Signed-off-by: Kairui Song --- include/linux/mm.h | 13 ------------- include/linux/pagemap.h | 19 +++++++++---------- mm/swapfile.c | 13 +++++++++---- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 0436b919f1c7..797480e76c9c 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2245,19 +2245,6 @@ static inline void *folio_address(const struct folio *folio) return page_address(&folio->page); } -extern pgoff_t __page_file_index(struct page *page); - -/* - * Return the pagecache index of the passed page. Regular pagecache pages - * use ->index whereas swapcache pages use swp_offset(->private) - */ -static inline pgoff_t page_index(struct page *page) -{ - if (unlikely(PageSwapCache(page))) - return __page_file_index(page); - return page->index; -} - /* * Return true only if the page has been allocated with * ALLOC_NO_WATERMARKS and the low watermark was not diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 2df35e65557d..313f3144406e 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -780,7 +780,7 @@ static inline struct page *grab_cache_page_nowait(struct address_space *mapping, mapping_gfp_mask(mapping)); } -#define swapcache_index(folio) __page_file_index(&(folio)->page) +extern pgoff_t __folio_swap_cache_index(struct folio *folio); /** * folio_index - File index of a folio. @@ -795,9 +795,9 @@ static inline struct page *grab_cache_page_nowait(struct address_space *mapping, */ static inline pgoff_t folio_index(struct folio *folio) { - if (unlikely(folio_test_swapcache(folio))) - return swapcache_index(folio); - return folio->index; + if (unlikely(folio_test_swapcache(folio))) + return __folio_swap_cache_index(folio); + return folio->index; } /** @@ -920,11 +920,6 @@ static inline loff_t page_offset(struct page *page) return ((loff_t)page->index) << PAGE_SHIFT; } -static inline loff_t page_file_offset(struct page *page) -{ - return ((loff_t)page_index(page)) << PAGE_SHIFT; -} - /** * folio_pos - Returns the byte position of this folio in its file. * @folio: The folio. @@ -934,6 +929,8 @@ static inline loff_t folio_pos(struct folio *folio) return page_offset(&folio->page); } +extern loff_t __folio_swap_file_pos(struct folio *folio); + /** * folio_file_pos - Returns the byte position of this folio in its file. * @folio: The folio. @@ -943,7 +940,9 @@ static inline loff_t folio_pos(struct folio *folio) */ 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_file_pos(folio); + return ((loff_t)folio->index << PAGE_SHIFT); } /* diff --git a/mm/swapfile.c b/mm/swapfile.c index 4919423cce76..0c36a5c2400f 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -3419,12 +3419,17 @@ struct address_space *swapcache_mapping(struct folio *folio) } EXPORT_SYMBOL_GPL(swapcache_mapping); -pgoff_t __page_file_index(struct page *page) +pgoff_t __folio_swap_cache_index(struct folio *folio) { - swp_entry_t swap = page_swap_entry(page); - return swp_offset(swap); + return swp_offset(folio->swap); } -EXPORT_SYMBOL_GPL(__page_file_index); +EXPORT_SYMBOL_GPL(__folio_swap_cache_index); + +loff_t __folio_swap_file_pos(struct folio *folio) +{ + return swap_file_pos(folio->swap); +} +EXPORT_SYMBOL_GPL(__folio_swap_file_pos); /* * add_swap_count_continuation - called when a swap count is duplicated From patchwork Wed Apr 17 16:08:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13633562 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (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 A73E115E5C8; Wed, 17 Apr 2024 16:10:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713370218; cv=none; b=m4Gxxr2cz5kVkcFUeYyXeGyHZnjQ0L1IMs1iLkwjmUkNqJL//ihRJ+KPZ1bHQTvkrW69mIv79xNkiEOPnWBdjJLBG+ku2xqN/BqtgHLS81xO6GQgP4aUBrbYzFwqhs2EtuqMcE1yIMUeBPkOPiuoKZw9sWgWuXTZgDY4wkq8ZQY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713370218; c=relaxed/simple; bh=KZObSuUFEwiL2XUy+iHhB+jH93pxoBqjptevaEbTOz8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=skXy1NL60O8GzmfRFGO4ySlt7VQDEcNhbBtAkSXePO8v7heWczKj8WCTi23hXdD+ErhIRlzVmrtDrVNh0/DeGlWaVNBXEVYrx+u5K900ErN7lCSccVqnZcyJN1RvkC71rkrlogKq3H922ydHTFOvheI3OSjvjb3PyHS2KndY+bk= 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=OeJEf1wx; arc=none smtp.client-ip=209.85.210.179 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="OeJEf1wx" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-6ed32341906so5185147b3a.1; Wed, 17 Apr 2024 09:10:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713370216; x=1713975016; 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=NbiFeHGTwOcTfQDQTaNNyMygitoQq98RBksPTjxdp5g=; b=OeJEf1wxIGuzC3yl0ENlxK/qJA/1DRcgcB3Q+gx96qYU+KToY12kFRXRDEm23OOYPZ 2/8kq/3qZTHoEsz5qcVNTpWly8SuMJCSNKY/SN51usH85YybTjutIvDZY1y25Vf7ck4d xdY3ES619cIMZTOVOFv1BPOjDclJrMlMCJom+s3YZb1CKyKBi6kaJBDTU9Lwk2JFcWVt Ed9zh+gjLyT2RSr9/J+8g1DfINYJV4GOBJnEbrTmpzahhmHzomGK4CFpLBCmTFj9WhId 8wgoNph9gFqs5F8wTT4XXWMT1TWgZ7P9qWdVsaedJbSo5ZZb8euDjgWTM2Y0JlXhZCeY 3C6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713370216; x=1713975016; 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=NbiFeHGTwOcTfQDQTaNNyMygitoQq98RBksPTjxdp5g=; b=eqLmETcHosmf6O+bn+bjW9nfUAYrojEJnKmehTrTlQYFiG+i5HXqltm2/XKlfvLycA l5qdYEEKo6gLOqpmuypcef0fBGKSgFvQSmh8sKlQc7TqEnZt0dPNISA9JzGmdWM2txyg PoCpdZb2OoMclSs/gRpSmo2qav8v0mS9QMjEp6co+IA1SEbhqBsUjcJv/RGlMzmcW69O Gn8Q1yNjeLy/e2hKyW8swYY/gMY7vLVDeQUo6Fd1z1oTVZG0Uh7sn8dPQqhcrMu5gqRY v/5wisr+frLQ2eobg8QRZpxy5Wp5Aw+Aph2wldTjkci0VncEtTF93dJUZTagiqKm+FRs jMbw== X-Forwarded-Encrypted: i=1; AJvYcCVrt9OLPWVb7CKY4qe5cL3WkU4iScRgIPA3MEHDAMrNCCaHm9/GQqm535TdWLkruQk3L/v5Z+cS+H5U5G9CNzMiQdkrNrSJuJKPleDlUH6QF4h2klSdNP7veBCm2fOPh+ulo38pEKw5nAyGHQ== X-Gm-Message-State: AOJu0YzyKqejncWbSoZJTYZcPQq5yqEjSLoGI52hd53S5oUcIj+bT+Ha Xhj/yZ/BhU2jv1Qec64k82qVB2iUG3xo/0e+DHpFMamVhAKiVeDY X-Google-Smtp-Source: AGHT+IHeqf5gBYmEe5ujb4SeEb6/MooBt6l5k+RX+WFyCklLUnpFVTfLPyz4C4t7qhymJtByjYRG3w== X-Received: by 2002:a05:6a21:8803:b0:1a9:90e0:4760 with SMTP id ta3-20020a056a21880300b001a990e04760mr61057pzc.56.1713370215887; Wed, 17 Apr 2024 09:10:15 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([115.171.40.106]) by smtp.gmail.com with ESMTPSA id h189-20020a6383c6000000b005f75cf4db92sm5708366pge.82.2024.04.17.09.10.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 17 Apr 2024 09:10:15 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: 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, Kairui Song Subject: [PATCH 8/8] mm/swap: reduce swap cache search space Date: Thu, 18 Apr 2024 00:08:42 +0800 Message-ID: <20240417160842.76665-9-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240417160842.76665-1-ryncsn@gmail.com> References: <20240417160842.76665-1-ryncsn@gmail.com> Reply-To: Kairui Song Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Kairui Song Currently we use one swap_address_space for every 64M chunk to reduce lock contention, this is like having a set of smaller swap files inside one big swap file. But when doing swap cache look up or insert, we are still using the offset of the whole large swap file. This is OK for correctness, as the offset (key) is unique. But Xarray is specially optimized for small indexes, it creates the radix tree levels lazily to be just enough to fit the largest key stored in one Xarray. So we are wasting tree nodes unnecessarily. For 64M chunk it should only take at most 3 levels to contain everything. But we are using the offset from the whole swap file, so the offset (key) value will be way beyond 64M, and so will the tree level. Optimize this by using a new helper swap_cache_index to get a swap entry's unique offset in its own 64M swap_address_space. I see a ~1% performance gain in benchmark and actual workload with high memory pressure. Test with `time memhog 128G` inside a 8G memcg using 128G swap (ramdisk with SWP_SYNCHRONOUS_IO dropped, tested 3 times, results are stable. The test result is similar but the improvement is smaller if SWP_SYNCHRONOUS_IO is enabled, as swap out path can never skip swap cache): Before: 6.07user 250.74system 4:17.26elapsed 99%CPU (0avgtext+0avgdata 8373376maxresident)k 0inputs+0outputs (55major+33555018minor)pagefaults 0swaps After (1.8% faster): 6.08user 246.09system 4:12.58elapsed 99%CPU (0avgtext+0avgdata 8373248maxresident)k 0inputs+0outputs (54major+33555027minor)pagefaults 0swaps Similar result with MySQL and sysbench using swap: Before: 94055.61 qps After (0.8% faster): 94834.91 qps Radix tree slab usage is also very slightly lower. Signed-off-by: Kairui Song --- mm/huge_memory.c | 2 +- mm/memcontrol.c | 2 +- mm/mincore.c | 2 +- mm/shmem.c | 2 +- mm/swap.h | 7 +++++++ mm/swap_state.c | 12 ++++++------ mm/swapfile.c | 6 +++--- 7 files changed, 20 insertions(+), 13 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 9859aa4f7553..1208d60792f0 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2903,7 +2903,7 @@ static void __split_huge_page(struct page *page, struct list_head *list, split_page_memcg(head, order, new_order); if (folio_test_anon(folio) && folio_test_swapcache(folio)) { - offset = swp_offset(folio->swap); + offset = swap_cache_index(folio->swap); swap_cache = swap_address_space(folio->swap); xa_lock(&swap_cache->i_pages); } diff --git a/mm/memcontrol.c b/mm/memcontrol.c index fabce2b50c69..04d7be7f30dc 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5934,7 +5934,7 @@ static struct page *mc_handle_swap_pte(struct vm_area_struct *vma, * Because swap_cache_get_folio() updates some statistics counter, * we call find_get_page() with swapper_space directly. */ - page = find_get_page(swap_address_space(ent), swp_offset(ent)); + page = find_get_page(swap_address_space(ent), swap_cache_index(ent)); entry->val = ent.val; return page; diff --git a/mm/mincore.c b/mm/mincore.c index dad3622cc963..e31cf1bde614 100644 --- a/mm/mincore.c +++ b/mm/mincore.c @@ -139,7 +139,7 @@ static int mincore_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, } else { #ifdef CONFIG_SWAP *vec = mincore_page(swap_address_space(entry), - swp_offset(entry)); + swap_cache_index(entry)); #else WARN_ON(1); *vec = 1; diff --git a/mm/shmem.c b/mm/shmem.c index 0aad0d9a621b..cbe33ab52a73 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1762,7 +1762,7 @@ static int shmem_replace_folio(struct folio **foliop, gfp_t gfp, old = *foliop; entry = old->swap; - swap_index = swp_offset(entry); + swap_index = swap_cache_index(entry); swap_mapping = swap_address_space(entry); /* diff --git a/mm/swap.h b/mm/swap.h index 2de83729aaa8..6ef237d2b029 100644 --- a/mm/swap.h +++ b/mm/swap.h @@ -31,11 +31,18 @@ void __swap_writepage(struct folio *folio, struct writeback_control *wbc); /* One swap address space for each 64M swap space */ #define SWAP_ADDRESS_SPACE_SHIFT 14 #define SWAP_ADDRESS_SPACE_PAGES (1 << SWAP_ADDRESS_SPACE_SHIFT) +#define SWAP_ADDRESS_SPACE_MASK (BIT(SWAP_ADDRESS_SPACE_SHIFT) - 1) extern struct address_space *swapper_spaces[]; #define swap_address_space(entry) \ (&swapper_spaces[swp_type(entry)][swp_offset(entry) \ >> SWAP_ADDRESS_SPACE_SHIFT]) +static inline pgoff_t swap_cache_index(swp_entry_t entry) +{ + BUILD_BUG_ON((SWP_OFFSET_MASK | SWAP_ADDRESS_SPACE_MASK) != SWP_OFFSET_MASK); + return swp_offset(entry) & SWAP_ADDRESS_SPACE_MASK; +} + void show_swap_cache_info(void); bool add_to_swap(struct folio *folio); void *get_shadow_from_swap_cache(swp_entry_t entry); diff --git a/mm/swap_state.c b/mm/swap_state.c index bfc7e8c58a6d..9dbb54c72770 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -72,7 +72,7 @@ void show_swap_cache_info(void) void *get_shadow_from_swap_cache(swp_entry_t entry) { struct address_space *address_space = swap_address_space(entry); - pgoff_t idx = swp_offset(entry); + pgoff_t idx = swap_cache_index(entry); struct page *page; page = xa_load(&address_space->i_pages, idx); @@ -89,7 +89,7 @@ int add_to_swap_cache(struct folio *folio, swp_entry_t entry, gfp_t gfp, void **shadowp) { struct address_space *address_space = swap_address_space(entry); - pgoff_t idx = swp_offset(entry); + pgoff_t idx = swap_cache_index(entry); XA_STATE_ORDER(xas, &address_space->i_pages, idx, folio_order(folio)); unsigned long i, nr = folio_nr_pages(folio); void *old; @@ -144,7 +144,7 @@ void __delete_from_swap_cache(struct folio *folio, struct address_space *address_space = swap_address_space(entry); int i; long nr = folio_nr_pages(folio); - pgoff_t idx = swp_offset(entry); + pgoff_t idx = swap_cache_index(entry); XA_STATE(xas, &address_space->i_pages, idx); xas_set_update(&xas, workingset_update_node); @@ -350,7 +350,7 @@ struct folio *swap_cache_get_folio(swp_entry_t entry, { struct folio *folio; - folio = filemap_get_folio(swap_address_space(entry), swp_offset(entry)); + folio = filemap_get_folio(swap_address_space(entry), swap_cache_index(entry)); if (!IS_ERR(folio)) { bool vma_ra = swap_use_vma_readahead(); bool readahead; @@ -420,7 +420,7 @@ struct folio *filemap_get_incore_folio(struct address_space *mapping, si = get_swap_device(swp); if (!si) return ERR_PTR(-ENOENT); - index = swp_offset(swp); + index = swap_cache_index(swp); folio = filemap_get_folio(swap_address_space(swp), index); put_swap_device(si); return folio; @@ -447,7 +447,7 @@ struct folio *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, * that would confuse statistics. */ folio = filemap_get_folio(swap_address_space(entry), - swp_offset(entry)); + swap_cache_index(entry)); if (!IS_ERR(folio)) goto got_folio; diff --git a/mm/swapfile.c b/mm/swapfile.c index 0c36a5c2400f..2e8df95977b7 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -138,7 +138,7 @@ static int __try_to_reclaim_swap(struct swap_info_struct *si, struct folio *folio; int ret = 0; - folio = filemap_get_folio(swap_address_space(entry), offset); + folio = filemap_get_folio(swap_address_space(entry), swap_cache_index(entry)); if (IS_ERR(folio)) return 0; /* @@ -2110,7 +2110,7 @@ static int try_to_unuse(unsigned int type) (i = find_next_to_unuse(si, i)) != 0) { entry = swp_entry(type, i); - folio = filemap_get_folio(swap_address_space(entry), i); + folio = filemap_get_folio(swap_address_space(entry), swap_cache_index(entry)); if (IS_ERR(folio)) continue; @@ -3421,7 +3421,7 @@ EXPORT_SYMBOL_GPL(swapcache_mapping); pgoff_t __folio_swap_cache_index(struct folio *folio) { - return swp_offset(folio->swap); + return swap_cache_index(folio->swap); } EXPORT_SYMBOL_GPL(__folio_swap_cache_index);