From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796248718; b=eZahDZthsdYJvPpdRDP2lMdBhhktA8BO9TtlQK4YKRnXH9b39N4DCNiN/Fs66McN1PX9 G/F9No2Wh7XNe41xk4HKg/JPx5oVJc8dmYGBCxeWwZq1GfkuO7+rl5xfs0uibuFZpsvMQ uNK84QZ3//onKswC+s/D536Fgxkek2tNdA2H+QKJLkc+g7XCBn4JyYtp+6jmNnPy2iui7 YZ9H7oNy9nE9WnJZ3bdZiDTwCtLWkNNaVq+Zx0tGMxe4/Fs1QGXQ0vyC74oi+I8aOeIQt rSteDVok053/ArxrbVvvXt8JI0tk1PHbuIZAePE5z10yj3nmtNsBIv8I8LF5iVxW14Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796248718; h=Received:DKIM-Signature:Content-Type:MIME-Version:Message-Id: In-Reply-To:References:Subject:From:To:Cc:Date; bh=byRBZwvz5fC+gJRBk1tzfEKk5MpTkwqM7UOlKCXmgZY=; b=zyDQ4AzN+keXMqoiizxUW0tga+7rbtxxflmTZzRB+WNO3ukDHXM0rJ/WlaDJ07BZk3SV 4aC32HgUV2FeU33BmHUTqeTWV7VchsmyJdc7KaL4Q8QAZDhSCp3AQWc4pTijq5Iwy9e0N EeIbWtNP8r5zl5BRyHlfkqjwejK8p/sQDfhlIwqvF2lxKq1boab53cOy/g51hfjFU9t10 +Q+6t8bGvD23586yIWBrFQmqvayMfke1u1P4Pt6HKVsEnbig/oHggPqXL6stXRThcu7pl VyUrZ3lz4JJ58dyKrLar2i7vZ7IsyWQKy1tneWOcyOu4dOASThTvA5NjD/v0e51Sa4A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=X0GpIMxy; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D524606A33C; Wed, 2 Dec 2026 21:58:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=X0GpIMxy Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91A7B1F00A18; Wed, 2 Dec 2026 21:58:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796248717; bh=byRBZwvz5fC+gJRBk1tzfEKk5MpTkwqM7UOlKCXmgZY=; h=In-Reply-To:References:Subject:From:To:Cc:Date; b=X0GpIMxyeqBub3+e3uf+zSRG0V+8P+IiJPGO07b7wP/RJginjjPiGEi7uF0ljlIOY 4EBC7/khzdOc9KuO8ZEYJxkaolurfGnatC5JxaMGdpiI7LmMS3ua4gk1O7MV6WaACq tY57BH7cGxidBFk4t3BkVIGVN1DnmkIfTBxjPg9IXLjyhHT1W76BKu8ZWUS1LhTqvo WDr7bCQTp1nlRvRz+NaZDW0E7bB6FiZVCn67Ujd8GkIVbPncIStJHcirQNy7BgjLl7 tuKurTKjp/fnjgmncHF+5OQP9r3c+6byPpqZbWobOUsUGDkW06p3Oq+AvItVKxG+iw fzLL8ikwvQdgQ== Content-Type: multipart/mixed; boundary="===============2298378233508756346==" X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Message-Id: <827f58df06295c61fa047bba622f9b1b7fc9874d181bb5ff45cd4516c350760c@mail.kernel.org> In-Reply-To: <20261202210415.517651-12-bgardon@google.com> References: <20261202210415.517651-12-bgardon@google.com> Subject: Re: [PATCH bpf-next v4 11/17] selftests/bpf: Add systemd-oomd style OOM policy test From: bot+bpf-ci@kernel.org To: bgardon@google.com,ast@kernel.org,daniel@iogearbox.net,andrii@kernel.org,akpm@linux-foundation.org,hannes@cmpxchg.org,mhocko@kernel.org,shakeel.butt@linux.dev,roman.gushchin@linux.dev,tj@kernel.org Cc: jp.kobryn@linux.dev,eddyz87@gmail.com,memxor@gmail.com,martin.lau@linux.dev,song@kernel.org,yonghong.song@linux.dev,jolsa@kernel.org,emil@etsalapatis.com,ihor.solodrai@linux.dev,rientjes@google.com,surenb@google.com,joshdon@google.com,sweettea-kernel@dorminy.me,zhouchuyi@bytedance.com,laoar.shao@gmail.com,benbwgardon@gmail.com,bpf@vger.kernel.org,linux-mm@kvack.org,cgroups@vger.kernel.org,linux-kernel@vger.kernel.org,bgardon@google.com,shuah@kernel.org,linux-kselftest@vger.kernel.org,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev Date: Wed, 2 Dec 2026 21:58:34 +0000 (UTC) --===============2298378233508756346== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit > selftests/bpf: Add systemd-oomd style OOM policy test TL;DR: Nits only in the selftest: setup code duplicated from test_oom.c, a redundant task acquire/release, a misnamed cleanup function, and unused decision fields such as swap usage. > diff --git a/tools/testing/selftests/bpf/prog_tests/test_oomd.c b/tools/testing/selftests/bpf/prog_tests/test_oomd.c > new file mode 100644 > --- /dev/null > +++ b/tools/testing/selftests/bpf/prog_tests/test_oomd.c [ ... ] > +static void reset_cgroups(void) > +{ > + int i; > + > + for (i = 0; i < ARRAY_SIZE(cgroups); i++) { > + cgroups[i].fd = -1; > + cgroups[i].id = 0; > + memory_holder_init(&cgroups[i].worker); > + } > +} > + > +static void cleanup_cgroups(void) > +{ > + int i; > + > + for (i = 0; i < ARRAY_SIZE(cgroups); i++) { > + memory_holder_cleanup(&cgroups[i].worker); > + if (cgroups[i].fd >= 0) { > + close(cgroups[i].fd); > + cgroups[i].fd = -1; > + } > + } > +} > + > +static int setup_environment(void) > +{ [ ... ] This isn't a bug, but reset_cgroups(), cleanup_cgroups() and setup_environment() look almost identical to reset_cgroups(), cleanup_workers() and setup_environment() in prog_tests/test_oom.c. The differences appear to be the new cgroups[i].id field with its get_cgroup_id() call, the rename of cleanup_workers(), and "worker" changed to "task" in a few assertion strings. The trigger/waitpid/WIFSIGNALED sequence in run_and_wait_for_oom() and the attach sequence in serial_test_oomd() also repeat serial_test_oom(). Could the table-driven cgroup and worker setup go into memory_holder.h, or a sibling helper, so both OOM tests share one copy? Also, cleanup_cgroups() kills the workers and closes the fds but removes no cgroups, which is left to cleanup_cgroup_environment(). Is the name accurate? > diff --git a/tools/testing/selftests/bpf/progs/test_oomd.c b/tools/testing/selftests/bpf/progs/test_oomd.c > new file mode 100644 > --- /dev/null > +++ b/tools/testing/selftests/bpf/progs/test_oomd.c [ ... ] > +static int oomd_kill_task(struct oom_control *oc, struct task_struct *task, > + struct oomd_decision *decision) > +{ > + struct task_struct *t; > + int ret; > + > + t = bpf_task_acquire(task); > + if (!t) > + return 0; [ ... ] > + if (!victim) > + return 0; > + > + { > + int ret = oomd_kill_task(oc, victim, decision); > + > + bpf_task_release(victim); > + return ret; > + } > +} This isn't a bug, but oomd_kill_memcg() already holds a reference on victim from bpf_task_acquire(), and oomd_kill_task() is its only caller. Is the extra bpf_task_acquire()/bpf_task_release() pair in oomd_kill_task() needed? Could the bare block around "int ret" in oomd_kill_memcg() become a plain local declared at the top of the function, like the neighbouring functions do? [ ... ] > + usage = bpf_mem_cgroup_usage(memcg); > + pgscan = memcg_pgscan(memcg); > + delta = oomd_pgscan_delta(policy, pgscan); > + swap_usage = bpf_mem_cgroup_page_state(memcg, swap_item); > + > + if (decision) > + decision->scanned_candidates++; [ ... ] > + if (decision) { > + decision->victim_cgid = cgid; > + decision->victim_usage = usage; > + decision->victim_pgscan = pgscan; > + decision->victim_pgscan_delta = delta; > + decision->victim_swap_usage = swap_usage; > + } This isn't a bug, but is the swap usage read (and the victim_swap_usage field) needed for this test? swap_usage plays no part in ranking and is only copied into decision->victim_swap_usage. The test also sets memory.swap.max to 0 on /oomd_test, so the value is always zero, and prog_tests/test_oomd.c never reads it. The same seems to apply to root_cgid, victim_usage, victim_pgscan and victim_pgscan_delta in struct oomd_decision, since run_and_wait_for_oom() checks only victim_cgid, killed_pid, scanned_candidates, skipped_omit, skipped_unkillable and kill_ret. Could these be dropped, or asserted on? --- AI reviewed your patch. Please fix the bug or email reply why it's not a bug. See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md CI run summary: https://github.com/kernel-patches/bpf/actions/runs/46974333971 --===============2298378233508756346==--