Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp1033522iof; Mon, 6 Jun 2022 18:42:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhjJrGhzh2R57SiuQc9UQRAfJb0aiPVx+4J9kldmkscK9j5gwkZbfEEFNtriG1iGfABQMB X-Received: by 2002:a17:903:1c8:b0:165:1395:dcb3 with SMTP id e8-20020a17090301c800b001651395dcb3mr26252922plh.76.1654566133374; Mon, 06 Jun 2022 18:42:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654566133; cv=none; d=google.com; s=arc-20160816; b=OFeb8DhL/45jzWnDTDWvjPqXWzs1bGPsQCXh6CWGKmXow98Gr/OZXng6lHWi6A84bQ +FkSlzVvKIAYuY+2A/TNP9BlwdHuvfnvcUM7sTuFzKmtBVjBnY04d2MkxSe1I+TZURR3 fwAtvjlyKPEF9RdhRSs6O0mipNDMyynQxRvk7VP2e9u3GEajqCEzsgwOziACkEJmZgdr +cuLfPdesOG27Wr3fKqvOceU+7yUORqG4mIa5yD4hqwkR+fJC6SA4Or7KlTM3KLM8F04 GO4PqBGHy+IYdtfvnm7u3/veSicjwhuN4XOoX4hYk1SW9AphcaXKiBapp8Nko3a2H4LM KlYA== 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=W5TqJYafwftJ1q16jDwsapCbeMrbhqufuDDjVq8Z1/0=; b=CFl1XCfB1mn8wcF/9KU0aPwPUbI+zSQ0KPG9G5CbhzcjtpHipINIIfltorp1UlB5+m YggCG/gXHhWw+l+ykrVvkLsnXCqQtgKvRjQFxxiHoqE0/C1L2v8s0R2K/rJW8EhSUnsK zsphw14m/99ib3f5dWMBreSSelimzV4bckBdd8+saksJwLbjxJavbBxj2V6p//6ssI3l d6ohjp2zc4uIBXt3tYNNl4bk2Z0NnG3yLv2FD72XH3MGfwtkwT6GTFlNb0nKp3Cf7jPQ DHwa5mc5VSLeNfer+9ghko63gHm+SLOVPYfdj9Q5bOyKQlKgBTWPUoiD3BoNnuovrrQY eDRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=dRai72lf; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w8-20020a17090a8a0800b001cd5b0dcab5si25091983pjn.12.2022.06.06.18.41.57; Mon, 06 Jun 2022 18:42:13 -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=@google.com header.s=20210112 header.b=dRai72lf; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232130AbiFFUBP (ORCPT + 99 others); Mon, 6 Jun 2022 16:01:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232965AbiFFUBN (ORCPT ); Mon, 6 Jun 2022 16:01:13 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE12721B4 for ; Mon, 6 Jun 2022 13:01:09 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id q15so5062327wmj.2 for ; Mon, 06 Jun 2022 13:01:09 -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=W5TqJYafwftJ1q16jDwsapCbeMrbhqufuDDjVq8Z1/0=; b=dRai72lfgPZVIbcYWbUJgQZW62213vXNScspB3WEJ8uXaErK7Wm69WAfoUX4ybfir5 hGG+oasznTALQNkRvzo4k3jjOa5QWG4Q7qaLY2vlMOL0HIQvV8DB/wJc4HPztmZJKHQg bgjw9FszVQUdeqkBcBCL7z1i3oUV4vGRLv7xGkQN+5dXsdh9YvZWGM8+UsJL45omX6bt OJMtAV9tYU83SJwh93SuVYmMkYMj96481RHZ/H7H9FNMPH5GSpI9UOCOvRo+0FZqUHkj DF/AA5b1zGXOO1kcS9aRFg/N6xzK0ao4g3Ic4hAsHSIMDrNE5Gmm9zTqm4+LahveQS/A nL+w== 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=W5TqJYafwftJ1q16jDwsapCbeMrbhqufuDDjVq8Z1/0=; b=fgWg53EqN4ioCgjgWq9XydHnFn3CRuNgDufkFzE4ofN/eUqT8WoPXcrmcy/zLmLDvY jAozvYXmoH6ingBynPOE5QmZsgtjVvm0ZCJEdsHZzwbuoLVSj6MwgH4xBCJwXc3kluBY hwj+UWQdpQo84+QYaKslgT5qLvr4GGjnhGoW3Qlpy0cJJZtLNJ4Gpo8Wc5zN0WA1r/Y4 jwPwcI++aKMBmj66uUPNUKkwj4bXDCvz5LVxY+fk6oQ7OSV65IEbuDfPaQVHVo4cEQmK 0rnSSxKzIK1RCbGMB25XrFrdctqA/mGk066+dw7uK4WPjIqghVQIofv9/hkpFntMYdcX E/qw== X-Gm-Message-State: AOAM531HJkpz8MgaOZMhmhaL4Mhv+rM9JOJYYDkNEC8IEgAvKn4eGE/r yV0W3utpg72zI1vAxK65z3Z5UC1cddiNMPd8sM7eOg== X-Received: by 2002:a7b:c7c3:0:b0:398:934f:a415 with SMTP id z3-20020a7bc7c3000000b00398934fa415mr25516158wmk.27.1654545667336; Mon, 06 Jun 2022 13:01:07 -0700 (PDT) MIME-Version: 1.0 References: <20220520012133.1217211-1-yosryahmed@google.com> <20220603162247.GC16134@blackbody.suse.cz> <20220606123209.GE6928@blackbody.suse.cz> <20220606195454.byivqaarp6ra7dpc@apollo.legion> In-Reply-To: <20220606195454.byivqaarp6ra7dpc@apollo.legion> From: Yosry Ahmed Date: Mon, 6 Jun 2022 13:00:30 -0700 Message-ID: Subject: Re: [PATCH bpf-next v1 0/5] bpf: rstat: cgroup hierarchical stats To: Kumar Kartikeya Dwivedi Cc: =?UTF-8?Q?Michal_Koutn=C3=BD?= , 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=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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 Mon, Jun 6, 2022 at 12:55 PM Kumar Kartikeya Dwivedi wrote: > > On Tue, Jun 07, 2022 at 01:02:04AM IST, Yosry Ahmed wrote: > > On Mon, Jun 6, 2022 at 5:32 AM Michal Koutn=C3=BD wr= ote: > > > > > > On Fri, Jun 03, 2022 at 12:47:19PM -0700, Yosry Ahmed wrote: > > > > In short, think of these bpf maps as equivalents to "struct > > > > memcg_vmstats" and "struct memcg_vmstats_percpu" in the memory > > > > controller. They are just containers to store the stats in, they do > > > > not have any subgraph structure and they have no use beyond storing > > > > percpu and total stats. > > > > > > Thanks for the explanation. > > > > > > > I run small microbenchmarks that are not worth posting, they compar= ed > > > > the latency of bpf stats collection vs. in-kernel code that adds st= ats > > > > to struct memcg_vmstats[_percpu] and flushes them accordingly, the > > > > difference was marginal. > > > > > > OK, that's a reasonable comparison. > > > > > > > The main reason for this is to provide data in a similar fashion to > > > > cgroupfs, in text file per-cgroup. I will include this clearly in t= he > > > > next cover message. > > > > > > Thanks, it'd be great to have that use-case captured there. > > > > > > > AFAIK loading bpf programs requires a privileged user, so someone h= as > > > > to approve such a program. Am I missing something? > > > > > > A sysctl unprivileged_bpf_disabled somehow stuck in my head. But as I > > > wrote, this adds a way how to call cgroup_rstat_updated() directly, i= t's > > > not reserved for privilged users anyhow. > > > > I am not sure if kfuncs have different privilege requirements or if > > there is a way to mark a kfunc as privileged. Maybe someone with more > > bpf knowledge can help here. But I assume if unprivileged_bpf_disabled > > is not set then there is a certain amount of risk/trust that you are > > taking anyway? > > > > It requires CAP_BPF or CAP_SYS_ADMIN, see verifier.c:add_subprog_or_kfunc= . Thanks for the clarification! > > > > > > > > bpf_iter_run_prog() is used to run bpf iterator programs, and it gr= abs > > > > rcu read lock before doing so. So AFAICT we are good on that front. > > > > > > Thanks for the clarification. > > > > > > > > > Michal > > -- > Kartikeya