Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2486184ioo; Mon, 23 May 2022 21:30:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2mBdLfYN5HU1KmPf4r3tp20Ks4NfzbULMIclTreL0J4HZayqWTJx17fovWNtLgr+iuBNc X-Received: by 2002:a17:906:9d90:b0:6fe:b875:171e with SMTP id fq16-20020a1709069d9000b006feb875171emr14222357ejc.517.1653366653674; Mon, 23 May 2022 21:30:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653366653; cv=none; d=google.com; s=arc-20160816; b=JFU5BNyMukK0tv92+VQgwu7wI0iKzrz3+T4rZl1xK12l3M0KWq5nLKcTokNaem+MpL 1cxcYOl0J6ND6vf3fBHFlVnnONE1nx3kEC/erthAIfxES5doCtxleW4NcG1IpScJeo17 OKyZ6m0Y3Q1CczHbRD3gLnJwahEX3sns+o3zf5WP6XQNzA6RWIbvnigf3QRAD+S+jxjQ BSqPfBAQ/tLZhNTSE7D5ki4L/+m88r1vos6tjFxSEs7iGa/ioGcBB1KbDsY8VuDIQVII qc/SskVel2haLKXqtub6HaYSU1J2VZJk2WUT89ytxM3shF3giArsiZSZhXQdTraoSBeY 8Opw== 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=M2mIELVIK9I45bOrNaHoPQeyzkFn9jybEus0u38+96s=; b=xDtp2fZlF95cKDH/JCcDC2aCascdHsaCB8twufWH63PdJI6f4kF6LRfFjgK8XQV/td FbsgUQE1dh9W0DxFj0mDydmf1i00D5gFtBa739J22DbPPhOxJs5tQ0pZhoeexKzrQFiT 38UCYWGYOi/leWb/wU0rIys7YbHg8s0AU1ragZHEPlkBUeNGuyhxq+8pZONO+pwKI21B 7U4sAu7BumW8zpJtWoh068NVSxMV1MKl5XbOZciB1qbuqxx9CZUtjuVaaiVo6I3Uldpe V8CVwk9rr865PA5+sed7VLoRXFuF2VonmudvLKUB/rVpectBmmhZwdqonCRYcQTADY2j ucKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VnHsSTwM; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z4-20020a05640235c400b0042ab4e83dd0si21478830edc.269.2022.05.23.21.30.26; Mon, 23 May 2022 21:30:53 -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=@gmail.com header.s=20210112 header.b=VnHsSTwM; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231127AbiEWX6g (ORCPT + 99 others); Mon, 23 May 2022 19:58:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229556AbiEWX6e (ORCPT ); Mon, 23 May 2022 19:58:34 -0400 Received: from mail-vs1-xe2d.google.com (mail-vs1-xe2d.google.com [IPv6:2607:f8b0:4864:20::e2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D7E15641F; Mon, 23 May 2022 16:58:33 -0700 (PDT) Received: by mail-vs1-xe2d.google.com with SMTP id m2so16646917vsr.8; Mon, 23 May 2022 16:58:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=M2mIELVIK9I45bOrNaHoPQeyzkFn9jybEus0u38+96s=; b=VnHsSTwMUvjWYssSawwJ5pEcHjByONf8kYvt/w+HAsB3Hf7IGHDWS7Y6jAhIIJxgVO uoGHf8AFlhnmaVzAx0LDqsXEYOMIdGPPaWZdOMXF2ti7VVCbzwWoI2o+2zpOlp7ZeH3J MG1TDy/haiNsWsXjjsgMr33/RadE8QOFl81bmI+r2cxjuo9+SGSEhVv1HObsiUTkmyqb LI1Tbohh27CSgCiIQUxZpaBNMPAvQn0IJ6akPOEMssVnm8VnXOVQ8JTz2zkzPUhvWMN1 g3mXFAPZy5hecxQph9G377xJS3izBXLE4OarMwRfQIzugPfNcTNsD/CykzREfCaaYKOp I/DQ== 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=M2mIELVIK9I45bOrNaHoPQeyzkFn9jybEus0u38+96s=; b=o1YKi7c58x61vPmQpSgBmj0qQOFWucIBgLfD7+3/X0pwjWiWS5a5lkW0OxsKMdsVJN 06rphcSiuM4di/KkmTw3SZwX8KvXwMBiYORg3RHYB+OycIEUAEIwS6Prs8nwOkkXy2Ig SA0+Lv4VcadMr9dikRmSO/S8fgcP1W6aZq6JZOJYsBAqAkZcHOo8JyapCsaupXMlnm07 fyeHqVgxSFF+760Mcm9YRZVzT2YOcdk+osTvPMWKWMzrxRi1WKILhfvX0Ax6JRvL501b lA1Wj6IfGHOHlCwq2K8aDip0YRPIy2Nx9KzcRW9z9QcIbZv8fA0z/KI5rcxiwaaM+ops TZCg== X-Gm-Message-State: AOAM5330SZyB1aRLJlaCzE9I07HaEbKgEP8A9Ouulok9jhhlHciWd4tJ LYhos46Ra/RjBztKoXKGd5wkLsbscZ8T9HAQEQE= X-Received: by 2002:a05:6102:4b6:b0:335:f244:2286 with SMTP id r22-20020a05610204b600b00335f2442286mr7796011vsa.54.1653350312371; Mon, 23 May 2022 16:58:32 -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> <20220520221919.jnqgv52k4ajlgzcl@MBP-98dd607d3435.dhcp.thefacebook.com> <5b301151-0a65-df43-3a3a-6d57e10cfc2d@fb.com> In-Reply-To: From: Andrii Nakryiko Date: Mon, 23 May 2022 16:58:21 -0700 Message-ID: Subject: Re: [PATCH bpf-next v1 3/5] bpf: Introduce cgroup iter To: Hao Luo Cc: Yonghong Song , Tejun Heo , Alexei Starovoitov , 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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Fri, May 20, 2022 at 7:35 PM Hao Luo wrote: > > On Fri, May 20, 2022 at 5:59 PM Yonghong Song wrote: > > On 5/20/22 3:57 PM, Tejun Heo wrote: > > > Hello, > > > > > > On Fri, May 20, 2022 at 03:19:19PM -0700, Alexei Starovoitov wrote: > > >> We have bpf_map iterator that walks all bpf maps. > > >> When map iterator is parametrized with map_fd the iterator walks > > >> all elements of that map. > > >> cgroup iterator should have similar semantics. > > >> When non-parameterized it will walk all cgroups and their descendent > > >> depth first way. I believe that's what Yonghong is proposing. > > >> When parametrized it will start from that particular cgroup and > > >> walk all descendant of that cgroup only. > > >> The bpf prog can stop the iteration right away with ret 1. > > >> Maybe we can add two parameters. One -> cgroup_fd to use and another -> > > >> the order of iteration css_for_each_descendant_pre vs _post. > > >> wdyt? > > > > > > Sounds perfectly reasonable to me. > > > > This works for me too. Thanks! > > > > This sounds good to me. Thanks. Let's try to do it in the next iteration. Can we, in addition to descendant_pre and descendant_post walk algorithms also add the one that does ascendants walk (i.e., start from specified cgroup and walk up to the root cgroup)? I don't have specific example, but it seems natural to include it for "cgroup iterator" in general. Hopefully it won't add much code to the implementation.