From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Yosry Ahmed <yosryahmed@google.com>
Cc: Hao Luo <haoluo@google.com>, LKML <linux-kernel@vger.kernel.org>,
bpf <bpf@vger.kernel.org>,
"open list:CONTROL GROUP (CGROUP)" <cgroups@vger.kernel.org>,
Network Development <netdev@vger.kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>, Yonghong Song <yhs@fb.com>,
Tejun Heo <tj@kernel.org>, Zefan Li <lizefan.x@bytedance.com>,
KP Singh <kpsingh@kernel.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Jiri Olsa <jolsa@kernel.org>, Michal Koutny <mkoutny@suse.com>,
Roman Gushchin <roman.gushchin@linux.dev>,
David Rientjes <rientjes@google.com>,
Stanislav Fomichev <sdf@google.com>,
Shakeel Butt <shakeelb@google.com>
Subject: Re: [RESEND PATCH bpf-next v9 5/5] selftests/bpf: add a selftest for cgroup hierarchical stats collection
Date: Thu, 25 Aug 2022 11:43:04 -0700 [thread overview]
Message-ID: <CAADnVQLD+PcyO1qmxaBxdK1_tLRfBEqth8kzxts_8f+nSqu+hA@mail.gmail.com> (raw)
In-Reply-To: <CAJD7tkZGxkV8_3qNy_Q=k-DT2=aGknzT08WiVtESpzur1JxCwA@mail.gmail.com>
On Wed, Aug 24, 2022 at 7:41 PM Yosry Ahmed <yosryahmed@google.com> wrote:
>
> On Wed, Aug 24, 2022 at 7:09 PM Alexei Starovoitov
> <alexei.starovoitov@gmail.com> wrote:
> >
> > On Wed, Aug 24, 2022 at 4:31 PM Hao Luo <haoluo@google.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.
next prev parent reply other threads:[~2022-08-25 18:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-24 23:31 [RESEND PATCH bpf-next v9 0/5] bpf: rstat: cgroup hierarchical Hao Luo
2022-08-24 23:31 ` [RESEND PATCH bpf-next v9 1/5] bpf: Introduce cgroup iter Hao Luo
2022-08-25 23:00 ` Yonghong Song
2022-08-29 18:07 ` Hao Luo
2022-08-24 23:31 ` [RESEND PATCH bpf-next v9 2/5] selftests/bpf: Test cgroup_iter Hao Luo
2022-08-24 23:31 ` [RESEND PATCH bpf-next v9 3/5] cgroup: bpf: enable bpf programs to integrate with rstat Hao Luo
2022-08-24 23:31 ` [RESEND PATCH bpf-next v9 4/5] selftests/bpf: extend cgroup helpers Hao Luo
2022-08-24 23:31 ` [RESEND PATCH bpf-next v9 5/5] selftests/bpf: add a selftest for cgroup hierarchical stats collection Hao Luo
2022-08-25 2:09 ` Alexei Starovoitov
2022-08-25 2:41 ` Yosry Ahmed
2022-08-25 18:43 ` Alexei Starovoitov [this message]
2022-08-25 18:45 ` Yosry Ahmed
2022-08-25 18:52 ` Hao Luo
2022-08-25 0:29 ` [RESEND PATCH bpf-next v9 0/5] bpf: rstat: cgroup hierarchical Alexei Starovoitov
2022-08-25 0:42 ` Hao Luo
2022-08-25 0:47 ` Alexei Starovoitov
2022-08-25 0:48 ` Hao Luo
2022-08-25 18:40 ` patchwork-bot+netdevbpf
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=CAADnVQLD+PcyO1qmxaBxdK1_tLRfBEqth8kzxts_8f+nSqu+hA@mail.gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=hannes@cmpxchg.org \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan.x@bytedance.com \
--cc=martin.lau@linux.dev \
--cc=mhocko@kernel.org \
--cc=mkoutny@suse.com \
--cc=netdev@vger.kernel.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=sdf@google.com \
--cc=shakeelb@google.com \
--cc=song@kernel.org \
--cc=tj@kernel.org \
--cc=yhs@fb.com \
--cc=yosryahmed@google.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).