Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp38140rwe; Wed, 24 Aug 2022 16:26:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR7wA85xmeP3bQBlJ4Ib4+cSkkCmRfaJ9T/yPTvkMiJo2WVculS2UJkisUGRi+9kKIigCJ6Q X-Received: by 2002:a17:902:6a8a:b0:173:14f5:1d89 with SMTP id n10-20020a1709026a8a00b0017314f51d89mr1131734plk.89.1661383589212; Wed, 24 Aug 2022 16:26:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661383589; cv=none; d=google.com; s=arc-20160816; b=nKJFyk4I435sb34WqGxK84c/SYqTEUG5z3dVNmzc3Xj3tatTCMITLsmIbivzHwWk1v EaYlNhnCA45LUGwtlK2S7CAl6mLXzSSGXas6Xfr1cl16I2q9j429Bz5cV+38t++dydSW 5c+5cLv4+kBwDwQn+L8TdPQoWYfa2bn9FxDFthonDBaZZkTO0zopAFRHeykZbJi6Cnat kGlkkJ+bNX3HL3Q0UonT0Bl+7K/kbZyi+6hEt3nO0O5R8TbejPwt/ahh7id2J9FYUnDc S1fb402sncQDKekKDhPajFWrt/qzllyWBrvpCTrKVYepqgba0AHtsWoAsttfaKGGuIP+ jjCA== 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=0T8rRMCDsA1j5qf5sbj+9e56n6YXfCGLxz6FeS+4egw=; b=WHq2DLL2/z5KYs7BwahKbOpx5u+9fAoL2WqO525fqf6/fxV6V16Lzb5QAKoG4D2c/3 oJuyu3JWmOybIgsjzArlYZc9/fpV05RU4eADLeZoP7dcDx8SN3uKZWxnKaj2+KXSkHsw JRJl2MyjCHeldlDjC6O98rGujAPmbsMb9gKjPGHuLQI8H/TZqW++gco1m7ix8ah7K8WK PKkDcdZPfEb1pehElxyVlWsaRqnDNZ5h+H4SDNXCQJ53dzlNh7qOexkLPRxuCN7N+h32 CIGOOh2IhuCOdbKX3szZtukrwwtp3zyYqMd/Zn9F1ffZ+y4KjLo7f4fDvON1naR6XtV5 jB1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=IezYPxrJ; 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 w12-20020a65694c000000b0041d7e787be6si19713963pgq.170.2022.08.24.16.25.55; Wed, 24 Aug 2022 16:26:29 -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=IezYPxrJ; 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 S231262AbiHXXOg (ORCPT + 99 others); Wed, 24 Aug 2022 19:14:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231206AbiHXXOa (ORCPT ); Wed, 24 Aug 2022 19:14:30 -0400 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E59B180B68 for ; Wed, 24 Aug 2022 16:14:27 -0700 (PDT) Received: by mail-qt1-x82a.google.com with SMTP id cb8so14023184qtb.0 for ; Wed, 24 Aug 2022 16:14:27 -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=0T8rRMCDsA1j5qf5sbj+9e56n6YXfCGLxz6FeS+4egw=; b=IezYPxrJxJ92Yq4G0IsZVX3XwrGTHfYdPo9SqR5McWQxWKPvNh7tCNXAr2i+Xr5eRa maAvXMi4mgRC9UFyouKdfxFdx8Gx890qgUr+oSyc4Q+dm4cmcRCvjjIfY9Rw7QGkskvS Jymg109i5njjRy3v9iHc2kOY0whrE6mmtbzniUmyZraeDjOJc7bml7eFXrm21pXdiQRl 6MhThB4UguShf7XDMpqJel42jBbvbDWlEv9lvPqHe7oy1fUb68OrNZB5OWHn1eOfbTpK sVlJWUrrfzuezk7vp58cqDHQypcvW49MVKsuep6BjhvFQWI5woGHZMA92TQLcw1lgnH2 dybQ== 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=0T8rRMCDsA1j5qf5sbj+9e56n6YXfCGLxz6FeS+4egw=; b=kLoo3ITHIkiMuqKMrGFy1AeiT5BBvTprj/LGhnybhrslEmbaTimtufhQf9QDCmWk3/ 9ftJuOaHgWpnM6r5o+ipa/Fxa2zUXYArVCv4u90Y/cx3KQoHB598p3ROOEJhdyeR1T3x nCEKPFILpo4d4MrmRRL/r1PPkmxJVtWa1PsjnFUs3jIIRbLFJjBagvtqCMZYWrIDJWAs Qq1mg7lH2XtSA1N81v6b0MLgTInE5sWcFAovYr89ZVAF6gYY3pOQk4pOig6+b+NILQIB KOyRCt3S6hczjeixiqh4va8IQwk+iszMioCZhPqAFt6fPw39l6z6QJ89xiNkxL8Lk31a HucA== X-Gm-Message-State: ACgBeo3GxYE1i39ek7CDUXGKzsq3aqub4Kfh18vP14f3u+Lkh4Adqk14 lUVTfVSuAPy8gi8oU0dBTH8hqcHnWQ8fNo4LzJ7wRA== X-Received: by 2002:a05:622a:552:b0:342:f8c2:442 with SMTP id m18-20020a05622a055200b00342f8c20442mr1469373qtx.478.1661382866682; Wed, 24 Aug 2022 16:14:26 -0700 (PDT) MIME-Version: 1.0 References: <20220824030031.1013441-1-haoluo@google.com> <20220824030031.1013441-6-haoluo@google.com> In-Reply-To: From: Hao Luo Date: Wed, 24 Aug 2022 16:14:16 -0700 Message-ID: Subject: Re: [PATCH bpf-next v9 5/5] selftests/bpf: add a selftest for cgroup hierarchical stats collection To: Kumar Kartikeya Dwivedi Cc: linux-kernel@vger.kernel.org, bpf@vger.kernel.org, cgroups@vger.kernel.org, netdev@vger.kernel.org, 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 , Yosry Ahmed 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 Wed, Aug 24, 2022 at 4:09 PM Kumar Kartikeya Dwivedi wrote: > > On Thu, 25 Aug 2022 at 01:07, Hao Luo wrote: > > > > On Tue, Aug 23, 2022 at 8:01 PM Hao Luo wrote: > > > > > > From: Yosry Ahmed > > > > > > Add a selftest that tests the whole workflow for collecting, > > > aggregating (flushing), and displaying cgroup hierarchical stats. > > > > > > TL;DR: > > > - Userspace program creates a cgroup hierarchy and induces memcg reclaim > > > in parts of it. > > > - Whenever reclaim happens, vmscan_start and vmscan_end update > > > per-cgroup percpu readings, and tell rstat which (cgroup, cpu) pairs > > > have updates. > > > - When userspace tries to read the stats, vmscan_dump calls rstat to flush > > > the stats, and outputs the stats in text format to userspace (similar > > > to cgroupfs stats). > > > - rstat calls vmscan_flush once for every (cgroup, cpu) pair that has > > > updates, vmscan_flush aggregates cpu readings and propagates updates > > > to parents. > > > - Userspace program makes sure the stats are aggregated and read > > > correctly. > > > > > > Detailed explanation: > > > - The test loads tracing bpf programs, vmscan_start and vmscan_end, to > > > measure the latency of cgroup reclaim. Per-cgroup readings are stored in > > > percpu maps for efficiency. When a cgroup reading is updated on a cpu, > > > cgroup_rstat_updated(cgroup, cpu) is called to add the cgroup to the > > > rstat updated tree on that cpu. > > > > > > - A cgroup_iter program, vmscan_dump, is loaded and pinned to a file, for > > > each cgroup. Reading this file invokes the program, which calls > > > cgroup_rstat_flush(cgroup) to ask rstat to propagate the updates for all > > > cpus and cgroups that have updates in this cgroup's subtree. Afterwards, > > > the stats are exposed to the user. vmscan_dump returns 1 to terminate > > > iteration early, so that we only expose stats for one cgroup per read. > > > > > > - An ftrace program, vmscan_flush, is also loaded and attached to > > > bpf_rstat_flush. When rstat flushing is ongoing, vmscan_flush is invoked > > > once for each (cgroup, cpu) pair that has updates. cgroups are popped > > > from the rstat tree in a bottom-up fashion, so calls will always be > > > made for cgroups that have updates before their parents. The program > > > aggregates percpu readings to a total per-cgroup reading, and also > > > propagates them to the parent cgroup. After rstat flushing is over, all > > > cgroups will have correct updated hierarchical readings (including all > > > cpus and all their descendants). > > > > > > - Finally, the test creates a cgroup hierarchy and induces memcg reclaim > > > in parts of it, and makes sure that the stats collection, aggregation, > > > and reading workflow works as expected. > > > > > > Signed-off-by: Yosry Ahmed > > > Signed-off-by: Hao Luo > > > --- > > > > I saw this test failed on CI on s390x [0], because of using kfunc, and > > on s390x, "JIT does not support calling kernel function". Is there > > anything I can do about it > > > > You can add it to the deny list, like this patch: > https://lore.kernel.org/bpf/20220824163906.1186832-1-deso@posteo.net Very cool! Thanks!