* Re: [PATCH 2/4] mm/filemap: clear PG_dropbehind on lookup under the folio lock
[not found] ` <20261202142513.2951661-3-usama.arif@linux.dev>
@ 2026-12-03 14:26 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-03 14:26 UTC (permalink / raw)
To: Usama Arif, Andrew Morton, willy, jack, david, axboe,
Christoph Hellwig, hannes, jlayton, brauner, tz2294, ritesh.list,
chentaotao, ziy, bigeasy, liam, vbabka, rppt, mhocko, apopple,
byungchul, gourry, joshua.hahnjy, matthew.brost, ying.huang,
clrkwllms, rostedt, linux-mm, linux-rt-devel, kas, riel,
shakeel.butt, kernel-team
Cc: linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 3/4] mm/filemap: don't drop dropbehind folios with interrupts disabled
[not found] ` <20261202142513.2951661-4-usama.arif@linux.dev>
@ 2026-12-03 14:26 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-03 14:26 UTC (permalink / raw)
To: Usama Arif, Andrew Morton, willy, jack, david, axboe,
Christoph Hellwig, hannes, jlayton, brauner, tz2294, ritesh.list,
chentaotao, ziy, bigeasy, liam, vbabka, rppt, mhocko, apopple,
byungchul, gourry, joshua.hahnjy, matthew.brost, ying.huang,
clrkwllms, rostedt, linux-mm, linux-rt-devel, kas, riel,
shakeel.butt, kernel-team
Cc: linux-kernel
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] mm/filemap: inaccurate Fixes trailer in folio_end_dropbehind()
fix
--
commit fa3358ee2feeec78d1d81bdc2f73fcecfd3a6f0b
Author: Usama Arif <usama.arif@linux.dev>
> mm/filemap: don't drop dropbehind folios with interrupts disabled
>
> Forced-threaded interrupt handlers pass the in_task() check in
> folio_end_dropbehind() but run with interrupts disabled on !PREEMPT_RT,
> and invalidating the folio turns them back on. ext4 RWF_DONTCACHE
> overwrites hit this with threadirqs until commit 7d7c9c83c822 ("ext4:
> complete dropbehind writeback in task context"), and folios marked
> dropbehind after their writeback was submitted still can.
>
> Skip the drop when interrupts are disabled. The folio stays cached, as
> it does when the completion runs in hardirq context.
>
> Fixes: ae21c0c0ac56 ("ext4: support uncached buffered I/O")
> Cc: stable@vger.kernel.org
> Signed-off-by: Usama Arif <usama.arif@linux.dev>
[Severity: Low]
Should the Fixes tag reference fb7d3bc41493 ("mm/filemap: drop
streaming/uncached pages when writeback completes") instead?
ae21c0c0ac56 ("ext4: support uncached buffered I/O") only enabled
FOP_DONTCACHE in ext4, whereas the in_task() check guarding
folio_unmap_invalidate() in mm/filemap.c was introduced by fb7d3bc41493
("mm/filemap: drop streaming/uncached pages when writeback completes").
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202142513.2951661-1-usama.arif@linux.dev?part=3
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-03 14:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20261202142513.2951661-1-usama.arif@linux.dev>
[not found] ` <20261202142513.2951661-3-usama.arif@linux.dev>
2026-12-03 14:26 ` [PATCH 2/4] mm/filemap: clear PG_dropbehind on lookup under the folio lock sashiko-bot
[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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox