Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp850333iof; Mon, 6 Jun 2022 13:48:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjRbJ7ITBNOlyB02Wi4OPPjdmqlCjM094/EwKEYyIu9QrZFPtcbwgytRCSxRSrCTz9qIMt X-Received: by 2002:a17:903:2349:b0:163:d235:71e6 with SMTP id c9-20020a170903234900b00163d23571e6mr25745284plh.47.1654548526748; Mon, 06 Jun 2022 13:48:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654548526; cv=none; d=google.com; s=arc-20160816; b=kbb8GZOma+8ginq1mwdY77zR3CQtoggohFV69vMZj6kTg3J4m6Vuv5uRdfAqK6TU2c TTC/XxSyJM2gjCiCe/C+IjbB5t3tdhemKtelji7den7q51kZoSS9yc8BbtcKjUaJVmUe qWHuh4MI+1E1E8c+ksfkUHMYdSKlVKqtFtEtPif7eyLNzVgn+yvQ6zRFGYGM2/uG4Ck2 wCbUkfn7iPBppBPrFV3WbrQjKPJXhEvDWpE4j2ShFo/P/RUPt4wnDRca+yTzu03M5gb9 OFCD9Rd/TQumTtLsgiRsT/2YBVwS0voC7olJGdAxvt4pZBP5Ix7tLcN5jAiyARjhHYsy w5OQ== 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=j/cPLNIZM1LCsTUDc6o0FCtYbw+beYsEKBGs5kqXcMs=; b=ZIJoZus+dXUKo54gF8PpMS9s7xLKPGpGpxRyQUIuH1Z0ZtlSVikcpi/3sjZAciKshM e0z+4JOtbWQK4V8zoRyodfbemC5drMv3BOVWUA3NbOmfhH6fgxkI684J9Wm0Ri5kspVN druIU4Fsg3Vbamqtfz3I54UdCNI3W1MWgPIcpoyqllQJjwklWqEI1NWQux3q7J8vy7uo na9VeHSzcP65MyHSBFC8bhmm2/dmlTCNk4PxbmSuQ+KdE8tm0PggpQ/SPDqk3Ww5shjW KCQduejd8ukC7EO5+ln5UTerWGcOYT8b+sfDpVLXl3ZhWgUe98CnDzkejDqaF//jkAdX 9pUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="lzQFh/at"; 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 l192-20020a6391c9000000b003fd87529fcesi141333pge.642.2022.06.06.13.48.35; Mon, 06 Jun 2022 13:48:46 -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="lzQFh/at"; 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 S232388AbiFFTcr (ORCPT + 99 others); Mon, 6 Jun 2022 15:32:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232386AbiFFTco (ORCPT ); Mon, 6 Jun 2022 15:32:44 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71E6A2BB03 for ; Mon, 6 Jun 2022 12:32:42 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id h5so21214467wrb.0 for ; Mon, 06 Jun 2022 12:32:42 -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=j/cPLNIZM1LCsTUDc6o0FCtYbw+beYsEKBGs5kqXcMs=; b=lzQFh/atdk+9YeyfEh+QiYmsQCHdhCw9He8IoqDkUDh70z79xt9WOeE69lDZxpcNjT bR141LudvjepsqtckXsTJExKjujhfBySeXX3lGBZdMyWw9Hj5GReFM3OKFmwi+TUoHQx oZsvwJKkDPX7u3JPtJIYSiEXF4g85cRoAjyT5U30WiD4Rahyvl6mTNRbQ2VRSRHhrZnc gLT5O+zMpFuaRqq5Q7CgrD1ALwUtROj44xO70cNoml5i78IH05nNERpThsHZQjrORuAS J1Hqkgqr3u7D3bTCMmD0YQ1IC4S8CknEj7+oNzqmijDOQei148Z/nshaGmchHBnxO64F DUFw== 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=j/cPLNIZM1LCsTUDc6o0FCtYbw+beYsEKBGs5kqXcMs=; b=Pt1/uklNNVesKPrY7ykSv7pUoYHDNsdEew1O/0ogs88mM3IQmp7KPqRxu0hFmzIHPX CewuleipsMa8PflViWf4COOimQF/YAcWDNMdnr2P3CKncYt5/yqkAojyEkf2xjoLFCyQ D4fNgxHRLYQIP1gF6TmKXYYEHlZeP8+tNI2Xf3agSLQwAXjp+wx9FDLZP/P8A2crdO+C qMF3HEjN+6+HR4ApRv5voBoPwievIT22EnfCrYZbgl/vvNluqnJcCoXDbKnemPWNLur/ hFAoA0E3ca888M0/y2ai2LQ5aZFlhKU3fvxnP2XbBb05/A+u6fWh4acdCBw2w5e3zak9 bQVA== X-Gm-Message-State: AOAM532Fd3YBdR6dg/aqouNZMiEcarhX5EZ/lXxzTULXaaTshqGg50pj ivwAwA/AomJ8mSkQ2i0gPqUfveyup7eXw3MlCDZkzw== X-Received: by 2002:adf:f688:0:b0:215:6e4d:4103 with SMTP id v8-20020adff688000000b002156e4d4103mr16603122wrp.372.1654543960673; Mon, 06 Jun 2022 12:32:40 -0700 (PDT) MIME-Version: 1.0 References: <20220520012133.1217211-1-yosryahmed@google.com> <20220603162247.GC16134@blackbody.suse.cz> <20220606123209.GE6928@blackbody.suse.cz> In-Reply-To: <20220606123209.GE6928@blackbody.suse.cz> From: Yosry Ahmed Date: Mon, 6 Jun 2022 12:32:04 -0700 Message-ID: Subject: Re: [PATCH bpf-next v1 0/5] bpf: rstat: cgroup hierarchical stats To: =?UTF-8?Q?Michal_Koutn=C3=BD?= Cc: 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 5:32 AM Michal Koutn=C3=BD wrote: > > 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 compared > > the latency of bpf stats collection vs. in-kernel code that adds stats > > 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 the > > 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 has > > 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, it'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? > > > bpf_iter_run_prog() is used to run bpf iterator programs, and it grabs > > rcu read lock before doing so. So AFAICT we are good on that front. > > Thanks for the clarification. > > > Michal