From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796307971; b=3CAOgv3iJPS1yEkqUUqhl/juHMZxuAqfDaG66Cih6NxlnCtapH1frqf984hu7B4wlTkG F2N/lI/OdbfcAvLMfHhy1yLKm6sqx5uEmcBofC76qJUydDEbiZCR5Gas3ayR2huJeR4oV Rgbi8IQMYafzxPmvOWxXe2uCK/Kt32+E9Re1j4Qczp0UFnCz6Dnf1RpTyXuvUATNPv5pZ Fx0wLfkWCLTjp81uKvtgSas4XTzWjF8bB5TE8qin0JLoHjc8XQpJzzxWNN/UPBgpriPgz XsznVWEEg3WvUz6hWBd7HFaywd5nImCDK+TeKRzDaukRTC1Mn/xJT0XHF4RR6a9I1sw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796307971; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=PunW3UPFA76DszS2UdQxqdA+Phm6lMJqECqkJmxfYfU=; b=vj1WuPuVE1VGkEgbBtDdtzoryc79vkSRLZHgoaYIexIwsZUIB6T5fKS84udJ1ZN5F1Ky P3Uk2oviLB/sTVMJAg93XhlvfsERaD+CW+b9nNYCdgqvijKE6C6II5mWhkspxmqaQYw8p sDnMujc89c5EzQVXSgkQm8zFaCIQxDvvxc4nJw4Lp3Lip7R/FjqsHA4umoBv2+uHingFI nydZUthx6anGnxMiw7Fbwt/qwmPpFNAti4Q4SaB5nUHI4wM8z1JwjZhjavkrgC2PcrkU7 RVs8PGN6dIuU619mYq+iklQBxbkehGyVDp50mYWKn0bBK4YdT1jDkdixP9doyx797NQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=E7XL6msb; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1066D606A322; Thu, 3 Dec 2026 14:26:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=E7XL6msb Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F36A1F00898; Thu, 3 Dec 2026 14:26:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796307970; bh=PunW3UPFA76DszS2UdQxqdA+Phm6lMJqECqkJmxfYfU=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=E7XL6msbSBZxgtTCAXHTpSYgN/y56n/2nv4QkWFdL22VO4hY93HL3QSpqZVOvMnIU L+Q1eN3AQTUcokiYQfEt32VJz/zvy9/5YkbmrgyjLAGwYsz5un43xkGlBoArAbKZAI iFdoLwcIiPC5mEsUpzqDgRWQjRsMDUWhy8zwKc8VDjIIdqYictVbvsAynPVBE02Zlr 6VjUtQGDVhgGkjuf4y7j2Q++6Xn43y97geY5ho63nAnJKRUp99ba2Rc0Y0dXWsm6th c5hAwoh3+6RusxSNJOF8o1DQerFKzS/uNfxcQoIDZSiGBZm/4Nu4dzS+WDueRlhPXW wQaXDvs1OPKVA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 2/4] mm/filemap: clear PG_dropbehind on lookup under the folio lock Reply-To: sashiko-reviews@lists.linux.dev To: "Usama Arif" , "Andrew Morton" , willy@infradead.org, jack@suse.cz, david@kernel.org, axboe@kernel.dk, "Christoph Hellwig" , hannes@cmpxchg.org, jlayton@kernel.org, brauner@kernel.org, tz2294@columbia.edu, ritesh.list@gmail.com, chentaotao@didiglobal.com, ziy@nvidia.com, bigeasy@linutronix.de, liam@infradead.org, vbabka@kernel.org, rppt@kernel.org, mhocko@suse.com, apopple@nvidia.com, byungchul@sk.com, gourry@gourry.net, joshua.hahnjy@gmail.com, matthew.brost@intel.com, ying.huang@linux.alibaba.com, clrkwllms@kernel.org, rostedt@goodmis.org, linux-mm@kvack.org, linux-rt-devel@lists.linux.dev, kas@kernel.org, riel@surriel.com, shakeel.butt@linux.dev, kernel-team@meta.com Cc: linux-kernel@vger.kernel.org In-Reply-To: <20261202142513.2951661-3-usama.arif@linux.dev> References: <20261202142513.2951661-1-usama.arif@linux.dev> <20261202142513.2951661-3-usama.arif@linux.dev> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 14:26:08 +0000 X-Mailing-List: linux-rt-devel@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] mm/filemap: 32-bit unsigned negation in __filemap_get_folio_mpol() -- commit 692fa43d891b2d863f2536d0298d2c5c841d89bb Author: Usama Arif mm/filemap: clear PG_dropbehind on lookup under the folio lock This commit clears PG_dropbehind and updates WB_DONTCACHE_DIRTY under the folio lock and within the wb transaction during cached folio lookups. > diff --git a/mm/filemap.c b/mm/filemap.c > index 64eefcdb24b39..a49cca600f8c3 100644 > --- a/mm/filemap.c > +++ b/mm/filemap.c > @@ -2104,19 +2104,32 @@ struct folio *__filemap_get_folio_mpol(struct add= ress_space *mapping, > =20 > if (!folio) > return ERR_PTR(-ENOENT); > - /* not an uncached lookup, clear uncached if set */ > - if (!(fgp_flags & FGP_DONTCACHE) && folio_test_clear_dropbehind(folio))= { > - if (folio_test_dirty(folio) && > - mapping_can_writeback(mapping)) { > + /* > + * Not an uncached lookup, clear uncached if set. Dirtying and cleaning > + * normally hold the folio lock; take it to keep WB_DONTCACHE_DIRTY in > + * sync. > + */ > + if (!(fgp_flags & FGP_DONTCACHE) && folio_test_dropbehind(folio)) { > + bool locked =3D fgp_flags & FGP_LOCK; > + > + if (!locked && !folio_trylock(folio)) > + return folio; > + if (mapping_can_writeback(mapping)) { > struct inode *inode =3D mapping->host; > struct bdi_writeback *wb; > struct wb_lock_cookie cookie =3D {}; > - long nr =3D folio_nr_pages(folio); > =20 > wb =3D unlocked_inode_to_wb_begin(inode, &cookie); > - wb_stat_mod(wb, WB_DONTCACHE_DIRTY, -nr); > + if (folio_test_clear_dropbehind(folio) && > + folio_test_dirty(folio)) > + wb_stat_mod(wb, WB_DONTCACHE_DIRTY, > + -folio_nr_pages(folio)); [Severity: Medium] On 32-bit architectures, does passing -folio_nr_pages(folio) to wb_stat_mod() corrupt WB_DONTCACHE_DIRTY? folio_nr_pages() returns unsigned long, so negating it directly produces an unsigned 32-bit value that zero-extends to a large positive s64 amount in wb_stat_mod() instead of subtracting the page count. Keeping the signed long nr variable or casting folio_nr_pages(folio) to long before negating would avoid this. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202142513.2951= 661-1-usama.arif@linux.dev?part=3D2