Re: Bad psi_group_cpu.tasks[NR_MEMSTALL] counter

From: Gao Xiang
Date: Thu Nov 21 2024 - 09:02:27 EST




On 2024/6/12 18:20, Max Kellermann wrote:
On Wed, Jun 12, 2024 at 11:49 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
The erofs one is also not entirely obvious, but irrelevant if you're not using
it... the below should make it a little more obvious, but what do I know.

We do use erofs a lot, and I read that very function the other day -
it is weird code with two loop levels plus continue and even goto; but
I thought it was okay. psi_memstall_enter() is only ever called if

The outer loop handles the whole inflight chain (all compression
extents that need to be decompressed).

The inner loop handles each compression extent (called as a pcluster
-- physical cluster in EROFS) in the chain, and it could contain
several consecutive physical blocks so it needs a loop:

If the physical block doesn't need a real I/O (due to cached data
for example), it will "continue;"
Or it will check if i/o is consecutive, if not, submit the current bio;
then get a new bio if needed and add the physical block to the bio;
if the physical block cannot be added to the bio, retry:
-- some similiar logic can also be found in:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/mpage.c?h=v6.12#n298

Hopefully it helps.

Thanks,
Gao Xiang