Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp91450iof; Sun, 5 Jun 2022 22:05:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9c//0JT1b3qeSXgviRo1f2oGf/4EJJE+QdxtKqp6FU8c+6XdPjqn7KMJ/g8bW/ojREnhn X-Received: by 2002:a17:902:a502:b0:151:8289:b19 with SMTP id s2-20020a170902a50200b0015182890b19mr22360249plq.149.1654491936538; Sun, 05 Jun 2022 22:05:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654491936; cv=none; d=google.com; s=arc-20160816; b=0Suc6kSFaV2jWGv/9dCzYxVyBK7P3wzP6Mv6Wm+1FJJ3ghCEHkIfIsVwL174Q4jQmE 0K4py5rlKvRa2LUI/IqMZ28s1HfW3z4smyWEDCq5aK0QWV8GeEy2BSnrEX9vKd21ZL2J fAaNnxdUD/Cor20r6/x0aPE8SVJII7FFNxLGheVfAv68sYCYDsEfqmIvoac/HReMMUTY A7bQjR9U2fsrMwr1FVHVBmxJZFOqs4K3wxIQ3XYeUJ+IOV3z9FD0hjn/iLm97tml8YkW TIEt6kJ6m8W4PdOKz8a15BlYkaFigauxzp2lgfDrWKPhYZrWYsIQ7BRQGWIyaTRFBQCD 8ixw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=75r9OCRaKxDbstDb8Q6rmHNx4VG7/Ol3FIsxmmQpCKE=; b=IaGoJTkr3IPNsWKzAkJxj3P/sqVgs55g9xx2t1hB4m7w4MH7JDdDdMHfe5SRT19EDj l36f7qdHey3vC+3hOiqLAWRuqp1gq33zq+pUv9c+EmJnHL8oRWF9dfPYVLWC7//rm5eY 5qbbUwZKoYiXM8JNQ0ysRv2yZal63WmI4PKp5BziPM4KhtJ2ChSmbIiWbIGpRWKOs55i gd/aoEJ3EY/Ww3T0hMxhVjdOdVjtHprCEJm79pg8BTv/0VMzP5zoWXNBIHpiVl6gZL5M XqoSh8NO8FRj0F7U4NAlXjwOjK2tXI5VxWJ4Y2wLfcW2pVVusk63mw8SABW4TQQCskgM cpYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=OFS10OD5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q18-20020a170902b11200b0016403c4ee3esi17956566plr.546.2022.06.05.22.05.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 22:05:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=OFS10OD5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A8FC512FEDB; Sun, 5 Jun 2022 21:15:12 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346266AbiFCTxI (ORCPT + 99 others); Fri, 3 Jun 2022 15:53:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346038AbiFCTxH (ORCPT ); Fri, 3 Jun 2022 15:53:07 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BF461AD86 for ; Fri, 3 Jun 2022 12:53:05 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id c5-20020a1c3505000000b0038e37907b5bso6896375wma.0 for ; Fri, 03 Jun 2022 12:53:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=75r9OCRaKxDbstDb8Q6rmHNx4VG7/Ol3FIsxmmQpCKE=; b=OFS10OD5jepWzQUQgDwqO+/YoB6ZmGdD0wKjnuqRWMntCfyc/zl6FJU7+8IfeQ28pE xXfqBHZknnzrk9L1ttKK0MWceb5jWsOOQGLBa0wl39d8rGlcGwBUk2ZanvmgXNAtJyZr 60Sf9V22ufhliS6cH9dvm+s6oX7B+irq5RWBwlaMWJ4Xko5YT9bz2OEzwuwSJ7i+fw0Z HR7HtVHJFw3Nj/n/X/vSCH6u1nQYW0Y81pb2f61wqTFPRYwQMCGNLv7vUeDBbRKT3Ig5 +QjBWVhxJyQFtQQtDtDUdoy97HliJNHK5A1yPoWyiD/mzBH/EmKmZkHNRagT44RS6jjS ZZEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=75r9OCRaKxDbstDb8Q6rmHNx4VG7/Ol3FIsxmmQpCKE=; b=v3uc/8kzypeg3marMVh+cmB7Tm/mFNfQSVX05NvPZRO0lbgmheOg1e4TCCy2RWZgqJ V1c/Llw34/yB0Ng99WLIiLerrxlywnFBigu8Qazjsn28B3/ywq5ox/jC++bpYyNL+W+l 97UBEt0IO3QX26hnDnl/wxfu8TvhBfU/zMbxtmbVs34RsbA/qQiuQR0Dwg8URTmdMj3M Xp16Nf2mk0fu1yYSfKqSlyMWmEuBa1i0TjVKyXGOkgY6bOYiWppV2c9zE24DJpUqROr8 gbtpFT2IEIB9VjknhCa0J14t+KspfdcbYZbpGB6mN7DAjC4f6XnlbY57a0kq/xYcTTGZ kwfQ== X-Gm-Message-State: AOAM531DzHPEZJyaWAUv6E12SJA/YoScN/HNfQixvVNHdrVZgtX9fakV GT0GN+YMk8s4VxFI5IXn3GYXaldIOQFyaDl8BBjvMA== X-Received: by 2002:a05:600c:3788:b0:39c:3a20:a50e with SMTP id o8-20020a05600c378800b0039c3a20a50emr6019549wmr.196.1654285983632; Fri, 03 Jun 2022 12:53:03 -0700 (PDT) MIME-Version: 1.0 References: <20220520012133.1217211-1-yosryahmed@google.com> <20220520012133.1217211-6-yosryahmed@google.com> <20220603162339.GA25043@blackbody.suse.cz> In-Reply-To: <20220603162339.GA25043@blackbody.suse.cz> From: Yosry Ahmed Date: Fri, 3 Jun 2022 12:52:27 -0700 Message-ID: Subject: Re: [PATCH bpf-next v1 5/5] bpf: add a selftest for cgroup hierarchical stats collection To: =?UTF-8?Q?Michal_Koutn=C3=BD?= Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Hao Luo , Tejun Heo , Zefan Li , Johannes Weiner , Shuah Khan , Roman Gushchin , Michal Hocko , Stanislav Fomichev , David Rientjes , Greg Thelen , Shakeel Butt , Linux Kernel Mailing List , Networking , bpf , Cgroups Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no 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 Thanks for taking a look at this! On Fri, Jun 3, 2022 at 9:23 AM Michal Koutn=C3=BD wrote: > > On Fri, May 20, 2022 at 01:21:33AM +0000, Yosry Ahmed wrote: > > +#define CGROUP_PATH(p, n) {.name =3D #n, .path =3D #p"/"#n} > > + > > +static struct { > > + const char *name, *path; > > Please unify the order of path and name with the macro (slightly > confusing ;-). Totally agree, will do. > > > +SEC("tp_btf/mm_vmscan_memcg_reclaim_end") > > +int BPF_PROG(vmscan_end, struct lruvec *lruvec, struct scan_control *s= c) > > +{ > > [...] > > + struct cgroup *cgrp =3D task_memcg(current); > > [...] > > + /* cgrp may not have memory controller enabled */ > > + if (!cgrp) > > + return 0; > > Yes, the controller may not be enabled (for a cgroup). > Just noting that the task_memcg() implementation will fall back to > root_mem_cgroup in such a case (or nearest ancestor), you may want to > use cgroup_ss_mask() for proper detection. Good catch. I get confused between cgrp->subsys and task->cgroups->subsys sometimes because of different fallback behavior. IIUC cgrp->subsys should have NULL if the memory controller is not enabled (no nearest ancestor fallback), and hence I can use memory_subsys_enabled() that I defined just above task_memcg() to test for this (I have no idea why I am not already using it here). Is my understanding correct? > > Regards, > Michal