[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAADnVQLD+PcyO1qmxaBxdK1_tLRfBEqth8kzxts_8f+nSqu+hA@mail.gmail.com>
Date: Thu, 25 Aug 2022 11:43:04 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Yosry Ahmed <yosryahmed@...gle.com>
Cc: Hao Luo <haoluo@...gle.com>, LKML <linux-kernel@...r.kernel.org>,
bpf <bpf@...r.kernel.org>,
"open list:CONTROL GROUP (CGROUP)" <cgroups@...r.kernel.org>,
Network Development <netdev@...r.kernel.org>,
Alexei Starovoitov <ast@...nel.org>,
Andrii Nakryiko <andrii@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Martin KaFai Lau <martin.lau@...ux.dev>,
Song Liu <song@...nel.org>, Yonghong Song <yhs@...com>,
Tejun Heo <tj@...nel.org>, Zefan Li <lizefan.x@...edance.com>,
KP Singh <kpsingh@...nel.org>,
Johannes Weiner <hannes@...xchg.org>,
Michal Hocko <mhocko@...nel.org>,
John Fastabend <john.fastabend@...il.com>,
Jiri Olsa <jolsa@...nel.org>, Michal Koutny <mkoutny@...e.com>,
Roman Gushchin <roman.gushchin@...ux.dev>,
David Rientjes <rientjes@...gle.com>,
Stanislav Fomichev <sdf@...gle.com>,
Shakeel Butt <shakeelb@...gle.com>
Subject: Re: [RESEND PATCH bpf-next v9 5/5] selftests/bpf: add a selftest for
cgroup hierarchical stats collection
On Wed, Aug 24, 2022 at 7:41 PM Yosry Ahmed <yosryahmed@...gle.com> wrote:
>
> On Wed, Aug 24, 2022 at 7:09 PM Alexei Starovoitov
> <alexei.starovoitov@...il.com> wrote:
> >
> > On Wed, Aug 24, 2022 at 4:31 PM Hao Luo <haoluo@...gle.com> wrote:
> > > +
> > > + for (i = 0; i < N_CGROUPS; i++) {
> > > + fd = create_and_get_cgroup(cgroups[i].path);
> > > + if (!ASSERT_GE(fd, 0, "create_and_get_cgroup"))
> > > + return fd;
> > > +
> > > + cgroups[i].fd = fd;
> > > + cgroups[i].id = get_cgroup_id(cgroups[i].path);
> > > +
> > > + /*
> > > + * Enable memcg controller for the entire hierarchy.
> > > + * Note that stats are collected for all cgroups in a hierarchy
> > > + * with memcg enabled anyway, but are only exposed for cgroups
> > > + * that have memcg enabled.
> > > + */
> > > + if (i < N_NON_LEAF_CGROUPS) {
> > > + err = enable_controllers(cgroups[i].path, "memory");
> > > + if (!ASSERT_OK(err, "enable_controllers"))
> > > + return err;
> > > + }
> > > + }
> >
> > It passes BPF CI, but fails in my setup with:
> >
> > # ./test_progs -t cgroup_hier -vv
> > bpf_testmod.ko is already unloaded.
> > Loading bpf_testmod.ko...
> > Successfully loaded bpf_testmod.ko.
> > setup_bpffs:PASS:mount 0 nsec
> > setup_cgroups:PASS:setup_cgroup_environment 0 nsec
> > setup_cgroups:PASS:get_root_cgroup 0 nsec
> > setup_cgroups:PASS:create_and_get_cgroup 0 nsec
> > (cgroup_helpers.c:92: errno: No such file or directory) Enabling
> > controller memory:
> > /mnt/cgroup-test-work-dir6526//test/cgroup.subtree_control
> > setup_cgroups:FAIL:enable_controllers unexpected error: 1 (errno 2)
> > cleanup_bpffs:FAIL:rmdir /sys/fs/bpf/vmscan/ unexpected error: -1 (errno 2)
> > #36 cgroup_hierarchical_stats:FAIL
> > Summary: 0/0 PASSED, 0 SKIPPED, 1 FAILED
> >
> > How do I debug it?
>
> The failure with ENOENT happens when we try to write "+memory" to
> /mnt/cgroup-test-work-dir6526//test/cgroup.subtree_control, not when
> we try to open it. So the file is there. AFAICT, ENOENT can be
> returned from this write if the memory controller is not enabled on
> this cgroup.
>
> In setup_cgroup_environment(), we should be enabling all available
> controllers on /mnt and /mnt/cgroup-test-work-dir6526 by this line:
>
> if (__enable_controllers(CGROUP_MOUNT_PATH, NULL) ||
> __enable_controllers(cgroup_workdir, NULL))
> return 1;
>
> The first thing that comes to mind is that maybe the memory controller
> is not enabled on your setup at all? Can you check
> /sys/fs/cgroup/cgroup.controllers (or wherever your global cgroup
> mount is)?
Indeed. I didn't have a memory controller in cgroup2.
My system booted with cgroup v1 and it had cgroup1 memory
controller enabled which prevented cgroup2 to enable it.
Without Tejun's help I would have been able to figure this out.
Anyway, pushed the set to bpf-next. Thanks everyone.
Powered by blists - more mailing lists