Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2588574rwe; Sun, 28 Aug 2022 16:20:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR5vvZYOr9u8LTQ2XtxzNyhk0Ffbh3VSohfSIPOy6RpKdlJk2ckMR07y5XzEd3xuYBbUttrN X-Received: by 2002:a17:902:b603:b0:174:8a6b:8e0d with SMTP id b3-20020a170902b60300b001748a6b8e0dmr6521868pls.105.1661728855327; Sun, 28 Aug 2022 16:20:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661728855; cv=none; d=google.com; s=arc-20160816; b=gM+8TxiDq0niblJ6vBRta5beDTVzc8ItiHrhNOOQ0XT/hi8117GESfCRV0qqzLENAi 3B+/vmPn9pFEE4mIFkZiSHWoN0upryz2dG0lTa6KiOE8jBvRlXggCJwZLxEBN06XnxMy +SFYE6sUuDriXI0BJnrHKbQbGjAmhi6E+5bwueGGyzTtqP8GEv3GCBsyUDkytQc/s3Eq BHI9tSJnntYD7YGLDgt9e7oh3DkelhXxSYGWH/YlVCKeuF0kK/LYJaG3NXzqPXZdeRkW gUpm5wERE6zI19RJ5PB274qj9MsHDmjkIscAZnNfncnVGq42Dbv3pn5Ysc7SeibODbPe H+Bg== 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=uVTGGMKAwKpvD8HwukHLgq+D4+p9O9Tstrbhy1xctJA=; b=lIu7IgvMgVnWLE5PHYEoO9+2vPJbPL/In3B6HOzAq5QvaQjfFuk31wvOTmjdheYpgr xUOc6IXXQcBl/TrvUEvuiapjxpDAj9KuVAUHH4QEBskHQiUAplxQoWzUGfTfHD3PIukM Ez4WnMqatkQgrTqnKyhPbnnAK9JGl8AnzMGy7IJ0hbU7JjZpQBfrUua5mLrIEh2dRKBO ocxmKr5/zggK6TDJNZGCDEtfSiOAYUwfunfX2BgTbMSt3pE9w/GREWVsfYMYiyQm2kdN Igp3oBbjTdCefZ0ScVBjq6zm63l05btO8Pu67YzScL/nn+7lltD2bVX1eVfNFstahHqR AWTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KtYMar74; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b7-20020a655cc7000000b00416071de334si7973964pgt.234.2022.08.28.16.20.44; Sun, 28 Aug 2022 16:20:55 -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=@kernel.org header.s=k20201202 header.b=KtYMar74; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229546AbiH1WsT (ORCPT + 99 others); Sun, 28 Aug 2022 18:48:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbiH1WsS (ORCPT ); Sun, 28 Aug 2022 18:48:18 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48A0221826 for ; Sun, 28 Aug 2022 15:48:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E4FDDB80B62 for ; Sun, 28 Aug 2022 22:48:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98834C433C1 for ; Sun, 28 Aug 2022 22:48:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661726894; bh=g4sSnE2xYkVAH8p7YGEDwc0bgpH1kc7LW9IpFl3JMhI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=KtYMar74Ys0rcLltG1bQpUFMAtQGmX7mnKw5qDqg6w2/3L/fQL8ceFEzYQ7B3yLPD aaTXFz9ahVpWNY3tiawn6ENGJZGLOwImOpYGTk8yQU0slYxEg4lyMwhvkbrIuCsNmU IW00+QfxnU5SakXBG3QA0oQIuIRRsoROLOxxddNmROvfh8otH1CAwLV5ZScjBQDq0j J2STxqt3c6acjVyJQILwUu3eemOkKNYNXipXCWIH2x8wt1FRd4JFeNf9M8RBbARVMK wsOMVwzSUN2sojbkbiudjC6HipPSRMXzlT0HZvbti7Qo9DGV61kU4WSAnoiccyFDSP U8GHZEdChsWlA== Received: by mail-qv1-f50.google.com with SMTP id kh8so5166048qvb.1 for ; Sun, 28 Aug 2022 15:48:14 -0700 (PDT) X-Gm-Message-State: ACgBeo3QuEVxSJk1RLp6iiZ7mM6GtJ1WmqPrfq21hJ0K1r2oKwNbShyc s+YpdIsp3l8L2sY0uRjv4O2zVcMwr5OhbiPXb8y++Q== X-Received: by 2002:a0c:b342:0:b0:498:ef25:abe5 with SMTP id a2-20020a0cb342000000b00498ef25abe5mr8412484qvf.21.1661726893619; Sun, 28 Aug 2022 15:48:13 -0700 (PDT) MIME-Version: 1.0 References: <20220826230639.1249436-1-yosryahmed@google.com> In-Reply-To: <20220826230639.1249436-1-yosryahmed@google.com> From: KP Singh Date: Mon, 29 Aug 2022 00:48:02 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] selftests/bpf: simplify cgroup_hierarchical_stats selftest To: Yosry Ahmed Cc: Andrii Nakryiko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Mykola Lysenko , Song Liu , Yonghong Song , John Fastabend , Stanislav Fomichev , Hao Luo , Jiri Olsa , bpf@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Sat, Aug 27, 2022 at 1:06 AM Yosry Ahmed wrote: > > The cgroup_hierarchical_stats selftest is complicated. It has to be, > because it tests an entire workflow of recording, aggregating, and > dumping cgroup stats. However, some of the complexity is unnecessary. > The test now enables the memory controller in a cgroup hierarchy, invokes > reclaim, measure reclaim time, THEN uses that reclaim time to test the > stats collection and aggregation. We don't need to use such a > complicated stat, as the context in which the stat is collected is > orthogonal. > > Simplify the test by using a simple stat instead of reclaim time, the > total number of times a process has ever entered a cgroup. This makes > the test simpler and removes the dependency on the memory controller and > the memory reclaim interface. > > Signed-off-by: Yosry Ahmed Acked-by: KP Singh > --- > > When the test failed on Alexei's setup because the memory controller was > not enabled I realized this is an unnecessary dependency for the test, > which inspired this patch :) I am not sure if this prompt a Fixes tag as > the test wasn't broken. yeah, this is an improvement, I don't think a fixes tag is needed here. > > --- > .../prog_tests/cgroup_hierarchical_stats.c | 157 ++++++--------- > .../bpf/progs/cgroup_hierarchical_stats.c | 181 ++++++------------ > 2 files changed, 118 insertions(+), 220 deletions(-) > > diff --git a/tools/testing/selftests/bpf/prog_tests/cgroup_hierarchical_stats.c b/tools/testing/selftests/bpf/prog_tests/cgroup_hierarchical_stats.c > index bed1661596f7..12a6d4ddbd77 100644 > --- a/tools/testing/selftests/bpf/prog_tests/cgroup_hierarchical_stats.c > +++ b/tools/testing/selftests/bpf/prog_tests/cgroup_hierarchical_stats.c > @@ -1,6 +1,9 @@ > // SPDX-License-Identifier: GPL-2.0-only > /* > - * Functions to manage eBPF programs attached to cgroup subsystems > + * This test runs a BPF program that keeps a stat of the number of processes > + * that ever attached to a cgroup, and makes sure that BPF integrates well with > + * the rstat framework to efficiently collect those stat percpu to avoid > + * locking, and to efficiently aggregate the stat across the hierarchy. > * > * Copyright 2022 Google LLC. > */ > @@ -21,8 +24,10 @@ > #define PAGE_SIZE 4096 > #define MB(x) (x << 20) > > +#define PROCESSES_PER_CGROUP 3 > + > #define BPFFS_ROOT "/sys/fs/bpf/" > -#define BPFFS_VMSCAN BPFFS_ROOT"vmscan/" > +#define BPFFS_ATTACH_COUNTERS BPFFS_ROOT"attach_counters/" minor nit: Is there a missing space here? i.e #define BPFFS_ATTACH_COUNTERS BPFFS_ROOT "attach_counters/" (this was a case in the line you changed so I am not sure if it's intentional) The rest looks good to me, so maintainers could, potentially, push it with the minor edit if needed? > > #define CG_ROOT_NAME "root" > #define CG_ROOT_ID 1 > @@ -79,7 +84,7 @@ static int setup_bpffs(void) > return err; > > [...] > - return 1; > + return 0; > } > -- > 2.37.2.672.g94769d06f0-goog >