From patchwork Thu May 2 08:45:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13651414 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (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 0A8BF51037; Thu, 2 May 2024 08:47:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639638; cv=none; b=VvW1ZfbLVzKLTh8kD2JhohWNld1Zc9hTYIFvwumntiIyaedaaPlS30LpmmYuWpH0bGILWBRoKR5wr/jQ1JrajkW9DiIwA/UQCYCZ5oQ8pJpCfId2NgtDaSsAXleVd7Hnk7wv1mEJV75CI15XJqj6TbbpYfbZOmy7g3cQaM02EnM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639638; c=relaxed/simple; bh=hDlPxTRmPzQHkSl/lYkJK+GDIbLDQq8I/dn2VuGCZ+Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tfiGt1ZwCrcai3YAO0nvxyxPpLG74XrcPWEhrMaAyYjOCARxNzc3XZTA4ahoWkX9OQTbANEO+QWlX6hGgbaL2YO6WeXqMw2vVWFea7yFfuVZWCET5G9QRuJ/qhXI75HOSAx6/TROEXJUDk/7+tE5GvnfXl9VmckRJn5Y8LKVkEI= 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=USIXoz5L; arc=none smtp.client-ip=209.85.215.180 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="USIXoz5L" Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-5bdbe2de25fso5833300a12.3; Thu, 02 May 2024 01:47:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714639636; x=1715244436; 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=WSvD/YVvY3oR/SV9lrJcxmGa9WfASg1z+eMVQdwymCU=; b=USIXoz5L7aQeO48zQYbJ8D9WH4ebRtl7/H5hFbpZm9stkqUbCBTdhHmw+KXqavbzai D0yQWWw0PfGLf8S48HKli5X7a4Rsdix03X7QH9ffyOc3zLm6FJWjNCJXq1cLfDkgfmXP wB0Zpl1JQ6rcHlut3t/Qij1G6XNCoMZAw3XsovXXMKUFdDuX9xhgO5/ni1JxLx6cG4sW w+N63RBAnLovqv99VYnG/xupFr+GbD2+I/gZi67Gx7nSkLYAZlCK2D/saQ9QuEQJcPso AdoZ8h+Ac49vh06Gjp70nIKskvFUIIuhFTyHIwJXv+aa+QlAO8a1T+tC1EV7WG5puTpu 5mpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714639636; x=1715244436; 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=WSvD/YVvY3oR/SV9lrJcxmGa9WfASg1z+eMVQdwymCU=; b=EIT6xxsuRcEp1zEbZ3yXgjzDwstnzfB69OfDz6lAnIQBQdhAwNheadHJlOUkRkC1pX S1nTPAGqiWpMoPP9mI3neq9CWxA1EcJ6WTga4D47ZHw0tYv5oAJBsb4euCnGD958LrNF sz58Td4/FqdJBiyfRjjZIe7z6L72va5/oTt35pD73mvDLWVE27623yd2dAoQUNtbusCz Mf88guIinli6Kvva63Cis5QvxUXlGk4m2ym9rJAZBMWWWc9bFchR9loX1+8omGJXSQI1 IUG5ClPOidxF69VACheijmDKnoheIKWbwLxoOtexA66mbabP0Ffs71AfxdUhCFH3NH5r Nn1g== X-Forwarded-Encrypted: i=1; AJvYcCWrbH0eG6QYqvYnu9RLGfmtJ+zOUicBjBEu64UiomjeT4KbxXDfz4XDBqXRXpp4kXOvTIzE9pJEyzk2OiL0lUnz3X2M6uPLmBRSDY/UPAfqWF8Un5EShJ8iONr6in9TaCyBNL5eZLaTZI/aog== X-Gm-Message-State: AOJu0YwCjJ5tE2yzjsWiIoiOl9smO47wkLLqGA9yk9DDguDZvEc9aqz5 iVnced3YW5Zrj6RNU9gGql/8mDvvibRJcuCYFkD4eORcfFcKIpe+ X-Google-Smtp-Source: AGHT+IHHmKPYxmQ1NnctSOq7P493kmk6LeLXH7PC/dx0NjjiKoIYGnc+kgONRssyDz3JCfG5GAiMeg== X-Received: by 2002:a17:90b:50cc:b0:2ad:da23:da0b with SMTP id sb12-20020a17090b50cc00b002adda23da0bmr5630235pjb.34.1714639636249; Thu, 02 May 2024 01:47:16 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id q6-20020a17090a938600b002b273cbbdf1sm686805pjo.49.2024.05.02.01.47.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 May 2024 01:47: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 , Chao Yu , Jaegeuk Kim , linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH v4 01/12] f2fs: drop usage of page_index Date: Thu, 2 May 2024 16:45:58 +0800 Message-ID: <20240502084609.28376-2-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240502084609.28376-1-ryncsn@gmail.com> References: <20240502084609.28376-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 Thu May 2 08:45:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13651415 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (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 7C86C53814; Thu, 2 May 2024 08:47:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639642; cv=none; b=oubLweWrMQ+HQtyRMYgFVbnqt8fkEuul3TDMQcmhbBSDoXeEKEHBHpUSSJbtZTFHZyKL7pL4qhHBkVfQ2YOAyw+N18tHQwDUqvFwSAXYozq3cnJBh0Y+J2vb9gSVOhs/nHXXaQ7vgl7kDtyTrukD7jKwt9NezBjdmX7cHGw/1TM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639642; c=relaxed/simple; bh=out7TTbYJtYzFrjWSVWEYtQyDDZ86WVDSmk+A+q/jqc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Plg7H4liYSfEE/ZynhJm/gCpbBigGBLWt+wzZiXGDkPfY7ZsUITcNslXnZCg5uhjWfnlZ0+5WT0gJ85LWe5IdtWNWgLgoo/sOuEuP2MQkKBzK8BdjtPe9D04Qk1lXqclVSltzztgXoTfOnBT7OBPge3J+LnLwz1U7C6y/4gtCVo= 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=Xzfq58w1; arc=none smtp.client-ip=209.85.210.169 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="Xzfq58w1" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6eff9dc1821so7070384b3a.3; Thu, 02 May 2024 01:47:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714639641; x=1715244441; 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=dKeW621Yklmzy6NXiq7Wct3/1VaKARCv12uVKwULRiw=; b=Xzfq58w1uIEfCN/UuIzsy1Mnn/LZOhAP8+Tw0cATRiPH/RqkXNnz+UUglmzJpUgtvI Jm2INLgOFtENgLeSAp1aJsMfl2hvrqArAddFXnBZq8RbOyOGVQkiHadpLzLh10ZZjM6t fryh8buznJtSqfh7meV6OAl6GyapL40oajwC8i7TU4pTh0uOx++pMvyPlNcF3r4MSApj TSJz8oXA909V5vOtaH3Ualm5JCek7SHyr7wRja/6+oMGwbSlcxfD8RDUNBWU14UFhODX uBZeQWt064P0rR10c9ATSIvR4nu0HMPEo0MQZLhsJ799HfFaYP3B5b/h3kbO9q3zQmBB 7wKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714639641; x=1715244441; 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=dKeW621Yklmzy6NXiq7Wct3/1VaKARCv12uVKwULRiw=; b=C7t6Tgo1ltiF0u7H/KE/Li6UQ/iQkPXDwHODA5878VDVs32pczY3rFBHfrBFrbnZ1T fwiP7nnX4iU6WJJJBOclmORlRAYXuk/LVML2oy4Pf/jQlirTjShyzoErJmauGoQfH7Gp cwJPSt7hWLE0Qz4oAQ84cPUX3o5db/rfp6o84O9Mu+RhyXdPj9uBPe+RJQOEdNlORCqH y2o0DlISN9oVuaLZO7wcmw0cCnWZrZ0TWp+b1ULc/Gh2yF/Uet+Gnzfn2eWJzPKdcttq TqSZyHX9ok1oCwZTgOeskInIDKJN3LnMKyjV7XwnlRSze4pciXNJIM2ORFnz8THFQXjO 1l1g== X-Forwarded-Encrypted: i=1; AJvYcCUmVw485CHmnrOiuDKXm61VIbiaKapnq+YhdRMNHYWN35LiZPjr/R6ln3bc495nsgKHkfYxkusIjFfvpmkFFuZO2l8TXRdiQ1wTnrGQsN6wvFTwvoItrAbog3DDqiPArZa3RlUiaoPKl7cWe38KguQfE0ksNPjHVxwktMp1/9Yq1v8x2NnV3YSK X-Gm-Message-State: AOJu0YydtxW//GmefM8Kix4vZ9m6oyPWN2Ga8JSh7wQK4qG/PpIOF6kk P5on7xNFDi823+3nhnQa61ixVDnuTYnCsaADK0oLAfBq6RErl8gs X-Google-Smtp-Source: AGHT+IFw7DPiHNZRifdJPZ097xuBBnwfxycsF06NxKzZyaEaRqiuEdjNax8xBn+KkdLO8zdGBCA7rg== X-Received: by 2002:a05:6a21:338f:b0:1af:66aa:f968 with SMTP id yy15-20020a056a21338f00b001af66aaf968mr6570426pzb.20.1714639640628; Thu, 02 May 2024 01:47:20 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id q6-20020a17090a938600b002b273cbbdf1sm686805pjo.49.2024.05.02.01.47.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 May 2024 01:47:20 -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 v4 02/12] nilfs2: drop usage of page_index Date: Thu, 2 May 2024 16:45:59 +0800 Message-ID: <20240502084609.28376-3-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240502084609.28376-1-ryncsn@gmail.com> References: <20240502084609.28376-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 Cc: Ryusuke Konishi Cc: linux-nilfs@vger.kernel.org Acked-by: Ryusuke Konishi --- 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 Thu May 2 08:46:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13651416 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (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 576F554BCF; Thu, 2 May 2024 08:47:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639647; cv=none; b=sSV1QfA9ZSl0v3mAQycwvfr2ywC+1GlOwZKnLlO1Gu1ehRNmUT7qUQ3Z9XJcLLMm4KBxz+q1jMW0otYnlHwEXZqm5bugl0hX4jly9xHSp3v4NX8M6kKkojUxDZkOFhDKnMX0IU9uP/SagIEoBCklO0/YZ3OOu1hE5ju6lg9MRho= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639647; c=relaxed/simple; bh=gNeowpHLn3XanGMjOPlcSsZZHe5AP0lM6lADWQVCs4I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ud6Sj7E2tBp/NwLnq+ZdRgw36KdW1L2+72ObfGqFnEx08ZI4pY9h88zySSUl9yDaiC46oXjncDDVH0FWHrjvi502ug58oiiZ4Dr+9Jev7gt58HgKHsgKl0RQuliXzVqijvCd+ki2gNeCFL1VGN094+IlX/RGAEDCiHvbIgT3LjQ= 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=I5PHE+4t; arc=none smtp.client-ip=209.85.216.42 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="I5PHE+4t" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2b27c532e50so1828766a91.2; Thu, 02 May 2024 01:47:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714639645; x=1715244445; 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=I5PHE+4twrtf5dhvKYH5hN/V49DsPYFYXHrVXJz4Uudg8ZC0JnomULnFERh+pUDA4L +jIe+95GH3pWuJRibjH19ZGQ8nPfRzvMy/asEY5jej+YiRGkV0rTqOZliapyETGSyFtC EvRCb6QFDUH5wDsHsYkjxMeTdxqbSiKA16p11OXacJ8wpX6G8s8MiMDHkKVpaPy6HnXh GXS6VRQ3NM3B/w3ZNoDyXBNuJF/dOFc03q/4Qw7OHBtcsMJTWLnlRpNpnzAbu7zojZOJ OmRDi7NmNjJLlecu862rZ8DG7Dilbu42zeRfXjqoSYekmaVyK+qt+i4r/8wo6RyQnYFi EdwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714639645; x=1715244445; 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=KeRVtBQrx/y2kb4ZFpkAdm3JWtuC7+anNISsYwz47BE5ZsTPwVesQ3xlSYQRSKFuNS mN5ql31LQjBDK1FEZHl5Qn+8H0IznG2eTSE5OXY7uF6pJdbm68m5SRv6Y1QdPLhtYbAx leLbb982onOMorYC7N/G9SlQSyyNlCquTRm+UF1H6OwJ4/p9HYb59hERzpyB0QvaSwZR VxPpfdtVJuRioOYqT2JAYVl3b1pl5WICMo/BnKAURzeEw5dYSNdpkvBuRN7xbEvdT25Q JC9KC53fKJ/BDNTeLH7uahrzALqnals293kdBv7uT52K5QHTMUHPBcv4kOUEkq8vuDJD f2Zg== X-Forwarded-Encrypted: i=1; AJvYcCXpGo9kKkAPlPut5Z2elNXqcAgM9FtaL8Ii9uoRV1iM+0kokB7d4IFM5d2GzKTBqqzmBwEC74suKXo2H08QbkG8jssui+lutK1QluD6M6ACoTS1qagVj8ItRJX1PNWQhkHaPa05sjrdmvbZEXrTREcsBk7zthk+1vqEgbv83nNTP3QiWSfXQXM= X-Gm-Message-State: AOJu0YwJTkqL1zF8S1jhuNj5cmTa7Hdoy79SAQTxdWQb5KhJCKRXTKFu 7AULcxZdG5/3um6nkoRuVOL1Wf3hIPk79pu3+ZnRheFaGJnWaISR X-Google-Smtp-Source: AGHT+IFyJzDWLYcpgS33rbs90FlHpYKxLcb6n/RLJGWRhgWQpaZsVJE2vmaB1MgKiD0eY8T7Jpul2g== X-Received: by 2002:a17:90a:986:b0:2b3:be55:bf6f with SMTP id 6-20020a17090a098600b002b3be55bf6fmr981227pjo.22.1714639645519; Thu, 02 May 2024 01:47:25 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id q6-20020a17090a938600b002b273cbbdf1sm686805pjo.49.2024.05.02.01.47.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 May 2024 01:47: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 , 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 v4 03/12] ceph: drop usage of page_index Date: Thu, 2 May 2024 16:46:00 +0800 Message-ID: <20240502084609.28376-4-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240502084609.28376-1-ryncsn@gmail.com> References: <20240502084609.28376-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 Thu May 2 08:46:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13651417 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 E622355C26; Thu, 2 May 2024 08:47:30 +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=1714639652; cv=none; b=YXMQyRQvEMKs4D/aOyL6MTG79pBWBhhbhWDdDEyqkyCYXUbocBtYbvH01YVWBLIv+ZJOik1bSfmjDTBOoTHBk+ffOoAzmd6ZTFJOX9mpywL5iOsu8dj5nZUtgSA766f2/aETb/xtwnIYFku8sK7qspwaIw4g9wzaXvJSUGe4cHU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639652; c=relaxed/simple; bh=pMXBuRSYRvxJ/Pm5/D0Ih9VGkrkcDFfmsJy8ADz5Yxg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TAmGkJvkid3giC51f53uULInrNKLkVwZbwxUnxUzNf/awRoT3uiz+iPopOLOPFcoW1Wr7POto+uLQW+DMtFTQC6of2JqWcHV/yCVwYpr1KIYdYhjDHP3yjoF50Zb9ThcCf5SyzrpQPPkEiNAq8HDj8CD2eKisCop6jp8HpAm9kU= 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=KF+QIr1D; 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="KF+QIr1D" Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-2b3c711dfd3so202913a91.2; Thu, 02 May 2024 01:47:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714639650; x=1715244450; 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=KF+QIr1DqAONLzH3vB2jI6l5AXTccKA/RqU8OeYJWEM0eI0jr2oAliAHcfd3UxuPCo 0ThfNF0bIPk3rBxShRAa0RgVY/S5RRAGs7vmEfEGu5eUGsB5AOWdtU/SlPTY4BhpZPDs 7tU2nY2iDX5zTrIdClM4ArS300zJ7dhgmIsobeiDyE40BmCeleAW6vdMTmh0Ya/I1cuH 4ZRsvoyLaMy+WYLRXrIKKyDTH9Q10X7ffOj3kZoAHCeG7c84DGgUKaRBpxehOukoFi1d H7a0k3yCC/J5ZQ3n+Cjtw6201hD4ygKbYURKiH7rSu3hmZ6SK8RIS/kSNTj7fcegQqU/ whVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714639650; x=1715244450; 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=mMXjJdQlRoXKMt/3xAcSJbNjMlFbCXhSboXykBzFn/ySQr6rmHjcDu+un9xMvvqlxZ qRmar/Roixd4bYN1Zu4WyxNgNvwV3u2JUapSmn27Xc35LkPGOYV6EmSXbHE807UdCkVO JyeyKSncHAWVHShjEZVf2QR+wPSbeUFncA5jgJZyTeSGJuUpkbOaw39DCccyLaWG0Lnq RHc0U2wVwen/bPNCVFJLh7/lICV4jMPDDnJYVEhQF4BWsYB1P3zuYTRbzVcpYh4+d1Rl +zFasnX9TOPBCyMESm8nHYMO6QsHu/GuOVVXWy5wOytHR/9pRamkaafop6qFAORErJsY ZPFg== X-Forwarded-Encrypted: i=1; AJvYcCVrMVbMp75FDo05ChffofO/xq9/0oC0CrDxjgf52Ip3dLZp+jcZpPm8rdMz+AWTnrNwvtpYCq3idFkm2VFmpZnkwCEjDoZGeuu1Wl5YejGINplmYEMRhVriInLIdovkANZdlPGOdi6vfFGsxfhJ/+bzRY6oLO44h8nvEo3IyTAh/OXIG+GbNA== X-Gm-Message-State: AOJu0YxYrv+UXETXZKUmUe0b1f+qZSae+CSeDAOHOHS1ByLtgV1z6a7o 6VwVjpBQwY5umf9ttDxDQx/oW/NjFECNpLLaDnV05gtJJ5y3yloo X-Google-Smtp-Source: AGHT+IGbccr4qE+jXDa3rX92HM+k+7c2FUJ+mYHNc+51KVaTYbTEv0IftYCbT5tTMeNMMnMz/pxdug== X-Received: by 2002:a17:90a:8814:b0:2af:fe34:8ce5 with SMTP id s20-20020a17090a881400b002affe348ce5mr4726191pjn.12.1714639650104; Thu, 02 May 2024 01:47:30 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id q6-20020a17090a938600b002b273cbbdf1sm686805pjo.49.2024.05.02.01.47.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 May 2024 01:47: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 , 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 v4 04/12] NFS: remove nfs_page_lengthg and usage of page_index Date: Thu, 2 May 2024 16:46:01 +0800 Message-ID: <20240502084609.28376-5-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240502084609.28376-1-ryncsn@gmail.com> References: <20240502084609.28376-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 Thu May 2 08:46:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13651418 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.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 BB0C856473; Thu, 2 May 2024 08:47:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639657; cv=none; b=EartS9+vOfa0SRT0Lv812r1W88WsBc+L3GnuQ55lGrRvA7GU5pA65d+m8j1FxdwJe4FGGNeZw8HY/9dRNSo9n72bHP8udma4NDF31Zzdsh95pI64lXbbU5mCAmAUB6dfaZl/4dLxiKeppTwGbS0dMGaxA88ATnRTrbQGS4Qaq+8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639657; c=relaxed/simple; bh=bkTdiJFGGBlH6tCXYVyOUBzvEQj2B5ZrCO6Nvtf8Xr0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=De8TYzw0VW4mi8nQdSP6bsh74RlHEL7UfXBD5MfR6SPnDZFxMY4lujscmHuPxmzPZQrr2xMOyJ2RHQM8w47JgG65rBKvzgeoE8B/C0C6DPAT+D+EMnB7Q59H01HzcVp0h3+2OLGPuIMkUCkMElcR5qRjCs3HiaSF3/OvQNZn2b0= 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=F/yVBxpZ; arc=none smtp.client-ip=209.85.210.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="F/yVBxpZ" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-6f043f9e6d7so7708938b3a.3; Thu, 02 May 2024 01:47:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714639655; x=1715244455; 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=7PiwJE9uQmN0uws0CC+HD/WsVJUPjjolITxGR0eGWdQ=; b=F/yVBxpZ4T1Q4ixwkoam34Gu8hCs1p0qhakVU/6VYvrTN7Zv/QGHwTUKOmhqOMn+tN XlE16OXT9GNOyWrokzC87sql6BwdedyRa4odWdZ4tQAND+NdvbTu5k2uKsXgOuhu9fUe HE29h/+DNGjuaGTCnhC9Iq4eD8dM9gzPYZRZTQs7ybPTyZ4Ghnqzr+tl1eZI+q5d3JYc M5YOY2q1tthWFG8yhWXSRafGlDCeZln7c7U9eOR+3h602owO+3sXNXmw8pJndxaO/NDg yX9rJ0jfeD0anboCyEiGlAqMTuVffgcWDtXq43vMIMIjFPZFeGJL41r+qygFPtcZCGy8 kdYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714639655; x=1715244455; 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=7PiwJE9uQmN0uws0CC+HD/WsVJUPjjolITxGR0eGWdQ=; b=aAwMfiy8piUokLj8s7mC5Q3bjbK+WXj8O7QQbsd0wVs5fh9ByyhuNGg39oXpkot03X CXNIdVtG17SRhwnvyHC8hOcrc2WGEwK/BDu9ogDFCyZ0+cs3cGWwbfoVDqTAewT2SFxo cPJ7wLVsSxdf/+d83/JIa6jVM/87fvlIKGjc+TIdbuUkYxwrYpRZ9T7ULChPz2WRmNqW PpnymdfrGjc5GpJ8BY4VUkF8Jl5Dp7mG6fVOJEtr8v7kiKAbpBSg0iutrYYuAd/SoMo+ FRO07LoZPQll2AXiuVgNBo0m5Kia21FGS1f5R8bjFpW2ajqDLYTxB6p0d+f1qbCeRQig LukA== X-Forwarded-Encrypted: i=1; AJvYcCWlIhJ4NcWF3m9I9G56Z2EaBnod1Dr2bd96GCp27Aq5Ipn/1rnWj8+eDA+MtmjUkDtswtasd/1gdGm104OWD7YjHugNRRCwozdM4utwDyDTGDrop2ZBLso9cHcWvaeOr8wlSeTT+A6Ci+1h7g== X-Gm-Message-State: AOJu0Yx1UiNEQkA8C/Ko7ka+RioA3ayjgXcIP6u4w7BzVvcH1O8CaZiZ ZfdD7G9Bf8I92m5WVvfImZar6AnFpIPTogopnVECt0G/nTXMAM9D X-Google-Smtp-Source: AGHT+IH8n+nmsJYFVIZGJmzndILHRpj0aN5unHTTwojRKIiOB2rktCNSIBo9mSCnI2OwpCiqNtBByg== X-Received: by 2002:a05:6a21:7883:b0:1a9:d9bb:acdc with SMTP id bf3-20020a056a21788300b001a9d9bbacdcmr5924624pzc.28.1714639655088; Thu, 02 May 2024 01:47:35 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id q6-20020a17090a938600b002b273cbbdf1sm686805pjo.49.2024.05.02.01.47.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 May 2024 01:47: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 , 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 v4 05/12] cifs: drop usage of page_file_offset Date: Thu, 2 May 2024 16:46:02 +0800 Message-ID: <20240502084609.28376-6-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240502084609.28376-1-ryncsn@gmail.com> References: <20240502084609.28376-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 and convert it to use folio. 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 9be37d0fe724..388343b0fceb 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -4828,7 +4828,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 = folio_pos(folio); int rc = -EACCES; unsigned int xid; From patchwork Thu May 2 08:46:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13651419 Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.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 8138A524D6; Thu, 2 May 2024 08:47:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639661; cv=none; b=TAAdBhFp+jTXufT5/QFt6MWQd25wZmQBV+XddP1U+Isymps015b9lPWwqs6e0eP/qvsWUw1/l3+t8nPRrgLOftyjZkwcfTl/vl5pDjlTiUnZahrpOh1TJpfZwFAsjsl0JsGi6rLWbG+f5/uQ1uB7ysxLkPaaLsmlwY5skY0Eyag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639661; c=relaxed/simple; bh=B3jn4ua9eS8lAn0HB5zwS6E4a9p45K+H69tZmQ+KMHQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=izwASeHUTipCakuI6BYsd1Ki2GmOaGZo2Fp4BxBUY4HVu396kchIs0GX5IfKTQrFXrlrlWjW1XJ5oiX63nZNpELZ3qC3YlocfhJr2PGlxmsC+RZJfTmvP0rBmQjZZ0XO54eBTCz+1ynu/YnIh1MNzRSQYcwrRfr+fGZ7xzSqXfo= 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=Y6ul+mi8; arc=none smtp.client-ip=209.85.215.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="Y6ul+mi8" Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-602801ea164so5205231a12.0; Thu, 02 May 2024 01:47:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714639660; x=1715244460; 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=o1JDj7M+VHieQbjCEGNpRgkTBIVb3xdVSM/lbKWffPE=; b=Y6ul+mi8BoBrJnzrE0msfNk4Ox40cKcQwQR9MrQDkvVUhoRP0KPP6lFplfkhDpPs0P PbXA6uOVgJQStiae3nJUIh8BDzY6qW9dfYHpnbqEN026A6khZqY2CNW22FF37bXlB3JT z/wpXYSfNdz7voI2djcvjGj8UcnmKNRUlWjnPxf8trbVfDwMjYTY/uyseqoA2KbSox6r +bjXtlwp0X5vCmi3++Fbr5t+dIEzHamhY03vtABZjt3HKQNA9uml4xYieTKeQLLeY3fV kvnQuBsgwH22xsFXcU/Wt+73pF/hufl/jhan82AONUifyLTNxioZ7tkOqXbRg4DYJaG6 V9sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714639660; x=1715244460; 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=o1JDj7M+VHieQbjCEGNpRgkTBIVb3xdVSM/lbKWffPE=; b=jodWbrLS8N0f2w1rfZgNfFmViIi5duEh/imyGbpbjn87HTdplH+u6xvejHjsLpEp7v hv2wO+XaR+qzzYKnpIZMCPAUoD+LvDBZ2Gxdcl+9cgmya35k6sE14FI86BzXlDwbMFsP qjrO9qxgyDCdKONHARlOxUYwKEFmye2r0jkoPF0qHZ8nnOoCQYyJLYy+lGHMCbrpHV/C JvKmcNtYNAS+dWQB3XA/yR+RnVG3CUMC/B0fPjdu7yjp9Nc4peD337Q0evYj9eC4Pl0W dwr55eJrfCcqSQq5pmltI8vc2cKbtlcf8UFjeQZhxQwlTnKsDFVizsOVE+UGWmPnK5qg VNLw== X-Forwarded-Encrypted: i=1; AJvYcCWTGe4GQm+wOOHkJY8Enb2l7Ei19ZAwvmPuuRlc5QxVKxO5wLbR2xI0D4y6f1UZKrLledKat3ZQ6ct9b/IWx8yP1YDs0Btv5FNPKwWL9/aIKhmId9ICIL1QhQC9Jt2QtMC2gQhVSqBfm/mU8Q== X-Gm-Message-State: AOJu0YyA+V4PgHZna7aVBdgwgUcomyODkKgJv+kwVo9cgpfTJMIv0xqH WDuL0DVPu0euj1gT6+r1QKtaxg2rRwvjnc6FCG2+EH0Jbrhb3Dm1 X-Google-Smtp-Source: AGHT+IFBu+Fs+rmoaivL9bptW5t+ch5V+p6LPKN15/2dRUJC/IPaj96UkzDDRSMAnS5vPG9aDDkxww== X-Received: by 2002:a17:90a:550e:b0:2b2:9d08:82d2 with SMTP id b14-20020a17090a550e00b002b29d0882d2mr4896166pji.42.1714639659690; Thu, 02 May 2024 01:47:39 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id q6-20020a17090a938600b002b273cbbdf1sm686805pjo.49.2024.05.02.01.47.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 May 2024 01:47:39 -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 , David Howells , Marc Dionne , linux-afs@lists.infradead.org Subject: [PATCH v4 06/12] afs: drop usage of folio_file_pos Date: Thu, 2 May 2024 16:46:03 +0800 Message-ID: <20240502084609.28376-7-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240502084609.28376-1-ryncsn@gmail.com> References: <20240502084609.28376-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 Thu May 2 08:46:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13651420 Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) (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 01069535B7; Thu, 2 May 2024 08:47:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.68 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639668; cv=none; b=r5AV6rUMMcZSU2gKsfC0D1tkMNRlxNoF4rjlL+qQfZY+D9WdXLp6idZroV7LQe0wyaQWhrT8CF3Z1WmqpECUZ6KDMIPjrbS1Q2afiVmQgposfoJbN77n8nS7fjyT1eL4RUqb4kjjwAi9TUgTwZszduvEM+nlq331VCAGubXa2ks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639668; c=relaxed/simple; bh=7wUERS10zASkjeML5DECo0InMoy+pGZDK8UElMVW8H4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ve4LagS/4AdjDI5L48hEa5GAI0+widojdPTiYH9Qd5KyzTz0Hjskev+gOlP4p9T7q5iE1UiU05bLHGuG/uVQrk69895jmFMqu6lnSAXJ8fswFOhUJpk7s+8xwIjEyPIs19K9Ap9tY/tP4irIV9ahJdwox9LJifh2DYGxFV+k5GQ= 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=Vuvoz1Mi; arc=none smtp.client-ip=209.85.216.68 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="Vuvoz1Mi" Received: by mail-pj1-f68.google.com with SMTP id 98e67ed59e1d1-2ae913878b0so5745437a91.2; Thu, 02 May 2024 01:47:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714639666; x=1715244466; 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=UP9GO2qb86H7nq2iI26LPAW8N+Z2bRcTv9KbrkM7mY8=; b=Vuvoz1Mi95c0Ee3Smu8CAdWhgkT3IpyGSn9+MqZry8VoxQnt9Bwmrf2tG2w+vslkJm 6+NekY84YGEMf4nH7Mvb3FpzHDSqZaa0Bzy7L/JsAsQO/flA1Z3837Fgh5TwDzgPz/n1 hKhpYlSFklEZIenVlGpO1bqdCauUMLdzCxfoK+nu0IUnBGO3xTjsWiIkCI20YIBH1hS8 SvUcACo5dPMXNd2uMd9olYJwrR8M4W0DHxAqU/dX/oNQ4Rqv0QFhPZr6Rix2aOwhNvIi SvlFpyWqF19Ai62mUI/vChDJcAg7OIXTL4w/jIzr+zy8s9wFJdzJc8SUAlp9ckqaQ1uF ODxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714639666; x=1715244466; 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=UP9GO2qb86H7nq2iI26LPAW8N+Z2bRcTv9KbrkM7mY8=; b=aDhx57IlKg6dYhcC5lyLLlHVizhUv4WY7fEFBfi81y10xXE66qHWTDgJr0yKNMyYpS p6IDHuoRBwN5dD4mw9wJYsYEZrq1twTBhHaHDxIK09aBtpecmaFM51Papnqf3qTFDVx/ YhPBRp6/sAtrcaf+H0KYgNbuvmWl+Sfes33HB7fO+cVMpf2AHhhvkJ3+dHivuC5qSQsk u1joW1O1W6bgdW/ue2sOGqAm4QNuv9GwICwUu8D2kKOkhh/h1SKSQnXUJuAEw5gWRhRR mjUrRh8xk0XuZBg8+7h+RZE3Hyq4u130AQYLIUHUj5G6QHAVTd27pY6uzt5wNTn4JZKe yrFw== X-Forwarded-Encrypted: i=1; AJvYcCUzYYi2QqbiGTxczGoQ+BffZDsv2X/PwKPwY01+hbZ33ip+8AG7zII8GioQ39/bKw17oXo6WxwD94FhRHQPR0USW/jhKWdvWx38fVfpA/v1S7SqJQ6bJbOSEkaHCkV76cjIUy3eOUkxLwSxxA== X-Gm-Message-State: AOJu0YwY4/kynzcmEB0ZCg9FPJIUqGqbW2lmr30MUspwS0u+vCBwey0k 52RbRGidwAKse/OVeTTgL4SZ29/ySBKJDI2ZAwo1HhkDMi7QqDoJ X-Google-Smtp-Source: AGHT+IGyyg1F0OUABpcZNF++9ikGsOK3Q2kFtyAm+9ixtgSVwbvUEaYTKBIULHXdrWlHyTAR46Kcsw== X-Received: by 2002:a17:90b:2303:b0:2ab:f9af:cdce with SMTP id mt3-20020a17090b230300b002abf9afcdcemr4828016pjb.36.1714639666422; Thu, 02 May 2024 01:47:46 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id q6-20020a17090a938600b002b273cbbdf1sm686805pjo.49.2024.05.02.01.47.40 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 May 2024 01:47:45 -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 , David Howells , Jeff Layton , netfs@lists.linux.dev Subject: [PATCH v4 07/12] netfs: drop usage of folio_file_pos Date: Thu, 2 May 2024 16:46:04 +0800 Message-ID: <20240502084609.28376-8-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240502084609.28376-1-ryncsn@gmail.com> References: <20240502084609.28376-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 3298c29b5548..d3687d81229f 100644 --- a/fs/netfs/buffered_read.c +++ b/fs/netfs/buffered_read.c @@ -255,7 +255,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); @@ -454,7 +454,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 9a0d32e4b422..859a22a740c3 100644 --- a/fs/netfs/buffered_write.c +++ b/fs/netfs/buffered_write.c @@ -63,7 +63,7 @@ static enum netfs_how_to_modify netfs_how_to_modify(struct netfs_inode *ctx, bool maybe_trouble) { struct netfs_folio *finfo = netfs_folio_info(folio); - loff_t pos = folio_file_pos(folio); + loff_t pos = folio_pos(folio); _enter(""); From patchwork Thu May 2 08:49: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: 13651421 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 621F047772; Thu, 2 May 2024 08:50:21 +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=1714639822; cv=none; b=FoTeih46n+TURkw99wbdN8fAlCF/ngrrijSt1+0uIPqyTmZyFZclyTCQyOdhiHzmN+fSqHSQIbFagUuXHmrT4Iu7QT8HaeuGKoKDh0s/Qap7RRXSdi2nv16AiOYxzhold1ufPEKabZSOUWxc580OIIdR/UdjdjyzV+pKvpe9LZ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639822; c=relaxed/simple; bh=h0/SRsAe2O/iKK/puk0MgmyOeDjetRM9hjyClQBU5Os=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AquZgpHBhEZRlbPMfHGVPJxuq0B5CyNAgwaqg9bTuRoY8h2IOeL0fS04XfahEA9OePZukISQqnBugqH9d2+JQ82/9ZwOaljZZUggQWK3Qt8vz8RX2wohtI5liAgdiLl18nnyLX5NaJhbFiDJcgasJcM6UeP+mSy8YUD34COoq0s= 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=Aofk9iud; 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="Aofk9iud" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1e9ffd3f96eso62731915ad.3; Thu, 02 May 2024 01:50:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714639821; x=1715244621; 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=7HU2SkQDR4mMrV58+lW5U65TL0KC+HX+uRYg6Mar4vo=; b=Aofk9iudXc7tkJNZ/CKQ+FNcAHOJaHny4Q+XPOVaD9dJu0hlwMEsIHEsw/d8mFajCt m9Eb5SYGJeh1FwMsfIXDF9ucB9orMQx2KN3qhxWXDs2+vOOFh2pi0CdSfXFgMK4JcIUQ O2EogDGThdjRaT0rOfDw5A2vLyoaA2B4jjO6l5dDlBkziG5WU6GhwoTAaIXivInj9Fk3 fnqi2FZVgSCcyJA+esWOACnJEejhNH40hxTktZ9naLwraDinjCwF/XXhSSfJi/d5GbZT M05v/dwZgJoF5snagff001jyESoFFzIMWOonWgGi4j8Of7ljpmYEAwprlglet2O57zK8 MtwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714639821; x=1715244621; 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=7HU2SkQDR4mMrV58+lW5U65TL0KC+HX+uRYg6Mar4vo=; b=P75QyQRo966DO8Dm4UgEsqCyQ1/j6AbND3PfmdVqEKQMmvR156MtznkI9AMmeoHcep 2NQUcJNKplG0K/BZ67vilYVEW86F/WQHcs7fEktIb+vsSHfvzV1ftHcQ5iUscCzZTqMc mD5V6OrDuV/nPvdLAqNIhO+MrRT6XNaJqqOcRFSTFNajX8sa6cPdEUR4fhJy6g6nqwTG qIqnsX79aCyAG9lp/0FLQ5yLD7iSQLM6TMgeJrTKgvDeJhx9y8CwALU+bsQ8n2sIIim7 O4msXUpXO6u3wLymQL9xVXNDSiFu9hteiI+Taq8gnclysWGdZOvG4vU49Lv5gdRcapoM npqg== X-Forwarded-Encrypted: i=1; AJvYcCXZM3I66d06cucypUuhi/g92hy9KIhklMWdPfWt0Tf8FPu0iAmCaALlbA3yNwqADjMrcATTbFENblAno4HWRamgH56V/gC/7GGZ45kPpCV/DvbvUgPPJxhbJrl5zj9qf9STWdBx+76HVyEVUtZ711q4Z9X3uXgUZNBHNbqORHhvZWTDnE2aXw== X-Gm-Message-State: AOJu0YyFu0uBFFqFWUPwzOTZ3uLZkNB+gjj1BY4e+6d8NqTqBuKzaxXT B23ZWdsbn28+dIel2vTZ+zD/gkdShBUdVJurMaAMZ8YhRDWsSAVk X-Google-Smtp-Source: AGHT+IEum/YkVi3jfWr1OA1pFH3dJL22MujEcP594sYqp7lP92G8EsNoWMfK9ZCNtKjcgZkH0nMekg== X-Received: by 2002:a17:902:c402:b0:1ec:c7af:881b with SMTP id k2-20020a170902c40200b001ecc7af881bmr3321063plk.54.1714639820550; Thu, 02 May 2024 01:50:20 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id j12-20020a170903024c00b001e43576a7a1sm737712plh.222.2024.05.02.01.50.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 May 2024 01:50: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 , 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 v4 08/12] nfs: drop usage of folio_file_pos Date: Thu, 2 May 2024 16:49:35 +0800 Message-ID: <20240502084939.30250-1-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240502084609.28376-1-ryncsn@gmail.com> References: <20240502084609.28376-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 407c6e15afe2..02741c32e114 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 5de85d725fb9..fc782d889449 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 Thu May 2 08:49: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: 13651422 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.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 A4905524C9; Thu, 2 May 2024 08:50:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639827; cv=none; b=mdsU8sn5VvVf4AcKxIQ09lP/duK0rJpyV0qyWP81uuz5zUJgTi4gRTDOTutdswZkEtKHj7cvq2ADe5m2C2n2EyRqrFIXhXcb4RdllnBYym/7xhLw6mDFfXcH37LfKhWITbi2dhmwNqxoxgVl3ha9/LoD8FB0wBpFymPQnJ3Lz8w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639827; c=relaxed/simple; bh=A16ESRJnqrffQYANB/rT6hqA8dSEkAter6OElqoTxSY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bL37oCRylR6SkX+xH2W8ZoTG9CuGeR+i+oKHLMkiErbo47wVaka7D8YAPqN8jrwKGzBtdRtjnEH1/L0sXXqIYUYUZNXX+mVEovE7Roq+eifb9fmZrB45LKR86sYZrlS0Y9r5asNwbwu39TGZOClpnNfxUIdh5jpfUhJdqkcDbyE= 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=nf18YyF8; arc=none smtp.client-ip=209.85.214.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="nf18YyF8" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1eab16c8d83so62453105ad.3; Thu, 02 May 2024 01:50:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714639825; x=1715244625; 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=6hBewYHOfG4Y6OYspQ+5fYKJoHCclq56Vlvet/Fbb20=; b=nf18YyF82XQUXhDPk7BAkVJU7SxRpwM4pQysIqgLE5RXdygcaFZfdiVsHKMcHit0k1 NTktnu5qgIs2DGa3IvcsC/rR3ncV6kB8OxwibF2+wFxMXfG87sIsFBCDAi5V785wTawp YSUBmzmBpvHu0tJ9R5pK/jc7NwVr24Ag1DHMilWdsCTGYX6rxRjbjzCvA6/nOVJjmSiD GvHMTUaGykV7EZ7cdq0ipsJSKJ5chs82UC7pyoQ2Nr+ec6Knh4FbAU9Dvd6iXRqJa+rK teVB2h7Vgf40yj/J2a/ucNaQFFy1/6vKzG+iI286hARLNQUTe8eUB05m6mJErPH42scV sXHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714639825; x=1715244625; 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=6hBewYHOfG4Y6OYspQ+5fYKJoHCclq56Vlvet/Fbb20=; b=p01DpRynRMgMJ/nRPTQl6zp69K6IN5LeCc4ED0Ftt7v51YKeHPYAnei5Op/8gnUOXf wKR5jWXTG9g5RFoYVYibcR0fklAYwavf5gBJOyIi0WxhciRiNGmK3hp1VmGBvOFuveeT 5+PS5kdkbONueHU2sKq5HcFTxakdeLujqC91pG+ZHt7iAOSwAAFW5Ec1Qvi14SAYwZ75 xpC/7vKcd+DwQ4qwp7vnBftvzyZftaSIU6mYymgxoVpJQSpmg6KXFw+HXhrfMnMsp/L3 7gFqUL2MDP8jZ3cnJq86okqQGpqdx9I5q3jftn6kXQaSQYfl64gIfeMOhYamwVtxvDax 0L6A== X-Forwarded-Encrypted: i=1; AJvYcCXK5aPHzH2MJ+WOp+SZJ4JBqs4TVlQvXx7JvwUAnJS3Bnafx0gMUOJSI6oh/Tg632POcUmP/UqmI5L2QCiI0/LeEBHf62r801SDHB1CascafQ5je33xhwKC5zgNLWoFEKx9wkEepls4WrAcug== X-Gm-Message-State: AOJu0YwgCIQkqg2YBJ9Vy8RQvlU55VQ9M7devt1GEJHbmYaBBoOYR2K5 XKhOK4hG7RJhMMohqAcYtdpiAo1PVG67NtXvLkrrwwSXJzrdn7KV X-Google-Smtp-Source: AGHT+IFwlpgfcGprAqZdcSgM1C0FcJW03lvq1L6XneBaZZ8VDethVtsd8vo2+hwdnNRHKZqs7qydvw== X-Received: by 2002:a17:903:298f:b0:1e6:40f1:93be with SMTP id lm15-20020a170903298f00b001e640f193bemr1586793plb.27.1714639824889; Thu, 02 May 2024 01:50:24 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id j12-20020a170903024c00b001e43576a7a1sm737712plh.222.2024.05.02.01.50.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 May 2024 01:50: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 , Hugh Dickins , David Hildenbrand , Yosry Ahmed , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH v4 09/12] mm/swap: get the swap device offset directly Date: Thu, 2 May 2024 16:49:36 +0800 Message-ID: <20240502084939.30250-2-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240502084609.28376-1-ryncsn@gmail.com> References: <20240502084609.28376-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 Thu May 2 08:49: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: 13651423 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 C955053E25; Thu, 2 May 2024 08:50:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639832; cv=none; b=YN3Q2CpWAGXHQAfOyEuYB90AFclmdzRKvQVeZP5ka3bCexHgVG0UUkm0wiBNmPM+zU7cBla0th2I/mnoITgvMhZFez4KYChQnadKdid/6MmJQz2kFlsWSr4InDRmKNvVaBZEZuvYlRzzQEJ9pqvdgP+g1YzCnumYO/+KV16soAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639832; c=relaxed/simple; bh=6okZCup/hwaohEI/Nc0kJ/Ps32cRxS/nkELSSS3LsjU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Kyymup6Dnl2MyT8Sn7A9ezzUeyPbWLWAB84jRzusF7C+PT9lJUnNLgjbxKGxa+3UCjS/seRylTK1vJPVHlF1IIwT4CcbUGeN7iEwk7wBPa1fLPtVchHkGW0bXqmcplULinn1dwxguPNC/1nvKhcJs/yfkD+3KnzyX9meC3QLTpc= 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=T7mux7+r; arc=none smtp.client-ip=209.85.214.180 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="T7mux7+r" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1e651a9f3ffso39782775ad.1; Thu, 02 May 2024 01:50:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714639830; x=1715244630; 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=hRYCaxyc5VxJ2RJEf4Sa/SOe2k8+YTvkzKGpn4vzx7s=; b=T7mux7+r3An3mECH17YpLxqK0QDcfXdoPg7Okbj9V6Z8dsOnrpRIbv6lJje9jvbDRm Ldp8/h1Rs/cdO/z2e//Wj9mFRA+9NAFmLjp6yg7OeuqQ2JXtmnUeIuVjGNlLxurec3E1 zbdWB49JCi48s6ziCx2rV7Cd2z5xM2cgpSYI6zSTIg/4q6rchK6X4Dzx2N6pNpq2/gNt JPzyPaYSNbbtzNqZshBKIM39Ql68Li7Ld88l12o+8lfhXiGqDlJZLpTZn/QJFgbxM+xk uy5gRy8QFU+JHoJVWdRvtmXCWtIiwyHBtdicJf4qHqTWV+xYCk844RDpmta/fpUuTm7Q zlVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714639830; x=1715244630; 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=hRYCaxyc5VxJ2RJEf4Sa/SOe2k8+YTvkzKGpn4vzx7s=; b=JhbP3HZhjim4VE/sfeuIKD37QjRe00Kadreq9LzdahqwljG/S6hrhmKtRhkEfjgWDA 4gNaAk8nLSVN7+50T7MdBTQoyKu0o8dQsufuyyGd2LjFgb4ITZA5DQB6CuR8LOTQEY1V WxrxbOzsg6uuGO5IaXIKt8okMUD68U+BoKjPKosWwjRKAuDqx3G84Jk+O4vc3S/nXVP/ RF7JVYncIp4W53n008e7TvtBxzu2TvZssJZGgQH/N/7Uf7fv3/w9t1rfCFBZBCl/a6eF 2DKy612cf5HOvffoYvS7lzHYwrRPUKtr7FKr9JbSjk9mdcPM28baVQNo5v7XrbTtn8zX QRKw== X-Forwarded-Encrypted: i=1; AJvYcCXRybxg3m8bDWUIVb1Ki2qoCw1AE88uga2wzi/FtLQeKDl6mrGb80AE7mlJoNd6zYdaf+YWix+CmgapKuwh5R1+djn4tAQ5OS7tq3FHR+GZA8bNpLC9fVlMagpkYm+PIqG3eNeaQL299UgVTw== X-Gm-Message-State: AOJu0YwgNk3bnbYcV3OG04aUCzDuhkquEAgYT0YeOPwUnbZhyyaRiQHH xkE5VHXBKslHfAxrvGtr1Ak6hNYYjhd6pXeFQOH0dM6RT7ryGLVBLaDIpyaGfmY= X-Google-Smtp-Source: AGHT+IHufI+b2KEWe7q4ZEgCWkfvkErjirIAQy1x6ZDt9+l/U2kkILUWyLVdHUQcPqggeeFX9lCXKQ== X-Received: by 2002:a17:902:c3d5:b0:1dc:a605:5435 with SMTP id j21-20020a170902c3d500b001dca6055435mr4637953plj.31.1714639830052; Thu, 02 May 2024 01:50:30 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id j12-20020a170903024c00b001e43576a7a1sm737712plh.222.2024.05.02.01.50.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 May 2024 01:50:28 -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 v4 10/12] mm: remove page_file_offset and folio_file_pos Date: Thu, 2 May 2024 16:49:37 +0800 Message-ID: <20240502084939.30250-3-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240502084609.28376-1-ryncsn@gmail.com> References: <20240502084609.28376-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 850d32057939..a324582ea702 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -918,11 +918,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. @@ -932,18 +927,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 Thu May 2 08:49: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: 13651424 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 5AC20548E3; Thu, 2 May 2024 08:50:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639836; cv=none; b=sC/cyN+zUi/igPdhpKulqFxD8ZV+Pork3nby8+yihQmNC0520hMxO0/EnnWTgMWnPwFvxgmMMbztDMjYqIFewFgfkOF8v3gtjstM1/+uIiBJdyuGpl3j+zVc2y1l4wcX2mbTZYPpqN8lu7bGKo9SAlXm0EpLkni1Iwa1WcPElRo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639836; c=relaxed/simple; bh=2lTtUhy8NY0Kb0Je8lGpuIe60RILdhnqU96HnhHFLoI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GOj2tKTYjM4Oo/tR15+jb1D2OoONWAJbSXWR5rdFmsjjxb4y76ySoo6Nq+0V2cVjoqpS5yCn++z6kNwBJO5Rbip4EG7iJBJK23Mf1NJRp7p2sQ1u440H2zL5Y1+I6piXgmm0q6050UHH/OlWDVCc9oLSS8EJhZslCKEzEK5HsgI= 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=GNZ7iUYx; arc=none smtp.client-ip=209.85.216.54 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="GNZ7iUYx" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2b387e2e355so476896a91.3; Thu, 02 May 2024 01:50:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714639835; x=1715244635; 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=Yc7f0BGrdGPhDGlU0I7BQHsZ8DqIMKXeboNv+kAHs2g=; b=GNZ7iUYx/MScLaN/taj5dbKE1Lf/YojN31fX6e1M6nLIOFM+Do6WuRW/0lbuVQJS28 XHnguTT+w/LMUt9RM8BmSFKoBDHGlVwX5crWokMYM+QL4GfRL6dcYj2z3LGOIRGdNxj0 0xyJ7lM/0Hczly2y7RRHmWP/y2/GLzAh5TCrRv8GTjL8D66Rr4GH+ryXkT2BH7OLKi3g 67gAhA4Gq1eKihJxXttReJ/lajRIdzgChDIAtXY3aFPjMIBmcxnmDfV+HoO8eK17YrBY x8Mfx6MJR4PKhuyob9H4LALcRb8TseXTxbhIFdK7mZW7jhFKFGxDroGJeo6NowtDUk3P MPQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714639835; x=1715244635; 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=Yc7f0BGrdGPhDGlU0I7BQHsZ8DqIMKXeboNv+kAHs2g=; b=v+eBRrQ2sCWtHsH+LLPg8eyZ51f2QKCMk1ujs0wBEeO/0v3mXyrMAkDLRn1+sjHTs3 wHALrPqsE+OV0M2b/0aFhyCnT2nfl7Gg9en/mbmAUwZ2518DVuMCB800ybEzepQGHAEC ikM4nGgHcDCuyvbCDdubgN2Fi/O9pVIa882Ol5twzVkFjX4wrGvjyI2736MVX42eNz2G qTtFkVCqZGhGHS4uZhIn8XiV/FVGefFy9gnirrengkk33UH2vigrMEqb/lGCWwsM7TG4 J0nmlGAIg8LzCflVxyQfgkumKBIM0K0WibyMYz3prOHmPz8k0KrLzk3ms5lK5uIHqQ+m iLPA== X-Forwarded-Encrypted: i=1; AJvYcCVkeVJHZDc5nijMk46wx5uOL7bxQmmtquOimA3wuGDcWvg2OIz/q09ajVd8PxXGq3+tBHFxKlUVlGigoX5Ee6BpENOYtnSUkh8jUfqPAgTJWidm+DwsQhQoR8ZHf6kgUqGbQtPwgue/le7TTg== X-Gm-Message-State: AOJu0YxNm5TkK8dFIbMznyboipftUBOUp3YnfiHoamMU5hw+2yJS41hH G+EVxLOJvA11uhIaU7swO8QpttZCTPrqbe9vf4s1XYO6onaSZNCS X-Google-Smtp-Source: AGHT+IF8JauY0lS+CclTlem6YP0P2WISNCLiZMNb+dGq5Yq+NqFjwzPOoTCiT1f3BMH1TlaypNnwnA== X-Received: by 2002:a17:90a:fd81:b0:2b2:b1c7:74cc with SMTP id cx1-20020a17090afd8100b002b2b1c774ccmr1628463pjb.26.1714639834668; Thu, 02 May 2024 01:50:34 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id j12-20020a170903024c00b001e43576a7a1sm737712plh.222.2024.05.02.01.50.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 May 2024 01:50:33 -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 v4 11/12] mm: drop page_index and convert folio_index to use folio Date: Thu, 2 May 2024 16:49:38 +0800 Message-ID: <20240502084939.30250-4-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240502084609.28376-1-ryncsn@gmail.com> References: <20240502084609.28376-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 (wrapper of page_index) This commit drops page_index, as we have eliminated all users, and converts folio_index to use folio internally. Signed-off-by: Kairui Song --- 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 a324582ea702..0cfa5810cde3 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -778,7 +778,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. @@ -793,9 +793,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 Thu May 2 08:49: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: 13651425 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 10A3051C52; Thu, 2 May 2024 08:50:40 +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=1714639842; cv=none; b=T6MJBHIsA8HhtznTOIa4mxUSPNUrzo3SeWPizmE5QuJnTaS7IT6MfhOANgzQdZBzBCDSLhTQFCcykxUXjOqiKtZEM8jRGmFV20mTebNxPhlfrp6fW35ShOx1W5OJLupBChzRbayo0DMoy6B0cQQqtWzLVVKZn+/evRp7PCoXiQ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714639842; c=relaxed/simple; bh=QtjPzm848WaTX4wD7eJT/9muTGxuvsi8xU+gsjdN0mU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R+bMSO/ELHaiClH/LWY5LsJOQ4rVE+uRW4TlhmSvL1CHPKdxoprKR3vDdtF5H25+hWgoj2LLmqdZu00EQ48lNoKh7JApM6vrMOJdUMVe2XB1pNNk74Zw7O3ZHMRUTL+YjMg9d2vlHuGAHElrjF56lMJfZ6DCfzHrv3yVA/bqLzA= 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=AsRJ/DBk; 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="AsRJ/DBk" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1e5715a9ebdso64232885ad.2; Thu, 02 May 2024 01:50:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714639840; x=1715244640; 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=3PiDuUAmL04AUzqx0Yl3XvlHAjrbgNtWVpZDxU2pdrk=; b=AsRJ/DBkDSfFzKn8p9MofA0nmJiaYelmjslR3OZhe8e2GVVfJlcq35lxDhXGRrIREJ z4Cp22Rno83TrWXpwQkLUt15rykz+pT3p1Tg8eQfQj+FxJo/f0DMip3oKgEZThfFUsUr K4/dSz9FI5p/4qnBR1328dSmAfSO6ufFTb/3UqfZD+HgIJGFYxjy7BChbtibEoAtdrU6 Yv9TRnZre/9q9qJQYPqGlGCui138KyM6XEG08uSC57BMjXpYX8w//+IVwEOFAzz1PRXE +wpF4Sr/HLXqMURflDrTFmuTbBMFTMnPTo+WWSG+cckL7Nz1HgoDmR2EKIByKtTtDxuV B2eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714639840; x=1715244640; 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=3PiDuUAmL04AUzqx0Yl3XvlHAjrbgNtWVpZDxU2pdrk=; b=uA0yL5jgeFTssNyBmmczz2PVRn2AdXdxsPAMdIVPVC2khjkNHwjAHO4vqT2Z/g3oPM yF3aCZVZ+C2szKAJNECIzDI6zZaHKhgookBjr30pjgvoULtaPMJ1t7oprB5mxoVQN9/o c9ysGo4lXaOdOoU6Q7b7+Ev7X0w30wrDbkv91Eb5eV6c6SAMuY+xV3UZDAj3TmhwBnFi DHZZS16V0eP5sVOce87Hyv14UUAT+0l1JI34mISXICHwh/t6OngiIOlD0tMMIsP8wHI3 X6dab6fplWB78j3c95v+c4r0XJiy+4fnVz1nmWHv6s6R/v/qALm/EwktHxz44y+UFrmJ 4Fog== X-Forwarded-Encrypted: i=1; AJvYcCVIE+7CNtoyTn2l3Hiu2RQvsLJl71eSbyX6pDDr0dSRjk2Q2V8I/XBGszkkENH7BKzDi0wkpGQkJF0dWMYBLlIjkEl8FNNgvadm+H/MbpOtob206XJ+IVSk3GqD/hDaN8zIMbgngBD+cBR3Sg== X-Gm-Message-State: AOJu0YwWalbxChDabWqTIJeVVEXEzVD7UDenhwfsNykemL0VUtGm3KZl YbNl1CLKdRXwqUWPbko2TcIjl5gqQQd7D4J4Ymr3iXEHhm/s3wEE X-Google-Smtp-Source: AGHT+IFQrOIhO4DW3kC/6U9SsFXYwY7es2c4HumW8eBEkpYQadnethvvJ5+C7OMiTTPsFpu/GER8Pg== X-Received: by 2002:a17:903:246:b0:1e7:8d21:7fd7 with SMTP id j6-20020a170903024600b001e78d217fd7mr6287081plh.28.1714639840392; Thu, 02 May 2024 01:50:40 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id j12-20020a170903024c00b001e43576a7a1sm737712plh.222.2024.05.02.01.50.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 May 2024 01:50: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 , Hugh Dickins , David Hildenbrand , Yosry Ahmed , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH v4 12/12] mm/swap: reduce swap cache search space Date: Thu, 2 May 2024 16:49:39 +0800 Message-ID: <20240502084939.30250-5-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240502084609.28376-1-ryncsn@gmail.com> References: <20240502084609.28376-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 --- 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 | 19 ++++++++++--------- mm/swapfile.c | 6 +++--- 7 files changed, 32 insertions(+), 16 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index d35d526ed48f..45829cc049d2 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2918,7 +2918,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 d11536ef59ef..81b005c459cb 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6165,7 +6165,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 fa2a0ed97507..326315c12feb 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..93e3e1b58a7f 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 (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) \ @@ -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..09415d4c7843 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); @@ -248,18 +248,19 @@ void delete_from_swap_cache(struct folio *folio) void clear_shadow_from_swap_cache(int type, unsigned long begin, unsigned long end) { - unsigned long curr = begin; + unsigned long curr = begin, offset; void *old; for (;;) { + offset = curr & SWAP_ADDRESS_SPACE_MASK; swp_entry_t entry = swp_entry(type, curr); struct address_space *address_space = swap_address_space(entry); - XA_STATE(xas, &address_space->i_pages, curr); + XA_STATE(xas, &address_space->i_pages, offset); 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, offset + min(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);