From patchwork Mon Apr 29 19:04:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13647532 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 2B56E13B292; Mon, 29 Apr 2024 19:06:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714417613; cv=none; b=Q82980/6epVuwscASfxjnpkm2OMjs+1AYy4y15Cwz3pmlDSzdmbepRIzVaLUH0Hvo5dNz7NpEV9jPw9mIgbyeCv7rV651o4NQT4evoJZGctzrbU/yCewDMEiH4VoonVAJqnCHoaITP98qMue99gVlB7PUhNLTJlJ9nYAIZk3RIA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714417613; c=relaxed/simple; bh=hDlPxTRmPzQHkSl/lYkJK+GDIbLDQq8I/dn2VuGCZ+Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lghgKr5FMYBqjIovdlWnysxFc8QeOE67RjdVgIHfJJIV3Gp2MD3RkaBbh9Za6sr8zdPyHGF7BTNqPEatiLV5e+xDwnlDLaT1pq0OLx1W5cv8dJVJdy64N5kbXjugIGPDDLUNV2PH0X2SJoOb4MPc0ygTOuPPSgkVKDP1mAHxTio= 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=aXZIHhLr; arc=none smtp.client-ip=209.85.214.182 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="aXZIHhLr" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1eab16c8d83so38643555ad.3; Mon, 29 Apr 2024 12:06:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714417611; x=1715022411; 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=aXZIHhLrZeNyFWhKGu/8Mw804jf9yqvaXYPvKV7DwUfDeCsQe7GJWrbKK1JbsKi6ds ePz9vhvNr2Q+Q5jgKrjlOPyEXM6uSECUfIbYteeWbM9E6eu1XuU6S9QMAp2ypF4SHFun UbfvgO3EBtNgy8/UdXGhoGA6GtiBA+TgesXCqwlCXNuFT1yeKsaGwGAGIFOXhgWyQXo0 g/tOcxstKUVTYKIeceAfI7V7BNbBstfoLkHDP9mULKG3vKdmfVrBN9m7Hm2tJa9osM5w 6y8WAcY62czY7C/VqfYUndSCLlhZfIIZzUsQgE5o7gwR0z4ktMPUBasarXMUQnFoV0Hh gWVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714417611; x=1715022411; 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=NJwoYoRjqTjXkkzYE0NbKmF+K58Z3wXG+DUo25atu6GbMWTjFs4rs+9UmWkym3r14i kHs6RygAstL03m8EShW+fiQINaH/Nt9XoM+vs4rYt0DsVsgRsLkcpZcDrXJiDEL4SinE 7gDs1comHV0QPe6yjGG3hcMGkBW6toYC107b2vMqHE5U6RFS97pLK3WqhBFoi42uTvXo M3aQMOgh4r03hhBpSpbz7nADK5s6d0EVrFgan672YDI73OdGHLYGdN+9DiNezDCX2F2v f/lh7p5PoucS49dMWPKCK+bRjBn4zWH/exqy9nbyJUQgpZ34+6qkbF3uHYg6z83VQ1kl SpFA== X-Forwarded-Encrypted: i=1; AJvYcCUkXNr0WfkrGDd/iPlzf96SmPOY+yZ7QRpRj7W2/vuO6Yex6lFFSTrZjpYVaMrwycJA2XVVQbQm/7yYWo47FKmKs4vgNQEsq88dxSSDgpusLg3N8EAJiZycUgyiRDc+NCzl5n7URUC/mM7xVA== X-Gm-Message-State: AOJu0YyKojKu1ucJnoOOJM5bjTkQHvSJ+TloikBPRqQqqnE9l4R17RLq jjggpa+oRaPZVN70rYqHKg5+GJCagiNNrHaT72lCUU3Y9VfbAhD5 X-Google-Smtp-Source: AGHT+IEWWyXjXq5qxQK4Wj2h+dXwYC3HBxH2tY9g+B+mmj2ONuL2mZBA9D6pxjlnJqOR4++MfTCr9w== X-Received: by 2002:a17:903:1249:b0:1e4:b1eb:7dee with SMTP id u9-20020a170903124900b001e4b1eb7deemr13466540plh.47.1714417611389; Mon, 29 Apr 2024 12:06:51 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id y4-20020a170902864400b001e49428f313sm20619356plt.261.2024.04.29.12.06.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Apr 2024 12:06:51 -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 v3 01/12] f2fs: drop usage of page_index Date: Tue, 30 Apr 2024 03:04:49 +0800 Message-ID: <20240429190500.30979-2-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429190500.30979-1-ryncsn@gmail.com> References: <20240429190500.30979-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 Mon Apr 29 19:04:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13647533 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 A8D5813AA51; Mon, 29 Apr 2024 19:06:56 +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=1714417617; cv=none; b=Ln/fZ9iiSNf4qFPP1IqBNbe+Nj9VKoV2st8zGa4hv0xLdEjfytIRjmO4O2Z4pTB7Au0YJGF0hCI3/d3WAbjuCCl0ISupHArdYR/VAB/JQWgEoe1KByxTaKN86O0rxKn1f7wcLcxal+39Pq6D0HWM0BiP/uPSrqpy+Ko53+ode2I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714417617; c=relaxed/simple; bh=YRby+TlApMR2BfFDBOTWsaAzBHBVctrqTpy56VI6Quo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q4idNbygMGet3nkg0W8F0WIGCriKnHWVxWM3UfEB9PiscGLwIu1YzkdoOQ+Xvr8XVq1SedtcrpxltfU3bNgkqJo3COTIOC8SRT8GhiCIaeSf8BRx6UAMu4ab30qLnhCWGsAT7M2jayJRg87Dum08mRoeRdamLdq/e9mO73lw6FA= 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=m4b46PBx; 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="m4b46PBx" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1e3ca546d40so41080465ad.3; Mon, 29 Apr 2024 12:06:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714417616; x=1715022416; 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=yfRM+qHBl7JEmbJr1xydN14sHfEFiHH0LtWIzSVr96Y=; b=m4b46PBxZIX3ey/S43hGI5HwXVFKEzP7J+VSxWxeajq3sB8vaBotkrA8yl9sEmGc+L dEdOy3e0NYDka9Vpi7dd+SWhYY2uvDzdsjnG0jD8LXMc4NYMnP7Yi7bOsHoSTQ6V2/nw 76yfGl4lDpsYAye9T0qepd73z3yMCazp29I+6o1Ekfs0plPgxrIX0W42dIroF7AJu4Po ucU/7d531oIam8qUdT97QleLIHnFIpqdtLTLNOL6p5y8fJI5T5WZjG3j0wP8R0Go3ZX1 f/BwmTHq6IWzszZG2xg3GXHkbAo0Eo7jSeVO+6l+B2q+yxTcCC4nrFC/dXoBiT8Ec/00 bcrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714417616; x=1715022416; 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=yfRM+qHBl7JEmbJr1xydN14sHfEFiHH0LtWIzSVr96Y=; b=TPGx7wtAUDL+BpvfZk2eyofWQqBKEXpbTLT7JlJa/XVuOeWdC0xS3F5Wk6D6wOYyCI dqkyyhHaeRuA9/m9jpXQJ5kHq+l4al84uXDMi92HspCPxRgPuwcdDyDv8IuGlojhZ6Iq 0EgLa/vr0f+nMlTaq3AXt0hpaHZQ16/VeEaFq3xqSpk646154jbrlaZpl3Fcu9NLegIx ncvhHJrUJG90RB7XX0K/l0NSmlFi4Dy9h8SFFpc9ubFl/jx4edGv3SjoebBfahB1E78R aTwMM+4rl8Cf2jLwqWsx7IsTrEUoSrSSe6+9MBWPFHlm61J2NAwI3f4PBFddpBKlf9Le vf9g== X-Forwarded-Encrypted: i=1; AJvYcCUKtoxNmnoO9OWNB6U2BeOmXmHeqkAVFMrZppFg4sWvlqAf05suwJIykckOkH8tRQpNcmTkgC/KRMZyolVC8p29rzRHw/tW2zDx/LCcbfQGrmNoNGW9JZaZTC6RF8FukKc1yvB2w6HaZkNKVdP1cVJkgDagwnTZv49gm8UYW7251apOC2iN7hiA X-Gm-Message-State: AOJu0YwTT5gj3JHw7TZnnt15xeaydJTWzpWF2mdXGByc3jdX7VvcAitw Vy1MLGKF6TlG4h6+A0iJjp+iRR5OKcgV5buFXJIsK45HTMoYhZMu X-Google-Smtp-Source: AGHT+IG6o6kI/bGN72Zio9V9EuR0QrMbdLin8hBig6iTqFcceqUVveJSWOkf2WaT/c9J9vt33sFWsA== X-Received: by 2002:a17:902:f681:b0:1e9:4f9:8478 with SMTP id l1-20020a170902f68100b001e904f98478mr524594plg.42.1714417615896; Mon, 29 Apr 2024 12:06:55 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id y4-20020a170902864400b001e49428f313sm20619356plt.261.2024.04.29.12.06.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Apr 2024 12:06:55 -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 v3 02/12] nilfs2: drop usage of page_index Date: Tue, 30 Apr 2024 03:04:50 +0800 Message-ID: <20240429190500.30979-3-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429190500.30979-1-ryncsn@gmail.com> References: <20240429190500.30979-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, also convert it to use folio. Signed-off-by: Kairui Song Cc: Ryusuke Konishi Cc: linux-nilfs@vger.kernel.org --- fs/nilfs2/bmap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c index 383f0afa2cea..f4e5df0cd720 100644 --- a/fs/nilfs2/bmap.c +++ b/fs/nilfs2/bmap.c @@ -453,9 +453,8 @@ __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); - for (pbh = page_buffers(bh->b_page); pbh != bh; pbh = pbh->b_this_page) + key = bh->b_folio->index << (PAGE_SHIFT - bmap->b_inode->i_blkbits); + for (pbh = folio_buffers(bh->b_folio); pbh != bh; pbh = pbh->b_this_page) key++; return key; From patchwork Mon Apr 29 19:04:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13647534 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (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 37C7C13AA51; Mon, 29 Apr 2024 19:07:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714417622; cv=none; b=RpYYLpzwEbUa5xGktjWUSJ+iDBVp0ObYKdXTxysK4J8DD5oHYT7FMxraeH4wpMdGplvbZpF0FfTbEmvGuwdmosQwzweNZeih1B5HDCHdNExzlmgzZt2Aqz5fSVOWooKYPN+LEEgYpZ44WBr4arzFgIMmgB8WuU3P2wkU+ooiKNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714417622; c=relaxed/simple; bh=gNeowpHLn3XanGMjOPlcSsZZHe5AP0lM6lADWQVCs4I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RNarrLQgut4/wEU8dV9SM/mkeKmmJaZnJrn4NKUMakU7uxYHf0u2uQqkq7XoGyxO62BLEF4K6zIgcQmTc95oySo8fj8d7goOd419krxJDcGz/s9x6oUjvv0jkQkbXPbJ+tJ1K+fpaEoVv6UzZHfQ8ZfxeGHV/JUTqsAlIhTLqvk= 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=gfRkM0Bl; arc=none smtp.client-ip=209.85.210.172 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="gfRkM0Bl" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-6ecff9df447so4772508b3a.1; Mon, 29 Apr 2024 12:07:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714417620; x=1715022420; 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=gfRkM0Bl2uYNacwxZWM/fH9gLepnhxSm3kE1PA30ZP7GsJBty2/mLX3R9fMk8zXcle lI9xvHoBCoeTmfOiXFyzkTmzkbCGzxK9dRGr3SFQwT2/V2JfcMchWxSRWD+pTIOl3ntB R3pwHZpQDRUx8QLtfQTffQMld4OQ01k8ijOyqutQKpuVeGwy9BS5xqW+0HQ5/isaSWS0 0R90XWv1jakRvT6CIcVwVGvukOYOWvaBOEz0EcnV8PSq5ZiaA7zXFx4LC+utYa9SxuNn f8KZAtUSA/tdCUeywIif63DGVhfesg4wdN8qGs/JOosC2VQDsCXSzXz8jHoJkPrFoqFN FyOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714417620; x=1715022420; 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=Z8fUTN0YvUIO4ULIoZ2ba9hnmsStz+FXbimENhLFAHXOoBRqXZ3yrw9je+EZ/317pk BkKHR+6K0oEjuh3JRLXKEWBgfLaA5a2xF1ndE0JpEgSOTwzMP1HxYroXjc7TkIMYWnGy FnxPIU0Db2/y1HaWhn3kjD669QTEeVVlME4f27Xpyj2xAPa7TNMmQHgbp2fKiD9Xxo31 2hrOnCBeKEVuOC4Hn7lwi5WQCln0EHtJ2VMtrM6uhPGzfIy2dr68HsbWATibxBtuboeq PUsfTwtjlhreGKOaXMVZAN3kPU+6Hzu3pHPZELBobNbF+N2bh18yXHoxaQhpbb2FbLcQ bYBA== X-Forwarded-Encrypted: i=1; AJvYcCWjNaWfHl8858u4Bs/GPy8pcBEwmg4LJrRdrmsmjgmB/HKJk71kEmydoIUX5WnUcGVqDZTCTZBisO0n1yEn3bbNB/gw8O0pDmtxl8vd39VT4u/i4//YZGBn4xzWKlZAHiHvoOlPHAq0G828uUiwfXhLtJ9Dv1Ge60rWlxLGUUbOiTgfavf0Pwg= X-Gm-Message-State: AOJu0YyV7DNvYYIZfaL20W9LJx4qZ8czh6V41qfZIKQ/sKXPd3t4t++a oFWLecRCrSHBDs2d6RB6z/p3mDGaDQW1AvD5hPCcSJjOGl6eNgZV X-Google-Smtp-Source: AGHT+IGvkma+YPu9xzUecSUUsFD1l+4n7xw1LuJ9VLq1yA2mCnKc5mpq0XVMSd8n6uL8gi84MJzVXg== X-Received: by 2002:a05:6a20:f393:b0:1ad:682d:55b3 with SMTP id qr19-20020a056a20f39300b001ad682d55b3mr555060pzb.3.1714417620501; Mon, 29 Apr 2024 12:07:00 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id y4-20020a170902864400b001e49428f313sm20619356plt.261.2024.04.29.12.06.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Apr 2024 12:07:00 -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 v3 03/12] ceph: drop usage of page_index Date: Tue, 30 Apr 2024 03:04:51 +0800 Message-ID: <20240429190500.30979-4-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429190500.30979-1-ryncsn@gmail.com> References: <20240429190500.30979-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 Mon Apr 29 19:04:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13647535 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 B6FA113AD3D; Mon, 29 Apr 2024 19:07:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714417627; cv=none; b=AbOVWgwG4gOryYWUjYHGclQLq+eZn0fmaie5PFqVbY9KxzLJx+1L60uultdfsjafbH8plPOXJnr7FHIw2Mn3KIz+ycDzPjtEavK9igGDYBWdb1K893Bhj0zBeYiBnTZ61CR3kcau54ImGfqqAdvc77hShN7U1k8/0CLkU8/v/1o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714417627; c=relaxed/simple; bh=pMXBuRSYRvxJ/Pm5/D0Ih9VGkrkcDFfmsJy8ADz5Yxg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lzhu9D+BIrgmJbfgtqk1bQgExGQUbzFPWAPL3QL56SQPUwtUVvNUbKNVMX8NQWmQTjBB8rGDkwDzSJpwBUwfkmhHkjiMpVq52O9L770UMqBy+3q4uGwnzVCR/cejelPQSAZJb50Q0Gy5LbphwfUZ1zGLVyH4698CTfqoETzQYro= 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=jb3GjCmg; arc=none smtp.client-ip=209.85.214.172 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="jb3GjCmg" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1e51398cc4eso43793365ad.2; Mon, 29 Apr 2024 12:07:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714417625; x=1715022425; 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=jb3GjCmgbgnZGDW8oQFmVnPqrI+A1+wyhXYjEvAV2G/Y/AVTFmMVU1dzAPUNh5iXss IqLMOK9Ig50wh/YxIGnHzYVl5fYq60oxdcewfQ0gZU275PTgXu9SF/xXSrNKOP+7auz6 JQMdssfl9+jBQnkIckrk479Jx15tvHsZPPFZRakxfarA2ll+zngrYCEmKLMpYHhkVAEU y4ODhtp09cpE0YOKqwZT6XuAcJqNarWzy6VY6BJYfbjy5TFq0VPMJJ4kfctk9a8mXadM zyz9uUHQwcYPpHBWeYOALdBgs7+zS2ozVdJwytgGWY4BH/xqnQ3uLhEepKXcBZA9eey8 Wg2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714417625; x=1715022425; 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=kFQqhGfOkh8nKWxIvmRJvshzyPutE8oPbxLAuKGq8yFfFMjB82FGb7ZyTeVCHdMgjs xnfRufZgoYq/P+QVRipgthlFl9ZTQ2R5PD2Bs7agQWIa378zb6libAhrhMcojBgloqI2 QtX6lCRPEkpfRFVDc7G6wjRnULexwUEBeLUfsya1PonpV+MzxdBdp6SK3HJBj9UfSvhH 5VQUcC3VZYN9WaVeyM7pAlc9YhQlW0DiNOD6DCSM6IpZwxRCDbZ1LV1m13KTdNOT3DqA h1ft6f0vvdxyN0nW90jUmRMoj3fAW0BL8uqWeUqFE7KZKfz2YRtCXUojBwDz+GfxCpAI j5xg== X-Forwarded-Encrypted: i=1; AJvYcCVX2bbm1YeIYPZmyFBqbeOpsFU68Nb7bTVrwLcP0tDotLdOP+KT0SsHFkQQvqZIj075mmeUU9LXhfS8K7FK1tyZl4RMY/6KWzl4CfaS+0+oQLmNy9+29keccYdU7T6a8GBuTg/o3UMlt+IcVf9bDO3uapx3Emqcgxfzbk0uWCeqcgHk7MMRAQ== X-Gm-Message-State: AOJu0Yx8CZwZNjIgMo9dIPoDV/qlOy2HdBqbScf7bIFiDpRBEJrWikUq Jtp+islLuXVRZtqmcp9nZMjT5UED171npb3HwSQrg7jpYsBP1It3 X-Google-Smtp-Source: AGHT+IGCpCshl3e+0jgFbNefsapLc8x0wT7Iwt/SLS3EHILX+IdhnoyhK9bIf4QdB7KeidxbJ/QzBA== X-Received: by 2002:a17:902:da8a:b0:1e4:a667:5528 with SMTP id j10-20020a170902da8a00b001e4a6675528mr16722842plx.3.1714417624876; Mon, 29 Apr 2024 12:07:04 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id y4-20020a170902864400b001e49428f313sm20619356plt.261.2024.04.29.12.07.00 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Apr 2024 12:07:04 -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 v3 04/12] NFS: remove nfs_page_lengthg and usage of page_index Date: Tue, 30 Apr 2024 03:04:52 +0800 Message-ID: <20240429190500.30979-5-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429190500.30979-1-ryncsn@gmail.com> References: <20240429190500.30979-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 Mon Apr 29 19:04:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13647536 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6466D13AD3D; Mon, 29 Apr 2024 19:07:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714417631; cv=none; b=RSaErfgj2APTqy31qwp6X405lwu6LIl4HuMw5ePE3VwwSK7uHzFY1A+gwuQ+DHnGedgnbqr9o/qqlj6BnHTGkSRs36mW3Fpv07mmEb4avmBt/Ay0pFUgjMbJpeXtxnxtw3BTXaT/LKQzyNdQQUf0BwK3nhgNlb5nE4JqRjoyG4I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714417631; c=relaxed/simple; bh=bkTdiJFGGBlH6tCXYVyOUBzvEQj2B5ZrCO6Nvtf8Xr0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pwz5UNn/WgNjsGz0mZJ9Cdzclt80aRm+p0mdvhnvN53A6A2le7l9Lmg1ooRVeZkZUBGjAsUxWoA5RnYCv+BdX9KDxZOaCf1cUXqCcrqTZMNDHK3YoOdw8a9W+Rl9j/7iMRQyJCKIzm/9X5815RQkjrdIzzXL/U3KT2k3tuydjxo= 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=Y4Biws0r; arc=none smtp.client-ip=209.85.215.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Y4Biws0r" Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-5e4f79007ffso3162243a12.2; Mon, 29 Apr 2024 12:07:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714417630; x=1715022430; 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=Y4Biws0rd8uXPURjxBNM05xrah1JGl/g5E2toNmP6dku0lzGkADil8vm9WV3MBeIMH gHYpgWNAzsnTs5Ax5DRQKe6ExwbaEVC1WRUROk4+5HqgrOBMwRoBPlFNUzi1kYgIcmYh InExNI0gc6izMjJH06Vgm6+RpGUB4WP/raeIXfmOUSNsm10D5wD/+Gwlj6awp/Z7QEiD uhEoTMBMqP32NJypZzNon8tnArcPlRJu8XjrFgowaobG9khlzX9/q9d01vfIwb/KXdxP wdJBDPnh7Xw7ROG7pZisu+4JDKqjrikGiW38RGL4jDCqy6HiwYZJzZOIKV7pdG/W4bTw GMSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714417630; x=1715022430; 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=Pu9JcktP5/8CC3fKF3iyiXYctp4NId1IxGwgZ1ObZlF105Xd9LV22Q6iMsRe46msF6 CVfOheZWgweComJYhUmN1EztXQxO0muG8dVpeyTRnHc9WHyBTvjvTguEAapJuS60wdQ6 iLlbWCfpvxg/klkz2hpP2Dp/2iKKMQKykyR0/tuM6pQgamd+g42c5abvstnkpCxyH2o0 HkkOYMlOSuDo42e846DVrMGVatrSK4xEn1zb/e2D+YtM3XyabQIQdca79Lu4F/yE2bns 2Kifx6nIdCI9SfJH50tzGlw6A9yayChyvCBx6VpJqd7yVWH1jK3Cod55uBg3nMb/cOP9 gagg== X-Forwarded-Encrypted: i=1; AJvYcCUK84721nBucZUWI7h9WHIWqusD2iyzQfWuT1AuMaURrzjpqeIqR6TWfkguOUCMIxUohZYIExaanZOukEceu3ZbfwyjofPONhKN611wgwBSJJz5ohDhxlJ/2KSJ/e9Ri0/eZ+WAOwquMluZTg== X-Gm-Message-State: AOJu0Yxvm5zhoYkG+ffLQdyxjiXF+InuMjkzW9vQXw2yY5VAxONMRRTG 2AbrIC87MQqMtNkhTbJggAu7+x/ZtNKO8n9jAsl5ErDCvOIJpSO3 X-Google-Smtp-Source: AGHT+IHTYDIYUhd7xIT9MpX0t66Q+G0hrqubyFH0j3AGRIM7zO+0pTNEqaULQZkZmC4aZ0qNTe1Z3A== X-Received: by 2002:a17:902:da88:b0:1eb:5a92:c939 with SMTP id j8-20020a170902da8800b001eb5a92c939mr707490plx.29.1714417629601; Mon, 29 Apr 2024 12:07:09 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id y4-20020a170902864400b001e49428f313sm20619356plt.261.2024.04.29.12.07.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Apr 2024 12:07:09 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , "Huang, Ying" , Matthew Wilcox , Chris Li , Barry Song , Ryan Roberts , Neil Brown , Minchan Kim , 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 v3 05/12] cifs: drop usage of page_file_offset Date: Tue, 30 Apr 2024 03:04:53 +0800 Message-ID: <20240429190500.30979-6-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429190500.30979-1-ryncsn@gmail.com> References: <20240429190500.30979-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 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 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 Mon Apr 29 19:04:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13647537 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) (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 8957513C91B; Mon, 29 Apr 2024 19:07:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714417635; cv=none; b=RjeR9nCN77R7vKgIHcnS5rvsTMnPfRJkGy/VJa7889gFl4+/6BTX/dEaVXq3OetEGwt7EK+k4lPoP7THWY8WFjNJYagxFOaO42ciUboZT2zlSgAMpBjxAnIXjktgM7BwOi/uTfjIWKfKd3T0WgVEhG4APcZC+gcltSqtHXc+sjY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714417635; c=relaxed/simple; bh=VNvVFoX6vwMwHN/TEFwnJJ3gkjqMJfxSRhvUOpIkZtI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uTBZtyXXTEcgR32F/b+NXJKV+kIDg4QBDpIedbVC9BHeBBmbw9s2JBJ23m5nK3ceCka04ojJrzSZQIVQ6Qv28j0Bmzqs/6AekJyTdUfWSu0bXiOFJNkBEMOJIwCSzYptkWsT94/VifWD8wOCPgizhUmu0M6rItPLS+oxA/gYWwA= 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=k8gTenSg; arc=none smtp.client-ip=209.85.214.194 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="k8gTenSg" Received: by mail-pl1-f194.google.com with SMTP id d9443c01a7336-1e3e84a302eso36602495ad.0; Mon, 29 Apr 2024 12:07:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714417634; x=1715022434; 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=j8CUFoSDp/EKaskCJGmVh167O46FIA8Hx1fDOeQzssk=; b=k8gTenSg2WTnuO2QR3Y2N7+9dKvs/L6LEdM3IiWpC/b5UVSz6IDlv4YIeNZVM1I36W vcqQa7BPR040roJVeqbjuJlgz0Hb/lT0cr4SPl21aDN8KIc9KcclH6OvuH1FLUVpjP6e bbFxlFKkAXwkjUkF+c9o0wpibRcdfz+shWNdTA2JEp8Qw0LgG9Lty1rnSJCQTYYohRJs jpADovMF/Oy3vkBQ1WSpC8t5CkhVycmSBBbQJUX+M31ZpFsPaBD4qQeUDZ199GY5mhf3 n+Kiqzi/8nP74rBiOb7y3Udo0pJhDATzI7hemTgwFq2+hEMC36fy9GcY63pRUPdiQGya WZEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714417634; x=1715022434; 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=j8CUFoSDp/EKaskCJGmVh167O46FIA8Hx1fDOeQzssk=; b=X9SLa/pD7IbWZAzG4Ro+aHarss1Y7vRF1nMvq18UvmndbjoDb/vmHrldj8RvNyvTTU wes5Gbg8FXjbRsChwJCi88v3BAhoD1RFNiID9j5/lCR1WXCw+1AcPqQvlBx5ZONeb7c2 yRzKcvmo/+osGGLgv0rA5ksEjpiLKNPJ5ERUfLGCZ0pkCGrrS6FSZ3J6uviKDdWUUI6n 3kpIsuRdA4S4EmEXh3N3HwxCdvxpjNfOrbmRCNEPB04flOa5QkOBOgwVSurr8GkTHEEV 7DaFhWpwOxxRle8vKK6IHSPLz7f+KNVjzPnHM9zYmmo7fMSnB/BmH9yLcq02K9HdsD9e lTcA== X-Forwarded-Encrypted: i=1; AJvYcCXOWDycAxiGeO8Ihz7fs9DsSnFzXgMShLr7pqEhMBU/emydI11tKJ8aKE0m/vXCpPgZlR/OLVrnv0eVaPYvodFcymXx6BXuifoRtPNZiaVY/PExogRvxkVpZTgKdLXC3FSPN1omYdxXelzj2Q== X-Gm-Message-State: AOJu0YxGImba/jlYkuIE1Mj1gVEaDGUpl81QL5Fd8epZmG4BFtFVC79S KBE4anERMJgWnvbTqhx1XmEYYrqd6rZ9B81jZK1lzisGj2zVUVEd X-Google-Smtp-Source: AGHT+IG1HlTPPFifaefvEDj8u3MJ3k3c8t/hPDMkQJOfz5CIi3ml/ryyLddQigyVsR+TdOh10trzuA== X-Received: by 2002:a17:902:f688:b0:1e5:8629:44d with SMTP id l8-20020a170902f68800b001e58629044dmr14089278plg.1.1714417633924; Mon, 29 Apr 2024 12:07:13 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id y4-20020a170902864400b001e49428f313sm20619356plt.261.2024.04.29.12.07.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Apr 2024 12:07: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 , David Howells , Marc Dionne , linux-afs@lists.infradead.org Subject: [PATCH v3 06/12] afs: drop usage of folio_file_pos Date: Tue, 30 Apr 2024 03:04:54 +0800 Message-ID: <20240429190500.30979-7-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429190500.30979-1-ryncsn@gmail.com> References: <20240429190500.30979-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 cache is never exposed to 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 Mon Apr 29 19:04:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13647538 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 675C813C91B; Mon, 29 Apr 2024 19:07:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714417640; cv=none; b=N73jDGZcHb7SiIA5R4GQ0F6AGq9Aaok9vatQZgfgpnWUzHMItKwjUDaqUw1keRS9SmadbFJuHsTK3yzT7FcfsNRpREkwqfAi6Itay79BdDxdLtrULdQTtvRG4x4ROGtZw5EqRKtj8AUnORReEgjDRzX8Cxi4DVs6eVtAk33cHVc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714417640; c=relaxed/simple; bh=qqZmyySN3ttr0mL8w3csYiQ6Lq6o3ZnWQDeTR//44Ts=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XSUJ/zmmU5X/p513KREaCDh8OOGVfjxnJIyPYq3RYLCQEQS6SRHBJYVUwoT6eiUGdHwlb+ce+aHcspFrdp+ewekBZlJysoMSO7dM+BpkrZBDY5WJyMMfFsunqSm2dyb/Gc755OIWPGbHAs/FOsCQLEoEbpm0R2qoQWoinfoYzog= 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=JQ2LSAo4; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JQ2LSAo4" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1e4c4fb6af3so33046505ad.0; Mon, 29 Apr 2024 12:07:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714417639; x=1715022439; 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=/ZAdz4nacsjUfg+kmWc7WaK5L40TR/d1vDMSfySNIi0=; b=JQ2LSAo4R+obODDRpfUZSKAVEQHQ8bsTRNn1aIm/NI7EA5xPbtu7QSu7PCS12bAyRo N3hxJ6oN+UayuKohyBE/sGgkVZoAlZlX+1E+UJrG5RO9V2XQnsKF46AQ/lqygBcFDfbo g/d5nuGeXBHNieJ5ePQZCrdj4guDSxoIxXTanDJx77Mn7nGOFjECPB3WdvuP8gnOxNfe 0olxPxKBKWXt9ZzPZzQyxm2ANpuHMNJHBvXvze6O3iEvwI5VrVoWgEvWgX2fxsBWJEVU n1txSUp1kJJTUjy7QelwiKdlzw6Pw6cH+sEj6uYlXCuzZ4PMk505Cwm2VfirVEDTYShl 6aWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714417639; x=1715022439; 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=/ZAdz4nacsjUfg+kmWc7WaK5L40TR/d1vDMSfySNIi0=; b=angW+WLC+N+Rm0mUItkNbxZBppy9bFHu1vZhjlgmn28nbBkchbeSL/TKo5FgeTYlLo 0kSVh8cdVvzpNcasi1jCmT3z4xoTmsqTflmjHRc87FyFy+lTi0CCursNRZRT0CIF9Hiz KS9ykZId1oFiPu8sVzOusMuG0C3o+VAj3iPinyHuyjZfCjec3w7ZhT3mhf3G42oYoS+v aVZJPZbiGG5EZBkZO4fAxsJ++MS4Hs4NxWXhCINTxppmN9i0oNo0G3CXbYfYPbc4HNFA 8o8lD7XaE/f+QVmD8ZLs6uy8usgYO8V01EMvBVXUZWjmnvhuepNBq6CgLZxbnetk4HsX Z7CQ== X-Forwarded-Encrypted: i=1; AJvYcCWx0z1V/goda4/GBsEIHjVfuoXt10YCs6OmcsPlgo+BW5WCxA52tBmw2GFIPwmRFfxZYdswxYquRKiXuosnoJwZ7k6ZhLq/QR31t2fmCXgFUSztuU+DWJg0TW4x3ChwLD1FC4qRRiJZNCZ9FQ== X-Gm-Message-State: AOJu0Yw1/mVV8tQAI5CRB08GPG1eSUTWbzYYWvJCHDa1jM/ajis4IB8r vm8Y8yHfIpJ3rs23d2hqW7p7T+OoupN8oE7TphfR+CyeLC70V4T6 X-Google-Smtp-Source: AGHT+IEmVRDgcLWQ+6tPsCb7ZBjy6NSNZhmYZz0nvDiJO9htXZ6R1aiOcZHSzS635P8dLMc8xNX3jg== X-Received: by 2002:a17:902:d489:b0:1ea:964f:9b0b with SMTP id c9-20020a170902d48900b001ea964f9b0bmr870204plg.5.1714417638707; Mon, 29 Apr 2024 12:07:18 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id y4-20020a170902864400b001e49428f313sm20619356plt.261.2024.04.29.12.07.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Apr 2024 12:07: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 , David Howells , Jeff Layton , netfs@lists.linux.dev Subject: [PATCH v3 07/12] netfs: drop usage of folio_file_pos Date: Tue, 30 Apr 2024 03:04:55 +0800 Message-ID: <20240429190500.30979-8-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429190500.30979-1-ryncsn@gmail.com> References: <20240429190500.30979-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 cache is never exposed to 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 Mon Apr 29 19:11: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: 13647556 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CBB3513A3E5; Mon, 29 Apr 2024 19:11:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714417914; cv=none; b=pCAyk5Ie0fp9DKJRXTyUH4JKX24cS61BmHPIRbQ/fVbCm5Agav76SHlDEsHHXCE/Bv8gOWsFGRpGtYJiCC9x29/zMX6jtmKaWz8Y5pmmwvktkQL4OozGCYaiypYVDyyE7z/gY5duRsKIefAQqoJnii/en9jLbMywL87mq3vbDlA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714417914; c=relaxed/simple; bh=aBlwHG+XSz2inbaFgGCXbG0yr6uY/trtijVmQNmku2w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u5wMI8c0A669c0cdX1r0aZiK4Ahux5KXCzes6kzNmnXGf5feI8huUIcXKN03klo5xwaEQ1rsXD0e6whfHcNQk5QibRGyQ1YJhTE/I7uQw488kwNFW2epLtX0vUgfx7qk3spZcb5pBrZ3NM0BELTztKdAqdP+0hZ2ceZsSWab2l0= 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=IcS4ErJs; arc=none smtp.client-ip=209.85.210.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IcS4ErJs" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-6f0b9f943cbso4028539b3a.0; Mon, 29 Apr 2024 12:11:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714417912; x=1715022712; 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=/1bORWOEMtQqR5EeJUVgL0AX3aI0603PhY0Dzu9DVzE=; b=IcS4ErJsjpy550acoJoLVe0uzHganOhk2s7EDEfUqDM+WzbntpTp6/ukob6/n0TvkM 1jAdHlpdfesbTsmR06/xHMbbofY4ECH/7U+UG/jzB/ARt+n61Xht6gv2Bt6k1JO8VzQU rei8uXlOBarMQ3GSdnMTOvDyNeKT8mejVfKbhfvUCNo/CIxvIBoyU9BtFJcbbv/haVdc 7svK4EZCIhe9EoUHQ9WhwnsWq4URAB67D83M3wzEzBcIYYN6YB+BsNDTdyxpxXadHmnS vqapbA8lyUbjHjU1OiPMXOtnz/8M/xnKFw3U10Uzlw0hWJYf8HlVlPphpv1n7jO+8V3f R3Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714417912; x=1715022712; 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=/1bORWOEMtQqR5EeJUVgL0AX3aI0603PhY0Dzu9DVzE=; b=Sf3h//fxHy4BIfZoMWcsjlVcpfMkW8Um6iP6S9YA5xOWGpLMiSzIO8KmUFbjosKqvu l7UDf2gZtOT2eEHkXZDV1R9wAD4Z9SQBxP/972WT3vhYpLT1IQdub4cb2keYPAdUCZL/ E+Br7JvZa9rdu3qhXsu96J5jA9bMtt9+E3TVtyHt2e150s733E5/7QpPuxS66/EZxwMG /jOKTE3zbxO3qFosgMXZN+U1nButWrFNFYdHybpX3dvhB6mN59L7ersbEAs2QfJAd4e+ NOIWxeMR/qy/qpBzlEhiCgatKd3h1sdM8Murw2T4nNvCNoiwv5yUOmeiC+RrUAo7ibVG DdiQ== X-Forwarded-Encrypted: i=1; AJvYcCXNW5p5hBSvUY+D8IJHknE1GV+07QaVpTkl7lsJGhE3dBAS+4XnfkXzJmouJ8nK7fRNpYYkaGDYRBjlOxwXNQpUh3mRhxk0CEFDwmgbtWRizIY5xdBpwcMEU9Y2+S9W3TMPzBFKQo1ljaL3hw== X-Gm-Message-State: AOJu0YzbGT8c+ebb8xSTVyihUga99Krw/fzmWkpkmxrr/d39VvJq+Bdp zFYdQF3NYmHh802exOzb3WiYeMWQEmxj0XaxShzAjUULcwyV/N49 X-Google-Smtp-Source: AGHT+IGx8aY8FR50gdhXj18Vz7j7jddJ8qW0aYfCyeOPPSYXuiUjoJ/c7FOQYDIpxGDCtkTEqeM7Ww== X-Received: by 2002:a05:6a00:2186:b0:6ed:cd4c:cc11 with SMTP id h6-20020a056a00218600b006edcd4ccc11mr431263pfi.25.1714417912024; Mon, 29 Apr 2024 12:11:52 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id e10-20020aa7980a000000b006ed38291aebsm20307988pfl.178.2024.04.29.12.11.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Apr 2024 12:11:51 -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 v3 08/12] nfs: drop usage of folio_file_pos Date: Tue, 30 Apr 2024 03:11:34 +0800 Message-ID: <20240429191138.34123-1-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429190500.30979-1-ryncsn@gmail.com> References: <20240429190500.30979-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 is never exposed to nfs and it can't be a swap cache page here, so just drop it and use folio_pos instead. Signed-off-by: Kairui Song --- 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 Mon Apr 29 19:11: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: 13647557 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 6292F12B73; Mon, 29 Apr 2024 19:13:17 +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=1714417998; cv=none; b=fZ81HgckpBoMCNIfEIJ/bgKFBKt1VW/f1midmmmbMas+yz5SmXPf4dbO7audqyBsFi6mtg5dumkvFEPIvibf52CEjOa8Mo8Tvj5nILZvcDWvErA2DM4wpt8p1S6DI4bXEzPHpONv63ihG3mtJZU/iaj+EW/fJxTIcSWHSALCN7c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714417998; c=relaxed/simple; bh=jgvygBW8CqDhFBa68pFHF5Z1PEjjMQjnloI/Wq6AjY4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S7mSX6ROwtEO1/8X8slgxs1Jpqq3NqnXu22SmboPU+BO24uE0HdIfINoWUeJ0L2rrr750+7Sl1LVvhWCntBGOGgJlZSd21LDnnu9McD072XrrnH8RjtDvnpdRz4WTipfxhiHD7ULQUo0k/4mg07CbLorSB2eyshxg4wXT4TCPQE= 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=fbp9bn6V; 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="fbp9bn6V" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-6f26588dd5eso4140309b3a.0; Mon, 29 Apr 2024 12:13:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714417997; x=1715022797; 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=54tBEeL3WLk/xvTe7LsTeIRT4DqSpvAgzssbqgMQpYw=; b=fbp9bn6VRXCdZNbfERvTb1fe82W24gw3vbhcf/eaPtBcSTmA2qFoLRx1d1cjzp/DaC +wJpVacIGIbpTHgTl0npVZ6xp19yx+Nf4a2BxzxJyeZOzedcAwi1GG3W93Bn75K1F8x8 ulROygEPf662WkyNRIZH459DGTHtNV+k+hgIPy0S1Io/O4cONolqnGtQyfYfByNix79q 6305kPdria4Jra0QakuwD9ZJoJq/Ey3PqTxnF2xnf04/FfS4WKP/b8gIUv+orJ5X/63G VbtGzVmRGQ1bfrrYV14+EIXlGa0avLLvZDJYrzyV9CtJaNasuiA/QmQ+B90qHpp7quxP p77g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714417997; x=1715022797; 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=54tBEeL3WLk/xvTe7LsTeIRT4DqSpvAgzssbqgMQpYw=; b=JyPvrsuUQFmUOgYZ0Gwqgn2JZrPObF9utklw24icS6W9bt8zTxxdIJB0aZuOiH+8S5 aVwvbSPHMP5xmvCD5qxgHi593sWhVVv10qW/g9DUmlJWhlRxCArUAmiK0BpciuvqdB7w aEv5idGutgv9WSOq+BkpdyxYWGBzsfbWM/+8KmilqmEXs7hlQrKqWzwdNH7EIYVrsy/0 26Q1G0SCeoy0xCMYNndP5tVSe1QyXFPg5yVhx7YFblPyC32b5SW0Q/slx3ZIVOyBzIk8 vJsAgaKWbTh5l0Fcu++MbnUnHDxLW8Iku9FehF+0ke4vY/bEY6J90MK2jbeGXSrNluod NnoQ== X-Forwarded-Encrypted: i=1; AJvYcCVX0Lk8LlS/XUgGivC9dk8RHjiHsF5rZrxK3IMgfeBz6XJKJqa+Pl7nkxkcxmvLV5LcuKrpcBOqf4kt4NV1o/SetEwQ+dTAyU0kMlDjw+jBfOlA446XYyElNIGaLcLmTUvuoXt+FpKhg7SbYQ== X-Gm-Message-State: AOJu0YxJ8emtGq3i9Tr5Ht4TNHm9KkxdRrl7ZGuvPC/D0GkQqfI+LzeW mLQ17WlwRDlC6loZGxNMlKDf3jIWLSie5LodnVI3NdZSZVGf362R X-Google-Smtp-Source: AGHT+IEkukKzFyXvcUcUCBcg+pFFl4Blb7KQzrcsvkEmMumk82TvVZAkxzMjSXvoKBD5ECjHeKmIeQ== X-Received: by 2002:a05:6a00:3a07:b0:6ec:ea4b:f07a with SMTP id fj7-20020a056a003a0700b006ecea4bf07amr12308186pfb.34.1714417996587; Mon, 29 Apr 2024 12:13:16 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id e10-20020aa7980a000000b006ed38291aebsm20307988pfl.178.2024.04.29.12.13.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Apr 2024 12:13:15 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , "Huang, Ying" , Matthew Wilcox , Chris Li , Barry Song , Ryan Roberts , Neil Brown , Minchan Kim , Hugh Dickins , David Hildenbrand , Yosry Ahmed , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH v3 09/12] mm/swap: get the swap file offset directly Date: Tue, 30 Apr 2024 03:11:35 +0800 Message-ID: <20240429191138.34123-2-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429190500.30979-1-ryncsn@gmail.com> References: <20240429190500.30979-1-ryncsn@gmail.com> Reply-To: Kairui Song Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Kairui Song folio_file_pos and page_file_offset are for mixed usage of swap cache and page cache, it can't be page cache here, so introduce a new helper to get the swap offset in swap file directly. 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 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 Mon Apr 29 19:11: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: 13647558 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 5AD7413B598; Mon, 29 Apr 2024 19:13: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=1714418002; cv=none; b=U/nQgI2ti31phiqgS7EPYLVaGmUSQ772ySxHm8o/CJpkqCz+XbUmJYdqVhVUh7lEItW82RllVZylcNF62xPDlxxHi9SN5976qBzN1ah20aKMBABr+TWF5EU7FqCQnuvNajJbqrvvbtVrLO7bujbOTDXMvA2YkyapmB9fA6CxhVU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714418002; c=relaxed/simple; bh=sgR0dU15JB8rGvD/MDR+dhiv67zgFby0JOYk45sAObs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W2mxemUD0n0d+XMMEUrXY5pxIj/CPwWY6IZwDlZuCtCPmz4vGB4ET8220m1PGrKo0/It17YHZQigxsf7EHf0pkCU3u20Go14AWumHNCn7P7KsWJMwZdgwvXGjcwXiZwzJiT6WGU2qdzKjSp63jC7AxG911fbtv0VuHxq3+rECyE= 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=V7bsrhX6; 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="V7bsrhX6" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6f4081574d6so1065517b3a.2; Mon, 29 Apr 2024 12:13:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714418001; x=1715022801; 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=hcA4nZ293WdWUF1yQsfhWEusCPbJDpQqrWzNvwMbGT0=; b=V7bsrhX6LZVEC3aKL2uLuwxn1avCMvO4nQyQmHDEHK/9wAOFISJFAGPs8cF58mm/YK bGJDhsTFRM4Ztjing/WgQUm2pN0Nlbap8RfW+oZjR2TY61KBAySKWa4OsVCHLrkYaLwo wJDwJL1gyBsZYlAV2jPMVdMMHZXvbITdEkTdf3fZvLBJulnecZKAWAgqVjt28ZS7FWjT +BszWc8w4dZKNmInqx5UknpsmllyuUiX9Fhq95s/32VHYGPTbfB6jrKFzeag3ROvtTgF Z2193ziC6mo7LCVlnoo5tmA7j438r1CILHzrQbSVyBE5IeR0jRpvfh8PN+6eF9wdvD4A Qang== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714418001; x=1715022801; 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=hcA4nZ293WdWUF1yQsfhWEusCPbJDpQqrWzNvwMbGT0=; b=djDtbODSML5P7EZMV9n8FaC9mh4MSXIh0/DMQ/M2Vcp145u3jE++iPxn8M0B3UMGuu whBavL8qJB9FFsV6kLWvbIhaPqHvMzbD2M3zWKWXq7DWJrsQo/5R7TI50R74iSy7IZEk OPw0yzPrgTW8JQpEeirjIeeKhTs2qww16iQuyUnYk0QwJAlxHQbz0hpFgiiyTMwKCB3x DGVktH6stP8JO27ifFrJDNdqvEZ0cYcvQxLgJ8BTHJVf1QjDU74l7Icw/4kDcP9U0vRT oYdxudDkmVZqsmftZd5tQ4r6vGUwoMk+EWt3fgMSoQA6CbiksJo5hrTIAzEs5lQ8zjgr ujcQ== X-Forwarded-Encrypted: i=1; AJvYcCV3VOzoqNYfqzlFEJGZQgAfG7v3ra4PMaWCgqtanoDc+ECuB+KYYRciQAQyJ8yegRL/h0utwyG1COJQyBdU2KH60ReQ2gjrepM/h/+PwVC+Pb5F42tZUu580Dyz5goz5umgYxsmXce8ibpSlg== X-Gm-Message-State: AOJu0Yx2zMyUdZjS+J3CnVj93O/LI4IRLyUutXsoLz+LRkgi34AC4PGS OweHxJCRnAskid8+NlF+8nMw+OdSYqWr6Qn6hGrhf+UxylB7NRkh X-Google-Smtp-Source: AGHT+IHLvjgAnYI9Ysv2ceA6BnVwlRDqXI0/taYU8YoY6DhE56amomjz9GVryhH/eJ61mj48VwV1lw== X-Received: by 2002:a05:6a20:2d0a:b0:1aa:930d:3dd7 with SMTP id g10-20020a056a202d0a00b001aa930d3dd7mr14861872pzl.6.1714418000676; Mon, 29 Apr 2024 12:13:20 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id e10-20020aa7980a000000b006ed38291aebsm20307988pfl.178.2024.04.29.12.13.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Apr 2024 12:13: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 Subject: [PATCH v3 10/12] mm: remove page_file_offset and folio_file_pos Date: Tue, 30 Apr 2024 03:11:36 +0800 Message-ID: <20240429191138.34123-3-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429190500.30979-1-ryncsn@gmail.com> References: <20240429190500.30979-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 --- include/linux/pagemap.h | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 4e85f33721c4..91474dcc6cce 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -917,11 +917,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. @@ -931,18 +926,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 Mon Apr 29 19:11: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: 13647559 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD31113BC1C; Mon, 29 Apr 2024 19:13:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714418007; cv=none; b=YyPF+iqmFhUTbnN33AHLSXqi2jXd9WyvI7z2RXaDVdhKFgQt1O+dfd9OMXtm8W1psOS1cljzsw/k7Xl5vyDo2bkpaXlpSzH0b8WdRczlwHTfHI77jgip8tDlGabRDYKXvCepP2DwVp7RcT9ZRCBD+twqoKEMiz8RIDBvFfCCj88= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714418007; c=relaxed/simple; bh=8EWzx+HGEvik1D+rKiMHX/VU9FNdzjA89r3P4lo5qBU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o0ARk4izV6mI+VSgWt1T7D+sEViI7ab8FdNPeR4aIyAEEzeaxwAJfQ4eosHy758CXF9N7w02FPCNGdaYcvxA+jFRkrpaP0jELJX1qLCp37lgz7O4LRIoqPygpc8Mf88fnB6hbD3ldNihyphrAcf6FNB/htkFLHr8KD+l80uoAjQ= 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=gNEPks4p; arc=none smtp.client-ip=209.85.210.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gNEPks4p" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-6ed3cafd766so4383696b3a.0; Mon, 29 Apr 2024 12:13:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714418005; x=1715022805; 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=8QazdPBRgLGfXIr1HFTGvtxzzbA+7izgwNyqAiebQ+Y=; b=gNEPks4pvcEHemW+4klDqGfe6zwZZMt/+vPcXl1kghgck/W5mlgnNBQtbMdw51Cw0N 7A3OhHOjOuOe26b9ZvWG9C9yKWyAVA5/Ug7aXWcYmBqFIENa6MWIHrL+srx03SFuT08E CtC0Wfm3UReGXuIGB720SbPtS7Bu9ghQfpDCWrx8wut1t0AW+uRTTKAyZKXbI8KkpOtX xY7tqkTRlpo06lPLc5/7qroc0kFTA58Kn/z1VwMaW9lqsLl2HC6sW+KjPwEPn7yrEu6L QFSJD33n7WGH4jVy7NBGsnFa8rVe9cS3I2bSYC3TzqzpKuV2LM+62h6Ufijfri9i3WPZ lpzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714418005; x=1715022805; 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=8QazdPBRgLGfXIr1HFTGvtxzzbA+7izgwNyqAiebQ+Y=; b=UxNHZ1md9Q56bWMtl+5aZ/vTFRIotLibFaj4cLqc8NxVEXSnp0gxj59ti0bCodhjM0 DDMjmUvCaTh9ZikCKYTM8ZGFjR87vZkuf5e1VSNcZ0SXRYlZMS3oqQEwPiAlnfXZ5LxE ATHPLFLGBe7QCrQtE16hqzG7OgM5Eqw7pfqpMJrhMXeZ705YpCQhFW3MP9nzGu/T5fhQ JyH6X1LusLRWRrQVr6StYpzEhaA9dV+r8bkn3qqL8e0xE+WMp6Pz3fpoSk6X/bjB+RK4 FrIzNygvoyXunzfzzJQ7oZw8xYzEOYQibfH2iVWJjLr8nWDTN5YiXSQlBqqcd1w4eoXL gcTA== X-Forwarded-Encrypted: i=1; AJvYcCX11DOofUhHr8XaOBJOAGT8eDsLkIDf6iHMr60KnOlutKFIpXB7K8r1EpfrriepUCioYpTK2IZf15mWTYTzFDOO6iNti2z8VuHA+X6o2RbR5Ki4fn7HAqZxalD3pFO2H2K3jhVMo/0ZWuekOw== X-Gm-Message-State: AOJu0YyfIhNII1wn1fmLKKkufrjRWPxf9B8F3TsOpiHWhKpaOFNvF2wd 0xIdVfg3NK1lokVoatYtmupwZCxINiPplz3t/Mb786l2ei/NWvQP X-Google-Smtp-Source: AGHT+IFPOFbp9pmt2653zFt0UEbOTrCGtp/cEwxyT9UheEYNDjImTX/zaDPWA1WmxxbAEpNdjTgHPw== X-Received: by 2002:a05:6a00:21cc:b0:6e8:3d5b:f3b1 with SMTP id t12-20020a056a0021cc00b006e83d5bf3b1mr11062453pfj.22.1714418005131; Mon, 29 Apr 2024 12:13:25 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id e10-20020aa7980a000000b006ed38291aebsm20307988pfl.178.2024.04.29.12.13.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Apr 2024 12:13: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 v3 11/12] mm: drop page_index and convert folio_index to use folio Date: Tue, 30 Apr 2024 03:11:37 +0800 Message-ID: <20240429191138.34123-4-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429190500.30979-1-ryncsn@gmail.com> References: <20240429190500.30979-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 91474dcc6cce..47171bf20b53 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -777,7 +777,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. @@ -792,9 +792,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 96606580ee09..6f028262898b 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 Mon Apr 29 19:11: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: 13647560 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (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 E68ED13C3F5; Mon, 29 Apr 2024 19:13:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714418011; cv=none; b=ClWne/JdzRg+jwsRXMYIQPJm4+pNXt3KUl1QppfKbxvrr0bsZE71ENAvf3yKtS1Me4ukikR8HCiZXQnb+0UoN9X7I/UPtPRT7OQSTfMTU7n6oa6ufouUMX//vwx9fzOxfBO8shkAxdbvUmkK5esLSudhVSn/bj2/ElUPytd2ggU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714418011; c=relaxed/simple; bh=ruPguBGn/jL44gWfkAWdwjzz7mpX0JB5xbh0t/SLx0o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E5ATZqSvpwXxTZajrSYcw40XpKxO4gx1or05q5fFtG5zGchEM/q2eG274mGOduhnmrGmvwMhVcuehkOROUuA/g6KivJMohHnnMHHnBodhZDRvhn+LaVsn1Vro7xdkuxNR3kXm7cclShjEpFgKMUFYJpSmx/PFJ8R5ASsSdlUF/g= 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=GTTtYTxw; arc=none smtp.client-ip=209.85.210.182 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="GTTtYTxw" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-6ed04c91c46so4719997b3a.0; Mon, 29 Apr 2024 12:13:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714418009; x=1715022809; 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=PY7g2cpmkbLDRH/cw0JP1fam/luoqXTBgJ66zM17H9Q=; b=GTTtYTxwDFAYdzQptdDCoGBF59NtgoI45fU0ErAx9u0bag2QJD7sb8HgwYI0jkPZzt JWbxlmdxsGWVZZw89URcMsnXK6K6zxUBX8asuo1SupUveQV6ACTtFzIxDRQwMotP1qAd raqMKieFnX9d4qhtj+xJE65YaztIJCv9GIB5u36OKIPQaH+/OyNfZZDP65WzHKL6p28X GcoFaQDlUFapdX4UmNn78SpVmfrUVN+xcgQgffwA8CFS9jyyCpQ7YlS8Wrcu+4Eo37Ms CGrrpCXMkvCvzgmyvSMtFznsCMJhi6E21DFaj3UD4D9PWiUToTMfAQZvQ2iTxIU2Uzm0 kxXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714418009; x=1715022809; 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=PY7g2cpmkbLDRH/cw0JP1fam/luoqXTBgJ66zM17H9Q=; b=Pqw7GcCKBhBKDvdZF/bo3NfFs8R24XJU3AdlHVRF56PPhTH7yIpHB3smPA93HL1iO2 hLFfQ+HAfUPmB1a8G6PiCJPtg84b1Drtq1HsFT7CbL2MNPQaZo+FqiixBmjG8WIXY1Kl y+cy/j9K9mgOpD+pdK2WRvVd+6q2UhD052mCBXyp0Pw9sS6yE4jqQtWcpNaR8m2tHZcu Rns0wGD8D91Cjx7L+Ciw+gXpWdIwoT84fK1pYMDUZjvpNMVKJkjHNuLzatHHJ3CvDOR0 qpaDU3rewEVFbq23OyqMfK2L3SgTtSv3x3bxwLpLsJL9palACoxr6IwNS4e1YtfWWWxy /8iA== X-Forwarded-Encrypted: i=1; AJvYcCV7drQWt4EKrN0T3k/JvRZakgnAx7o1KXmaD5ERxyNrxD7C0WzKCd8QNglKFPPkmMt4uLsnl6nuYMK+nCjVxEwzur3xFvngYX0G2ldoZ03/ru6+xrfCi5k4/oF9b7wHEdCB26V8m+U08OoInw== X-Gm-Message-State: AOJu0YzM30hJmJiuWhuJK+/xrsbyLHZ1o3Ep/IOsZ82QWV5mWoxnPAxB EvRg4OJTUkXGJeB09qPm4JRMh9BQt7qxy35Ee+igiNG1+vwPr0MX X-Google-Smtp-Source: AGHT+IExOJ/p/bJW9q/f21ksPY2gdiW8nSTfaSxNTc1Poa54zyXrIO+xTyTWMo/yh/qLCiK2/+zrZA== X-Received: by 2002:a05:6a20:4386:b0:1a7:ae5d:5fb4 with SMTP id i6-20020a056a20438600b001a7ae5d5fb4mr15127477pzl.28.1714418009348; Mon, 29 Apr 2024 12:13:29 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([1.203.116.31]) by smtp.gmail.com with ESMTPSA id e10-20020aa7980a000000b006ed38291aebsm20307988pfl.178.2024.04.29.12.13.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Apr 2024 12:13: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 v3 12/12] mm/swap: reduce swap cache search space Date: Tue, 30 Apr 2024 03:11:38 +0800 Message-ID: <20240429191138.34123-5-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429190500.30979-1-ryncsn@gmail.com> References: <20240429190500.30979-1-ryncsn@gmail.com> Reply-To: Kairui Song Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Kairui Song Currently we use one swap_address_space for every 64M chunk to reduce lock contention, this is like having a set of smaller swap files inside one big swap file. But when doing swap cache look up or insert, we are still using the offset of the whole large swap file. This is OK for correctness, as the offset (key) is unique. But Xarray is specially optimized for small indexes, it creates the radix tree levels lazily to be just enough to fit the largest key stored in one Xarray. So we are wasting tree nodes unnecessarily. For 64M chunk it should only take at most 3 levels to contain everything. But we are using the offset from the whole swap file, so the offset (key) value will be way beyond 64M, and so will the tree level. Optimize this by using a new helper swap_cache_index to get a swap entry's unique offset in its own 64M swap_address_space. I see a ~1% performance gain in benchmark and actual workload with high memory pressure. Test with `time memhog 128G` inside a 8G memcg using 128G swap (ramdisk with SWP_SYNCHRONOUS_IO dropped, tested 3 times, results are stable. The test result is similar but the improvement is smaller if SWP_SYNCHRONOUS_IO is enabled, as swap out path can never skip swap cache): Before: 6.07user 250.74system 4:17.26elapsed 99%CPU (0avgtext+0avgdata 8373376maxresident)k 0inputs+0outputs (55major+33555018minor)pagefaults 0swaps After (1.8% faster): 6.08user 246.09system 4:12.58elapsed 99%CPU (0avgtext+0avgdata 8373248maxresident)k 0inputs+0outputs (54major+33555027minor)pagefaults 0swaps Similar result with MySQL and sysbench using swap: Before: 94055.61 qps After (0.8% faster): 94834.91 qps Radix tree slab usage is also very slightly lower. Signed-off-by: Kairui Song --- mm/huge_memory.c | 2 +- mm/memcontrol.c | 2 +- mm/mincore.c | 2 +- mm/shmem.c | 2 +- mm/swap.h | 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 8261b5669397..d0c6d30d72f2 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2841,7 +2841,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 602ad5faad4d..8a75eb6c86cc 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5983,7 +5983,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..9994b8d17741 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); @@ -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 6f028262898b..81bd61d0a7a6 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);