Re: [PATCH bpf-next v2] selftests/bpf: Fall back when memcg_proactive_reclaim data lands in shmem

From: Alexei Starovoitov

Date: Wed Nov 18 2026 - 22:46:00 EST


On Wed, Nov 18, 2026 at 07:04 PM Hui Zhu <hui.zhu@xxxxxxxxx> wrote:
> What about two things: only check when the test fails, and check
> KPF_SWAPBACKED instead of f_type?

It's still overkill. 50 lines instead of one more compare per test.
It doesn't cover arena_memcg. The failure there is a dead child,
and its O_TMPFILE is gone.

> 1. Check only when the test fails.
> What the test needs is "these pages are reclaimable", not "these pages
> are not shmem": with swap available shmem reclaims fine, and then
> reclaimed == 0 is a real regression that must not be skipped. So probe on
> the failure path only -- nothing is paid when the test passes, there is
> no polling, and a regression cannot be masked.

It can. Kurt's guest has no swap, and /tmp is overlayfs over tmpfs.
Make bpf_proactive_reclaim() return 0 there:

skel->bss->reclaimed 0
si.totalswap 0
file_is_shmem(data_fd) 1 -> test__skip()

With the f_type check workload_dir() moves on to "." and the test
fails as it should.

Swap alone is not enough either. The prog passes swappiness -1.
With vm.swappiness == 0 get_scan_count() doesn't scan shmem:

if (cgroup_reclaim(sc) && !swappiness) {
scan_balance = SCAN_FILE;

So reclaimed == 0 with swap on is not always a regression.

> 2. Probe with KPF_SWAPBACKED.
> f_type is a blacklist, so the next stacking filesystem repeats this.
> shmem-ness is a property of the pages rather than of the mount, so ask
> the pages: /proc/self/pagemap for VA -> PFN, /proc/kpageflags for
> PFN -> flags, then test bit 14.

Bit 14 doesn't replace f_type. ramfs pages are unevictable and not
swapbacked. file_is_shmem() returns 0 and the test fails.
Let's deal with the next stacking fs when somebody hits it.