From: Jiayuan Chen <jiayuan.chen@linux.dev>
To: Emil Tsalapatis <emil@etsalapatis.com>, bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Shuah Khan <shuah@kernel.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Clark Williams <clrkwllms@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-rt-devel@lists.linux.dev
Subject: Re: [PATCH bpf-next 3/3] selftests/bpf: Add a test for arena fault-in under memory.max
Date: Mon, 3 Aug 2026 19:42:19 +0800 [thread overview]
Message-ID: <db99502e-ddf8-42e4-beb5-65d866a820ea@linux.dev> (raw)
In-Reply-To: <DK9SMAEXY39E.195HV3J7GB8AI@etsalapatis.com>
On 7/28/26 8:54 AM, Emil Tsalapatis wrote:
> On Mon Jul 27, 2026 at 2:24 AM EDT, Jiayuan Chen wrote:
>> A child joins a memcg capped at 64M and faults an arena in until it runs
>> out of the budget. Without the kernel fix the child dies with SIGSEGV on
>> a valid arena address; with it, the child is killed by the memcg OOM
>> killer.
>>
>> With the fix:
>>
>> serial_test_arena_memcg:PASS:child killed by signal
>> serial_test_arena_memcg:PASS:not killed by SIGSEGV
>> #5 arena_memcg:OK
>>
>> # dmesg
>> arena_vm_fault+0x655/0xa90
>> Memory cgroup out of memory: Killed process 512, file-rss:67920kB
>>
>> Without the fix:
>>
>> serial_test_arena_memcg:PASS:child killed by signal
>> serial_test_arena_memcg:FAIL:not killed by SIGSEGV: actual 11
>> #5 arena_memcg:FAIL
>>
>> # dmesg
>> test_progs[508]: segfault at 100004025000 ...
>>
>> Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
>> ---
>> .../selftests/bpf/prog_tests/arena_memcg.c | 158 ++++++++++++++++++
>> .../testing/selftests/bpf/progs/arena_memcg.c | 24 +++
>> 2 files changed, 182 insertions(+)
>> create mode 100644 tools/testing/selftests/bpf/prog_tests/arena_memcg.c
>> create mode 100644 tools/testing/selftests/bpf/progs/arena_memcg.c
>>
>> diff --git a/tools/testing/selftests/bpf/prog_tests/arena_memcg.c b/tools/testing/selftests/bpf/prog_tests/arena_memcg.c
>> new file mode 100644
>> index 000000000000..9665946fa29e
>> --- /dev/null
>> +++ b/tools/testing/selftests/bpf/prog_tests/arena_memcg.c
>> @@ -0,0 +1,158 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +
>> +#include <test_progs.h>
>> +#include <fcntl.h>
>> +#include <signal.h>
>> +#include <sys/mman.h>
>> +#include <sys/wait.h>
>> +#include <unistd.h>
>> +#include <sys/user.h>
>> +#ifndef PAGE_SIZE /* on some archs it comes in sys/user.h */
>> +#include <unistd.h>
>> +#define PAGE_SIZE getpagesize()
>> +#endif
>> +
>> +#include "cgroup_helpers.h"
>> +#include "arena_memcg.skel.h"
>> +
>> +#define CG_PATH "/arena_memcg"
>> +
>> +/* Budget the arena gets on top of whatever is already charged after load. */
>> +#define ARENA_BUDGET (64 * 1024 * 1024)
>> +
>> +/*
>> + * cgroup_helpers builds paths from getpid(), but the work dir belongs to the
>> + * process that set the environment up. The child references it through that
>> + * pid, so build the path explicitly.
>> + */
>> +static void cg_file_path(char *buf, size_t sz, pid_t owner, const char *file)
>> +{
>> + snprintf(buf, sz, "/mnt/cgroup-test-work-dir%d%s/%s", owner, CG_PATH, file);
> These are copied over from cgroup_helpers.c, but it's not obvious they
> originate from there. Maybe let's move them to cgroup_helpers.h where we
> can use them everywhere for consistency.
Agreed.
>
> The main issue I see is that this only triggers consistently with PREEMPT_RT, correct?
It's not RT specified issue.
> I tried with the default vmtest config we have but it does not trigger
> at all. More importantly, it doesn't trigger reliably with PREEMPT_RT,
> either. Does it for you? Can we cycle forks/frees multiple times to try
> and trigger this more reliably?
I stated vm(RT and non-RT) locally and ran test_progs 100 times and all
tests passed.
I also used official bpf CI(non-RT) to run selftest, but still all tests
passed...
So I'm not clear which config is associated with...
https://github.com/kernel-patches/bpf/actions/runs/30795982316
https://github.com/kernel-patches/bpf/actions/runs/30798024430
https://github.com/kernel-patches/bpf/actions/runs/30801539977
https://github.com/kernel-patches/bpf/actions/runs/30808717560
prev parent reply other threads:[~2026-08-03 11:42 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 6:24 [PATCH bpf-next 0/3] bpf: arena: handle memory.max on fault-in with reclaim/OOM Jiayuan Chen
2026-07-27 6:24 ` [PATCH bpf-next 1/3] bpf: Add a sleepable page allocator for map memory Jiayuan Chen
2026-07-27 6:37 ` sashiko-bot
2026-07-27 7:30 ` Jiayuan Chen
2026-07-28 0:48 ` Emil Tsalapatis
2026-07-27 6:24 ` [PATCH bpf-next 2/3] bpf: arena: allocate the fault-in page outside the lock Jiayuan Chen
2026-07-27 6:42 ` sashiko-bot
2026-07-27 8:00 ` Jiayuan Chen
2026-07-28 1:00 ` Emil Tsalapatis
2026-07-27 7:10 ` bot+bpf-ci
2026-07-28 1:22 ` Emil Tsalapatis
2026-08-03 6:43 ` Jiayuan Chen
2026-07-27 6:24 ` [PATCH bpf-next 3/3] selftests/bpf: Add a test for arena fault-in under memory.max Jiayuan Chen
2026-07-28 0:54 ` Emil Tsalapatis
2026-08-03 11:42 ` Jiayuan Chen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=db99502e-ddf8-42e4-beb5-65d866a820ea@linux.dev \
--to=jiayuan.chen@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=bpf@vger.kernel.org \
--cc=clrkwllms@kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=rostedt@goodmis.org \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.