Re: [PATCH 1/2] kselftests: cgroup: update kmem test tolerance for multi-memcg stock

From: Michal Koutný

Date: Wed Apr 15 2026 - 05:56:38 EST


Hello Xiaokai.

On Tue, Apr 14, 2026 at 11:05:23AM +0000, ranxiaokai627@xxxxxxx wrote:
> Fixes: f735eebe55f8 ("memcg: multi-memcg percpu charge cache")

An interesting catch.

> -#define MAX_VMSTAT_ERROR (4096 * 64 * get_nprocs())
> +#define NR_MEMCG_STOCK 7
> +#define MAX_VMSTAT_ERROR (4096 * 64 * NR_MEMCG_STOCK * get_nprocs())

When you touch this, I think this could be factored into it too:

+#define MAX_VMSTAT_ERROR (sysconf(_SC_PAGESIZE) * 64 * NR_MEMCG_STOCK * get_nprocs())

And given how much the selftest depends in this implementation
detail(?), I see that there are other selftests that include directly
from the tree, I'd suggest also
#include "../../../../include/linux/memcontrol.h"

and use the constant from there (i.e. move NR_MEMCG_STOCK to there too).

That should make the selftest more flexible, resilient to future changes
and it'd document ramification of these constants too.

Thanks,
Michal

Attachment: signature.asc
Description: PGP signature