bpf: BPF-driven proactive memcg reclaim - #13375
bpf: BPF-driven proactive memcg reclaim#13375kernel-patches-daemon-bpf[bot] wants to merge 2 commits into
Conversation
|
Upstream branch: f79066c |
AI reviewed your patch. Please fix the bug or email reply why it's not a bug. In-Reply-To-Subject: |
AI reviewed your patch. Please fix the bug or email reply why it's not a bug. In-Reply-To-Subject: |
530113d to
4ad06cb
Compare
|
Upstream branch: 91ec203 |
0043ab3 to
2ab08c3
Compare
4ad06cb to
5a80da2
Compare
|
Upstream branch: aed1bf1 |
2ab08c3 to
a1d73c0
Compare
5a80da2 to
914a3df
Compare
|
Upstream branch: d19862d |
a1d73c0 to
4342bdf
Compare
914a3df to
c8ffd25
Compare
|
Upstream branch: 4191e49 |
4342bdf to
53e5d5b
Compare
c8ffd25 to
6a714eb
Compare
|
Upstream branch: 4954de7 |
53e5d5b to
fc690e4
Compare
6a714eb to
27a2ebd
Compare
|
Upstream branch: e40f61a |
fc690e4 to
50c4aec
Compare
27a2ebd to
7b6ba88
Compare
50c4aec to
772dc4f
Compare
7b6ba88 to
d696d45
Compare
|
Upstream branch: a284ed4 |
772dc4f to
852c4c8
Compare
d696d45 to
b8b6131
Compare
|
Upstream branch: 5e289c5 |
852c4c8 to
846080a
Compare
b8b6131 to
71e031f
Compare
|
Upstream branch: 5e289c5 |
846080a to
55d8a15
Compare
71e031f to
909ca3a
Compare
|
Upstream branch: d83fba2 |
55d8a15 to
07015ff
Compare
909ca3a to
b010507
Compare
|
Upstream branch: ce36e38 |
07015ff to
c652fda
Compare
b010507 to
975b11a
Compare
|
Upstream branch: 05ea1b6 |
c652fda to
0811d07
Compare
975b11a to
f8c8078
Compare
Expose memcg proactive reclaim to sleepable BPF programs: unsigned long bpf_proactive_reclaim(memcg, size); unsigned long bpf_proactive_reclaim_swappiness(memcg, size, swappiness); They perform one reclaim pass on @memcg, like a write to memory.reclaim: swap is allowed, and the anon/file balance follows the cgroup's swappiness or an explicit override in [MIN_SWAPPINESS, MAX_SWAPPINESS] plus SWAPPINESS_ANON_ONLY. Both go through a shared helper, bpf_proactive_reclaim_pages(), which guards against reclaim recursion and calls try_to_free_mem_cgroup_pages() with GFP_KERNEL and MEMCG_RECLAIM_MAY_SWAP | MEMCG_RECLAIM_PROACTIVE, the same parameters user_proactive_reclaim() uses, and unlike memory.reclaim they do not retry until @SiZe is reached. Reclaim must not recurse: try_to_free_mem_cgroup_pages() overwrites current->reclaim_state on entry and NULLs it on exit, so a nested call from an in-flight reclaim would corrupt the outer reclaim state (e.g. MGLRU dereferences current->reclaim_state->mm_walk). Both kfuncs therefore refuse to reclaim when PF_MEMALLOC is set or current->reclaim_state is non-NULL. The latter check also closes the window in try_to_free_mem_cgroup_pages() where reclaim_state is already installed but PF_MEMALLOC is not: only a tracepoint call sits in between, and while a sleepable BPF program cannot attach to the tracepoint itself, it can attach to the generated trace iterator function (__traceiter_mm_vmscan_memcg_reclaim_begin) via fentry. The kfuncs take @SiZe in bytes; the return value is normalized to bytes as well, matching the byte-based unit of bpf_mem_cgroup_usage() and bpf_mem_cgroup_page_state(), so callers can mix them without manual page/byte conversions. An out-of-range @swappiness is reported with (unsigned long)-1 instead of 0, following the convention of bpf_mem_cgroup_vm_events() and bpf_mem_cgroup_page_state(), as 0 cannot be told apart from a successful pass that reclaimed nothing. Signed-off-by: Hui Zhu <zhuhui@kylinos.cn>
Add memcg_async_reclaim selftest that verifies BPF-driven async proactive reclaim can mitigate refault-induced slowdown under memory pressure. The test creates a parent cgroup with a fixed memory.max, and two child cgroups (high/low) under it. Both children concurrently write and repeatedly read-fault a file larger than the shared limit. A BPF program monitors the "high" cgroup's WORKINGSET_REFAULT_FILE stat via a periodic timer, and when it detects refault growth beyond a threshold, triggers async reclaim on the "low" cgroup using bpf_proactive_reclaim(), expecting the "high" cgroup's workload to finish faster than without such reclaim. The reclaim work is queued asynchronously via bpf_wq. Signed-off-by: Hui Zhu <zhuhui@kylinos.cn>
|
Upstream branch: 1555de3 |
0811d07 to
9fa4eb9
Compare
|
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=1148841 expired. Closing PR. |
Pull request for series with
subject: bpf: BPF-driven proactive memcg reclaim
version: 4
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1148841