From patchwork Tue Apr 23 17:03:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13640388 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFACBC4345F for ; Tue, 23 Apr 2024 17:04:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F9246B0142; Tue, 23 Apr 2024 13:04:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4809D6B0143; Tue, 23 Apr 2024 13:04:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 321F86B0144; Tue, 23 Apr 2024 13:04:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 148086B0142 for ; Tue, 23 Apr 2024 13:04:03 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 9D806A0125 for ; Tue, 23 Apr 2024 17:04:02 +0000 (UTC) X-FDA: 82041419124.12.1BDE763 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by imf19.hostedemail.com (Postfix) with ESMTP id 4839B1A0016 for ; Tue, 23 Apr 2024 17:03:57 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=fAl977Ry; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf19.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.216.45 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713891837; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=BixicrujN2w/NN7W8Yk1bOtYDD16jf87ysiCrI+mjZw=; b=vEqow1L7KAD3v4h7SOsH6lC6FoCekqIPB5i+xlxFstSzjKd5vfeYDjMOndXzrIG96Vd32H a6UpTjGPeNjTX/lPRLfrOzA223Gpb+n9V+k5gRQMcPsCUWf0gNxPUtZ57nvNOXiF0ToVSF Yhhi/MCNM6+2/NVFUEBZVISh9uTMdjs= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=fAl977Ry; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf19.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.216.45 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713891837; a=rsa-sha256; cv=none; b=OtDKc+LQTHq/qadaTCh0GD9BaOXNtWmiudQRfHGmFHL85EzxiYfC4Q0T3AjEU6Pj4ClZF8 Uth7qbNb0Om+MSjelbnekQK73JV7EYikbsk8qVOA6PtlEW1+4H5CeWlbp0NlxE6h/uqdFp U+L07dWNmtCXvyyiQb4mVX/WSEhBrfE= Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2a526803fccso3868762a91.1 for ; Tue, 23 Apr 2024 10:03:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713891836; x=1714496636; darn=kvack.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=fAl977Ry6bphYRyw8xToHIyLh19iYDIaiDvBKR2oKPj6QbxeqpEFlUpToi85vBUon8 l5YJ6EdgR24tfP0O5iEMX0eAWEhYOGglWzQ/SS/K2W8ulN42ic1WzizcBA+4UAsDydrM gpRAJk8v+iuMm/ZJoXdxchoBkaJznoq14u9P9STUX5XMa+HbxO07ePWDDnYHm1Bo9CL4 wOBpoa42bsxFp+ydVd05mFULx7RpbLabCAfIm2jL9H73nIAWWyeMmhpTcO3Fww6/zFz7 uHAVcXTE4w8EbaplEtlNS1IwgRIrXsUSTW5BaYszuF/bkrDW6PCfOQBaOPJL7f0uml6q AN/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713891836; x=1714496636; 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=iFYm9ZP9fYxuxOjIDx6X4SfldsY+BE8V562EFrkkYSwxKybdQdEmm8lgd25P+sYpSb SAZzKMBZiFEibg3+xUXRb6wDKnizB8RG5f5bahd2n2mSZqu4kSzn0hzKGtEiLMveRbvj S5szdGFD+VmGx0EPk/YyN6xLAPFjEx5ApRdJ4D0R/Zg69t2h5qgAy4MBaMc1Ls2WS1Lk wPphpeoxQg78FmbtnkAOSoAkNuLOH4JcN65B211Wpj5DKZHx3IpTrJIYkdqkiaOr521Q RwrjDL3l0nm4CKxxUoYof6B9lUpgYvpZGuudleAYvYUTYGxkgNfQ458T5J9EAkdF16Q3 cNAA== X-Gm-Message-State: AOJu0YyhKhaxLeDX/cQPTDUsFlaGucM7fIFKfpwP75He+6cDIoAKydbg bdn+CxoktJKQJO7YZOcDXgVJcNlsmjrhnq6Vp3/tSnaowSrCnOeaveO/tfoYVvO7sw== X-Google-Smtp-Source: AGHT+IEZ4GKNo+ZGTgIioZ6E8Q2/FLCJDMv5q/lYaYPH5b0i9NhmaYmcUV6iKdtOBuu19Rf+VfV0Ww== X-Received: by 2002:a17:90b:1205:b0:2ad:c098:ebca with SMTP id gl5-20020a17090b120500b002adc098ebcamr7093107pjb.20.1713891835397; Tue, 23 Apr 2024 10:03:55 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id s19-20020a17090a881300b002a5d684a6a7sm9641148pjn.10.2024.04.23.10.03.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 Apr 2024 10:03:54 -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 v2 1/8] NFS: remove nfs_page_lengthg and usage of page_index Date: Wed, 24 Apr 2024 01:03:32 +0800 Message-ID: <20240423170339.54131-2-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423170339.54131-1-ryncsn@gmail.com> References: <20240423170339.54131-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 4839B1A0016 X-Stat-Signature: 7hwznbyk5ek5m35qkyj1m4tycfbasagr X-HE-Tag: 1713891837-777316 X-HE-Meta: U2FsdGVkX1/IVT8kXpNn9N22AEjYgxXqxKO8NTgGubB8JagLyw8QO6f7jh3H8wG4jHGjHAbWP4WCf4wAh6+QzdThb+cIB+syoaP9oS7RXfvMddtK+cY7n7nhnRFzNQ0zH5KNg97tuep7VR3qrJa5wEZluvi19ceFFHR/pMisPMtqzVX2+myLcVKWWy6ckybMyzaI+dU3RSorf12H3MI+1O6ipXWX5+Op+MHwyR2XbU2ugXNk3KCRXTrxw1BeLPoF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7f4Y1bEjP4JzaAp6Xo7dD6EYSrqrh6MLvEf7TOuLmpDB1PQpIaaqFqE3/kcmaOkRh+LLmS1Q910yuIfH59iRBPCr+gkuxKyW5dprh4NscXKM0muN3g7BJ6z02Mo3I0nCEOISRM3FO9rSM/IoqWE9QLMfgztp+Yo5Eoh44TPEXeEJrGNDL9l7cDTvLCzX2fh76K7ZK8Ikk5yRl0P6fpfYnq2ARfAAZVRkdQwn9KPvF+0xh3CYtJ7NTS2vt1O3apfwnpf4sV48LaOju3WPHTR3YN8AB9FXI2ngs7ifT4WpodP0tD6+SZAxz1TDfM9kOIfn7D1zs14/2rV2EK8cDSWMt2Fts0EhqNEqMqUvH3D+Ii7yimvuDT886zf0iR5CxZxEdTetvo91MbTYxDSWrDPOh+blCO7Za41eJpyC/Z6J6IcNK8I/oPRGgjc8YLW6J3StltLOrjeAgARzmDtgZQGNhUkwdC X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 Apr 23 17:03:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13640389 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50005C10F1A for ; Tue, 23 Apr 2024 17:04:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 14E986B0146; Tue, 23 Apr 2024 13:04:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D81D6B0145; Tue, 23 Apr 2024 13:04:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF6AE6B0146; Tue, 23 Apr 2024 13:04:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id BCE216B0143 for ; Tue, 23 Apr 2024 13:04:03 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7EE7D804F2 for ; Tue, 23 Apr 2024 17:04:03 +0000 (UTC) X-FDA: 82041419166.16.4622DA8 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by imf08.hostedemail.com (Postfix) with ESMTP id 9FB9816001D for ; Tue, 23 Apr 2024 17:04:01 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=eGoHdEg+; spf=pass (imf08.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.215.174 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713891841; a=rsa-sha256; cv=none; b=ntFuOlKi6arrRG60Fh9DckyDhJf+yUqOIy8AWv6eY20uwcsNO7SP75Fgc3Rh5qFHZ7lNxR XiysVdpEyfqqOAa1BfcWIWNcO7y8FRzLKLxwKnZUTDhQrwecpKccyBZYFo6p37P/LqzvmK WOFe07uofjbDvRBnUXogMMncH8sIAXI= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=eGoHdEg+; spf=pass (imf08.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.215.174 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713891841; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=YfpxwnN8CfoAe7aR3YgTjEdl37ZW9GmobE0CddHnTJA=; b=v0oH4jlCUHMoeu3chG+/KSMVWG/so/aDpZ8fSmwPMIjqxlIwrNVCGbWckht8AfTcFhVXPr /ctWBXFvQzcu0EHy9bqRNFqnF+nSdfaHpYG7GaLKVPYTbaWuJjc9/8d2W2zUoUDPrHBAU4 EwFIOHW4Eio5F2I0sAV7a9n8CNmfPbA= Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-5f034b4dcecso44654a12.1 for ; Tue, 23 Apr 2024 10:04:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713891840; x=1714496640; darn=kvack.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=YfpxwnN8CfoAe7aR3YgTjEdl37ZW9GmobE0CddHnTJA=; b=eGoHdEg+LAgQCr/N64QaScmkpif9KPZjnJjoyR6+SeY0cxF5F4i8xJ/kGfZXyFp0c3 P/7dPoPq/AJX3vYvU7lBR3+zDOSK8hlfarvYAhnzhOCmT5ofuau1jE/Lb+r9ed5l/bL1 GWrcgX543kf/xagoDe1Av+kiYteNN+fU7FYwn+SMVFTnA9xQ1Rb5dEecKq2qXOMSo2jP Ri7lsd59cOiJHiDEntiFn+wkzUu/N6hZpyWI5tKK1u5RQVrHAkC8eY75hWqD1cVPAGgq lWoHCUP7O+ylWl1JI6wZoZVgo6ZG0NXp4If28cKCmDIjWx/Qj5uXwtrxTnTXwYfDiFpT IPjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713891840; x=1714496640; 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=YfpxwnN8CfoAe7aR3YgTjEdl37ZW9GmobE0CddHnTJA=; b=DHwOxEXHf0N8+BeKv1hlVVqUlqfeW5u4Nev1OR8HgfFL0D2D7kfNI5Wx8C4jqGCRZ4 OhG/yhEL9KneWxniHJq6dnDuBbaipaSerncsLcWPqOiEZwL0huib1WaodJsIXhHTTjNc GERMCK7bEv3uEW6EUAMydps3O238MXz/lm0lyG52LuTFE8TnF1hi+SJ3yWR9UeZnPTDZ kMuaTyYQ8VnUcl+DXEPEo8HW3yq00lejA3C5KpelKQFOS8jb/kG4ZZNbjNMSzXXUKnjk bB0E+6LBHFl36Z4kF+erhShZbfQJo58/pUboDoacrlixg2mhtQTTTrsNFWG5ao7jxSko KCqw== X-Gm-Message-State: AOJu0Ywmw7YMjkX/PjSAsKMSgnxOZzUpVozbWuybNX2MeT8mxUb3Yfmk +th9Nt+cLIjctGKGqnDMpM/2iDSMwo+uzijDXqe0b/HfdWPKpW67n2B1WbdPmJb+hg== X-Google-Smtp-Source: AGHT+IEWWHhF19ksGF0RHc9H2/SNsHmOpvGzFHUqvC8eQ1hIjSvMBjQypYUZq4AUNd9PZKflJXxjrw== X-Received: by 2002:a17:90b:815:b0:2a7:8674:a0c8 with SMTP id bk21-20020a17090b081500b002a78674a0c8mr4130992pjb.1.1713891839853; Tue, 23 Apr 2024 10:03:59 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id s19-20020a17090a881300b002a5d684a6a7sm9641148pjn.10.2024.04.23.10.03.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 Apr 2024 10:03:59 -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 v2 2/8] nilfs2: drop usage of page_index Date: Wed, 24 Apr 2024 01:03:33 +0800 Message-ID: <20240423170339.54131-3-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423170339.54131-1-ryncsn@gmail.com> References: <20240423170339.54131-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 9FB9816001D X-Stat-Signature: sgdnnk7e4kcghhgooh4d84wn3u4ogh6b X-Rspam-User: X-HE-Tag: 1713891841-203761 X-HE-Meta: U2FsdGVkX19JTHGtEsiGj+OkDjzqC+p3f9Rs29Rxjf8mZpGU/81mqIr1ExHzqr6X79VN2UBYyA9hHBaUDr8AQClNPFwZ/ZUuIvXRgSof7Qaao4qy0kcT+sQjwzRW7r0wo4wvCsaaZynPhqTVN1EznGbWRGbvadqHGVF82KGYR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4OUTUzjdnAv0wH6HvJeoyEiHMd6/VgXfEGUgLsA43o7plXrxQryEkC6XMLXG3iaz0aOj9dnWT/PTf10yVPGzbfTc9NbuyA2acDI6m5FZF84shFeZ08+7plyel8/97AFdmVhdy8XD1PHMzG/fRa9y2T+v10L7N9MJmth6MFUD8fngVodk+/HCp6PRAHoy2l8Rb9Z/zyRy17iMyOyqgKZZ3PPaJt6+KZ8kGy84QgCz/V8fZtDqlr6ynIhAMR0ahZ+iCGF+8vde262NejgMS2xGYLtwy5LngpGM4dz6kuR94O1nKCQImyiZ5m2LBdnQJCC/t3B/39vQETC8kF+8AwvVysJmFhW8KsRIOPIEbbMNssOKujZR61Z1wp2xNXia/V3C5QURX1L9xYBKlQqmZahT/zKRG/uqK5HB+zD8Iw2ltxyBKkWfnbOibRUSTp8meJvb9D9lk7+cQV14AL8NNG9Lmb7jIrXxgSAzwDjzMyur/ywelSO8OaI7NZsf1yFAc1jqx5GnTKCtfURWsZw9sAZw63WktcVMDUEBKQTIpyUKe+wsx0lgJpkS+RNnpDaqc0hUAtoNHuQ1QA//crsZn3lA8uql/2jmKw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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, also convert it to use folio. Signed-off-by: Kairui Song Cc: Ryusuke Konishi Cc: linux-nilfs@vger.kernel.org --- fs/nilfs2/bmap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c index 383f0afa2cea..9f561afe864f 100644 --- a/fs/nilfs2/bmap.c +++ b/fs/nilfs2/bmap.c @@ -453,8 +453,7 @@ __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap, struct buffer_head *pbh; __u64 key; - key = page_index(bh->b_page) << (PAGE_SHIFT - - bmap->b_inode->i_blkbits); + key = bh->b_folio->index << (PAGE_SHIFT - bmap->b_inode->i_blkbits); for (pbh = page_buffers(bh->b_page); pbh != bh; pbh = pbh->b_this_page) key++; From patchwork Tue Apr 23 17:03:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13640390 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB727C4345F for ; Tue, 23 Apr 2024 17:04:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 67E6A6B0145; Tue, 23 Apr 2024 13:04:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 608D86B0147; Tue, 23 Apr 2024 13:04:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4816A6B0148; Tue, 23 Apr 2024 13:04:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 229636B0145 for ; Tue, 23 Apr 2024 13:04:08 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D6B3B160F33 for ; Tue, 23 Apr 2024 17:04:07 +0000 (UTC) X-FDA: 82041419334.07.8198B10 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by imf18.hostedemail.com (Postfix) with ESMTP id 0245E1C0012 for ; Tue, 23 Apr 2024 17:04:05 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=kmQsIYUi; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.215.169 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713891846; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ccxP7TY1LZd03lAzTUSjd/WMiiw2l1TFGZjibmTvaRo=; b=4fcY9SwNd7/yHweC/bRZQZ+oFo4FQfTTPjAEkw9Cwy0oopBrmGlQmP1/pZITOf2cTEeFCh LS4kNJhv7HXlvqPRAjIBmpk1/k+pg2P6JXeNJv3UouqULkUW3ax30thk/e3tCV6J2KIl9D t/ReqZBXA74B7PpQ9ftZ8iQH33YSAxM= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=kmQsIYUi; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.215.169 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713891846; a=rsa-sha256; cv=none; b=6+oYcat+fhRYMq2UReRMC4o8Grg68jydbTSnjDBDXvgK3mGyloL5JTX4Y7MmtGZBwwq4wD GC3ZxTgFPYUdZSPgZnq7keAfgxH4scUFAX4wQa6G3+cCyfFFKfI1aaoIaAWiMoLt7NtEsS dF6/U0bBBAF1H/tEorwAX8SCt8x6MHc= Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-602801ea164so1226634a12.0 for ; Tue, 23 Apr 2024 10:04:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713891844; x=1714496644; darn=kvack.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=ccxP7TY1LZd03lAzTUSjd/WMiiw2l1TFGZjibmTvaRo=; b=kmQsIYUizEfV8/zustHfKwaTBxr6F20Cj/KtAOk6XUDDsq6JkKP/JbjLTkmADzrpFH SYiPRM/zDAIlY4adTYP4GnqacmT0BaAvGHGJHCzsuInWfyGHWYe317Rchf8ND5WmKSt2 pvcCik9NqrpeQ8psP1JPwDInqhaXn/f/+vJoUPdaQHRcz4IycmciSf/HhEPcEMIJjyR2 bwpCV09vea7JmTfED38BETuq8SkzNwM142zHNHkTRfuE6e8cfQEFUnt3najLjA0RisU5 xqrMWcZBLyAq0sHheCx2+Se12nuqJcZbkM04hCO3ExjWcz/xkO1Q1pWMAWt/wbs1b+/e /trQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713891844; x=1714496644; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ccxP7TY1LZd03lAzTUSjd/WMiiw2l1TFGZjibmTvaRo=; b=JB5e5mwdTsmInf2t/p/REfTwBUaWZccIOIfukiywOjIfbgaYFZRTz5A8VFVeJz8Qfx tyjVCMuT0CAG3QqCq7RhS3gTIlIng6tN938T1SzOvEFuByrLVVh80IX5K7/szH/LWdp3 L7S3m4d2MryCAtVhDcmfu3PubdIhKOApq6UPAC33RL22strqD+StsQNHPeFYRg0ya5GR kpIrxqvvaD+td5OUsp0uHfJcnEIG8rqMxKbHeKaThd4f0eLHVBSNw/9V63d0yciLVW+c Zw9EeuEXPbbNKnBHtjclNM0UPFyYuAjGzKLYeZYVS+rNiUZQHXPfYiFpQygRskG5/Opb BrRA== X-Gm-Message-State: AOJu0Yzlh0krtvI4dZ/U0Cr3O050lX7zk/ygNPXzt/Im2Pz8Ze6FeyPM jcsw0gkUMDEzO6Vx6oAlsaCa/tCHAT3EQ2LevJT/2ulxpU1yANgzaCy5V2VoPzPW7w== X-Google-Smtp-Source: AGHT+IFl9PJyw3gV5yMYnps/pmPpaL5DbNMyQbbzhrOpZIakLlc/OOAGq7K0pRF3PyTBE2M2iwLZlw== X-Received: by 2002:a17:90b:238b:b0:2af:15db:c741 with SMTP id mr11-20020a17090b238b00b002af15dbc741mr325358pjb.13.1713891844299; Tue, 23 Apr 2024 10:04:04 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id s19-20020a17090a881300b002a5d684a6a7sm9641148pjn.10.2024.04.23.10.04.00 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 Apr 2024 10:04:03 -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 v2 3/8] f2fs: drop usage of page_index Date: Wed, 24 Apr 2024 01:03:34 +0800 Message-ID: <20240423170339.54131-4-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423170339.54131-1-ryncsn@gmail.com> References: <20240423170339.54131-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 0245E1C0012 X-Stat-Signature: s6u3kh73u8qp8f9ofzzzuk53qj1wsjwo X-HE-Tag: 1713891845-920219 X-HE-Meta: U2FsdGVkX1+bw8dp7OXlCpRReksEWLlqFEn9UxzT5wdjl8fywcqjjLWmxqyVS2/3CsmF/EN/WDod6tOnWXy7aqdUu0uv/yJgJJ73lFEocqcx2hsSuSRnpYZdgF/1T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aDxQNTfxbfPiklL+WH4Go2VjBQWXSivSWB1niqwe4ws02wcSyGrUPnAFSGQ+QHtWsT1ug9olwA9qpAdix8cVSNfgDIikv1qSI5VoxnAjER9QzFE41pn+7GaNIjSBu1svjf/IaDSVb7W6XdVthRwgwqpF2nSj0h5IokhI9sT8Y7pEaExZOoUTqY281cMxQnRXqvj5gTjf4+pzrUJlbOqOMkAuwtHDzHZyH5818jg5qiUPbc39eWkyFzjRP097/mtft1FIBE+r40jU9+vF2YmtX0nd8LQMuCBupDqd2xJOUkcbEUt/v9Aw7gE0LKgDNywk7C5vG66GEJO6ApebWK3uYU78SRx6EQHSLG3EeVfIqbo5EGHY2EJgiTx/lWM14L2f1+jaR1VxIZMJW/2TLxn0YH+0QiqSZ/f41n6KIsi/PCQK9DslvJCRXHwVngSa+MQXX0GTfwwTRzC0JbE5qTsWFATKh5MvbJY2hGv75DwXiPEE4Kf7qnybWdlUtqzOu47H3HkrUo130h/KBXe9QwbImfDsKdaRoLQ6kDj+6hdG4QQr X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Kairui Song page_index is needed for mixed usage of page cache and swap cache, for pure page cache usage, the caller can just use page->index instead. It can't be a swap cache page here, so just drop it. Signed-off-by: Kairui Song Cc: Chao Yu Cc: Jaegeuk Kim Cc: linux-f2fs-devel@lists.sourceforge.net --- fs/f2fs/data.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index d9494b5fc7c1..12d5bbd18755 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2057,7 +2057,7 @@ static int f2fs_read_single_page(struct inode *inode, struct page *page, sector_t block_nr; int ret = 0; - block_in_file = (sector_t)page_index(page); + block_in_file = (sector_t)page->index; last_block = block_in_file + nr_pages; last_block_in_file = bytes_to_blks(inode, f2fs_readpage_limit(inode) + blocksize - 1); @@ -4086,8 +4086,7 @@ void f2fs_clear_page_cache_dirty_tag(struct page *page) unsigned long flags; xa_lock_irqsave(&mapping->i_pages, flags); - __xa_clear_mark(&mapping->i_pages, page_index(page), - PAGECACHE_TAG_DIRTY); + __xa_clear_mark(&mapping->i_pages, page->index, PAGECACHE_TAG_DIRTY); xa_unlock_irqrestore(&mapping->i_pages, flags); } From patchwork Tue Apr 23 17:03: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: 13640391 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 628FDC10F1A for ; Tue, 23 Apr 2024 17:04:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C72566B0147; Tue, 23 Apr 2024 13:04:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BFB486B0149; Tue, 23 Apr 2024 13:04:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A75116B014A; Tue, 23 Apr 2024 13:04:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 845116B0147 for ; Tue, 23 Apr 2024 13:04:12 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 44C3E120AD7 for ; Tue, 23 Apr 2024 17:04:12 +0000 (UTC) X-FDA: 82041419544.10.53BEA30 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by imf03.hostedemail.com (Postfix) with ESMTP id 9C1FF20023 for ; Tue, 23 Apr 2024 17:04:10 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=IVEr7Lp+; spf=pass (imf03.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.216.42 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713891850; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5+IkB3+J9K42d+V5Wi+AdhWpwnXMtEpYhZXm/5fw+dM=; b=lStpTaFk85i8t0GpPLYSqAtNUySw6ye1hIOqUUCvHbhxnTC5uovZN6sVLGqZkoJDx/48T3 BYhuKynXFK8/yZM31Vwe79j+tpXOfI7Lx2eBQKMyeXTY1wV0vy6MAvPUD9rWTx9lWF7etP emR6kWfw52/EthtVKbSqA7ZEydgS6jA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713891850; a=rsa-sha256; cv=none; b=7VKm1fJmUJF3zRiuLa8AW0s0HClOrgXUeIOO463eUVBwNrZY+j5h+j0oiTzZozcw1KBsd0 zB3z1+aG0886/B6/8T2sADYqOSUA/RkA23LqWT9vYmsp4zbP5w8j9+SN/xH0gt3D8PlOWd K5L79SQ4OpHQXLtezrBkEGzl38JpJf8= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=IVEr7Lp+; spf=pass (imf03.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.216.42 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2a7e19c440dso4155960a91.3 for ; Tue, 23 Apr 2024 10:04:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713891849; x=1714496649; darn=kvack.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=IVEr7Lp+sLJMLkVmZJri5UmCBSe/E0zmhcfAAY9e3b8hWx49sMCsV78BHKGxQJOHyl ev9E0YNc14F+CoflVIYsbn+aiAN+oKu6GIUz9mT805WB00iEEsRXU8IrkGsOROJJit3h Q5nrjNdhf6UgYE6X1M3+CmuLaj/JOGcOfEsxUjYiRCaanYpAAKjUFY9zTsVfJZlKaiMD I0avyEuLsNNDI4HjCkRIZXJco8d9JPMsbEB0cSBoin8MHkBUobVIaP8DfhhA+6mPI/06 pMc5ZWqVWfb8Fpz6xPkJ1UaKQxyYbg7GGYS0++1z1mgolZZg5MAyzsquUY+zKTJtrnQG fcFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713891849; x=1714496649; 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=i3chcFCwrflv07BF7zjEnwfmfYprvgdwaia1uwWtFOB3vI+bSDFnFzVXytXNlkdGQ1 7QuKANUZHdcKWmpkCLCQNpEGC1RLkzqisnS1zzvlV0rFKKbtz7Q5Wd0qXKbLao5lHciL ADwaIHipcgNpXt64agyS0UKX5xe+yp2TJITmiI951MvlgTcOK8MoD+RY26gN5IbRZPLa /BMlauvn8UlOMIAmGv6qvyITbYT1r7H0j64AJY2+1g31GwS+1PoaDgQ8V/mBOfco1hqY LYA2RlYnp2CZSt8g9U8/3YNRsB2zqADR2qNe5JC8Qc2Hn3kU2E0qPBaJdCI0vaA9oxTw hO8w== X-Gm-Message-State: AOJu0YxJlq7dIySLJZo9R8JLdg3TImuf0VgeW/5LtWjObPaWAB+RLCD3 Lfk0/wEvsv+GNIYLofoFAB29vR/JUBWeDyEI3lVCnyYw5ZpmJw3herDZCe8dUahNvg== X-Google-Smtp-Source: AGHT+IGWT+ho4KjjKYkt4pXE9QMNwfjSrpJN8MJZvcmr2D9GT4W4gI0wGDBUlpVmvv4mlpFse7FLPw== X-Received: by 2002:a17:90a:cc0c:b0:2a5:d979:8eb2 with SMTP id b12-20020a17090acc0c00b002a5d9798eb2mr10816827pju.19.1713891849092; Tue, 23 Apr 2024 10:04:09 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id s19-20020a17090a881300b002a5d684a6a7sm9641148pjn.10.2024.04.23.10.04.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 Apr 2024 10:04:08 -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 v2 4/8] ceph: drop usage of page_index Date: Wed, 24 Apr 2024 01:03:35 +0800 Message-ID: <20240423170339.54131-5-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423170339.54131-1-ryncsn@gmail.com> References: <20240423170339.54131-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Stat-Signature: dusuj7eqeinx7xfgo7bfwpf1zfb41byn X-Rspamd-Queue-Id: 9C1FF20023 X-Rspamd-Server: rspam06 X-Rspam-User: X-HE-Tag: 1713891850-277701 X-HE-Meta: U2FsdGVkX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XLsWakTlOzrEDTzx0Ln+D3Vj9coUokskxbCKJSHI4adlv0kIMY0xFyIP+G1NreokDYUg99SZrHismpaeeoPzxYyyuo2RdZdmr9BwOkRPLcHPhxNOZ2vw/cCDwiy++SFD6O5cHpElFpniIXPUe0nmCuwi10H4iYpC8tVIuSknvsofJBBGaqwNoDmiLsdDjrBA9hqG93BjKx75V6y9N3xoVHw47WQkRQeQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 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 Tue Apr 23 17:03: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: 13640392 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF999C4345F for ; Tue, 23 Apr 2024 17:04:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 67FA66B0149; Tue, 23 Apr 2024 13:04:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 608356B014B; Tue, 23 Apr 2024 13:04:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4812E6B014C; Tue, 23 Apr 2024 13:04:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2392A6B0149 for ; Tue, 23 Apr 2024 13:04:18 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D0E8F80C3C for ; Tue, 23 Apr 2024 17:04:17 +0000 (UTC) X-FDA: 82041419754.22.C6489CD Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by imf07.hostedemail.com (Postfix) with ESMTP id 02D0740004 for ; Tue, 23 Apr 2024 17:04:15 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="Y54/+xPb"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf07.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.215.169 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713891856; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=GV/G4qXk1onz2IqC3/BpNLYGtgLEbJph1C4Exu3LQ8Q=; b=GltMie/7IUUjKRGWI94lIcb11wD+cYc3y7wHdNRlr4EFvGzAR2XUVboh+QJf+iYr2YNdRF zRhTkihZwTVQ4LILMuN5s5doGcIGabeDyPruBI3awbr2maz9HJ7MydFaGWTGS04DAjNIRg qu9HFCO/03XBOK+iZbzkqcmyoERGjhw= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="Y54/+xPb"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf07.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.215.169 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713891856; a=rsa-sha256; cv=none; b=jvg2ACVHKB9AXFKzf3YVyigXcVEPHwsvz6ijdMmKnmVX1jPD5VZtT/QCi7GcAGI2hoP+sD 8wF1HLUqCLp/tPEDMFa7JPpZJtib1tA4GCa92O5dmgpsJjYAvSqsMbh/QV4Ew3M1xxb9D1 UPBxAic9wGESreAQ3XMWShVFs77xdzw= Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-5dbd519bde6so4192564a12.1 for ; Tue, 23 Apr 2024 10:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713891854; x=1714496654; darn=kvack.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=GV/G4qXk1onz2IqC3/BpNLYGtgLEbJph1C4Exu3LQ8Q=; b=Y54/+xPbgftcb/iRWc6nLMMTFw4nT5IsqVfcu5qxrgoMFA1osgfDOHrqqea8Kw/V0u i1VexfDjRNHF2IkhVIqsRyjoGWhOQ1+1oGjcSjml2EBs1SsgYdndcWCf2g4OcELpiH9q bmeDZyrjIR4GSz62rujPgPkJUTIbBOBr7cd8WGeVGvB1zBNKZNglA55Oct7DLDt+5nkW nJPpqG+cVzEnE1A5tbSovhFUzd0RR4f5e2GUUMP0zqNs56EWPwQU7pYsZXXITz0bD9TJ WIWETr5Y/sbPhruTaN30xDeZws11xM2jghvugIXpZQ7ZxBiTQX/ja2rROlGrSg3QZXO8 iDGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713891854; x=1714496654; 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=GV/G4qXk1onz2IqC3/BpNLYGtgLEbJph1C4Exu3LQ8Q=; b=d/ltc3wF2nDtQdvc83EnQujJZjJezGwKlS3Y0gq+Io72PHbz6CMcNb6Rty72ROpZ6D /zUEiC/cKBoxByv58KaFdskwVqVyAnYSmLjgSnxO5Py72HEnpZUYo1oCJpCWoAcHCETz qvW9ctADfC3RXng+JQx7GJH6C5iFjFO8iYsVfmcrSmpzDSWcTvJmCu2n+7r7DFc0zITf V5pACci7V8Y6ADLdEW14qzvKGouqLw6Mo958mSplt/XISyL5sJREL/jkdyB6QPLX15uf 73TsiM7zZuQv6m3lXfPrhOw+bBsxhKD4mFezyqjAgu3/FpdxvPaZgAIg/1sRDcDr3aGa xvzw== X-Gm-Message-State: AOJu0YzaVVThcSPsaRCsQjbY+TU9opr0gC/1yTdS+lY0tp9bLvC1u2bz /hwrChHfjxcSk087rUeK+HsigabSmEyXZfN6LduwT0pxoJh17sXNqV6p9AR1JrbhNw== X-Google-Smtp-Source: AGHT+IFXnXzggSbP9Ki4cPzdCkuwcEVn65pZLG0YlEPbx8oPpQU9xrUurI5P4h73FEaKFW5G55uUNA== X-Received: by 2002:a17:90b:3796:b0:2ad:e055:bb34 with SMTP id mz22-20020a17090b379600b002ade055bb34mr6180074pjb.3.1713891854019; Tue, 23 Apr 2024 10:04:14 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id s19-20020a17090a881300b002a5d684a6a7sm9641148pjn.10.2024.04.23.10.04.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 Apr 2024 10:04:13 -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 v2 5/8] cifs: drop usage of page_file_offset Date: Wed, 24 Apr 2024 01:03:36 +0800 Message-ID: <20240423170339.54131-6-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423170339.54131-1-ryncsn@gmail.com> References: <20240423170339.54131-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 02D0740004 X-Stat-Signature: i6z6d6kzqzij4r1jrc6t96ntorc8hfnb X-HE-Tag: 1713891855-323617 X-HE-Meta: U2FsdGVkX1/WoPX+7FhSsCIhI7KGnQ1FoeKse7FH0HJX0lkkfUFu97rFkje6NHaRkCX0WTMNy9hj1JzYOHw3VQGYv9xl7uxbolPLMkRRw85okt65uyXTY+/zr4leO1b7ZDcAfESaRqqGnk19Tg6uhjltdR73aaRsucC5xoW47xIWTA1+mmpEpbBjlDwMn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/qRWMizWwt+TmmZwUuKLxUuv6vN2bLAVQVXT85AvzNtza3Bvw4+LfhTT3QeXX4ooRlKmh8oRFhrzaYtWMVhWywfO/cclb5AQsQAD7qnuIyDzioHthoLG4RYHcmEBCs5kbvVDI5RBzSS2MGXkbcm1JBzX4Bx5cTI+l05tKOeUlCFY68Ktw5aRRPFqguLi1FhMc7g84K9bB5xBDuljBFnE0SrD++Zz2GyDMV/vpx9NJRUM0Kek1btiAgr1+4NJHI9SoGQzNt/wE1gx+fyVS9mM3keN3EEuRsOc6dla1O6NAwy0zy9Qfz92wcbkSNJwGwR1AOjx7xpVHZKY+5ZUMTcl4X7Q8uhVOWANUUes2KtG67IjnlGPTV51MnNLcqQGELhC5ohE81LfT2RYYwNWIi6GTmfMUM2ItfnW0dgzjb+tp4TGW/NU1QZ2tWb0I0VPllK4VmxkfUGOrCslcSURLy+UiyqIVWEeW4LKum3vR0Z6KYhyoGKfHfyUyZm2cMFYLo/QqEJpxn+Wjf0/FDhkhtE0zSm89J34i3Lu/07FQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 Signed-off-by: Kairui Song --- fs/smb/client/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index 16aadce492b2..56ebc0b1444d 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -4749,7 +4749,7 @@ static int cifs_readpage_worker(struct file *file, struct page *page, static int cifs_read_folio(struct file *file, struct folio *folio) { struct page *page = &folio->page; - loff_t offset = page_file_offset(page); + loff_t offset = folio_pos(folio); int rc = -EACCES; unsigned int xid; From patchwork Tue Apr 23 17:03: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: 13640393 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33480C4345F for ; Tue, 23 Apr 2024 17:04:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B3ADB6B014B; Tue, 23 Apr 2024 13:04:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC3A46B014D; Tue, 23 Apr 2024 13:04:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93C876B014E; Tue, 23 Apr 2024 13:04:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 6F7AE6B014B for ; Tue, 23 Apr 2024 13:04:22 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1708D140530 for ; Tue, 23 Apr 2024 17:04:22 +0000 (UTC) X-FDA: 82041419964.13.BA1DE6F Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by imf06.hostedemail.com (Postfix) with ESMTP id 28FEE18001F for ; Tue, 23 Apr 2024 17:04:19 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=MrmhWJPJ; spf=pass (imf06.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.216.46 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713891860; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KNG88VEX6ymli+8A661y92lZCXehoPGwKzjIttUG4iQ=; b=vGIVuijv1o0PP4pnFtDRzeOnHzCkuElSTf1vf3kPraNs5nGcv0kSifs5D2opYqEOxYJKxU r96z4oMyzRLzTV5Af11OX1GiAdjctyCSCOYYRV9+dRDYkZpcqG/HuM+fwWRfeA2Z9klPQB xWdfUHNouE5e3PMBYxAt+S3k/kY5s4A= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713891860; a=rsa-sha256; cv=none; b=FfZgLTAMb+c8a/AZZqA/kDWlJW8aO7dic6+EQvIQR0jcIA1Yw1+juvvjdW1caC+TWB7R0h yaJQ1bM6M4A2hhTeDpxVTWMEHOn+HGvjv6biarCfGVMwzSFOFnVPjuC6th02l0xkd6JLiK 9oc90VXc6ymK27e9zl+0tmH7+JUnW70= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=MrmhWJPJ; spf=pass (imf06.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.216.46 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-2ab1ddfded1so4913063a91.1 for ; Tue, 23 Apr 2024 10:04:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713891858; x=1714496658; darn=kvack.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=KNG88VEX6ymli+8A661y92lZCXehoPGwKzjIttUG4iQ=; b=MrmhWJPJneAPuj8Jo8OzWbtDypEGqXxFxWNIGQT/kpha5Z9OOG1puI1gQnzvTHUIIj 1gshyACilPtf3lZsrHNb7R5RpwvaaR7h9NPrMKDre+7ut+ejlpUxZoCL/7P4MLUJk+hq Cg9B8nvWs2oBRPJZK66ALs8ZAftplngHqsG428QV6OqHip3bfXbDTmj7h/BaMNuEQOWp yS0SDRzTW4uwBDFfX37wGAEXMV4qRjhGDAHMe0XlSormNFolL+E2v6AqG/TmdFZWj15d iDOoUZ+KtCzvoBHAEtVIEhAeJBvaX3phSJqY4uBOdFVyC1c+Ojz8x9b8f30x/sas3E3V FP8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713891858; x=1714496658; 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=KNG88VEX6ymli+8A661y92lZCXehoPGwKzjIttUG4iQ=; b=BYzAcwYFNMfEKQ5K1MA937VkVWBRlTHCyBEQTvFUU54jYKDFLx33ALhqciYnFjTbWl B+pHlShbNj0OIqbhRR63mZWA02Dz66O4Hy9rWHj53XVZaht9sn6jxmTbD752+4FjRxfl rKrc6kBpoX8Byfo2L+fzKbu+XvtFbLlD8AzAncr9g7I6aHY0loHWp4swlZMCHq8cIlod w6tqDbwWZv+EBsIOpHlxXn07KQfDI/QANYvZ11vMxM0XsmbtCqWw7tkYsj7QSUlYeo5G SeOGreHxSDbfiRL/LakmD2KpblHTKx5AQFGFExXEoIkZhfdqeqWwXwEnivewlgDL+9NL CYrQ== X-Gm-Message-State: AOJu0YxsglhZ2uY+K+EsNO85kyR6spXrK7rUvi5SqVyfhxhyIhEgScXI TzDqfMJ4Sg+YjGthaG9iWzGhfehaNp36gJWnxWCK9JNh9unCBnsl8pdYc08z8MrI+g== X-Google-Smtp-Source: AGHT+IHXKQ3glHiIimSKVos8NC6ThIL+D5to0mzqdpKPEwEZ9osxyRN208oepV+c07VYuM6yym9TLw== X-Received: by 2002:a17:90a:7847:b0:2a2:981b:2c9e with SMTP id y7-20020a17090a784700b002a2981b2c9emr14886163pjl.36.1713891858028; Tue, 23 Apr 2024 10:04:18 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id s19-20020a17090a881300b002a5d684a6a7sm9641148pjn.10.2024.04.23.10.04.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 Apr 2024 10:04:17 -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 v2 6/8] mm/swap: get the swap file offset directly Date: Wed, 24 Apr 2024 01:03:37 +0800 Message-ID: <20240423170339.54131-7-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423170339.54131-1-ryncsn@gmail.com> References: <20240423170339.54131-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 28FEE18001F X-Stat-Signature: yddyccgozsnhj9rtqqnumzbrzu9e6k99 X-Rspam-User: X-HE-Tag: 1713891859-990637 X-HE-Meta: U2FsdGVkX1+xvKmT0yYJ/IEDHck5y6+EozebalEdccZ1/BDnikfM6Z9udJPqNL40xdHzWyXrMCnWdbSvhJefKHhTpRBygkWoDbW1iNzmafhJKStW7SOjSR6l/4WbQ+dQBVjGDIGDr/L0yBr5ohVneYIvU+yfwFVJwuwqb0NriDrKMNTAspeyk3KBP8O5Lyaub/vp11wfM8Zsf++GT8893O2IcEgAD2n8WHmFEbctHobF/r6ZDYMc+BHsgiZx9cZpyDearmbsYhqjZtY2IXNCuq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JTfwQOflw6ih90JWHzha4ntH9GYSo1wKHoBDj1z7OiZ/7GWdniCxLqi0Pbdk4yBq8VOz3dob+Unc0pfgl8VIgLSmpVMaEZcVwuMUJHW3SHeBj08HnUzNQq1rcwWvWR/oNQCmHeV9GiO7u+UxHoDmmO4f84FbJO8kvbiRyCeQ6+2YtiyNPt0EYDIZlS1KpTtakeIG2hmFcZxrVupC07pzXkijSunHgNCChc6ICexVb1oe98d04lbIfYroYPHFc9qlc4CPEVGHV5ONl4le3CMHhbX8ZbMtI2DrnukYA+cP X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Kairui Song folio_file_pos and page_file_offset are for mixed usage of swap cache and page cache, it can't be page cache here, so introduce a new helper to get the swap offset in swap file directly. Need to include swapops.h in mm/swap.h to ensure swp_offset is always defined before use. Signed-off-by: Kairui Song --- 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 ae2b49055e43..615812cfe4ca 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -279,7 +279,7 @@ static void sio_write_complete(struct kiocb *iocb, long ret) * be temporary. */ pr_err_ratelimited("Write error %ld on dio swapfile (%llu)\n", - ret, page_file_offset(page)); + ret, swap_dev_pos(page_swap_entry(page))); for (p = 0; p < sio->pages; p++) { page = sio->bvec[p].bv_page; set_page_dirty(page); @@ -298,7 +298,7 @@ static void swap_writepage_fs(struct folio *folio, struct writeback_control *wbc struct swap_iocb *sio = NULL; struct swap_info_struct *sis = swp_swap_info(folio->swap); struct file *swap_file = sis->swap_file; - loff_t pos = folio_file_pos(folio); + loff_t pos = swap_dev_pos(folio->swap); count_swpout_vm_event(folio); folio_start_writeback(folio); @@ -429,7 +429,7 @@ static void swap_read_folio_fs(struct folio *folio, struct swap_iocb **plug) { struct swap_info_struct *sis = swp_swap_info(folio->swap); struct swap_iocb *sio = NULL; - loff_t pos = folio_file_pos(folio); + loff_t pos = swap_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 Apr 23 17:03: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: 13640394 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BF1BC4345F for ; Tue, 23 Apr 2024 17:04:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 239206B014D; Tue, 23 Apr 2024 13:04:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C2D06B014F; Tue, 23 Apr 2024 13:04:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F31156B0150; Tue, 23 Apr 2024 13:04:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id CF7FC6B014D for ; Tue, 23 Apr 2024 13:04:25 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8E6BAA10C9 for ; Tue, 23 Apr 2024 17:04:25 +0000 (UTC) X-FDA: 82041420090.13.32444B5 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf02.hostedemail.com (Postfix) with ESMTP id B435A80016 for ; Tue, 23 Apr 2024 17:04:23 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=jKhoyNwC; spf=pass (imf02.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713891863; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=QrfJLtSyOHzdWNwAoeEt63qAvh/YvWPDSOmG3agvpH8=; b=VFx74fOT93AHula+6C6r7GvXXUB935u3SkCACRsJyAiIoGX9kdkTfXtBn4FYbD3ldpk/GB izf4sAqNjXySYiq1ewCqsNdeb7gc9VpdPaePFLz155tlB7/MzC+u+0mO2Hn/FbwRgIx2vy /rS5hbF9ITQPrKJWcmEvQtcnEBQRNtY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713891863; a=rsa-sha256; cv=none; b=XC8BIYbAlCdqpiKQNWKmOfZmWE1PNTs72zipb3K1qw49gfXL1Vem7lTilTTnw1sXon6h3c 1+j/dJQMY+HD/xfOVLDL4KHAxlTrEWHLZKiuQntzyBWFRlShwsm83nTgxFIBrh662PfoWy 3Jb5Dud54Y1q/Qd41EqOyF1qWy4Zfkg= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=jKhoyNwC; spf=pass (imf02.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-5c66b093b86so58591a12.0 for ; Tue, 23 Apr 2024 10:04:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713891862; x=1714496662; darn=kvack.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=QrfJLtSyOHzdWNwAoeEt63qAvh/YvWPDSOmG3agvpH8=; b=jKhoyNwCbAqO+wGeVEYy/zZ7NU0aplGp8PezUnNS5RM6iozyyKJG3NLfBeuVjhCoj9 m/in19oUiJ9r7yV6quNO7UoqL7bOn2i0iYwxdqBYEB8MGj0BpOyAwTXWksIzpSxQ3ukG mVb+iaxe6fa1xEoe71gs8YGsE3CDAJlO3Ggy0Z/jGQZkPw3Im8Z+RxQG1kNN8WG+DP6K 6otnYQwAP+U3j0OmJFtHDJs5qOV+BKhBWbUnv5QtcSsp9SBnGXugmKRTUh0vPS+3Pehx BZ7GxhSxaTtjcethm+npNHpzIR5MEyra57g/3TkHumHVp2QgP2BGgYnPdXMYvjauTWoQ E+Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713891862; x=1714496662; 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=QrfJLtSyOHzdWNwAoeEt63qAvh/YvWPDSOmG3agvpH8=; b=ZE5rIRznt0XSrWOxv6HHCcwSdm5D5zyKzhx+xpR9yeSffeqpqqOaexgebcFy/N4Q6a 4K37jhApNNFM/gar3RkPg8orQKPYPVzjtK12PSe+/37iJtXvoHy5ze/NBNeP/Y9vWSu2 wAfJDODOXgH7Lr0N3/w9Ef2D00M6jT4pNSeq6o7wuy/N9QR82yUsN3aBHLx43QVjnnm/ pSCU4I7cNziQlF+9rSMAEzanlRDUG3FKPeyTEKmhLMhTODFb284d71bfiIfBfdF/alpi Ku2tXcCj0MN/XWi1w7rA2/RdJ4Vr+bNVdZ7ztWHNr2knHQn6Aa3PUG6IBlD4V1j7rMkp /KEQ== X-Gm-Message-State: AOJu0YxicuTbvvCCf6nG2qdHD25PK9TSAYRicqXFVequj3fHtXGfP1T9 B5FasQ79EH2Xu11vnG/LyEEWJl1boLwKIvaObLRq41DQtSO+R1YuqDt5569XW8V5Uw== X-Google-Smtp-Source: AGHT+IHl29mA2dJ+DAVqdOiUnUGnuaMZJ8DMUB92M2KECrfDvhzldwg40C7x44GzkGKAl0R+XjVRbg== X-Received: by 2002:a17:90a:f40f:b0:2a5:506f:161c with SMTP id ch15-20020a17090af40f00b002a5506f161cmr104445pjb.4.1713891862010; Tue, 23 Apr 2024 10:04:22 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id s19-20020a17090a881300b002a5d684a6a7sm9641148pjn.10.2024.04.23.10.04.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 Apr 2024 10:04:21 -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 v2 7/8] mm: drop page_index/page_file_offset and convert swap helpers to use folio Date: Wed, 24 Apr 2024 01:03:38 +0800 Message-ID: <20240423170339.54131-8-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423170339.54131-1-ryncsn@gmail.com> References: <20240423170339.54131-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Stat-Signature: 9or1tdbb5j7i9mkpe3qfbja698m8p39c X-Rspamd-Queue-Id: B435A80016 X-Rspamd-Server: rspam06 X-Rspam-User: X-HE-Tag: 1713891863-739628 X-HE-Meta: U2FsdGVkX191Etr7RAPgxADtFXy6rhHR084OdttprWtfv8B85OR8ApEOijIbqNTgrstEEe0J/G762zZW+GbqDdloz8RFobdLVlZQobs6YIAPWq5HkfUv6Zks6DiGCBLDq2iJRMnHUJ6h1xx+JG+qqLCHDWG+bUCa1Kpy4D/jDfMF2r5bT3GYPK1daK6dVih8OC2+PJ7HrgM2dOP7rFT5DrDpt5pJ+9H2J9fL3RYPhOsOT3kvwcM2AoCabqcp0QKLsYpXQypMWaJxhMxN486AcKLoIJNDMcP65geKfZvvBN2jgxF3BU7d014QCyO1Tks6YKRvBfDYezOY0UhIiH8a2l+Q3DdwQnq0NoJeG1BN+ryaoLbTxcK3EfWPCtgcF1C8mtDbAX0klKITGDPYQdThKhqbP/jEkkKCO4ElddHh5nj0cSsjIXny3ZT4Q3mTc4J0FC4dKOA+KY+7UpyNBJV/zUhpkGK9+7bfEy4LHynBNSsrvT6OwcV/9QL7bnXqFYlNC46KhHvplix2n92wTy9R33q63wHZ0x2fRqRHeoAfFrnry+oKwSa0dhafKeVyWlxd2yG9WKYRHluDNkXWZLsWxauFLnglTiyJfTjUGj0pXH1T2R268ofuZbmPXz38N4L5IGr34XNzguFickntNlBPzsHWqMoiu0Z8qZ7noBasrGI7Ynf2jzhKBtzVF5db5v23kZs/AjMeaT1Fp4eB4E2j25sZPdrxIRR2Yl/gTCdoAgL/eGdKdKBPw0Lsym5zjd6fRzgmlpORLsqlGfWzW8nadQbvSf4r7qbiKhnTErwrUWnbI8RLiMC92QXbCmZXfz0Wx0iny1VSqeTh+jNYPzqPy1gHCspPUg9BsSveMDh6FfSuSYY06Z9pRUOG2NLEuaur2TSvPA3h+4WwjG55MwCsxkkLIke0NzyavqVGqg6974cCc1epbmWY3DR4ebmVCoPCMdKo7Ul0kxzT0QSSjN3 MUkr8syC N6SGIYA0tY6BziH6P7szMK+ppJvraLZdGMrvLpCtFoMpu3bunvC0E2vfOpB/2DBbxtEt9Ht3Ooiebah1PgXZCM5JOtdh8MoTSamrbGqZh/w4JaOSHI412xZV27UK8yj8RUbOM5Xw39zNNBTLL80Dfu+irXNfFfoX+sRzzkUwoD37Ut72tEcadaByEPF3IwxXost4gmppWBtZvhJ9NH0W5TD3yTK2Evgo+chWWYteYPqhGh4N5g8KCTMzPL5zJdhiiNSfsiAOJKM/9XfW/5PP4srgs3fmsOpv41NaUunrzCT738tGmQx8dwTu2j71vcwedHTkHlqcnQYXE33g7IM77pjer2UEKXmUWatbkIFsZTQim6YZwaq2PwXZIehmmNs9UAMOVbKzlIqkfSDQPLm36A06jwkhIMtu5kbpzJ46fYd3iJv5ndbMxUf01ZIrcFhPm1S22bugu3s9DikesKxJ6Y+2+EaP297qzt1Z19H5n+yF2kQWm0ucPIlHWm6Yl0WFO7kTDIW3txi4uNNj0mN4DOxtTUHWlLntS1O6C4UuNK3mUKXsb6S0wjQjjUSQbp52qHQYn7/JcVp8alTUtIA01QFo6Rh5lUVyZIfShln+On78FBLWDIYu/j+blS+7A9h1K8oGem0NVAywXR3SdTySIXWUiNfCJ9m7uz1TTfsEP6PPz1KQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Kairui Song There are four helpers for retrieving the page index within address space, or offset within mapped file: - page_index - page_file_offset - folio_index (equivalence of page_index) - folio_file_pos (equivalence of page_file_offset) And they are only needed for mixed usage of swap cache & page cache (eg. migration, huge memory split). Else users can just use folio->index or folio_pos. This commit drops page_index and page_file_offset as we have eliminated all users, and converts folio_index and folio_file_pos (they were simply wrappers of page_index and page_file_offset, and implemented in a not very clean way) to use folio internally. After this commit, there will be only two helpers for users that may encounter mixed usage of swap cache and page cache: - folio_index (calls __folio_swap_cache_index for swap cache folio) - folio_file_pos (calls __folio_swap_dev_pos for swap cache folio) The index in swap cache and offset in swap device are still basically the same thing, but will be different in following commits. Signed-off-by: Kairui Song --- include/linux/mm.h | 13 ------------- include/linux/pagemap.h | 19 +++++++++---------- mm/swapfile.c | 13 +++++++++---- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 0436b919f1c7..797480e76c9c 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2245,19 +2245,6 @@ static inline void *folio_address(const struct folio *folio) return page_address(&folio->page); } -extern pgoff_t __page_file_index(struct page *page); - -/* - * Return the pagecache index of the passed page. Regular pagecache pages - * use ->index whereas swapcache pages use swp_offset(->private) - */ -static inline pgoff_t page_index(struct page *page) -{ - if (unlikely(PageSwapCache(page))) - return __page_file_index(page); - return page->index; -} - /* * Return true only if the page has been allocated with * ALLOC_NO_WATERMARKS and the low watermark was not diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 2df35e65557d..a7d025571ee6 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -780,7 +780,7 @@ static inline struct page *grab_cache_page_nowait(struct address_space *mapping, mapping_gfp_mask(mapping)); } -#define swapcache_index(folio) __page_file_index(&(folio)->page) +extern pgoff_t __folio_swap_cache_index(struct folio *folio); /** * folio_index - File index of a folio. @@ -795,9 +795,9 @@ static inline struct page *grab_cache_page_nowait(struct address_space *mapping, */ static inline pgoff_t folio_index(struct folio *folio) { - if (unlikely(folio_test_swapcache(folio))) - return swapcache_index(folio); - return folio->index; + if (unlikely(folio_test_swapcache(folio))) + return __folio_swap_cache_index(folio); + return folio->index; } /** @@ -920,11 +920,6 @@ static inline loff_t page_offset(struct page *page) return ((loff_t)page->index) << PAGE_SHIFT; } -static inline loff_t page_file_offset(struct page *page) -{ - return ((loff_t)page_index(page)) << PAGE_SHIFT; -} - /** * folio_pos - Returns the byte position of this folio in its file. * @folio: The folio. @@ -934,6 +929,8 @@ static inline loff_t folio_pos(struct folio *folio) return page_offset(&folio->page); } +extern loff_t __folio_swap_dev_pos(struct folio *folio); + /** * folio_file_pos - Returns the byte position of this folio in its file. * @folio: The folio. @@ -943,7 +940,9 @@ static inline loff_t folio_pos(struct folio *folio) */ static inline loff_t folio_file_pos(struct folio *folio) { - return page_file_offset(&folio->page); + if (unlikely(folio_test_swapcache(folio))) + return __folio_swap_dev_pos(folio); + return ((loff_t)folio->index << PAGE_SHIFT); } /* diff --git a/mm/swapfile.c b/mm/swapfile.c index 4919423cce76..2387f5e131d7 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -3419,12 +3419,17 @@ struct address_space *swapcache_mapping(struct folio *folio) } EXPORT_SYMBOL_GPL(swapcache_mapping); -pgoff_t __page_file_index(struct page *page) +pgoff_t __folio_swap_cache_index(struct folio *folio) { - swp_entry_t swap = page_swap_entry(page); - return swp_offset(swap); + return swp_offset(folio->swap); } -EXPORT_SYMBOL_GPL(__page_file_index); +EXPORT_SYMBOL_GPL(__folio_swap_cache_index); + +loff_t __folio_swap_dev_pos(struct folio *folio) +{ + return swap_dev_pos(folio->swap); +} +EXPORT_SYMBOL_GPL(__folio_swap_dev_pos); /* * add_swap_count_continuation - called when a swap count is duplicated From patchwork Tue Apr 23 17:03: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: 13640395 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C66F5C4345F for ; Tue, 23 Apr 2024 17:04:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4AA636B014F; Tue, 23 Apr 2024 13:04:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 433A26B0151; Tue, 23 Apr 2024 13:04:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 25F776B0152; Tue, 23 Apr 2024 13:04:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id F0C466B014F for ; Tue, 23 Apr 2024 13:04:29 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8FB84160886 for ; Tue, 23 Apr 2024 17:04:29 +0000 (UTC) X-FDA: 82041420258.30.5E9819F Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf18.hostedemail.com (Postfix) with ESMTP id 96EA41C0013 for ; Tue, 23 Apr 2024 17:04:27 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=nVpEwD1K; spf=pass (imf18.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713891867; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=CnMzyp4v7D+bPlM4VXqNTLQwTcA8u3vvnjSU90ZgW/k=; b=NWt3o/1hbTmJjG4V7A+OGCjoUH7zDdnma2++KMo6QtSDsI7/iDqM3rx2bRYpGlkLmleiuH jFOMC+XGJBm37Ybytm/gDvsA7CV5TU5P3ZmWCTp781xfbNjbUcozMxDS611zZb0ZQOdEF5 u8yoQSTRhLLujrOkoQmZ4gQOMRi9yY4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713891867; a=rsa-sha256; cv=none; b=iFXvr0m8h2VEfFJ6MoKDE9QmuM6+UJDzCfOqELerjGlmUvvizZTsQA4lEULjF5ArzOoiZC nh2Aze+nAAmpN+wELtEI3tSkiyP2bRYyatXIYTaj08QQ+S3XLNZHgwMl3tMGACwf2t6X0C KLUlg22Zku/w+OHdGQ7d9Dd6cuuGyrM= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=nVpEwD1K; spf=pass (imf18.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-2a78c2e253aso4679456a91.3 for ; Tue, 23 Apr 2024 10:04:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713891866; x=1714496666; darn=kvack.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=CnMzyp4v7D+bPlM4VXqNTLQwTcA8u3vvnjSU90ZgW/k=; b=nVpEwD1K0nIJt7KQ7NtjxKn0KbV+O62FsEyU0qBM/aaGV/9sYOqsPL+AzfG+4A/N6/ 36wZlp1uDbKXYmnCq7UfkqkaIHJDg8CnOKQj4lT7VMiYJePZrzMckCpUbT/reqyCsa56 g3dY4j7aezugU8jnfeo0lvabURJLLcdrn0J5m3WSjCBEfZT8H6+pQiQC8wkH55emsnv+ pmMT1Ctm1+butlKPLEkYHm6tVO7eHsWoVnsZ+UkV29jDR9xAWysHHO+dJ86jqoWxyS/k 9Lda7c1e3BO3RgX0hZJnEjetXGVWqi/yzmzQhaZ4KvbUqQgQvpoYcvdnuaw+Fy4RfGMM Gcqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713891866; x=1714496666; 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=CnMzyp4v7D+bPlM4VXqNTLQwTcA8u3vvnjSU90ZgW/k=; b=XM+KYCkmajxnxRTHD1qoSaO/cAUX+1di6aXMSRMvISf4fab1kAxELZv+Vq5rApYNE6 C6xQyN3daYZCdFdMFo5mvvk6PZ0IxyPi29QxAt2BcJY5vPIK1WPNJN9v5p7v8r8oizrH SZLQfNsJZK/pJRHYe3tQsTlIRM2S+K5ced0iJ6HuoC1kiadKQsfnRiKOt9cBGlGHhGV+ V66VxmtA3udq2yqPP8QPsI7s4SO0ugVsX3Z24USGnzHhe7FWXQjjUGweWtl0cdjkHmMT zl0xcmIuTlJ0TbPxweTl6XzjHaD5jt4Ig0tVFuHZ08CuV/IDWswlNCNLmEDb/oyfxYQT iT9Q== X-Gm-Message-State: AOJu0YxqzJqqiKvRJVBFCwHjv/summxyIU7f7mL5fTS//eSKaSzJ5Zqb YXrDz/zgJkRickX6du5VKc21v0vjWXlFFBITwGv+fERhQrcMdFMcpHaHOi84jStfCg== X-Google-Smtp-Source: AGHT+IHsdf0a0hXaosoeNJct0li+Z9JISuE3KsVNLbRolhiRYgiN4NDjYwA6cqx8BtEiKf1+SehY8w== X-Received: by 2002:a17:90b:3506:b0:2a7:e71:eb72 with SMTP id ls6-20020a17090b350600b002a70e71eb72mr37270pjb.0.1713891866020; Tue, 23 Apr 2024 10:04:26 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id s19-20020a17090a881300b002a5d684a6a7sm9641148pjn.10.2024.04.23.10.04.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 Apr 2024 10:04:25 -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 v2 8/8] mm/swap: reduce swap cache search space Date: Wed, 24 Apr 2024 01:03:39 +0800 Message-ID: <20240423170339.54131-9-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423170339.54131-1-ryncsn@gmail.com> References: <20240423170339.54131-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Stat-Signature: j9nuwsen6cgfrn4o76i7ewscitdo6hr5 X-Rspamd-Queue-Id: 96EA41C0013 X-Rspamd-Server: rspam06 X-Rspam-User: X-HE-Tag: 1713891867-341551 X-HE-Meta: U2FsdGVkX18vBYj8LN8OT4cFNnp84IA2dslJ8z7xvNOT/6YPe73Ol8vjGcWDZFhEmc8ZOtEXpEU+RkILSnYG9dlUf1vIUssu8nNDfKROGgD2y4G64tvuQHSl0Pn3CQXhDpyeL55HejCz4t8Yp1Cr4AD/VR2OYuM2kskU1Ch6Y94zEp9zB0CAbQSMbQS4tzWa8TonxYHKoTxF7DyqvJlG8R7nJKyy51w6iAcpybwAm6v3g0+ccFe8b3n4kriDtbv09ALgLCNy2dfjeVL0aMQPq0jzq39OvTKNKgkFeVG/F89y33DY5iawZmwyNUAI+P7qZROuz7WlTZsGzfBb9XhvI5Xfl6R5HKREHuofLcpNUusskY0gpoTuzbDYLseMU+0tjbOUGAAU1ogNd00svqHFFUdVswltgLQJOgFvg3W0U8qOI2+oCIPituSicEuql7Rc2oSYJzLsqzDlKJpr9n80kq6oXQQOrurW4IcoY+ArZUZOA0mzq9GvYXqNN4j1IQzJBFSAD0IEne1PSNzazDcZQrNBqDBUFBuVLGXF8lAndV4WP7WhHoFtsjc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osity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Kairui Song Currently we use one swap_address_space for every 64M chunk to reduce lock contention, this is like having a set of smaller swap files inside one big swap file. But when doing swap cache look up or insert, we are still using the offset of the whole large swap file. This is OK for correctness, as the offset (key) is unique. But Xarray is specially optimized for small indexes, it creates the radix tree levels lazily to be just enough to fit the largest key stored in one Xarray. So we are wasting tree nodes unnecessarily. For 64M chunk it should only take at most 3 levels to contain everything. But we are using the offset from the whole swap file, so the offset (key) value will be way beyond 64M, and so will the tree level. Optimize this by using a new helper swap_cache_index to get a swap entry's unique offset in its own 64M swap_address_space. I see a ~1% performance gain in benchmark and actual workload with high memory pressure. Test with `time memhog 128G` inside a 8G memcg using 128G swap (ramdisk with SWP_SYNCHRONOUS_IO dropped, tested 3 times, results are stable. The test result is similar but the improvement is smaller if SWP_SYNCHRONOUS_IO is enabled, as swap out path can never skip swap cache): Before: 6.07user 250.74system 4:17.26elapsed 99%CPU (0avgtext+0avgdata 8373376maxresident)k 0inputs+0outputs (55major+33555018minor)pagefaults 0swaps After (1.8% faster): 6.08user 246.09system 4:12.58elapsed 99%CPU (0avgtext+0avgdata 8373248maxresident)k 0inputs+0outputs (54major+33555027minor)pagefaults 0swaps Similar result with MySQL and sysbench using swap: Before: 94055.61 qps After (0.8% faster): 94834.91 qps Radix tree slab usage is also very slightly lower. Signed-off-by: Kairui Song --- mm/huge_memory.c | 2 +- mm/memcontrol.c | 2 +- mm/mincore.c | 2 +- mm/shmem.c | 2 +- mm/swap.h | 15 +++++++++++++++ mm/swap_state.c | 12 ++++++------ mm/swapfile.c | 6 +++--- 7 files changed, 28 insertions(+), 13 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 9859aa4f7553..1208d60792f0 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2903,7 +2903,7 @@ static void __split_huge_page(struct page *page, struct list_head *list, split_page_memcg(head, order, new_order); if (folio_test_anon(folio) && folio_test_swapcache(folio)) { - offset = swp_offset(folio->swap); + offset = swap_cache_index(folio->swap); swap_cache = swap_address_space(folio->swap); xa_lock(&swap_cache->i_pages); } diff --git a/mm/memcontrol.c b/mm/memcontrol.c index fabce2b50c69..04d7be7f30dc 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5934,7 +5934,7 @@ static struct page *mc_handle_swap_pte(struct vm_area_struct *vma, * Because swap_cache_get_folio() updates some statistics counter, * we call find_get_page() with swapper_space directly. */ - page = find_get_page(swap_address_space(ent), swp_offset(ent)); + page = find_get_page(swap_address_space(ent), swap_cache_index(ent)); entry->val = ent.val; return page; diff --git a/mm/mincore.c b/mm/mincore.c index dad3622cc963..e31cf1bde614 100644 --- a/mm/mincore.c +++ b/mm/mincore.c @@ -139,7 +139,7 @@ static int mincore_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, } else { #ifdef CONFIG_SWAP *vec = mincore_page(swap_address_space(entry), - swp_offset(entry)); + swap_cache_index(entry)); #else WARN_ON(1); *vec = 1; diff --git a/mm/shmem.c b/mm/shmem.c index 0aad0d9a621b..cbe33ab52a73 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1762,7 +1762,7 @@ static int shmem_replace_folio(struct folio **foliop, gfp_t gfp, old = *foliop; entry = old->swap; - swap_index = swp_offset(entry); + swap_index = swap_cache_index(entry); swap_mapping = swap_address_space(entry); /* diff --git a/mm/swap.h b/mm/swap.h index 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 bfc7e8c58a6d..9dbb54c72770 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -72,7 +72,7 @@ void show_swap_cache_info(void) void *get_shadow_from_swap_cache(swp_entry_t entry) { struct address_space *address_space = swap_address_space(entry); - pgoff_t idx = swp_offset(entry); + pgoff_t idx = swap_cache_index(entry); struct page *page; page = xa_load(&address_space->i_pages, idx); @@ -89,7 +89,7 @@ int add_to_swap_cache(struct folio *folio, swp_entry_t entry, gfp_t gfp, void **shadowp) { struct address_space *address_space = swap_address_space(entry); - pgoff_t idx = swp_offset(entry); + pgoff_t idx = swap_cache_index(entry); XA_STATE_ORDER(xas, &address_space->i_pages, idx, folio_order(folio)); unsigned long i, nr = folio_nr_pages(folio); void *old; @@ -144,7 +144,7 @@ void __delete_from_swap_cache(struct folio *folio, struct address_space *address_space = swap_address_space(entry); int i; long nr = folio_nr_pages(folio); - pgoff_t idx = swp_offset(entry); + pgoff_t idx = swap_cache_index(entry); XA_STATE(xas, &address_space->i_pages, idx); xas_set_update(&xas, workingset_update_node); @@ -350,7 +350,7 @@ struct folio *swap_cache_get_folio(swp_entry_t entry, { struct folio *folio; - folio = filemap_get_folio(swap_address_space(entry), swp_offset(entry)); + folio = filemap_get_folio(swap_address_space(entry), swap_cache_index(entry)); if (!IS_ERR(folio)) { bool vma_ra = swap_use_vma_readahead(); bool readahead; @@ -420,7 +420,7 @@ struct folio *filemap_get_incore_folio(struct address_space *mapping, si = get_swap_device(swp); if (!si) return ERR_PTR(-ENOENT); - index = swp_offset(swp); + index = swap_cache_index(swp); folio = filemap_get_folio(swap_address_space(swp), index); put_swap_device(si); return folio; @@ -447,7 +447,7 @@ struct folio *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, * that would confuse statistics. */ folio = filemap_get_folio(swap_address_space(entry), - swp_offset(entry)); + swap_cache_index(entry)); if (!IS_ERR(folio)) goto got_folio; diff --git a/mm/swapfile.c b/mm/swapfile.c index 2387f5e131d7..3d838659f55f 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -138,7 +138,7 @@ static int __try_to_reclaim_swap(struct swap_info_struct *si, struct folio *folio; int ret = 0; - folio = filemap_get_folio(swap_address_space(entry), offset); + folio = filemap_get_folio(swap_address_space(entry), swap_cache_index(entry)); if (IS_ERR(folio)) return 0; /* @@ -2110,7 +2110,7 @@ static int try_to_unuse(unsigned int type) (i = find_next_to_unuse(si, i)) != 0) { entry = swp_entry(type, i); - folio = filemap_get_folio(swap_address_space(entry), i); + folio = filemap_get_folio(swap_address_space(entry), swap_cache_index(entry)); if (IS_ERR(folio)) continue; @@ -3421,7 +3421,7 @@ EXPORT_SYMBOL_GPL(swapcache_mapping); pgoff_t __folio_swap_cache_index(struct folio *folio) { - return swp_offset(folio->swap); + return swap_cache_index(folio->swap); } EXPORT_SYMBOL_GPL(__folio_swap_cache_index);