Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp158594rwe; Wed, 24 Aug 2022 19:44:51 -0700 (PDT) X-Google-Smtp-Source: AA6agR61wUnD8ixyHhvHP4zM1/xjzK7zlDrLmAd0PCzYru/ZFYq+KR3rp/4QzSuXyJICiNUblc2B X-Received: by 2002:a17:907:7210:b0:73d:9c29:890c with SMTP id dr16-20020a170907721000b0073d9c29890cmr995631ejc.770.1661395491260; Wed, 24 Aug 2022 19:44:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661395491; cv=none; d=google.com; s=arc-20160816; b=0AVjlw4ecuOA9L+b9i3hwU7ToJZS/9tx0DN3f9ZNNoYwPWYrrCOueK1uMWs11PiLN0 fSJFeal1DSprWRF/o6FDP92xN3LCulu+h9Y4+zUdKsmqo0BjuaXIqZItaKUwe4O5CvRc UD1IERkOq5J7yLS4DGC/HxDYTTyrbd1qRx7OVSItyfh1DlhrqGn+K5UD5syENTsIu6Gx MawoqwqcuDVr0pa6hYPxxQJwXDOdxswwW7Nkg2+/0Qkcpl6cwBp5CA/q5tRQCwD6bu4Y x5N54FxwJ/Y/+vgGn6asLuRiL+A0UVkvP/M/AXxDCMjvyPdDQD26+VY8skOyE2+KS+9E X55g== 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=doFUHdVPTABkZsDuf0MJLhPZVm+o4dycrmtaBb1zaGg=; b=F2sGnRffvPozv3og9i46/oPk1HH5UzL8wyxamm1xQeFdWBQYZzaodLBtezRfVAa/Aa VlhnKOpO+jF3F9xgEtNHHk8WPOSSt/h15PfnqLsMfEbPxhgC/+KXdp3iIiReyZWtJaej nbcqLFgi+czmm4GM3cc6z2M8GKrEh1pI+QArwIKoaI5q+eYqypbavKBJ5WyDdYsM/N9T wCoh/jYv6eMFYcK//WJs/Dwr+IALBw1DqqzZgdECiIhgiN8X+bOWhv+3BSzZjLSseDwv u/08XsGlj3iGl/kKxqRfOTHW9lYdiWo4OJAtArRYh0dmPb/xslnaFWf5AnXZJcnHzjNY 13Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ljEZc6yM; 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 b12-20020a056402084c00b0043df391fcbesi6202637edz.583.2022.08.24.19.44.25; Wed, 24 Aug 2022 19:44:51 -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=ljEZc6yM; 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 S232271AbiHYCmV (ORCPT + 99 others); Wed, 24 Aug 2022 22:42:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232848AbiHYCmI (ORCPT ); Wed, 24 Aug 2022 22:42:08 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A13E69DFB6 for ; Wed, 24 Aug 2022 19:41:59 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id j26so9603880wms.0 for ; Wed, 24 Aug 2022 19:41:59 -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=doFUHdVPTABkZsDuf0MJLhPZVm+o4dycrmtaBb1zaGg=; b=ljEZc6yMBm22SLRA96eNiZ8zgNwa6AiCs/mIj4MH8Lu0ITLXCDbw1rPAThOIFT6Hls ospWapMqLKqRDIfRiC+dCGUxBR5sBvXQ26YTcthtauabE4uJitMLdbltOEAcI4UYmaD8 j1f06IYOrOaeiFBdUe+UDv9Lah3WVcDkkdi7vs8AauhaW43RVxrNEy24rmWtaAHHHM+u h7B3HLp+8WRyddXXmzTHtWjnkO1iV1aa6u2vo0XFu1N8LA90hsMIcwYJkyIP72cSCzHn Oy6w8nNGH41msDEU6rjbzxVYJQG80prf38WQ/d2GRWv/I5OlSZFlOdPtahy7/ehSx+7F 8fAg== 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=doFUHdVPTABkZsDuf0MJLhPZVm+o4dycrmtaBb1zaGg=; b=7Q2Xp5l6u4Jn1348oiHuPN+LA8jduu22q4jiYQnhv+hudDI5c9BGcpXokPxZdMRtf4 FCfxlAEayMpE3ozKP+qa3kQPDHpi2C/fAm6cHT+3WpdH/8V9c2tlEEOL3N9EVudFDboc RvH3QTVqmK2bsqQMakPqIgMEKo8DxQQckTtGWF+Y7i7o6pQOIBiz2KbjapbNxT2uQQCi Qqk2lU8HZS13D+dHe5BEICj7Hr0MYXuxgK/3H5yO21VZdoqSCmtXl/qC/VVImD412jnp TeyTy4LOuzS8WpjkiZO5s26reU/U7PLtALyQkxYuWLTkFZNtPQYbVwxh33j6cxFHqpj2 /D4g== X-Gm-Message-State: ACgBeo1EIBwoFMpW9hEhsiskjOffbQIqfvmBZHPGTDEmyqkomPmy1CKf TuiMva7Yt09RDT1AQFExE29RdeFbLNkU86gREpQI5Q== X-Received: by 2002:a05:600c:1e05:b0:3a5:b441:e9c with SMTP id ay5-20020a05600c1e0500b003a5b4410e9cmr794100wmb.24.1661395317923; Wed, 24 Aug 2022 19:41:57 -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: Wed, 24 Aug 2022 19:41:21 -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=unavailable 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 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)? I don't know much about namespaces, so I am not sure if the privately mounted /mnt directory here would be the same as the cgroup root or not. Maybe we can add a pause() somewhere and check /mnt/cgroup.controllers as well?