Re: [PATCH bpf-next 1/2] selftests/bpf: Unmount the bpffs that cgroup_hierarchical_stats mounted
From: Yosry Ahmed
Date: Thu Oct 08 2026 - 10:12:28 EST
On Thu, Oct 8, 2026 at 7:03 AM Qiliang Yuan <odys.yuan@xxxxxxxxx> wrote:
>
> setup_bpffs() mounts a bpffs on /sys/fs/bpf and records in mounted_bpffs
> whether it did, so that cleanup_bpffs() unmounts only a bpffs that the
> test mounted itself.
>
> cleanup_bpffs() checks the flag the other way around. As mounting on
> /sys/fs/bpf succeeds even when a bpffs is already there, the test never
> unmounts the bpffs it mounted, and every run leaves another one stacked
> on /sys/fs/bpf.
>
> Unmount the bpffs only when setup_bpffs() mounted it.
>
> Fixes: 88886309d2e8 ("selftests/bpf: add a selftest for cgroup hierarchical stats collection")
> Signed-off-by: Qiliang Yuan <odys.yuan@xxxxxxxxx>
Reviewed-by: Yosry Ahmed <yosry@xxxxxxxxxx>
> ---
> tools/testing/selftests/bpf/prog_tests/cgroup_hierarchical_stats.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/cgroup_hierarchical_stats.c b/tools/testing/selftests/bpf/prog_tests/cgroup_hierarchical_stats.c
> index 3bd27d2ea668c..a93b16ed629e9 100644
> --- a/tools/testing/selftests/bpf/prog_tests/cgroup_hierarchical_stats.c
> +++ b/tools/testing/selftests/bpf/prog_tests/cgroup_hierarchical_stats.c
> @@ -110,7 +110,7 @@ static void cleanup_bpffs(void)
> ASSERT_OK(rmdir(BPFFS_ATTACH_COUNTERS), "rmdir "BPFFS_ATTACH_COUNTERS);
>
> /* Unmount bpffs, if it wasn't already mounted when we started */
> - if (mounted_bpffs)
> + if (!mounted_bpffs)
> return;
>
> ASSERT_OK(umount(BPFFS_ROOT), "unmount bpffs");
>
> --
> 2.43.0
>