All of lore.kernel.org
 help / color / mirror / Atom feed
From: KP Singh <kpsingh@kernel.org>
To: Yosry Ahmed <yosryahmed@google.com>
Cc: Andrii Nakryiko <andrii@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Mykola Lysenko <mykolal@fb.com>, Song Liu <song@kernel.org>,
	Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>,
	bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftests/bpf: simplify cgroup_hierarchical_stats selftest
Date: Mon, 29 Aug 2022 00:48:02 +0200	[thread overview]
Message-ID: <CACYkzJ4=YCZ-rwBdjm59zff-M9q103m6yTnm7da1znbAGX2Ojw@mail.gmail.com> (raw)
In-Reply-To: <20220826230639.1249436-1-yosryahmed@google.com>

On Sat, Aug 27, 2022 at 1:06 AM Yosry Ahmed <yosryahmed@google.com> 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 <yosryahmed@google.com>

Acked-by: KP Singh <kpsingh@kernel.org>

> ---
>
> 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
>

  reply	other threads:[~2022-08-28 22:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-26 23:06 [PATCH] selftests/bpf: simplify cgroup_hierarchical_stats selftest Yosry Ahmed
2022-08-28 22:48 ` KP Singh [this message]
2022-08-29 17:24   ` Yosry Ahmed
2022-08-29 20:08 ` Hao Luo
2022-08-29 22:15   ` Yosry Ahmed
2022-08-30  1:06     ` Yosry Ahmed
2022-08-30  1:42       ` Hao Luo
2022-08-30  1:50         ` Yosry Ahmed
2022-09-06 21:35           ` Yosry Ahmed
2022-09-10  0:49             ` Andrii Nakryiko
2022-09-19 15:24               ` Yosry Ahmed

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='CACYkzJ4=YCZ-rwBdjm59zff-M9q103m6yTnm7da1znbAGX2Ojw@mail.gmail.com' \
    --to=kpsingh@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mykolal@fb.com \
    --cc=sdf@google.com \
    --cc=song@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.