From: Hui Zhu <zhuhui@kylinos.cn>
This series follows the bpf_proactive_reclaim() kfunc patch (v14, acked
by Shakeel Butt, reviewed by JP Kobryn and Barry Song). Review feedback
on that series was that ~1200 lines of selftest for a ~20 line kfunc is
overkill, so the test material is split in two:
1/2 is the minimal selftest. It mirrors the memory.reclaim selftest:
charge a cgroup, call the kfunc once, and check the single bounded pass
semantics (one call reclaims at most MEMCG_CHARGE_BATCH pages and, unlike
a write to memory.reclaim, does not retry until the goal is reached).
2/2 moves the complex asynchronous scenario out of the selftests and into
samples/bpf, where it belongs: a BPF program watches the workingset
refaults of a pressured cgroup and, when they grow, reclaims a target
cgroup from a bpf_wq callback through bpf_proactive_reclaim(). It runs
in two modes: bench recreates the high/low priority benchmark of the old
selftest, and watch keeps reclaiming for user-specified cgroups as a
simple proactive-reclaim daemon. Besides exercising the kfunc end to
end, the sample is meant as a design reference for anyone building their
own BPF-driven reclaim policy on bpf_proactive_reclaim(), bpf_wq and the
memcg kfuncs.
Hui Zhu (2):
selftests/bpf: Add bpf_proactive_reclaim test
samples/bpf: Add memcg async reclaim example
samples/bpf/.gitignore | 1 +
samples/bpf/Makefile | 10 +-
samples/bpf/memcg_async_reclaim.bpf.c | 349 +++++
samples/bpf/memcg_async_reclaim.h | 39 +
samples/bpf/memcg_async_reclaim_user.c | 1141 +++++++++++++++++
tools/testing/selftests/bpf/config | 1 +
.../bpf/prog_tests/memcg_proactive_reclaim.c | 124 ++
.../bpf/progs/memcg_proactive_reclaim.c | 34 +
8 files changed, 1698 insertions(+), 1 deletion(-)
create mode 100644 samples/bpf/memcg_async_reclaim.bpf.c
create mode 100644 samples/bpf/memcg_async_reclaim.h
create mode 100644 samples/bpf/memcg_async_reclaim_user.c
create mode 100644 tools/testing/selftests/bpf/prog_tests/memcg_proactive_reclaim.c
create mode 100644 tools/testing/selftests/bpf/progs/memcg_proactive_reclaim.c
--
2.43.0