Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1667128ioo; Sun, 22 May 2022 23:39:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfVeCN4cH7b8coxnKkVOSNzHFL/Eo8a2Ebfp3tXEkkFP0Vn9tL84Ud1Fj0yJYRyrtNIgOR X-Received: by 2002:a05:6a00:1511:b0:510:30d1:e8fd with SMTP id q17-20020a056a00151100b0051030d1e8fdmr22488872pfu.37.1653287998300; Sun, 22 May 2022 23:39:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653287998; cv=none; d=google.com; s=arc-20160816; b=Bv3tT4+L+gmP2jqfqEJO792XpStmDkB3yrskuD5mmNhgW7moSPjecesPgalRCPC7vR N5mm+ItU6GZNZOZG9hdnxPYC9mL2uzZuWpnUlytOVQ4lUiydAXj7xMsisaMbcbH9qXcI zLQbXb8Zi7km+q7QltzOW1gy4rIvxs3g/mgua4JcNgTqWVU3PEp1+axB3uqZuMWTEQbn 1mziULzIPFCcygk3NV+bjDAie0yye9IyamUAP4iFNGlHweCdiPOBgrJndht6UfpOnZwJ FRxrHEdZEycenTdxdayyh76xkq7fVnqpeDMD3eHFROLg72/zwKsx0LKYaKMeFtAOGONX WGKw== 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=ea7uCWmZvVi7x8pZXNpq32JNdBnZG/d3z6FlMpmBFbQ=; b=p2/LMeStn3be4kXw9AH5mhx4vsZx8zpAYwURzeC6y7xotfYVOszOmhFEdsfYfYrrKt xI8jVSRR286IZY+nn6aL11i29EQFdMo4Al1DYaXjLc6Gy7z4R49aa7CYt1E+QWbFzux+ LX0OsqDL0qm8cPocvVO26N8SHe+ANBo6xwZ/Jg0p5DDoDDohSObsLxnq0JI4WK6Le6Mf QqlW9lnYz6ADVCHGkKeOPZXWZSB60MWb9mFgTF/8g/9UzMswfJ8KF7Mhm34wZJLmopT2 dIJTJznjQcJ4kUpLVqKqSopV/Qfsi44b4MLSnuTJM5HU1DTH/Tu5e95SKHswQRzFCkbk NmDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=aEdYT6oI; 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 x2-20020a170902a38200b0015f3cb011fesi9001127pla.419.2022.05.22.23.39.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 May 2022 23:39:58 -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=aEdYT6oI; 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 9A44E4A3C1; Sun, 22 May 2022 23:12:19 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346738AbiETH7v (ORCPT + 99 others); Fri, 20 May 2022 03:59:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346764AbiETH7b (ORCPT ); Fri, 20 May 2022 03:59:31 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4144615D312 for ; Fri, 20 May 2022 00:59:30 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id i82-20020a1c3b55000000b00397391910d5so369528wma.1 for ; Fri, 20 May 2022 00:59:30 -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=ea7uCWmZvVi7x8pZXNpq32JNdBnZG/d3z6FlMpmBFbQ=; b=aEdYT6oI+uAOu9UjBKXVmQR4Vqb7G4k23KZ5L2K3v79YnkqWwIWGGGpsdip/no9LKF OX6p+BYYQM+OElnkM9nMH0jOpS1lznXRg3lJ6uwuxhXtFofh4fsrAfY8PoByvVgIOv14 TnBJGNIAxOy63rP8B+4+4uWMpcRLRAsdAJDUbp+llYUTUriz6jRPAyL4AWOccmuIKhOI 69qZZCmel4W+VjPG+18N18R/0StDr7wRnLfT06tb+/NpzgX2jn1EsTpE4Ls55bXco/k/ wIf7IpYqEmW72htmBiltvUNLA/eOWjZyVZAxP36v1WUwj5Mh1B+IcLpkSxewV90tvTLs HEGg== 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=ea7uCWmZvVi7x8pZXNpq32JNdBnZG/d3z6FlMpmBFbQ=; b=BJ2o7umGXES1JKdUqHqknv+sQYt8FPYTnpTmV/f+J2aQD/NOou/UOGb9T3bN7pNmUX bN5L055v4fs+QG2JeB8KjpCSW7V3e7Si2Xb+Kid0sPEg3s9xLKkF+cG0UDM3t5nzMrkR diX+ZGfWDAAsQDjIEp83SwTha4XX098CpWXQyCHzQUnAARrDuERsV1Rjuk/AOy2poTEC nkvN30IjaBnWY9ziB+6RBJ/2b4+29Tuz9EpmUZMbUpS70nl87v38Y5zkX/YAcpuLpVGB 1ThfWqjCuyjJEaoA2TRWXmPg/2htjSeFKSaSj6N4GNm79xyuyRAEtu1bKiVTGpcWhjXQ RjGA== X-Gm-Message-State: AOAM531K49X/X1z/7bQXCDmwiZGEYu7sruvsFHM9zwf/TI0ImGy1llnj 66ynabaNeFAuPADSaqCx5V1bfwuGYQLBvCR3nsRIMw== X-Received: by 2002:a05:600c:1908:b0:394:867d:66c4 with SMTP id j8-20020a05600c190800b00394867d66c4mr7447568wmq.152.1653033568515; Fri, 20 May 2022 00:59:28 -0700 (PDT) MIME-Version: 1.0 References: <20220520012133.1217211-1-yosryahmed@google.com> <20220520012133.1217211-4-yosryahmed@google.com> In-Reply-To: From: Yosry Ahmed Date: Fri, 20 May 2022 00:58:52 -0700 Message-ID: Subject: Re: [PATCH bpf-next v1 3/5] bpf: Introduce cgroup iter To: Tejun Heo Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Hao Luo , 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 On Fri, May 20, 2022 at 12:41 AM Tejun Heo wrote: > > On Fri, May 20, 2022 at 01:21:31AM +0000, Yosry Ahmed wrote: > > From: Hao Luo > > > > Introduce a new type of iter prog: cgroup. Unlike other bpf_iter, this > > iter doesn't iterate a set of kernel objects. Instead, it is supposed to > > be parameterized by a cgroup id and prints only that cgroup. So one > > needs to specify a target cgroup id when attaching this iter. The target > > cgroup's state can be read out via a link of this iter. > > > > Signed-off-by: Hao Luo > > Signed-off-by: Yosry Ahmed > > This could be me not understanding why it's structured this way but it keeps > bothering me that this is adding a cgroup iterator which doesn't iterate > cgroups. If all that's needed is extracting information from a specific > cgroup, why does this need to be an iterator? e.g. why can't I use > BPF_PROG_TEST_RUN which looks up the cgroup with the provided ID, flushes > rstat, retrieves whatever information necessary and returns that as the > result? I will let Hao and Yonghong reply here as they have a lot more context, and they had previous discussions about cgroup_iter. I just want to say that exposing the stats in a file is extremely convenient for userspace apps. It becomes very similar to reading stats from cgroupfs. It also makes migrating cgroup stats that we have implemented in the kernel to BPF a lot easier. AFAIK there are also discussions about using overlayfs to have links to the bpffs files in cgroupfs, which makes it even better. So I would really prefer keeping the approach we have here of reading stats through a file from userspace. As for how we go about this (and why a cgroup iterator doesn't iterate cgroups) I will leave this for Hao and Yonghong to explain the rationale behind it. Ideally we can keep the same functionality under a more descriptive name/type. > > Thanks. > > -- > tejun