From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3087CECAA28 for ; Thu, 25 Aug 2022 18:46:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232019AbiHYSqN (ORCPT ); Thu, 25 Aug 2022 14:46:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229575AbiHYSqK (ORCPT ); Thu, 25 Aug 2022 14:46:10 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 195475F221 for ; Thu, 25 Aug 2022 11:46:09 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id k9so25736013wri.0 for ; Thu, 25 Aug 2022 11:46:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=nIUljFBkx0nexRnIBmlsCUVPOXret1NOSFaDab7BEyE=; b=k6cregGwdCXEynRFHNQnjLAXb0RFMfFa3FMHdPuHUfi6T8dfpJl4HEIbDYqwcxOel3 ksJqS6FWaDJApbXU3uJcpWyQbkvpdQSW2R/rFtjn5aDhBWRsI99ESDf3XLfqeqwW+tVU Dkv1FS2oCKmHJkt6wXRtQ4rv7corYV1o3nvyYOi0Gs9QqDDzvMk53+PNJ46oz+a9G95G ZxvIoGSbblrukcDX0lGfen/S4JaEdakZONRpoX6cJ1lSdnDDIW33z3ifDMacL9p1qE16 M1JxwcDkSA6vcYd90XZDbW7UbSnga5SIddpxYn/3oewqT4QcarLSQIO36hnkUPHC7QqD xiMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=nIUljFBkx0nexRnIBmlsCUVPOXret1NOSFaDab7BEyE=; b=0wRIH+PeWxXyaj5uOaRigBmunMphY5fLKxvZSoO3jVNElbjaOcTlmTwbVVjfnaNml/ f48ETGPScOUL0RNKdrZlj3bb5u4mIK+Wd9zKgN4XFtcaLVj2LNPVG9kNz65kJzgn0KuN 3BoxmWybGUF75RaMxMm5/e/DGPVQD67EEh0z7JS07JnIbYh+KJb5cgRfMZn4jGhS/LGx GEr7IJzZyqtclu2RGgGxyG8X4oC7NtU5Gsh53z0EUMD3YcjwbDiCMZtkk4/XJPu+aKPU QE1PYf0WIS+rivuEKs4d2vxTqpPJkqKiw/V+nVsXNeRFvBBanf0Yn1wXv/DVEag6D01A JLcw== X-Gm-Message-State: ACgBeo0FAZvsCwNIfv5inROxMD2vOubNX4pwaZXIa+5ggU4JQiB8iJtq eN8zDAS7SOAZbZxeXMSnv45A4vpZdBd8GaX8bgxiXw== X-Google-Smtp-Source: AA6agR5LFET4yCFkQ8vwQbxb3eFWAptn2L9E3gpXGgxbfnZMZebQzL/ASi9e2kdBGAZQCqlaOF+AFzYG3fCODNNPjXs= X-Received: by 2002:adf:9ccf:0:b0:225:4934:53e3 with SMTP id h15-20020adf9ccf000000b00225493453e3mr3158455wre.210.1661453167369; Thu, 25 Aug 2022 11:46:07 -0700 (PDT) MIME-Version: 1.0 References: <20220824233117.1312810-1-haoluo@google.com> <20220824233117.1312810-6-haoluo@google.com> In-Reply-To: From: Yosry Ahmed Date: Thu, 25 Aug 2022 11:45:31 -0700 Message-ID: Subject: Re: [RESEND PATCH bpf-next v9 5/5] selftests/bpf: add a selftest for cgroup hierarchical stats collection To: Alexei Starovoitov Cc: Hao Luo , LKML , bpf , "open list:CONTROL GROUP (CGROUP)" , Network Development , Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Tejun Heo , Zefan Li , KP Singh , Johannes Weiner , Michal Hocko , John Fastabend , Jiri Olsa , Michal Koutny , Roman Gushchin , David Rientjes , Stanislav Fomichev , Shakeel Butt Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 25, 2022 at 11:43 AM Alexei Starovoitov wrote: > > On Wed, Aug 24, 2022 at 7:41 PM Yosry Ahmed wrote: > > > > On Wed, Aug 24, 2022 at 7:09 PM Alexei Starovoitov > > wrote: > > > > > > On Wed, Aug 24, 2022 at 4:31 PM Hao Luo 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. Thanks Alexei!