EBUSY is returned when attempting to install a new BPF program while one is already running, though updates to existing programs are permitted. Signed-off-by: Yafang Shao --- .../selftests/bpf/prog_tests/thp_adjust.c | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/thp_adjust.c b/tools/testing/selftests/bpf/prog_tests/thp_adjust.c index bf367c6e6f52..6e65d7b0eb80 100644 --- a/tools/testing/selftests/bpf/prog_tests/thp_adjust.c +++ b/tools/testing/selftests/bpf/prog_tests/thp_adjust.c @@ -227,6 +227,27 @@ static void subtest_thp_fork(void) bpf_link__destroy(ops_link); } +static void subtest_thp_policy_update(void) +{ + struct bpf_link *old_link, *new_link; + int err; + + old_link = bpf_map__attach_struct_ops(skel->maps.thp_fork_ops); + if (!ASSERT_OK_PTR(old_link, "attach_old_link")) + return; + + new_link = bpf_map__attach_struct_ops(skel->maps.khugepaged_ops); + if (!ASSERT_NULL(new_link, "attach_new_link")) + goto destory_old; + ASSERT_EQ(errno, EBUSY, "attach_new_link"); + + err = bpf_link__update_map(old_link, skel->maps.khugepaged_ops); + ASSERT_EQ(err, 0, "update_old_link"); + +destory_old: + bpf_link__destroy(old_link); +} + static int thp_adjust_setup(void) { int err, cgrp_fd, cgrp_id, pmd_order; @@ -308,6 +329,8 @@ void test_thp_adjust(void) subtest_thp_policy(); if (test__start_subtest("khugepaged_fork")) subtest_thp_fork(); + if (test__start_subtest("policy_update")) + subtest_thp_policy_update(); thp_adjust_destroy(); } -- 2.47.3