Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1677047ioo; Mon, 23 May 2022 00:01:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYDMtt1/yRNPSz686chk86UC4xx62JhRD8PRWXMLWdnBzOv6nhl7HKRz0CKaKMyA5d/mB8 X-Received: by 2002:a63:570a:0:b0:3f6:2e7c:4b58 with SMTP id l10-20020a63570a000000b003f62e7c4b58mr18518229pgb.249.1653289273941; Mon, 23 May 2022 00:01:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653289273; cv=none; d=google.com; s=arc-20160816; b=X4ydm/YfRniAPPHvpVZYYyxMCgK5a5UsCJWq/DJmF3F/ImQkal2gwPXauG05E6tMAl vH1c4j9BtvFN1uYHX9AG43UHMKtP924M87RCveCJC02y4dSObfzZeQ55KidmZPXoXz7t 8EfpO7eobFGAGTn5JXT2LlmOD62GIQWeiLeuER7+EtZnCWTQVTTiX+N0yHlJtfY3C1Rx lPsG8Xmy8xZhNml+yP5K48V4sJ3NxUxwxzD3+pqXGRaoaVW+R+AlKBR9zuqq8Reokt4k MAbDh+lanKq4tdF0O1wEcRl95JfK88jp7Mjhw5fLRU28PobpU8fTMzjClUPiOfPgE1mx 2Dbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=b7Vm31N1KmiKaz7SbohqBjKzTjmGJnpUAVkpKWUThMY=; b=KfiwutwDuSoAvjaLDj8i5cIOMsNlXFiLkvRPi/ItKpLibm72lkT3XhQ4JLjQkefy6d 6C1GdRwXxsGNqYIcw6XY75Ml+sagA41XqAgwY1Kn3kflll9LpxZSLHvwJ8X08e01ZgDb rzGMSwQLLuFY4Nsk2K5LoqpU8IizqkIGpUSNTj2+WsSOJ9t9OaedLMQ4jK1YzZaRZO+a jludwZPAiGRTGzNE45JR08KJk6D0ES7PGO+ewXwZ0mXkuoubAx2+tQiN1YAH7kI4quBJ tqT6u0qVFVFUbgGg08tk521wlpHhhY/nCkQetvl+OOV8bwuGzea10wg3ZWRZiPigkj4S G4BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=H3ZjIy79; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i70-20020a638749000000b003daf6356570si8516780pge.3.2022.05.23.00.01.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 00:01:13 -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=@gmail.com header.s=20210112 header.b=H3ZjIy79; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 33EF164721; Sun, 22 May 2022 23:25:36 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353883AbiETWTd (ORCPT + 99 others); Fri, 20 May 2022 18:19:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353875AbiETWT0 (ORCPT ); Fri, 20 May 2022 18:19:26 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED4EB1A076B; Fri, 20 May 2022 15:19:24 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id 202so1824916pfu.0; Fri, 20 May 2022 15:19:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=b7Vm31N1KmiKaz7SbohqBjKzTjmGJnpUAVkpKWUThMY=; b=H3ZjIy79fwHtkOfYF1Ill/fMPUjrPR7E2pkOa/YhCb1jGsvLLxRr6uOQICQCl8yq2h KzSERIApbRFXR9lmG4Uk3nHZvFVq8Uue1kE4LnmFLR/v/rN9npvSJts7f+iytk8LCo9a fpRMMlwIruvdNJLVHaMg5qOJAgX4M5Fc/F1tt0tD6yZZrIAOeapE9xs6S16JiuWCsju2 Asxl3i8dLiXmCXxEAOBresM3uaNtP212C8mONg3FwmL4Z7oqEaT+taMPqifRHmMmn/nx 2IQLI+zcVqY30ca/PvxFcTrMC7DqzhHrftAfzpFMlIUEPLJgJV9MGm5xgioYQqWSeEHB nm+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=b7Vm31N1KmiKaz7SbohqBjKzTjmGJnpUAVkpKWUThMY=; b=CMWLtJPDj7rM4ifpTEJnVv7hK+1MX4Egzl1yiDoI66yNBAcCKJYr1dn3idm9L1rrh2 YPqr7D+iKQA8kDh2ysmWJAZbvqXkRVboaxGI/F6wxP5iCzWGHKSYLVlPJVkUg137/AhG /hG4oCcr+v1ofdxWwogIiBiN6E0ZMH1UI9gsH5WPbB2J3ol+RJB6j3yu42yP2xQDWtY3 qljKbMz7OtsJHmbNYOQwTS8TWtxEywLRMCk48KN2Myrd3ylNm1GGHr71ZjXMTUnM7Mut SY13+WmIEInbHD0Xhdl0s4RgGx2xk4jY2Cn6K7N9ZLQB997W60mWwhSWTh4LSbej77JD K/Xw== X-Gm-Message-State: AOAM533PD2bbh9lT193sVem6ulWXOY6Q5nPrUAHnGf15JsN/bMOk3FV/ qR2PHZg3uOpeYf8kt5NHnQk= X-Received: by 2002:a63:dc42:0:b0:3c5:e187:572 with SMTP id f2-20020a63dc42000000b003c5e1870572mr10364737pgj.82.1653085164314; Fri, 20 May 2022 15:19:24 -0700 (PDT) Received: from MBP-98dd607d3435.dhcp.thefacebook.com ([2620:10d:c090:500::1:c6aa]) by smtp.gmail.com with ESMTPSA id 7-20020a17090a098700b001d25dfb9d39sm2356730pjo.14.2022.05.20.15.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 May 2022 15:19:23 -0700 (PDT) Date: Fri, 20 May 2022 15:19:19 -0700 From: Alexei Starovoitov To: Yosry Ahmed Cc: Hao Luo , Tejun Heo , Yonghong Song , 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 Subject: Re: [PATCH bpf-next v1 3/5] bpf: Introduce cgroup iter Message-ID: <20220520221919.jnqgv52k4ajlgzcl@MBP-98dd607d3435.dhcp.thefacebook.com> References: <20220520012133.1217211-1-yosryahmed@google.com> <20220520012133.1217211-4-yosryahmed@google.com> <73fd9853-5dab-8b59-24a0-74c0a6cae88e@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 On Fri, May 20, 2022 at 02:18:42PM -0700, Yosry Ahmed wrote: > > > > The userspace needs to specify the identity of the cgroup, when > > creating bpf_iter. This identity could be cgroup id or fd. This > > identity needs to be converted to cgroup object somewhere before > > passing into bpf program to use. > > > Let's sum up the discussion here, I feel like we are losing track of > the main problem. IIUC the main concern is that cgroup_iter is not > effectively an iterator, it rather dumps information for one cgroup. I > like the suggestion to make it iterate cgroups by default, and an > optional cgroup_id parameter to make it only "iterate" this one > cgroup. 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?