Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp964250rwe; Thu, 25 Aug 2022 12:28:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR60n1KPutONE5kWy7OYXbozlpftz3gMb2d93JTdGogxIiMYz1q8rfcf/0WXQLc3KNbKdCyP X-Received: by 2002:a17:906:5a5f:b0:73d:6061:5696 with SMTP id my31-20020a1709065a5f00b0073d60615696mr3318270ejc.595.1661455726999; Thu, 25 Aug 2022 12:28:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661455726; cv=none; d=google.com; s=arc-20160816; b=Wto/V0kABBnGxdwlWQypNvb6G6dxJQAvzqbiEGL4t7THsCaHK0VRCZ6HQUHTcouxvC 5ykPtwIdbw6jtDrTAimTLBw9PksbA/jZ0r9GEQG0uaYvPQ2/vSdPh4xEFL7HcYhXnmVU vIKzgDR2zHgUiLT5rSOZ62qeGpVwuhVDWZq51iMsi4thlQrPp2D4Z+6TzP1Rxbol+hfu jy0ZUS1vsUGnHuhNmL6uVj/tZmGQEMgBlfVQ5fVIOqConHCwXp1Sy+fm3XFSuZ4J5nBO UEZSryofpQ53kKgOS8odoZqIuyusyRNNqcuqxCeQanpFS+oKEQ1qjW7+L7/UmPhTJAo7 Efwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=nIUljFBkx0nexRnIBmlsCUVPOXret1NOSFaDab7BEyE=; b=S/835t+H1UxfSoGvz9ZW+5+i0/zzTe2i6CksesRMloXKvxZl5RUb2u4o7TMbBsorvA np5g9YHaoAFrCX3TzS36gGb330VB25p8leMLssZCEuV22A3d9Fpr2VVMu5bh1OY284Dv LDuTmGx9ljfZwKkY7XUljfsthKOk7QiB2M/EIo1ilrfBOvSMujJpGrN6hsZDypSScr/4 XvtQWEkO7uEEyNhUDJ+J4StgbG+rbfX4h7FGuEN9wkmum77v9m0KgXZeetgVVycy3TB7 sHuIpDXfbNnuC9QPP4kteFLXTEqodbgoJucb1Ko637xdIGbfBrO+PkcqP+2EucT/fEsJ vwvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=k6cregGw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hz5-20020a1709072ce500b0073beb58e98dsi36626ejc.276.2022.08.25.12.28.22; Thu, 25 Aug 2022 12:28:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=k6cregGw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235120AbiHYSqM (ORCPT + 99 others); Thu, 25 Aug 2022 14:46:12 -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-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" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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!