Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3299807lfo; Mon, 23 May 2022 01:04:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6Gc76lSY2bRobJdIEDeja/nlw09RDIuFX2iS35qx4XuO+cTQoEjQczMxYGopcZy3KO3qj X-Received: by 2002:a63:6949:0:b0:3f6:5b37:e949 with SMTP id e70-20020a636949000000b003f65b37e949mr15310973pgc.24.1653293093090; Mon, 23 May 2022 01:04:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653293093; cv=none; d=google.com; s=arc-20160816; b=P6e5RzwELzxOiAF/DIlCilmr+YVmolgG0ol9TtdbmysKozDUgYILoflfQJxV3ky+MJ AEFWe5VQqXLoTcVFIJjZZg4OvFUGAVl/cj21JwahMZXNzHnMqK+0IWf9VZ02hAvqaWMB AAzkyw9K7MqdbQtvPyjdiMh68uPvKIQEP72KQVo1IIJ1xAUgLKmXZ4QqD6aBN68Wqt3v zdlk6IOTXZy19B6eT/63fjxfgBlUQ2M/QCbw2egA+f6XwbUhV449TapjpssuJ4FRa2gw +VbBu+hPgm87RHQYsgkQ02eJf6cV5/tc/aGdUcX9h4bAGp0CgJ0uyHsAQX9kSAGNecbR rZVg== 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=p5lqA4V2Z2dTb6TSdgJsb3QItFMtbNECXgovUnmle3Y=; b=TBQrkQpTgrQitw5VlzbRIiduofE+Z45sF+OYs7FYEqV3uK039yY3sNlvT+rjz9RFKu 5MluftmwBtYdoXOGx7lRrBeu0U5M2bFPyZi2t0uOm/5eDVb64JRAWG4Mfwj9prk+J4iN BXNtl3CX0ZhJmG8kAYUdTIhuG3vpv8PilUvzdnbAnWmV2bQutsPCXC6wFI84IPcdu/rW AeFJRP6jgxttV2LRYriAPkUtqPWWwExyRFAej9oltZ4d9q9uJUMZvdBx+qS+hL/ekIk9 BJ2DivEsFGjPCzu4jDaj3DcVWux8CVWESlzclKGxjswbRmPVupZ4al5sXq4xtYI3PbnQ g/gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=kS4vFnX9; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id v8-20020a17090331c800b001616652f769si8335854ple.240.2022.05.23.01.04.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 01:04:53 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=kS4vFnX9; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 F0F5B6D393; Mon, 23 May 2022 00:08:49 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352986AbiETVuA (ORCPT + 99 others); Fri, 20 May 2022 17:50:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348277AbiETVt6 (ORCPT ); Fri, 20 May 2022 17:49:58 -0400 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41FCEBC6FD for ; Fri, 20 May 2022 14:49:57 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id a22so8497496qkl.5 for ; Fri, 20 May 2022 14:49:57 -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; bh=p5lqA4V2Z2dTb6TSdgJsb3QItFMtbNECXgovUnmle3Y=; b=kS4vFnX94EFG9U4QcDfkpXRrX2RNEKg6t5fFXIM1d4BF31cv67BKOWBC2/lKKWdWbn eAiIo+bdJTHT1tFbHYiYmgVpOrVsoU4ftSDk7vordIX8o06a1mV0wVr6JDtOc50c47Y+ 0GLRmWg6ZMMrDP/lrewoqr2ZIF//PQqiqRIMWoBfc+gkgSVLmF7StWfErdeSzc8IStzs Dpqt3hNNZFs1UiH/n2pe0dgtzveVE5rAsr/WcqdlXXfiGC9hLiZaINDKyifpLvdtlCUs BuqqQ6VdPyyv9LSKYr3Orpz88v4ptMLSyEV3N8jFFGfKGlpEvQiPEU6RQs+WPn2sulTo CTKg== 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; bh=p5lqA4V2Z2dTb6TSdgJsb3QItFMtbNECXgovUnmle3Y=; b=3KwwPrM9Lh+Sj7RHQEjEyenvgq11rkcItrC9zYY/LSnZW/Q+UbiHCR8IJ9Vp17pETc ONljfnTZJGNkwDpwt4robge4/4M+FxoKogbG94/RyzpmRDKLlXFw4+T3yKnN/kWX+RMl bWL3aSxqXkCe/NpMPlEJIxNF/PEMlN07oxg1YhqN85NdXHZ5W9STiqw1U30WJHRNKPB0 uzaf/vY/7a1AGaoZfooSJukLL3Qr9eUleMZV99yZTC+m4hJBPICHnWGUoAxQ6U4JHiKz M++tM55xz0vxywZv0CHMnCa1BYb+jKHUkHpiyqCBYVEK8euuvL1EM2SHTN07X6TIUvLX 8wLA== X-Gm-Message-State: AOAM5314lAnsfVgQUqClAY0IKHZ/IyhgJMgb93e7ipOxmvq0LNHZ5nO7 JN3C863BP6jhzBAnjBoas1PPYa8Li5L4ETOn/mD4nA== X-Received: by 2002:ae9:f504:0:b0:69f:ba2d:29ff with SMTP id o4-20020ae9f504000000b0069fba2d29ffmr7651495qkg.583.1653083396226; Fri, 20 May 2022 14:49:56 -0700 (PDT) MIME-Version: 1.0 References: <20220520012133.1217211-1-yosryahmed@google.com> <20220520012133.1217211-4-yosryahmed@google.com> <73fd9853-5dab-8b59-24a0-74c0a6cae88e@fb.com> In-Reply-To: From: Hao Luo Date: Fri, 20 May 2022 14:49:45 -0700 Message-ID: Subject: Re: [PATCH bpf-next v1 3/5] bpf: Introduce cgroup iter To: Tejun Heo Cc: Yonghong Song , Yosry Ahmed , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , John Fastabend , KP Singh , 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" 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 Hi Tejun and Yonghong, On Fri, May 20, 2022 at 12:42 PM Hao Luo wrote: > > Hi Tejun and Yonghong, > > On Fri, May 20, 2022 at 9:45 AM Tejun Heo wrote: > > On Fri, May 20, 2022 at 09:29:43AM -0700, Yonghong Song wrote: > > > > > > > > > This way, user space can easily construct the cgroup hierarchy stat like > > > cpu mem cpu pressure mem pressure ... > > > cgroup1 ... > > > child1 ... > > > grandchild1 ... > > > child2 ... > > > cgroup 2 ... > > > child 3 ... > > > ... ... > > > > > > the bpf iterator can have additional parameter like > > > cgroup_id = ... to only call bpf program once with that > > > cgroup_id if specified. > > Yep, this should work. We just need to make the cgroup_id parameter > optional. If it is specified when creating bpf_iter_link, we print for > that cgroup only. If it is not specified, we iterate over all cgroups. > If I understand correctly, sounds doable. > Yonghong, I realized that seek() which Tejun has been calling out, can be used to specify the target cgroup, rather than adding a new parameter. Maybe, we can pass cgroup_id to seek() on cgroup bpf_iter, which will instruct read() to return the corresponding cgroup's stats. On the other hand, reading without calling seek() beforehand will return all the cgroups. WDYT?