From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C74AC433EF for ; Mon, 6 Jun 2022 19:32:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232310AbiFFTcs (ORCPT ); Mon, 6 Jun 2022 15:32:48 -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-Google-Smtp-Source: ABdhPJzOrH3W8CG5y0UhEiUwZCc/frlgpaMAC/wiDonpCoj3ndzKhQc7jzNy9XpNg/VeI6CYpTOKxRkUoRt6Vw65fS0= 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 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