From: sashiko-bot@kernel.org
To: "Usama Arif" <usama.arif@linux.dev>,
"Andrew Morton" <akpm@linux-foundation.org>,
willy@infradead.org, jack@suse.cz, david@kernel.org,
axboe@kernel.dk, "Christoph Hellwig" <hch@lst.de>,
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
Subject: Re: [PATCH 2/4] mm/filemap: clear PG_dropbehind on lookup under the folio lock
Date: Thu, 03 Dec 2026 14:26:08 +0000 [thread overview]
Message-ID: <sashiko-outbox-247961@kernel.org> (raw)
In-Reply-To: <20261202142513.2951661-3-usama.arif@linux.dev>
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 <usama.arif@linux.dev>
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 address_space *mapping,
>
> 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 = fgp_flags & FGP_LOCK;
> +
> + if (!locked && !folio_trylock(folio))
> + return folio;
> + if (mapping_can_writeback(mapping)) {
> struct inode *inode = mapping->host;
> struct bdi_writeback *wb;
> struct wb_lock_cookie cookie = {};
> - long nr = folio_nr_pages(folio);
>
> wb = 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.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202142513.2951661-1-usama.arif@linux.dev?part=2
next parent reply other threads:[~2026-12-03 14:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261202142513.2951661-1-usama.arif@linux.dev>
[not found] ` <20261202142513.2951661-3-usama.arif@linux.dev>
2026-12-03 14:26 ` sashiko-bot [this message]
[not found] ` <20261202142513.2951661-4-usama.arif@linux.dev>
2026-12-03 14:26 ` [PATCH 3/4] mm/filemap: don't drop dropbehind folios with interrupts disabled sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-247961@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=axboe@kernel.dk \
--cc=bigeasy@linutronix.de \
--cc=brauner@kernel.org \
--cc=byungchul@sk.com \
--cc=chentaotao@didiglobal.com \
--cc=clrkwllms@kernel.org \
--cc=david@kernel.org \
--cc=gourry@gourry.net \
--cc=hannes@cmpxchg.org \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=jlayton@kernel.org \
--cc=joshua.hahnjy@gmail.com \
--cc=kas@kernel.org \
--cc=kernel-team@meta.com \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=matthew.brost@intel.com \
--cc=mhocko@suse.com \
--cc=riel@surriel.com \
--cc=ritesh.list@gmail.com \
--cc=rostedt@goodmis.org \
--cc=rppt@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=tz2294@columbia.edu \
--cc=usama.arif@linux.dev \
--cc=vbabka@kernel.org \
--cc=willy@infradead.org \
--cc=ying.huang@linux.alibaba.com \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox