From patchwork Tue May 21 17:58:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669596 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (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 7D9EA148859; Tue, 21 May 2024 17:59:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716314347; cv=none; b=fj6FXTm1d3T2hm6wVGHpAAfqZOWBkiyZP9c/NwQFtloocxhMJO189QpHtbCBvpgER3ZqDxmXCka8kCh06FL+rKaZGjYmAySKjVnW5l1W5mjTEsiGGNyAjM8xz8awoJKHaji0/JoLhQYcLgu2mtzL7I/Bt6MN6ZLRyv/GKRwDrdA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716314347; c=relaxed/simple; bh=ku8t2GgilDn0tasewSdg0prSSx3qEczJXd6flM0DvOE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R0qbQg5suJPRHycyypNYSO6UYWdV3Mejz+h+CCeBhn6jdWXtZ1gvnbZQmtPdCAPW1P5jIN+rwS6Ubm2BIHtlNzEl0JIqduxjEGFQ2g0Zcam9zn3Wr4hn6kbJZMxR/rEf7tlCOJHedjrxFPQ58N5XUGz/vd5tHMhFesyrvUohfbo= 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=Fta008Ki; arc=none smtp.client-ip=209.85.210.178 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="Fta008Ki" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-6f44dc475f4so1472461b3a.2; Tue, 21 May 2024 10:59:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314346; x=1716919146; 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=R7lhdO5v0hVN0l2qTLtMelKVtmq+aBFR854K3Ld5uQo=; b=Fta008KiV0PFaHv8K6X+/D+800H+zYqsuVnK1CrXShDpjMRoDsQlMlYeEkdnpTbMy9 SXw8LxQ03gasZ0+zKxuokJa6MhP591IAVRvmqZKZ1mZPpDxOzDkYSHbNx/ZBD2u+cxPv Bp11FyrhEniiR7kdNvaCMWy2Ouocb6jSojDT/f8KvvjxbV1+h7D53ec4uOgOMFF59+E6 Zw2CtPQbF+BwNPq6A4J4cDV4FkN6PXpoiTqkMdfQKgyKa69YOQA4JU13/s3ivhaJXAsv 76e2ukl05hTXS7MAntL6uaxlpe0zJKJWzLEdbzirag2GTECJvZtrn7LA3BZamC++4Cy6 BXmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314346; x=1716919146; 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=R7lhdO5v0hVN0l2qTLtMelKVtmq+aBFR854K3Ld5uQo=; b=ISp6+EJw39JwUQfJN74q87V6BbgFjLgYTa6eeFlquag4TpCeAVY2ZENb+GAVW0rlll VhR2nJJ8JrEmqom419YsMIEw4BgA6jfszMfp8fENA98KOLHBcHmA0s0wuNYrgAx9nY40 fN7LKKDGYIklAzcKPArMo52Zlj9Zuntg9JKxlyIW/cRbeuZRp/Kz8dNDYeBCaClKOkXI cJI585uR10WhOmpEynJLvk+uPU3oe43xuC5ppVZbSDA7WB9Uk0MaAh2wzjtet+VgLjNY pRE4o470MnZtoxpaUWAukg7GfJ1QLBYOB3vBrCtvdPHBpAoyHFxBgUGQCA5VfG9je95+ dZ/A== X-Forwarded-Encrypted: i=1; AJvYcCWDg4UO+aWx6XH/FXemPWrT9FHRTgn+coE6PJPl3xlGH62If63jOtUPVRaQ0pe5Q0zb6NFWMfLyPq1eJna9H4xqEfHOVWyuhNPtp5dCPDTdHbizIA3F53g8xQk/xxZAld5ANvmyCMZOhJ0ONQ== X-Gm-Message-State: AOJu0Yz5tze8SYWTZhS1usvpdbkQnWUDGAB+pdZVBIfOfE9DVMu9JRKi 87b1g/4YN5F0hZ9CEEyGiNr7pB30pQl2GXTFXN8uXwLXLvR8YtjC X-Google-Smtp-Source: AGHT+IEPpozMM0L+20HNGIEKpe29SmAQZrslVrxqPFNwn5ThpFi4hMV2N2JdR99RXw3BFqLPSnJwLg== X-Received: by 2002:a17:903:245:b0:1e4:4ade:f504 with SMTP id d9443c01a7336-1ef44161e45mr347769925ad.46.1716314345665; Tue, 21 May 2024 10:59:05 -0700 (PDT) Received: from localhost.localdomain ([101.32.222.185]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f2fcdf87besm44646935ad.105.2024.05.21.10.59.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59:05 -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 , David Hildenbrand , Hugh Dickins , 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 v6 01/11] f2fs: drop usage of page_index Date: Wed, 22 May 2024 01:58:43 +0800 Message-ID: <20240521175854.96038-2-ryncsn@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240521175854.96038-1-ryncsn@gmail.com> References: <20240521175854.96038-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. [ This commit will not be needed once f2fs converted f2fs_mpage_readpages() to use folio] Signed-off-by: Kairui Song Cc: Chao Yu Cc: Jaegeuk Kim Cc: linux-f2fs-devel@lists.sourceforge.net --- fs/f2fs/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 961e6ff77c72..c0e1459702e6 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); From patchwork Tue May 21 17:58:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669597 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.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 F2F50149015; Tue, 21 May 2024 17:59:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716314352; cv=none; b=W6XwCj/RD0S2eFJlWlXijNQPjs59HqLDxCtUXtHojYPBb6j51l+KF3g3y2MwDC0LlCElXDma/Rogo/REbSxktx3V+tM507avYa+oAiD4gbUrp4C23W98o6ZmKPlfd7LSm+QjmfSyXEqRpkH+rBTK66V6RlvZbcV2tWlqB7/HqdA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716314352; c=relaxed/simple; bh=9nVCD8ADnlgjsIYAZwlJG/eJ9+TUZ5nuVmBLfa+tbeg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G97xFckkGYsrVqaKEjWDlKObmR5r9QwpwoA0sezELBKlQt1IsNtPo22aVj9/EsrKnAr42sY9/DH/FNlH37Ryz5q/nPZQeB6lF51vxDOfzwT10AFzDazc5kZ8YaaA+1OwuRw4rdF1cQ3sErktxuKrZsDvXmBmLdGNBKlA/hNUtL8= 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=AXdbpYbE; arc=none smtp.client-ip=209.85.214.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="AXdbpYbE" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1ec69e3dbcfso3509225ad.0; Tue, 21 May 2024 10:59:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314350; x=1716919150; 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=xFpAHzqRgSiz2xm2CXznKixemcT6aD8kBzQB3tTCfzo=; b=AXdbpYbEAfuLEYRX3SQzUbJMqXNn7QUJotHE1x+yFtvoQ/xFFZMYW8iIrBXs1WlN64 P2RDDjgYy/b/Xqoy8DCSi+sXfF5HnyKf3Y+Pm4DbR6Fv2a/WKjz9stNobOnT6dt9qWfY 747qO0TrioFx8vR70JWNNO5y74x61vAiA9J7hN7fVxczEcWq6jJl176VAhdmngL3Bn5B FZiufn9FLz6fC8KXbsEy7Wj8ZukIMHaDAwYDlrOn4B4/uiulLb5fAYA4ZLB49sPqmiCv XLVVJVrPN95nyTMRlpt6Lgl6gVgQjobIJm7kjniFAb95Q/TQdCWdqUSTMcATgfJspI5B X99g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314350; x=1716919150; 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=xFpAHzqRgSiz2xm2CXznKixemcT6aD8kBzQB3tTCfzo=; b=carrzeq7+mbLdNgEfPanGcROCz/qJK1mJRKxja4Kp1uJvGfXKC9caYtQq/kOn9RrJi oCJ+ecxTo5hIKdAB2LJzPtx8tEgPIlVlOY+rcLQXkTHGTO+2uRV9X3Clh7ZTMhe/nVoW xxW+LcmKMVgXlboWhLApwMEGUkIo5EMM/1zvD4/GEPZeIC3bEKUI26ww/cxEOxvyVCj0 /Hp8u1gzpsYByjQZ0FHmfXnTrbItTZzUz4yztCC9KmSeWAQhe8CohTjiYpBsl8UmWVDZ 8P0u7euCec2DgTLJkvSnGg6UDJ0uvlTc86BcWvUcjdE1imVeUS3VSDQSHltbUwslj6ix tYDw== X-Forwarded-Encrypted: i=1; AJvYcCXOSi4xS1qlfdBtXA3dh8x0g4TC+9UqzYA7y/HjVlNaRWF3kghhEFeMUS+/28h3EKkxUH7lsWLpM+LYA6eBpsLeYBcIN1z7xI6eO2Uz+p/e5hVrh9Ghq/lptEeTZvhMyS0K6xS1MFNtKkplAsn8ETbbCWFEJTUfBopZuSluFYlP3QUVwvIkl+0H X-Gm-Message-State: AOJu0YzM2IBt1WEmI0AMBZxb/ucuIis/KTQPsBAeRKwT175eba5rricv rfNSdp03G8+XvJmo1t+crw2EiorgSm73Em6bUw9YMKImCoPZ6dHG X-Google-Smtp-Source: AGHT+IEQVix1xCQAJ7lu1JC4bqBxGgwlzW9PigTCcx2l2HRAdtg3GNuIH6M9NtM55RShJgSvR61swA== X-Received: by 2002:a17:902:c407:b0:1e4:3b58:7720 with SMTP id d9443c01a7336-1ef43c0c962mr357191475ad.2.1716314350150; Tue, 21 May 2024 10:59:10 -0700 (PDT) Received: from localhost.localdomain ([101.32.222.185]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f2fcdf87besm44646935ad.105.2024.05.21.10.59.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59:09 -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 , David Hildenbrand , Hugh Dickins , Yosry Ahmed , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Kairui Song , Ryusuke Konishi , linux-nilfs@vger.kernel.org Subject: [PATCH v6 02/11] nilfs2: drop usage of page_index Date: Wed, 22 May 2024 01:58:44 +0800 Message-ID: <20240521175854.96038-3-ryncsn@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240521175854.96038-1-ryncsn@gmail.com> References: <20240521175854.96038-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. And while we are at it, optimize the code by retrieving the offset of the buffer head within the folio directly using bh_offset, and get rid of the loop and usage of page helpers. Suggested-by: Matthew Wilcox Signed-off-by: Kairui Song Acked-by: Ryusuke Konishi Cc: Ryusuke Konishi Cc: linux-nilfs@vger.kernel.org --- fs/nilfs2/bmap.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c index 383f0afa2cea..cd14ea25968c 100644 --- a/fs/nilfs2/bmap.c +++ b/fs/nilfs2/bmap.c @@ -450,15 +450,9 @@ int nilfs_bmap_test_and_clear_dirty(struct nilfs_bmap *bmap) __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap, const struct buffer_head *bh) { - struct buffer_head *pbh; - __u64 key; + loff_t pos = folio_pos(bh->b_folio) + bh_offset(bh); - key = page_index(bh->b_page) << (PAGE_SHIFT - - bmap->b_inode->i_blkbits); - for (pbh = page_buffers(bh->b_page); pbh != bh; pbh = pbh->b_this_page) - key++; - - return key; + return pos >> bmap->b_inode->i_blkbits; } __u64 nilfs_bmap_find_target_seq(const struct nilfs_bmap *bmap, __u64 key) From patchwork Tue May 21 17:58:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669598 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (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 CD1D6149015; Tue, 21 May 2024 17:59:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716314357; cv=none; b=e8+8YuCXjaTOTUucgOvmsU4G1Clx4VCMkqRRcyi5t0A8HPp8FiQyZFbVg3y+JWc/NmSCgu0NFl1wqZx73JpiY/NsacL2ItpOBdxMzsKLLkDpT6UcRNRBu9bivRcht8nOqztUQUiSZTUKJM4qzedhvrrPO8W2By7SrpCeRCRNATM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716314357; c=relaxed/simple; bh=pF5hHy19sUckxhcdMkEFs5kvEYZ//ekSfwCm69AGbd8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QCXmVROmaCnzayYIKNHJ/IDtt+WZXDyNLEMMV9VMVHUDsbQCJ8FUe4uyOmhtGrYEovnd4702g3NVYB5WZQgtZfBJS5SUUccHQ45NKJgmEY156gJrJgaEv5Q7KupSyGRfJjBbAIBIQPwJRnDjDbq1YUXY7ryPuMfIy0UfpPcDMmM= 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=fDPzEdJG; arc=none smtp.client-ip=209.85.214.171 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="fDPzEdJG" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1ecddf96313so94011325ad.2; Tue, 21 May 2024 10:59:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314355; x=1716919155; 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=XI4mdMYQHMDzDk9xWjXkWCPqz9rl1k4l8GTTN28ztKU=; b=fDPzEdJGcl1Fz/kN3HfWEEnx2idgTNqCtf/oyANLXEZ2E0dwiZeD+LOI6YXcxmNH6F TDazD1T3afBWh30KLXROF7f/WEal+MolYq5UrvbHQDgoTOPRds/X/hrYDdYB+0u3Hkz4 YNzgaqySRGffuOBS6aESxl8ICdytzBtyrpxkPJ2GnExiFXVPi+BtVKREz5aOnc17NhJM xl+5e08S6JofsYUNZ03UmXTIymgk4NUfYtuaRg5uPkxF6lLY5O7YFlgW9acSt5jyfKxh rAOAb0Ccby4tyO7L/7BhQ1k4aZZ8UEOnMlOgKjZtlPfFDsl4Q97/bAKcifBwx5gO8hrn FOKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314355; x=1716919155; 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=XI4mdMYQHMDzDk9xWjXkWCPqz9rl1k4l8GTTN28ztKU=; b=nLxP+cx6+e+GTRynXC6lWmixWQHJKol6kKeUjb0Xt1kkhRYQbsOa7+I4kbBNNq9bbl UWAE8TUL0+zCx6lUEoKyEnvU1ALlw+MAqTjJSAEIdTf8m/sQ1/GdM+QRF5WcbJPU+G7w RDY5QPncs0SUO35mrKOCgtqy5NZvB40AZAqTXpSLUfrgEQZy5t583IZmikVfikDo9/GE tusem8J22buhmvmVr286hUAkd7Lad7ycbV+/1092e8nDncNTl4idrurRWpLI01zN1Ayl 0613zkPVtAv2KdRytjFVWqWu672lCjMvbI0xgqdfOB77qNbQbj803OOpYheqTgeNqxy3 Q32A== X-Forwarded-Encrypted: i=1; AJvYcCW7oyNOnXJcQdaAHd+uDzs07Xyw60xKPFKJDgQH2TjwiJnfjuLclw++hNdE1K1YPMU8eekEoI4RErFvIZ2YI0u2FHFeeB5+7jIRdOWAA1iW9dZUniPae2TpNMjOH751ZCjBHA9zIi38IotLdG/n+7u8ok/tIVVHS8ewp9iwYllWC0YUUnjF92g= X-Gm-Message-State: AOJu0YwswMk0AkMFUhrImb4zSQB7tmfHGRRe4m6stqrIEyJxHD2pGm+R /dOw/UAnjQ3944ETU0X5wWpH9LtRW2WTXULKFVixGJu0sUe1aFuh X-Google-Smtp-Source: AGHT+IHhaw8cihGDeGD+zUXeJgbKIcB5gsMYz1cB7sCZetbMXuUWE1Yeub/1vlqxEDZ7M5X2P6lZ2Q== X-Received: by 2002:a17:902:7845:b0:1e2:a807:7159 with SMTP id d9443c01a7336-1ef43c09602mr364682635ad.6.1716314355180; Tue, 21 May 2024 10:59:15 -0700 (PDT) Received: from localhost.localdomain ([101.32.222.185]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f2fcdf87besm44646935ad.105.2024.05.21.10.59.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59:14 -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 , David Hildenbrand , Hugh Dickins , 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 v6 03/11] ceph: drop usage of page_index Date: Wed, 22 May 2024 01:58:45 +0800 Message-ID: <20240521175854.96038-4-ryncsn@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240521175854.96038-1-ryncsn@gmail.com> References: <20240521175854.96038-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 Reviewed-by: Xiubo Li --- 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 99561fddcb38..a69570ea2c19 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -1863,7 +1863,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 Tue May 21 17:58:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669599 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 BC99914885B; Tue, 21 May 2024 17:59:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716314362; cv=none; b=oXHsQIQFnBg+LXZ7hLMLHfR2i/ud9OFpmDHNArhrrITme3avI7r4PhP+1GZoRmVLJjbcgSzKpu8cA2h3o/RchNE5OndIJizltCg+V7DlfppnzxFrBe6UiIkKyq7MJw9LjYIAzOcKWxnIIYkob1kXugr6XWKgGV/80i1fEablmIU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716314362; c=relaxed/simple; bh=ShAn5fhCYPl8qlhBHZU43ypZj6BFHQvlTb/1BJsqubw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TacF9syJ+Wq0aSOsn5OL8EwSmqgQjAkUnevKHN1bSLSgje9le7EZQJYLAUsYKQizLiJee6Lk7LJCyDcOVM//eww9gJ4iYycdzqVbl60oX3fYQF2Jd6Zccs4K2m+3QL6AK6nMFaa9/GurpePTmCrAzQIA7bGct5d9leO/FT5pPSs= 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=AiAahNAq; arc=none smtp.client-ip=209.85.214.174 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="AiAahNAq" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1ed835f3c3cso3881045ad.3; Tue, 21 May 2024 10:59:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314360; x=1716919160; 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=T/Y01wUoc8GqRpvXAplln3XTaKFYbBI0hlcfHL66MPg=; b=AiAahNAqpArWDRE8AbpeyAaitqGUv6JLlT/9Cr25UxYKzlwvOAZz4eIxTRSD9p2Zyo oRSMMLvsYoTH9A0IMUfsyvWTONiEzodtL0CEiCv//R7KqXn2UnNia7UjRdeIzF7mhZU0 bF510YgbNmVdqppkDYf2/kN7s8pmDlBxmlkpoa6eJ/TC8UZje0v5F/CiP9HoOBBUgcEp ggD+jRrhKzqW+wuh9At2MVtU4oqH0mUdpjJJUD6KlnPByEHDwoWuVVJC824zhmge6hpO iNzhsOaAiSuhJC2EY0AqoIU+3NFtsRzNzJgymKCMrCmTeWa9mJRTzhkxbqYLdhEFnNRu 6SgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314360; x=1716919160; 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=T/Y01wUoc8GqRpvXAplln3XTaKFYbBI0hlcfHL66MPg=; b=FxRdsdNVKUyl0sl8qjGUJPwnSlOyS1k98skj1C4KDbVO+q7hejr0y3+x6aM3NGzRfX Jr/4dgq5lp8xeQTwKi3QfGl76hUC3mV7jVv+DXCUdi9a2qqFOX1NJkiWPffQzYJ4oTCA Blj4Lto4h2U907Ya3TgO4sMPlboH1y6kOzET/gxYUXnq/cx73FgnRoufNV2Y4y/wMrTS Y7SXQmnKGDk6ddnFEXx1PiPjpRrL2uBtFKzfU1sDsx6eQ7ehCcKKKJRdXwNlknNp2Hxo 0IlJHTLsOdYwMpHTfYDp7B3QQbulEDajipDFn8ow9agQgTbx65IBxq1kNrXXF8fcU+6g mFCg== X-Forwarded-Encrypted: i=1; AJvYcCUH4C5WXiImIQkhU1U3M7/wu45azEVCs09obulQXrvyRo9HYnpCZL2rsmqSL5ARMgu4PVXu8lpIkPZtoPZL2rd2xngiIZZQUO3S/Jp+vWgUhH2VaAjldu8RunyJTujtCNyy5iJ0pl7rEMnZohNZzJe11UKT4mwr/r2ZJr89Jkha8cQ0AuKjQA== X-Gm-Message-State: AOJu0Yy8mgTSi+uec43/R3ZIrZUdzNckcXqVoUpV7dZ3sDm7vE4dAMmU V1JGmaC6IzV45+fLpnacbb5FCXasbz19z5k0wyGjWYfWVDDsEvwL X-Google-Smtp-Source: AGHT+IHoEUt/0l1rn7y24nEEjHG5IB3IdC9BGhTGoiXG18qSAHAVRm5IJU0l3mpAfVMLarJhvGzQmA== X-Received: by 2002:a17:902:e847:b0:1f3:21e:23c4 with SMTP id d9443c01a7336-1f3021e275bmr80072115ad.21.1716314359988; Tue, 21 May 2024 10:59:19 -0700 (PDT) Received: from localhost.localdomain ([101.32.222.185]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f2fcdf87besm44646935ad.105.2024.05.21.10.59.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59:19 -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 , David Hildenbrand , Hugh Dickins , 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 v6 04/11] NFS: remove nfs_page_lengthg and usage of page_index Date: Wed, 22 May 2024 01:58:46 +0800 Message-ID: <20240521175854.96038-5-ryncsn@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240521175854.96038-1-ryncsn@gmail.com> References: <20240521175854.96038-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 Tue May 21 17:58:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669600 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.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 72952148FF1; Tue, 21 May 2024 17:59:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716314366; cv=none; b=VF349zFHFZJf3AF8UNYhoaEN2kH4BkrgVME7sGvJnMQaLiztUpwUwv2DGcKcMk6BG7+wa+Pn/h2nr9ruCeA5h/jLVpphEhevbd8TV9nQL07AC5PIWBPQDQQPnRIcfC3EfG4olAAFBiReVndpqZOsGj0oDIkE7ORAXLUZS76HBvo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716314366; c=relaxed/simple; bh=1MRIiBP0wDFyNfh4532Vxucv6112mEx/goVx7Jaownk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cJ7wv/Sr2g76zg4v5JUVIyC3loWcb+pdMTNrL0kZSxIN24aAntpWKeE7HH0GX1plhGQeELjo38ClM/cq3jjYw28FYZeA9puAZNA54I2QepWv5fW0YouBH2P6R8t1ESXbWoC+MdmLVv3apYDcfl8gkYRy0lF0vj0NwnhOgRc0kPs= 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=Jd4qPjh7; arc=none smtp.client-ip=209.85.214.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="Jd4qPjh7" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1ecddf96313so94012535ad.2; Tue, 21 May 2024 10:59:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314365; x=1716919165; 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=P42QJurgga8X3tClV+VU5iyd0pTaBz/Ss0EAkzfZsy4=; b=Jd4qPjh7XF3FpqO3jJ1mrhTFtw8Q5Z7RA9eTKtPSrTyX6r5XvLx5A/HCdHylRWEWWb 3EKV6BRMrVrBxmBHJtpA/78GpLuRslIS4RYmnGUlgvLYoWZHjsgWO+wi5kIgZiMK2Eps gOE0pDGPSHHzoCelzQAwM5mr2UrdfLVzIngUyn8HHHjjsGo6MY8B8SwbUOHI78EyDkx1 HbT/y/5U3167TE/o2pNmo73H0ETSULZ3V9plGxdk53UhK4fPjTPZ39HISS92E00H1LN9 h/l/227k96h0Mz0kKlUejJYvRTLfdpGJZiN6WTr78xyT3wjUlNV6d78uCk2Ake+JjnCW SSNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314365; x=1716919165; 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=P42QJurgga8X3tClV+VU5iyd0pTaBz/Ss0EAkzfZsy4=; b=T7m30ppjskFUeC2yamRf0fRr2+cfXdaiHJguwRw5ljJxGrDrEDJ3we2gaRcDTkHdH1 XXKbopOr8Bf1MFc809aj2M/KmhsYNYEVv6QAH8fqogUs02t3xEdofNb4uVXN1l/OlS18 V0t4pXyhfMjahMnX1AMGIaa8JcFPMcLzEONWsTgiacuy/aFs0T4HGYCYGEZ8lKSaSsN/ BHhBd9Xufu3mEZbdPMhNMJKGyo1Rs721yGJvrQVwDcukGTfBjprvaI3QAyOHHulWnj06 GI9/aJGJjgazEK35+5pn5jkVNSQ1ICR1MQcbN1MojQZA98agprOd5RPF/Ud2oz/Xl79f XYCg== X-Forwarded-Encrypted: i=1; AJvYcCXtcnEktI3AeCFifikeYkOqWMeAtWADAsIG8V1JJj84mG6qeno7nMfKGPv0eWwfKj6teDqOPqLna7twHNjQAFQpEi+JEftA3/9uZPyvEP2KewdbmqU9Elh725jYCNI3DwAjigfO5ggLECFQrw== X-Gm-Message-State: AOJu0YxBmS0DxLYL573p6gTrdGbMxGBdoiPWFoB9npNMEAJcgAEpLUgw zNNjFhtvFskHXOyYrD3Q7ZejFWOu6UOnr9XysuoevYOPHk0gMXI4 X-Google-Smtp-Source: AGHT+IF1cRebeOkZju1vxHpZ1ZTdsLqq2r6EkmnYiCv6kOq5t90eVHUHeUPz1jz1sKsUOH9AfM/KuQ== X-Received: by 2002:a17:902:760e:b0:1e5:a025:12f9 with SMTP id d9443c01a7336-1ef43d2836fmr395328615ad.28.1716314364758; Tue, 21 May 2024 10:59:24 -0700 (PDT) Received: from localhost.localdomain ([101.32.222.185]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f2fcdf87besm44646935ad.105.2024.05.21.10.59.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59:24 -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 , David Hildenbrand , Hugh Dickins , Yosry Ahmed , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Kairui Song , David Howells , Marc Dionne , linux-afs@lists.infradead.org Subject: [PATCH v6 05/11] afs: drop usage of folio_file_pos Date: Wed, 22 May 2024 01:58:47 +0800 Message-ID: <20240521175854.96038-6-ryncsn@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240521175854.96038-1-ryncsn@gmail.com> References: <20240521175854.96038-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 is only needed for mixed usage of page cache and swap cache, for pure page cache usage, the caller can just use folio_pos instead. It can't be a swap cache page here. Swap mapping may only call into fs through swap_rw and that is not supported for afs. So just drop it and use folio_pos instead. Signed-off-by: Kairui Song Cc: David Howells Cc: Marc Dionne Cc: linux-afs@lists.infradead.org --- fs/afs/dir.c | 6 +++--- fs/afs/dir_edit.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index 67afe68972d5..f8622ed72e08 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -533,14 +533,14 @@ static int afs_dir_iterate(struct inode *dir, struct dir_context *ctx, break; } - offset = round_down(ctx->pos, sizeof(*dblock)) - folio_file_pos(folio); + offset = round_down(ctx->pos, sizeof(*dblock)) - folio_pos(folio); size = min_t(loff_t, folio_size(folio), - req->actual_len - folio_file_pos(folio)); + req->actual_len - folio_pos(folio)); do { dblock = kmap_local_folio(folio, offset); ret = afs_dir_iterate_block(dvnode, ctx, dblock, - folio_file_pos(folio) + offset); + folio_pos(folio) + offset); kunmap_local(dblock); if (ret != 1) goto out; diff --git a/fs/afs/dir_edit.c b/fs/afs/dir_edit.c index e2fa577b66fe..a71bff10496b 100644 --- a/fs/afs/dir_edit.c +++ b/fs/afs/dir_edit.c @@ -256,7 +256,7 @@ void afs_edit_dir_add(struct afs_vnode *vnode, folio = folio0; } - block = kmap_local_folio(folio, b * AFS_DIR_BLOCK_SIZE - folio_file_pos(folio)); + block = kmap_local_folio(folio, b * AFS_DIR_BLOCK_SIZE - folio_pos(folio)); /* Abandon the edit if we got a callback break. */ if (!test_bit(AFS_VNODE_DIR_VALID, &vnode->flags)) @@ -417,7 +417,7 @@ void afs_edit_dir_remove(struct afs_vnode *vnode, folio = folio0; } - block = kmap_local_folio(folio, b * AFS_DIR_BLOCK_SIZE - folio_file_pos(folio)); + block = kmap_local_folio(folio, b * AFS_DIR_BLOCK_SIZE - folio_pos(folio)); /* Abandon the edit if we got a callback break. */ if (!test_bit(AFS_VNODE_DIR_VALID, &vnode->flags)) From patchwork Tue May 21 17:58:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669601 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 4C7A9149C7B; Tue, 21 May 2024 17:59:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716314371; cv=none; b=OLjyXzo3dLZ3o4ft71jnh1NyP3sbhcBx1WHPQeGTkTS21VkfOFsqatLl2gTDXa2OjuYvyqtIFlcmBLVub7eDSpO+k/ebD5QdiIAWNf+kxZFUwgh3kM98247X2Eu+XRzbvOkMy59OvopA6YflWPcm0F4nL9ZXSpbwz3RuMZxG3kw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716314371; c=relaxed/simple; bh=8KtNWQs4oLqQnrcIx6ZN5romD3/jWxvpvKP8KnV42Ts=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qeW8hKsYvlYwbF/AeCiMgZV99W59IYpt9dv8Z1zaNe/zYBzBBH9Eef0qodkEazvEsxuvrY095Aqb1KVl4vv0mI8gEgxFrX9TfXeMGECkwO4J7/SPjIoHHUOGt5t9mkEAgG+QzBQVdZOiOcXjcSW9vZcixwrH6JC6084Z2BKXX6k= 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=SsjB+EgM; arc=none smtp.client-ip=209.85.210.175 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="SsjB+EgM" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-6f4d6b7168eso1236505b3a.2; Tue, 21 May 2024 10:59:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314370; x=1716919170; 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=Xg2lyZdavS/xqDWMBFosXrNzMBl51D2SBqOTVmsbmqo=; b=SsjB+EgM6JpeXYoi2RagpAzFrqDKZzoEdhEMIuZhRuyIBKaPTzx6r4ldGnaPyUVmqC AfGVrk+64xThVHddEooYZq0tkBDLrKZneNenleWuKRdv9563oa/gpKrLzMVGNxtEryvb XAgf547/0bLTFDaHfqkNoKhu5XhkjjGz+wCPClSCxBJEkLMFMKxkTX177bRqtLFuJPrO QUGOCqOYoSB4rygmS8dpzIPlJ8c1VeDLZY+jxgEXy6y/sN4UUQ5AzMu1nlyi8XrXFfGQ xIURi91VO9LojZUeU5U0iDsw9hTABU4uiljwdxk4Pi/Ci1EVbBX6T1we1qJzF4dyMUdi LXfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314370; x=1716919170; 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=Xg2lyZdavS/xqDWMBFosXrNzMBl51D2SBqOTVmsbmqo=; b=GMiKRoL9mDk9zKBM3mBpjdj2uQ8FllVEMqwl4y52veRNOhBt6vVSQyUyNIg7dKIEqf jZMjWg1CR0WxkyKIhN8uFdyF7a3W1AB6KtzAWHhzCttf+HFARebrFnVpng8Rd+Sl+dJH p7Pos9JRat0bhPYZ9hHdMTOjh2s3lNTTwSDC7Wss+NFW/Xb4PHDieB1SykfKgcIog7uv v6urvA8BVLha9rz8js/Vu41zKYCSEiT8hjR39U2+c2dtTbhh9EQlCae92ZX+B7uL+ctU UqwDGaY6oYtKAzC7FiabMWpThk/FE/LauWbn5bjaKVowze+zeFaf3MZjU+1jXo/11AlW IShg== X-Forwarded-Encrypted: i=1; AJvYcCU1GTfnl0C4A/BXr0qhdnIAgRiMsLNtgdD/ZXLxAqSGE0yXelF7yfz8yKrY58AagI+SQUgksLzwYR/Hse7+O0P5Q18gH4q3o7Xrj/0GM9srkriWr/6zUgOKGyI5Sk2T7aXKfGkjMkMhTYbcpg== X-Gm-Message-State: AOJu0Yxh0MZHNv8ODBh31yuymGW0BX48uCzHduYqfe+SM8xqguYY6xHa 1d3U79U1ejqtDD2N6B7kIuMQ6mWvsmbCH0TehnmCD8DQKoeTf+9e X-Google-Smtp-Source: AGHT+IFJcbaL2RYoor2pNfsZrFdmKgf74KAMgNVGow1v7hTBzhmhyuQsxHRR2tBe0moomC0BGjEz7g== X-Received: by 2002:a17:902:d4c4:b0:1f2:eff9:cd4 with SMTP id d9443c01a7336-1f2eff910a4mr117995375ad.0.1716314369672; Tue, 21 May 2024 10:59:29 -0700 (PDT) Received: from localhost.localdomain ([101.32.222.185]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f2fcdf87besm44646935ad.105.2024.05.21.10.59.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59:29 -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 , David Hildenbrand , Hugh Dickins , Yosry Ahmed , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Kairui Song , David Howells , Jeff Layton , netfs@lists.linux.dev Subject: [PATCH v6 06/11] netfs: drop usage of folio_file_pos Date: Wed, 22 May 2024 01:58:48 +0800 Message-ID: <20240521175854.96038-7-ryncsn@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240521175854.96038-1-ryncsn@gmail.com> References: <20240521175854.96038-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 is only needed for mixed usage of page cache and swap cache, for pure page cache usage, the caller can just use folio_pos instead. It can't be a swap cache page here. Swap mapping may only call into fs through swap_rw and that is not supported for netfs. So just drop it and use folio_pos instead. Signed-off-by: Kairui Song Cc: David Howells Cc: Jeff Layton Cc: netfs@lists.linux.dev --- fs/netfs/buffered_read.c | 4 ++-- fs/netfs/buffered_write.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c index a6bb03bea920..a688d4c75d99 100644 --- a/fs/netfs/buffered_read.c +++ b/fs/netfs/buffered_read.c @@ -271,7 +271,7 @@ int netfs_read_folio(struct file *file, struct folio *folio) _enter("%lx", folio->index); rreq = netfs_alloc_request(mapping, file, - folio_file_pos(folio), folio_size(folio), + folio_pos(folio), folio_size(folio), NETFS_READPAGE); if (IS_ERR(rreq)) { ret = PTR_ERR(rreq); @@ -470,7 +470,7 @@ int netfs_write_begin(struct netfs_inode *ctx, } rreq = netfs_alloc_request(mapping, file, - folio_file_pos(folio), folio_size(folio), + folio_pos(folio), folio_size(folio), NETFS_READ_FOR_WRITE); if (IS_ERR(rreq)) { ret = PTR_ERR(rreq); diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c index 1121601536d1..b3a6b7b41192 100644 --- a/fs/netfs/buffered_write.c +++ b/fs/netfs/buffered_write.c @@ -54,7 +54,7 @@ static enum netfs_how_to_modify netfs_how_to_modify(struct netfs_inode *ctx, { struct netfs_folio *finfo = netfs_folio_info(folio); struct netfs_group *group = netfs_folio_group(folio); - loff_t pos = folio_file_pos(folio); + loff_t pos = folio_pos(folio); _enter(""); From patchwork Tue May 21 17:58:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669602 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.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 1C899149E0A; Tue, 21 May 2024 17:59:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716314376; cv=none; b=Ng4HTDChqJag1R0119Rd5cIcsGlrvt0nSRs44LmYU42FeECGBfrypoqNRVnrhrInyKbMEz5wQoFeI5Ee1ijtAuMowyZ4W3eYK1T4WJhmlPRv96lBqnj3PuGkllVJK5Hpx3y7mCdktqM2baHebpydmm0YkhuqGUjOGz49z9Sws7M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716314376; c=relaxed/simple; bh=FFy+LiTwedpRsIyT68peUiF1eFVcwa9s+FW1r2ahYc0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lhjSuyj5xzostL2YYLt+fNZTUrtw4V7HCI0ozWLN4aOsxaSZUdcn6i8KcuHTzNkV5p30YeEOBfNcLJfj6xkdf/uFiFjKqCw28hvy5KVlxAz0xhvh03vqBaAc0EoDJOSHE8CDGa5ecOHfLeeBisTx1qtSFAFkXOUWGVHWd57JzQg= 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=ONr8ZiI5; arc=none smtp.client-ip=209.85.214.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="ONr8ZiI5" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1ecddf96313so94013695ad.2; Tue, 21 May 2024 10:59:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314374; x=1716919174; 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=vrfVlxH6/yrMp6Vv9D3jm93+yp0/ZPJ6N0ZTxwsTE5E=; b=ONr8ZiI5O3OxDZkAjSR8dOwxsI+xG9sJZ4seyyS2xLAr1XQSQIy2waK4qxNmh6bZE5 18b5mMaOJ/ICcI8LPr+IVlk4pCOzrmY7i1QhgFLj9FokafC3f5z2RcUnZEVl7RzCd2e7 YiRyF6BojwJWZsA0TiTBHqmI2SVrIHKuQsZCGL5ebvZ6KZAeCve2kfIQJYhDc+E+qS/3 OjLxn2SQ3ketIPU9GkUQzGV3Em1sMtRdrzpZsLTCrU1M/wkLg2VpI8matrZy86E2uvlm LHJc3JHuEQz/rNNAS6LGzLsEXy4Mxc/xlLPlWPj11kudQPaPeKXIlBpUUWjcWsouzThY 08BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314374; x=1716919174; 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=vrfVlxH6/yrMp6Vv9D3jm93+yp0/ZPJ6N0ZTxwsTE5E=; b=DOT7Fs8l7r3/TLhBUWo8Zxh+E0LbXwjRdCpWSEbFUlrBNA4hDFqI8CyJJyUpV/22Rz wtmxajUQvWnG7m6Kn0LDQmnCpq9/VKA+a9WreFXHQAODK6okTQXeqa+3+2+uGNJ3XzVU C5DVzDuOEApJmZQWSY7RbtxdAtD5iaJaDQV3x91hcElJ3ddxtgN+4pWFohmQw9D6LmwR IlZWMKDrd+Dc6PsXHs2nb9NjnhXKQqxgcy48tJgnD2xRrWB46Lgyi/diNxX84ozunusQ C7vgKK+fLSVEVa9yb82HheMhmNwU6vxgXuMQ6mUuBLT60TAWgRBLZQoUcm6C+XrKX+b/ x+jQ== X-Forwarded-Encrypted: i=1; AJvYcCX/GkfsLLq3YiF+8woKuQM4hRonoVYtbdTh457TyjSk1b1NaGDr0gqFZXgXP+JMVg5KKoOIduAnuxyRT2eR5QYNYkXHsb3vWQlew92SSpPL/4a4SggQxJ9/vwsocJ8MxZz4w100Nr0/DVaUW188TxWjNWnFIDKhUkzXzuTP5e+nDx9g1rFQBg== X-Gm-Message-State: AOJu0Yzg7fyfuIycjeXVQzdaqaRccVMt220xU9UBqgILgJcRt8qrklEN 32PngBE0Ktjq2G+Pkdwa+DMFVCREVJ4UUfDFBdLJe8ARf8B6iuw8 X-Google-Smtp-Source: AGHT+IH54wg5eRYpZnCkwQreGAMbgDD/WonVhjZ99mB7DacBqGVRwQ0mpsTZPZ18Q+815AsjuwwFeQ== X-Received: by 2002:a17:902:7845:b0:1e2:a807:7159 with SMTP id d9443c01a7336-1ef43c09602mr364690065ad.6.1716314374422; Tue, 21 May 2024 10:59:34 -0700 (PDT) Received: from localhost.localdomain ([101.32.222.185]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f2fcdf87besm44646935ad.105.2024.05.21.10.59.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59:34 -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 , David Hildenbrand , Hugh Dickins , 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 v6 07/11] nfs: drop usage of folio_file_pos Date: Wed, 22 May 2024 01:58:49 +0800 Message-ID: <20240521175854.96038-8-ryncsn@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240521175854.96038-1-ryncsn@gmail.com> References: <20240521175854.96038-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 is only needed for mixed usage of page cache and swap cache, for pure page cache usage, the caller can just use folio_pos instead. After commit e1209d3a7a67 ("mm: introduce ->swap_rw and use it for reads from SWP_FS_OPS swap-space"), swap cache should never be exposed to nfs. So remove the usage of folio_file_pos in following NFS functions / helpers: - nfs_vm_page_mkwrite It's only used by nfs_file_vm_ops.page_mkwrite - trace event helper: nfs_folio_event - trace event helper: nfs_folio_event_done These two are used through DEFINE_NFS_FOLIO_EVENT and DEFINE_NFS_FOLIO_EVENT_DONE, which defined following events: - trace_nfs_aop_readpage{_done}: only called by nfs_read_folio - trace_nfs_writeback_folio: only called by nfs_wb_folio - trace_nfs_invalidate_folio: only called by nfs_invalidate_folio - trace_nfs_launder_folio_done: only called by nfs_launder_folio None of them could possibly be used on swap cache folio, nfs_read_folio only called by: .write_begin -> nfs_read_folio .read_folio nfs_wb_folio only called by nfs mapping: .release_folio -> nfs_wb_folio .launder_folio -> nfs_wb_folio .write_begin -> nfs_read_folio -> nfs_wb_folio .read_folio -> nfs_wb_folio .write_end -> nfs_update_folio -> nfs_writepage_setup -> nfs_setup_write_request -> nfs_try_to_update_request -> nfs_wb_folio .page_mkwrite -> nfs_update_folio -> nfs_writepage_setup -> nfs_setup_write_request -> nfs_try_to_update_request -> nfs_wb_folio .write_begin -> nfs_flush_incompatible -> nfs_wb_folio .page_mkwrite -> nfs_vm_page_mkwrite -> nfs_flush_incompatible -> nfs_wb_folio nfs_invalidate_folio is only called by .invalidate_folio. nfs_launder_folio is only called by .launder_folio - nfs_grow_file - nfs_update_folio nfs_grow_file is only called by nfs_update_folio, and all possible callers of them are: .write_end -> nfs_update_folio .page_mkwrite -> nfs_update_folio - nfs_wb_folio_cancel .invalidate_folio -> nfs_wb_folio_cancel Also, seeing from the swap side, swap_rw is now the only interface calling into fs, the offset info is always in iocb.ki_pos now. So we can remove all these folio_file_pos call safely. Signed-off-by: Kairui Song Cc: Trond Myklebust Cc: Anna Schumaker Cc: linux-nfs@vger.kernel.org --- fs/nfs/file.c | 2 +- fs/nfs/nfstrace.h | 4 ++-- fs/nfs/write.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 6bd127e6683d..cebddf36b923 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -588,7 +588,7 @@ static vm_fault_t nfs_vm_page_mkwrite(struct vm_fault *vmf) dfprintk(PAGECACHE, "NFS: vm_page_mkwrite(%pD2(%lu), offset %lld)\n", filp, filp->f_mapping->host->i_ino, - (long long)folio_file_pos(folio)); + (long long)folio_pos(folio)); sb_start_pagefault(inode->i_sb); diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h index afedb449b54f..d249741452e1 100644 --- a/fs/nfs/nfstrace.h +++ b/fs/nfs/nfstrace.h @@ -960,7 +960,7 @@ DECLARE_EVENT_CLASS(nfs_folio_event, __entry->fileid = nfsi->fileid; __entry->fhandle = nfs_fhandle_hash(&nfsi->fh); __entry->version = inode_peek_iversion_raw(inode); - __entry->offset = folio_file_pos(folio); + __entry->offset = folio_pos(folio); __entry->count = nfs_folio_length(folio); ), @@ -1008,7 +1008,7 @@ DECLARE_EVENT_CLASS(nfs_folio_event_done, __entry->fileid = nfsi->fileid; __entry->fhandle = nfs_fhandle_hash(&nfsi->fh); __entry->version = inode_peek_iversion_raw(inode); - __entry->offset = folio_file_pos(folio); + __entry->offset = folio_pos(folio); __entry->count = nfs_folio_length(folio); __entry->ret = ret; ), diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 2329cbb0e446..3573cdc4b28f 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -281,7 +281,7 @@ static void nfs_grow_file(struct folio *folio, unsigned int offset, end_index = ((i_size - 1) >> folio_shift(folio)) << folio_order(folio); if (i_size > 0 && folio_index(folio) < end_index) goto out; - end = folio_file_pos(folio) + (loff_t)offset + (loff_t)count; + end = folio_pos(folio) + (loff_t)offset + (loff_t)count; if (i_size >= end) goto out; trace_nfs_size_grow(inode, end); @@ -1362,7 +1362,7 @@ int nfs_update_folio(struct file *file, struct folio *folio, nfs_inc_stats(inode, NFSIOS_VFSUPDATEPAGE); dprintk("NFS: nfs_update_folio(%pD2 %d@%lld)\n", file, count, - (long long)(folio_file_pos(folio) + offset)); + (long long)(folio_pos(folio) + offset)); if (!count) goto out; @@ -2073,7 +2073,7 @@ int nfs_wb_folio_cancel(struct inode *inode, struct folio *folio) */ int nfs_wb_folio(struct inode *inode, struct folio *folio) { - loff_t range_start = folio_file_pos(folio); + loff_t range_start = folio_pos(folio); loff_t range_end = range_start + (loff_t)folio_size(folio) - 1; struct writeback_control wbc = { .sync_mode = WB_SYNC_ALL, From patchwork Tue May 21 17:58:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669603 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.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 3036214A092; Tue, 21 May 2024 17:59:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716314380; cv=none; b=Ikmi7lXbkPwzpiXz0EJYtCJbKIp1tPv4H/dmvTvR8/6ixzj4Vqs9LA1C47uRYJvpkVFSLQYATqhAtNo7YgUNtbsWlk3cYtj9FHqxc+Huv7dgJgluSTvJv1Wt4ptSlEKiDj0KgqRSSPXbn0DMdq1Ml3HUii/sEQgAouVdVlJbf9s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716314380; c=relaxed/simple; bh=1SAVvMr94KYXIST+pzvRHms13THqgeIYsOrrjA5MSRo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cwA7/JrBMmq+6SScogt5KjsAPXiLnbGmBu7uHgRBwdawtflSOHuoVHwgnxIxP0fiIBYn8qTmEt/jQSV+XCttjyuc+7VeLdJD1/GIBkCbYrg/0MYyMjZb3jDYt4Ol5pSbN++qvdbJjwmXVDIicH0laDIsLjZjShHclLpKxy+WexM= 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=NPd4mqu3; arc=none smtp.client-ip=209.85.214.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="NPd4mqu3" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1ecd3867556so3832305ad.0; Tue, 21 May 2024 10:59:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314378; x=1716919178; 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=D1huxSjfPNpI2elfAn7WJAQ+EPp79T3Zke3qFamrARc=; b=NPd4mqu3NU0f7qss566tcJ/azZMP4iUWlPIq2D0PWoL2McobfvI/4K+ITZFarnTc5V ZvXo9UMFf3rES4IoWRFzkVKH59EjJc41V+vAEJ8v5a0NbGZsHU/d3zeA/+/NBnzrjt9r qr+3naN7+ai0e0BNAjKWvVAG19kUhdy0tr8Tayj69QMwSYUItxuzTHAaVborBH6L9sBQ VHRvmr9I971vEUh7D8FBgoPOhGAeCfNOT5THqLPPyjM9LyXajinlSSFpsu278TtSVN1q FUe4mBwpvZs+Nesz6fIa1Yn/bQIIVymAEo/aJRrbHJanAzYW4rAi4wft8yXagH4a2N+5 Hr/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314378; x=1716919178; 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=D1huxSjfPNpI2elfAn7WJAQ+EPp79T3Zke3qFamrARc=; b=hMDNXzwkfei4QgB4+u+hu/tAHgZBoL4zeULUgQoSh8dAn7NyPmeZqrBfaA3vxscmhO 3XFLZ0JyN9R38te/kJL11/GsCj6g0Osf1+i2No63FzNIsWbyE8CWpR4bUDnOVBp4DR2b g99GRvjWVyO8xaBXDcy6UziFmAts3avzWXFIUmshNc04ohPM/DPVe7MsJiMM23sk7tln hS2vvxks1DOzmB16IS8rJGQQFqjVU+UuMWvZAuPFNL9vKNvXtetDKKHvvCWw8B6Um7T7 Z3TSAhi9L5Kf+QL+GIWXYkzY1dAf+2KNWv9a8cGVZoby6I+sqqPd8xxbV+pHyVsV10Yf YTOA== X-Forwarded-Encrypted: i=1; AJvYcCVGnKTkKN3A+48jwENQQrE11APu4i+ga0THTi5yr0qVi7Ai/0F/TrDXQFQVOeKTmozTOwLasJdwSxZT9IrEF5huE3oNf64Pyjl2HN2V98rIJ6FOstxf52ZKK3QV4b4CFS2THjEespuRnzeXOg== X-Gm-Message-State: AOJu0YzeNf7/8IPwbLH7xcwdulCsCc8Cswzx4TcfXggUj9U1EwdGpUlU 4yhdf/te8o0UqCGpp7HOkI7cswXvZTX7VImPSTmC++iCBBwrVWnu X-Google-Smtp-Source: AGHT+IFhWVOawISt67dDcpWfcLwWNuJAcHjeZXZi5aR2zc9zllf3tQdQzGB28iJi3njxKzYTcZWE2A== X-Received: by 2002:a17:902:db09:b0:1f3:1026:2750 with SMTP id d9443c01a7336-1f310262acfmr25409265ad.61.1716314378510; Tue, 21 May 2024 10:59:38 -0700 (PDT) Received: from localhost.localdomain ([101.32.222.185]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f2fcdf87besm44646935ad.105.2024.05.21.10.59.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59:38 -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 , David Hildenbrand , Hugh Dickins , Yosry Ahmed , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH v6 08/11] mm/swap: get the swap device offset directly Date: Wed, 22 May 2024 01:58:50 +0800 Message-ID: <20240521175854.96038-9-ryncsn@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240521175854.96038-1-ryncsn@gmail.com> References: <20240521175854.96038-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 device directly. Need to include swapops.h in mm/swap.h to ensure swp_offset is always defined before use. Signed-off-by: Kairui Song Reviewed-by: "Huang, Ying" --- mm/page_io.c | 6 +++--- mm/swap.h | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mm/page_io.c b/mm/page_io.c index 46c603dddf04..a360857cf75d 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -280,7 +280,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_dev_pos(page_swap_entry(page))); for (p = 0; p < sio->pages; p++) { page = sio->bvec[p].bv_page; set_page_dirty(page); @@ -299,7 +299,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_dev_pos(folio->swap); count_swpout_vm_event(folio); folio_start_writeback(folio); @@ -430,7 +430,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_dev_pos(folio->swap); if (plug) sio = *plug; diff --git a/mm/swap.h b/mm/swap.h index fc2f6ade7f80..82023ab93205 100644 --- a/mm/swap.h +++ b/mm/swap.h @@ -5,6 +5,7 @@ struct mempolicy; #ifdef CONFIG_SWAP +#include /* for swp_offset */ #include /* for bio_end_io_t */ /* linux/mm/page_io.c */ @@ -31,6 +32,14 @@ extern struct address_space *swapper_spaces[]; (&swapper_spaces[swp_type(entry)][swp_offset(entry) \ >> SWAP_ADDRESS_SPACE_SHIFT]) +/* + * Return the swap device position of the swap entry. + */ +static inline loff_t swap_dev_pos(swp_entry_t entry) +{ + return ((loff_t)swp_offset(entry)) << PAGE_SHIFT; +} + void show_swap_cache_info(void); bool add_to_swap(struct folio *folio); void *get_shadow_from_swap_cache(swp_entry_t entry); From patchwork Tue May 21 17:58:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669604 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.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 5A81914A4DB; Tue, 21 May 2024 17:59:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716314384; cv=none; b=H/1JzjEHUBQ4XL6p/YQUZXkOEBqU8RSX7BcLFPnfRUC2AWZtwlW7YtLGaO35clQDool/KMMkBySxeQF45TLo55O0tqBD3GoRdpxpmiCNtJnViXiwlyxf+4itXRSlOrjXCuO/E1ylnan/KGqq4wO8ybYl2YIr2aLe2LCpoyzTY2w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716314384; c=relaxed/simple; bh=fF9uSlLawr19O3w96oImtZJmaTPOxhRLrgNGWkUu8zc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pVARrJPS8WdJiROxrnkijQYAKUW6QB/m4exQGM1Pqcu02sn++zrfPtGcTXWJEDiOMg+2VA3+idXHYL67Q6vlVyNll8y89Mfof9a8cj+oTZW7wrT8rEB6Holajeld1tdMx2kJ0Q+UXnMlSJhv3k3055ebFeaBInwEyj6zL8nGzdM= 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=Tf7Gyqhu; arc=none smtp.client-ip=209.85.214.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="Tf7Gyqhu" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1ec4dc64c6cso3417745ad.0; Tue, 21 May 2024 10:59:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314383; x=1716919183; 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=PHrzc7CPuMjcf8HiikXMyTuP6q46A9jLQj3ikc6Mh0Q=; b=Tf7GyqhuFEvwKORgqAdFWrYyhVr9AocuHxfp+9Nq9rU8vHXWR3hiWNBenZ2OoiP/zP wD09L1CgVUKKsr+dFyiuFL1/YcxHrWSpv2MVh9TPvFzS4tfMOP/PYhsyDU2UatwqoJfR z/IaWEL3uKwxRVcISsoUQQ8d1xCDr9whVZYl2nNoy+n0HStXZoTvwndo/wGyKC6aDU9Z Bg3UE0F0/m9LadQC3ffAV3uYsQztfW+3SBC5LL+KKSIOn6r2E1n6+gpmQPUtPAGgTcG4 x76AYzrkWb+P2edTOi9G9dCpKlTpkFK0XL9wfgiQErcRpeszdiwE4+vySETgR95vFDnE gsXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314383; x=1716919183; 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=PHrzc7CPuMjcf8HiikXMyTuP6q46A9jLQj3ikc6Mh0Q=; b=NTy8vDGS5NSqXWn+MHPuxamg/7dxikr4FQaS2PXBHEorgGZayqWJnBH7dGha/i4NrO +e1+nOjfy4sb+vwForfAN56ML5FVx7mIK2gxCKJ0Zud5/q0evr6UxG+oxwHpkMIOovt7 P0+pnNr51pUkh09zisg92QtzJVmOq9FODCDjC3nekPIdMCGySlEe6U8QtqwEJDgD8eRv uvgPQi9VuI9V/GByDNevLtxqHSNy6RZyc3rokPf7dR5XKjnfi4xa70G6HD360ZH+6PK0 1rSsmo0Ymqwt2zKDAXh4CFM7Q0o2JzMBQiE5Ls6a2868o4PjMwH8KMInTUSiPcFormb5 hjXg== X-Forwarded-Encrypted: i=1; AJvYcCWjBxuC6KgVtnQ/MbSUPvTlrvZ3sIXVI5xNCfpThIdVwYRVQy/xhXaDhPtrsIttzxu1FM9cg3dvrr6I8uy6OBKLf5CdJJ+YkNU5vln+5oE9DMxDM/sKUgDIZ23PRTDEYsiNe74psI6yAjrbBg== X-Gm-Message-State: AOJu0YwGtOGyn4ojvxN3gBB3VR4ozYW/3mK/E1tCvHMGfyCYJcswBoWB IdFM5w3zgYilY+rsin/AQh0v2X6jy4Pan644d29fDhl8T73+IDfrqMn5kRejOoI= X-Google-Smtp-Source: AGHT+IEqeNhAh7ppNHI9aB2X1JvWm56eouCLIcYDXiomK1yXxCwOtcxJysWQ/3ie5h+P2MMqSoR/GA== X-Received: by 2002:a17:903:2287:b0:1f2:f512:7a5f with SMTP id d9443c01a7336-1f2f5127d48mr99268225ad.42.1716314382853; Tue, 21 May 2024 10:59:42 -0700 (PDT) Received: from localhost.localdomain ([101.32.222.185]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f2fcdf87besm44646935ad.105.2024.05.21.10.59.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59:42 -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 , David Hildenbrand , Hugh Dickins , Yosry Ahmed , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH v6 09/11] mm: remove page_file_offset and folio_file_pos Date: Wed, 22 May 2024 01:58:51 +0800 Message-ID: <20240521175854.96038-10-ryncsn@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240521175854.96038-1-ryncsn@gmail.com> References: <20240521175854.96038-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 These two helpers were useful for mixed usage of swap cache and page cache, which help retrieve the corresponding file or swap device offset of a page or folio. They were introduced in commit f981c5950fa8 ("mm: methods for teaching filesystems about PG_swapcache pages") and used in commit d56b4ddf7781 ("nfs: teach the NFS client how to treat PG_swapcache pages"), suppose to be used with direct_IO for swap over fs. But after commit e1209d3a7a67 ("mm: introduce ->swap_rw and use it for reads from SWP_FS_OPS swap-space"), swap with direct_IO is no more, and swap cache mapping is never exposed to fs. Now we have dropped all users of page_file_offset and folio_file_pos, so they can be deleted. Signed-off-by: Kairui Song Reviewed-by: "Huang, Ying" --- include/linux/pagemap.h | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 3d69589c00a4..010ce7340244 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -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,18 +929,6 @@ static inline loff_t folio_pos(struct folio *folio) return page_offset(&folio->page); } -/** - * folio_file_pos - Returns the byte position of this folio in its file. - * @folio: The folio. - * - * This differs from folio_pos() for folios which belong to a swap file. - * NFS is the only filesystem today which needs to use folio_file_pos(). - */ -static inline loff_t folio_file_pos(struct folio *folio) -{ - return page_file_offset(&folio->page); -} - /* * Get the offset in PAGE_SIZE (even for hugetlb folios). */ From patchwork Tue May 21 17:58:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669605 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 F416B14A60D; Tue, 21 May 2024 17:59:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716314389; cv=none; b=pK+G8OxPngUdpSQB0gOmUfUI9ozxgb99Bzq6cXzEkpHaV0GVUFWus0UfpjiQl090G6VTW+NjMDxiRyZOIuxUwo7+tODdBBpuDhY/7IPeD57y2v6embGRdrk4JCikMuYg9z8JY9naVFBd/2Qx0VJu9KHf4xSBmjlxhDZyzjmbPcM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716314389; c=relaxed/simple; bh=VD8sZfJ72lfQgdHFrG3SRqwVHzGV6YcqHHzkbEi6vO8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fFnH5+nl7lLozMHoyILc8MFIphUwv07PUrPchG1UOB+JDi48IPMLq5RNM0qRNAtszlEJ6iGhQRDI3XdfdgRFvT4kZ24zlX/D2+5p6rsH6wDscVjXJrm+vksWPpElbT7TeZfh1F9lZglSIZvVgDLxKK/frlW6uj3xeEn94cAzl6k= 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=QtG25+cu; arc=none smtp.client-ip=209.85.214.174 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="QtG25+cu" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1e651a9f3ffso102551445ad.1; Tue, 21 May 2024 10:59:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314387; x=1716919187; 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=7qQgvaLUE9M4rws6iEQt+/SaZKzeTop758mxKe3fzns=; b=QtG25+cu/KT5F0Mc/W69K8M3LMGfoT6jgaDm3/TI1tilHhHRV4/oMdJ3ygiwTcyWd0 7SvRN3/yLglNqE0mkZZFxjJuEiITTC21QM0K/OZl9s/jA6XxsqyN0OxnEFkZSoHgsU6R vXFtF2+uxgks+sVgl/IRSWUkE0fSvkm4VJq+rnCPP7jxVnRhyyfluRlKGMhNpKzDSGoY etKZUDZByCBRInz8hj1vO8t/wTQPnBS51WlGZOsgPiK3Aw6/DJNe2rZI4h9PbU7YLc1b jNpfwqH/BeKcdQKnPLxubWAsPpGZ0rAePljQb3U65jQsNxB0ADkZsaAvg4Y/uaqC8Ep7 1gwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314387; x=1716919187; 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=7qQgvaLUE9M4rws6iEQt+/SaZKzeTop758mxKe3fzns=; b=DYFMYF/0o4xvXMdyc2oQGRbVjp3ZAYZJ+eWZitOJ2Fza3GqtNh0q9Luyjj8QfaVGwp eFqYYw7Tro15kfSG99kUvow1Dr7wvZay8H37dUZYITTZ3A76UugyreEFFXKZdMHbu285 6ur2lOlVbJ75IE4gWIgJtWalAdcBy/MNRxy078Ysb9VKFNjBPYa7N4EGdx+a5KFtws0z vEFT9UMc1AohGIgw2oa2q6BuEFAd7iO4wHhmcGDhtTeycjwr7P8CUn1Gsw9F50weBw1G GizE7htncnmcxE0M5K89cq9KwbSyv4piFCQDh46JT97PAniAkqmGBAootSsOqtI8gd56 4brQ== X-Forwarded-Encrypted: i=1; AJvYcCVhvJQKMSq9UIs42k6jjjgGdxjR2EZe2+sQUQzdXcDedNiRUJx05VoRPjJmvECSCNZyJU8UT2vcW19FmioT7bhqJFvTdYb1Qe+urYT/1SdQO3rDAOuA1PW5/0IcEaYgwZZdykedHFmt7SrQRQ== X-Gm-Message-State: AOJu0YxmjnTUXFVsjG81/CVSEqvWFiD4NrjqTa9VYi7e75wptRGjzKxJ yGeM/9b/4qOMbEoxuuWuohxK5aq/HMJeyUGcRl6Yi25akawz7tPX X-Google-Smtp-Source: AGHT+IEZakWrbVxlRp22N1fNkpJSK0qMF00Dd6C/77G4znr2CuE4Uf3FXSSlP5KZRo8UMc08FAqQKQ== X-Received: by 2002:a17:902:dac1:b0:1f3:3ab:a4fb with SMTP id d9443c01a7336-1f303aba649mr57889605ad.10.1716314387027; Tue, 21 May 2024 10:59:47 -0700 (PDT) Received: from localhost.localdomain ([101.32.222.185]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f2fcdf87besm44646935ad.105.2024.05.21.10.59.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59: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 , David Hildenbrand , Hugh Dickins , Yosry Ahmed , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH v6 10/11] mm: drop page_index and simplify folio_index Date: Wed, 22 May 2024 01:58:52 +0800 Message-ID: <20240521175854.96038-11-ryncsn@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240521175854.96038-1-ryncsn@gmail.com> References: <20240521175854.96038-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 There are two helpers for retrieving the index within address space for mixed usage of swap cache and page cache: - page_index - folio_index This commit drops page_index, as we have eliminated all users, and converts folio_index's helper __page_file_index to use folio to avoid the page conversion. Signed-off-by: Kairui Song Reviewed-by: "Huang, Ying" --- include/linux/mm.h | 13 ------------- include/linux/pagemap.h | 8 ++++---- mm/swapfile.c | 7 +++---- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 9849dfda44d4..e2718cac0fda 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2290,19 +2290,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 010ce7340244..7fd67edc0bcf 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; } /** diff --git a/mm/swapfile.c b/mm/swapfile.c index f6ca215fb92f..0b0ae6e8c764 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -3474,12 +3474,11 @@ 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); /* * add_swap_count_continuation - called when a swap count is duplicated From patchwork Tue May 21 17:58:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669606 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 28C0E14A638; Tue, 21 May 2024 17:59:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716314393; cv=none; b=JemiOJ/Olegs0cJ96ix4BWGofKl02WdYViu7oDPrFmhhbVMLLJqrwFgdKCEcbdawRa/4VrrVoXuSHWzEpVEQ3tEbJCsB0h+eeA0LkBn0uzEbUk5WYKKJwi/IRHi/HjbexVncL6X4a7X5y8xRGQC8WQVeKAjz4hUFdLLpPbDgyrc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716314393; c=relaxed/simple; bh=61MriWGtPLPpZsrO73fCBAhdwQo0/XaJgc8eagLcVXc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DRDidvLU26GJ+Y67lt1o/AW7tYxGC7Yq3Sa+d9GnmU+9gS2ZB+AwUMVBaVwqk1BsIv+rQ0BMslVBq6WdCSVxv5+vh/BSZLtK2VcgCoIGYR4dZV05V8zyqylkQuz60hDZCIUPA67ejNsxjx2mZTFMGqaU6Exq5Yw2/wPYwB2wapI= 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=ke1Bi5bD; arc=none smtp.client-ip=209.85.214.181 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="ke1Bi5bD" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1ed904c2280so3304305ad.2; Tue, 21 May 2024 10:59:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314391; x=1716919191; 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=jX6zUCloIMLeC0AtUUIo54oV7OGNQUUzaEpWo4Ucc+8=; b=ke1Bi5bDcBWNP3Nf3MDgLLxSoGYKpmrBe6HYtKvwgJguKqRmSAOb5hsHK/Ci5+umRf eqK357InbnULcr3Y6ON3lCa6yp8WWAxYuaj5DGPb3TzKoRn2QNqxqq7EsfXHX2mfYLY/ 5z0g7Cw5Da/Rhac8kwpACW2zoNYTFvSVt5z0VbS1gB1Ci1uPjPdZlO571uB2hR229i1y QD7M4sj57sSNXh0WnUpn08tE//Qws4pqkM/p4S7Ku7z6UccFYbTMXxQTM2tWI5DqSeIb /nN/dhx6m+HEkBXccQIa7QXBxjeQOou5YUzRSpQhqUvvSIJINCmyCfRhyD2ACgwv3IAy 4Efg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314391; x=1716919191; 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=jX6zUCloIMLeC0AtUUIo54oV7OGNQUUzaEpWo4Ucc+8=; b=W7FEMkxH9qjt/RLq4QAsNpC1/0Pqhu+HRzf+COH6FiegMI8csVdu2osrY17EKjfsye aGUZqAKUU+uWp6Kl6vrzPk+d8xFFumaaPekZqv7PJxhVvqeK6CeIILwnlsPMKJo5TDRa I6wNlDIoJhYoWxuUnMdnzV9KJzIHE1kHsoYNZ1K7AREypksLlX++UjjASnAxVrPEEMb5 pgn40JsvIMnzlEXfQlkX5+i0rkqT0CWPzQDISG4mFH648MuBURmq4AX/THGrryA8FmnF VbvzknDNtRfE7R2DKhrQdoUNEBQJ9LYkotkogRnS4zL5Uu2kZxK/q9GsehOjVIPE7040 GD0g== X-Forwarded-Encrypted: i=1; AJvYcCUK0FeFEM3lR9cebua1hGlCGavCy65WUbmOavtwwWvP16hQ8tHUs8eIJfbmj2hPQlEmQS0lz6nQOOL2jOUNlddEk8dUIBRGMCEfCtVPwubpoUTFovEO/qQuJAPxIktNcse8WGkf95eqnwTVPQ== X-Gm-Message-State: AOJu0Ywx0osXnJAzMDDbiS48bpSqNnViLWle0MZsiaDu0wYrpzuSfaqB s5p0FCcbLvRlhHbz5kQrAgb4IrVF0InWYSVejk3fScQMue+BOdaF X-Google-Smtp-Source: AGHT+IExAfgsIwWGDABBN/J81IQxzi7Xmus1MnTq7EO1h5SpSUKVtCl9UBUAT3KpqGVr3jZT+Cbd4w== X-Received: by 2002:a17:902:bb17:b0:1e0:115c:e03c with SMTP id d9443c01a7336-1ef43f4ce9fmr320876095ad.53.1716314391332; Tue, 21 May 2024 10:59:51 -0700 (PDT) Received: from localhost.localdomain ([101.32.222.185]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f2fcdf87besm44646935ad.105.2024.05.21.10.59.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59: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 , David Hildenbrand , Hugh Dickins , Yosry Ahmed , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH v6 11/11] mm/swap: reduce swap cache search space Date: Wed, 22 May 2024 01:58:53 +0800 Message-ID: <20240521175854.96038-12-ryncsn@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240521175854.96038-1-ryncsn@gmail.com> References: <20240521175854.96038-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 swap device. But when doing swap cache look up or insert, we are still using the offset of the whole large swap device. 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 if we are using the offset from the whole swap device, 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 Reviewed-by: "Huang, Ying" --- mm/huge_memory.c | 2 +- mm/memcontrol.c | 2 +- mm/mincore.c | 2 +- mm/shmem.c | 2 +- mm/swap.h | 15 +++++++++++++++ mm/swap_state.c | 17 +++++++++-------- mm/swapfile.c | 6 +++--- 7 files changed, 31 insertions(+), 15 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 317de2afd371..fcc0e86a2589 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2838,7 +2838,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 7fad15b2290c..cee66c30d31e 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6148,7 +6148,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 f5d60436b604..f9b0c34c435a 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1756,7 +1756,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 82023ab93205..2c0e96272d49 100644 --- a/mm/swap.h +++ b/mm/swap.h @@ -27,6 +27,7 @@ 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 (SWAP_ADDRESS_SPACE_PAGES - 1) extern struct address_space *swapper_spaces[]; #define swap_address_space(entry) \ (&swapper_spaces[swp_type(entry)][swp_offset(entry) \ @@ -40,6 +41,15 @@ static inline loff_t swap_dev_pos(swp_entry_t entry) return ((loff_t)swp_offset(entry)) << PAGE_SHIFT; } +/* + * Return the swap cache index of the swap entry. + */ +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); @@ -86,6 +96,11 @@ static inline struct address_space *swap_address_space(swp_entry_t entry) return NULL; } +static inline pgoff_t swap_cache_index(swp_entry_t entry) +{ + return 0; +} + static inline void show_swap_cache_info(void) { } diff --git a/mm/swap_state.c b/mm/swap_state.c index 642c30d8376c..6e86c759dc1d 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); void *shadow; shadow = 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); @@ -253,13 +253,14 @@ void clear_shadow_from_swap_cache(int type, unsigned long begin, for (;;) { swp_entry_t entry = swp_entry(type, curr); + unsigned long index = curr & SWAP_ADDRESS_SPACE_MASK; struct address_space *address_space = swap_address_space(entry); - XA_STATE(xas, &address_space->i_pages, curr); + XA_STATE(xas, &address_space->i_pages, index); xas_set_update(&xas, workingset_update_node); xa_lock_irq(&address_space->i_pages); - xas_for_each(&xas, old, end) { + xas_for_each(&xas, old, min(index + (end - curr), SWAP_ADDRESS_SPACE_PAGES)) { if (!xa_is_value(old)) continue; xas_store(&xas, NULL); @@ -350,7 +351,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 +421,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 +448,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 0b0ae6e8c764..4f0e8b2ac8aa 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -142,7 +142,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; /* @@ -2158,7 +2158,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; @@ -3476,7 +3476,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);