Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3609151rwe; Mon, 29 Aug 2022 15:50:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR7ed0zSIoN3WYL4x1re8tAjKmnYa7NrZodCk2Mtr0NQwqN6WDwwhNhXrB5wfO6CD+2VWPe0 X-Received: by 2002:a63:2bcc:0:b0:40c:95b5:46a4 with SMTP id r195-20020a632bcc000000b0040c95b546a4mr15655725pgr.535.1661813436392; Mon, 29 Aug 2022 15:50:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661813436; cv=none; d=google.com; s=arc-20160816; b=zW0lpznwyr78Lmdhkaan368yXuXN8VTeFx3EFtOeDHL/9bZTfFiW9G/OB1s4aJBzPc 2Y85ebiTe5s7IJetQV4gvVsKI7UW3kQCtWVnSCQWwt1RCG5txrEUGlbAIgWcYA9g7+LD RVRiQFLIWXsDDV3VJ8Lf79oeUEyh6VSkWlx+yh2EqNkR4M/N+3LdKCkQEd30qFn9vBVl /dOSc60QLyafuKEiZtDhR/XcLftxNFEbAqJAdRcYmiktPwAF6zBL25V7ICgAwwotBH3A 5P8MxKc96pH6zmCjaH73QSNXpPCp3U6ccDEEVVgutuFdkBTWjFGFgLFP0ffy9yFeuAtT tr3g== 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=HD633EfbN3tb6uFCu45l1iRXG26ohor9loINMI5UFVU=; b=ylSWrypqtfxMLcGdK+4nhuOhEZNCCbXTzJXI2dfA8U9EPR8StxpfdemMdOdRHtD4Bu shRTZM69UwubjHuAyRo8chsZVsJLKd9gk/kuPoMD2tKlXVlWl8VH5VBZqDqc3lxUaoy6 KeVJ9TXdDRXEAhhHY5X3fnZ2g1o8/Ofn4HPTMrD/I0di+04IkuXNyoEY2KPDnHjuK2wa jVy6Tdi6N9wicdv345UAufTZrlMwzhra+OjbjEPWI0wRnAAiBrriUufifh4JHl37THeo WUeIIPjmvkB/vDnZi3xZUgxYuRErPfnkiLedokTpNYFOcDRzsZL+ztCAbm8YcmRfn+ZW pmjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="SUtdpCu/"; 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 73-20020a63054c000000b0042b2718bd80si460967pgf.658.2022.08.29.15.50.25; Mon, 29 Aug 2022 15:50:36 -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="SUtdpCu/"; 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 S229992AbiH2WQ5 (ORCPT + 99 others); Mon, 29 Aug 2022 18:16:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230049AbiH2WQm (ORCPT ); Mon, 29 Aug 2022 18:16:42 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6031A6ACC for ; Mon, 29 Aug 2022 15:16:32 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id az24-20020a05600c601800b003a842e4983cso2645556wmb.0 for ; Mon, 29 Aug 2022 15:16:32 -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=HD633EfbN3tb6uFCu45l1iRXG26ohor9loINMI5UFVU=; b=SUtdpCu/SOcGU+qWxAFpyCReRSxrL/K6PFzJ+/br9oyXDpUkXwDACFm/6ovQltGWUO XBOMhVQTIv8mu0iVlA9ww+iYaabHGloTy6maqou87zRcCNHTk4Z/XIa6lSFamNNHjGVK Ru5pgBK29+Scxi+a+0gpuu1hS7KRPw1fxgJZPT40JSLE3HAQ4odX3g1cyXW0rW7PeZIY AXfIO9HwuZY8P8gbV/Y+UTQKp/EMy0t0NQNKX7n2gWLPHvNNDVQYh7qOH2OSgHmCdPA9 yX0wuw95Jwu1z6HB5J1Pr1Y18Viec9NZp3PL8uGCbSNOvES7yoNsmBTOqKhWzPDJUknV 78Aw== 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=HD633EfbN3tb6uFCu45l1iRXG26ohor9loINMI5UFVU=; b=gCZTjPGJQVQO6AnrRHTNk39S8LwKCfaS6LCPQ5rN05PDE7TZVnhs7Levp4+TEftJnJ qYkJiZ2rwftln8eikUwN29WF64gGx2BpC93tW1ZDy++DP0Vat5L/M/i3WP8/xnAIkz2a IwLS4IkGDJQTmvYlJ50JBgaNBTWVD2/fkuHjcWt3YrUqPKrftz1SluHdz4LKHocS+EA4 zE0ygWKU3OdWK864GVTKUdXNZxjsgNHGscjGYtPEggzG7TFVuCQilKP0P7osOQZxUHYE WgmpFpYh+bjACIKn3O8n+iYSov3MdzFRg660Lj2E5s1r96E9qUY4gdGuEIunnEcnUOUC Z2RA== X-Gm-Message-State: ACgBeo3vHg1hi1iySPwc0v+5bCaKHFkG7jgdxwzP5XVli2+fIHdxIBbD tVaXEKlH5PA4SEn/wEETItwWZq9bbhKM+GH1FxgnyJrfncE= X-Received: by 2002:a1c:7315:0:b0:3a5:ff61:4080 with SMTP id d21-20020a1c7315000000b003a5ff614080mr7826816wmb.196.1661811390850; Mon, 29 Aug 2022 15:16:30 -0700 (PDT) MIME-Version: 1.0 References: <20220826230639.1249436-1-yosryahmed@google.com> In-Reply-To: From: Yosry Ahmed Date: Mon, 29 Aug 2022 15:15:54 -0700 Message-ID: Subject: Re: [PATCH] selftests/bpf: simplify cgroup_hierarchical_stats selftest To: Hao Luo Cc: Andrii Nakryiko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Mykola Lysenko , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Jiri Olsa , bpf , Linux Kernel Mailing List 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 Hi Hao, Thanks for taking a look! On Mon, Aug 29, 2022 at 1:08 PM Hao Luo wrote: > > On Fri, Aug 26, 2022 at 4:06 PM 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 > > --- > > Yosry, please tag the patch with the repo it should be applied on: > bpf-next or bpf. > Will do for v2. > > > > 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. > > > > --- > > .../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/progs/cgroup_hierarchical_stats.c b/tools/testing/selftests/bpf/progs/cgroup_hierarchical_stats.c > > index 8ab4253a1592..c74362854948 100644 > > --- a/tools/testing/selftests/bpf/progs/cgroup_hierarchical_stats.c > > +++ b/tools/testing/selftests/bpf/progs/cgroup_hierarchical_stats.c > > @@ -1,7 +1,5 @@ > > // SPDX-License-Identifier: GPL-2.0-only > > /* > > - * Functions to manage eBPF programs attached to cgroup subsystems > > - * > > Please also add comments here explaining what the programs in this file do. > Will do. > > * Copyright 2022 Google LLC. > > */ > [...] > > > > -SEC("tp_btf/mm_vmscan_memcg_reclaim_begin") > > -int BPF_PROG(vmscan_start, int order, gfp_t gfp_flags) > > +SEC("fentry/cgroup_attach_task") > > Can we select an attachpoint that is more stable? It seems > 'cgroup_attach_task' is an internal helper function in cgroup, and its > signature can change. I'd prefer using those commonly used tracepoints > and EXPORT'ed functions. IMHO their interfaces are more stable. > Will try to find a more stable attach point. Thanks! > > +int BPF_PROG(counter, struct cgroup *dst_cgrp, struct task_struct *leader, > > + bool threadgroup) > > { > > - struct task_struct *task = bpf_get_current_task_btf(); > > - __u64 *start_time_ptr; > > - > > - start_time_ptr = bpf_task_storage_get(&vmscan_start_time, task, 0, > > - BPF_LOCAL_STORAGE_GET_F_CREATE); > > - if (start_time_ptr) > > - *start_time_ptr = bpf_ktime_get_ns(); > > - return 0; > > -} > [...] > > } > > -- > > 2.37.2.672.g94769d06f0-goog > >