]> git.baikalelectronics.ru Git - kernel.git/commit
fs: fix leaked psi pressure state
authorJohannes Weiner <hannes@cmpxchg.org>
Thu, 3 Nov 2022 21:34:31 +0000 (17:34 -0400)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 8 Nov 2022 23:57:25 +0000 (15:57 -0800)
commit9d154f8913439d4b8c692f7a8573fe5805e5f8d3
tree631fb24b9dcf69eb3010c2f05d2098f46f827abf
parent52d51e6ad3db8490477a242f5c8b9906a0d3830f
fs: fix leaked psi pressure state

When psi annotations were added to to btrfs compression reads, the psi
state tracking over add_ra_bio_pages and btrfs_submit_compressed_read was
faulty.  A pressure state, once entered, is never left.  This results in
incorrectly elevated pressure, which triggers OOM kills.

pflags record the *previous* memstall state when we enter a new one.  The
code tried to initialize pflags to 1, and then optimize the leave call
when we either didn't enter a memstall, or were already inside a nested
stall.  However, there can be multiple PageWorkingset pages in the bio, at
which point it's that path itself that enters repeatedly and overwrites
pflags.  This causes us to miss the exit.

Enter the stall only once if needed, then unwind correctly.

erofs has the same problem, fix that up too.  And move the memstall exit
past submit_bio() to restore submit accounting originally added by
1f97b202d918 ("block: annotate refault stalls from IO submission").

Link: https://lkml.kernel.org/r/Y2UHRqthNUwuIQGS@cmpxchg.org
Fixes: 0675f7b73cc0 ("btrfs: add manual PSI accounting for compressed reads")
Fixes: 667f7afd1f5e ("erofs: add manual PSI accounting for the compressed address space")
Fixes: 9c735ec483eb ("block: remove PSI accounting from the bio layer")
Link: https://lore.kernel.org/r/d20a0a85-e415-cf78-27f9-77dd7a94bc8d@leemhuis.info/
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reported-by: Thorsten Leemhuis <linux@leemhuis.info>
Tested-by: Thorsten Leemhuis <linux@leemhuis.info>
Cc: Chao Yu <chao@kernel.org>
Cc: Chris Mason <clm@fb.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: David Sterba <dsterba@suse.com>
Cc: Gao Xiang <xiang@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/btrfs/compression.c
fs/erofs/zdata.c