Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3271099lfo; Mon, 23 May 2022 00:23:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNJD87OX03S0v3C34q8VlXKt8vHiH3DtsRwCo8IKKok5oQreEfnbUp0Z3oGSeFQ/YwJaPT X-Received: by 2002:a17:90a:930b:b0:1bf:ac1f:6585 with SMTP id p11-20020a17090a930b00b001bfac1f6585mr24595457pjo.88.1653290624439; Mon, 23 May 2022 00:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653290624; cv=none; d=google.com; s=arc-20160816; b=u3AQrlfFtpdfA1bK+Jp0zBjLVRP/3K3yaiAQe4LvL4yu0Air61b881//P/zpIwA3kT EJybGVwsN65FW8s03gYxWfxPze57t6RbtekAC718S6iewuZs0+b/d7Vn4vwRjSo02/gx sHmM/e+yJn85fxSqaHUrZUsNjOt/vfG19RSNGXLNaZ2HRiaN/o9nB3H7hvPGJG7pOayj rFrT5+QHuxPT3wxquivacMhcPn7lem68Fkjq9QWMmv8Sa+Sy6mYP57LFjHy5COdhDRIk bQJJ25FLs51sY+xSGVLhE+YRbICqVFY1z5VSF9I2ZV0Q7kWJkH2yPVh4SjKBFu7MbTsh /eEw== 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=GarL2Kn/zNIJwCptfjfJ4swfJzGY6bIsUnYiG/oxiuI=; b=XC9Qfronj3mfrZf2rr1ezPflEGnDpYNrLeqcQJcFPm+XFWmvWi+eu8UmJkMsfG7HhL W+Q6tb232KP//9NfSXsX3ICTN8t+sp4OUZv9nRLTgGG80NB9w+bLteRwRwaUfSHFMnW6 TgY9N1wV0Kaq9q2ZVePOnf3nYwhZ+fb1JrxyziHH8jgnZ30JAZX4naeIWTHGLAGkvCwc ybQejBcEgbQlKSTntDEflPyAZOc0dQx40XsgvRSj2Ffyv9Dhcl2x4GRj/1DdZN9oGRoc c97EIrH0zNI3ElqLzCsxobAOgoYzifg/tU4m6nAPo0vPaHkEGV7i7WEf+AU7B+0Cp6DH gwLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=TtgVg9kR; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j3-20020a170903028300b00162094f21c6si9699265plr.424.2022.05.23.00.23.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 00:23:44 -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=@google.com header.s=20210112 header.b=TtgVg9kR; 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=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 6B5C8B36FF; Sun, 22 May 2022 23:38:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351538AbiETQU4 (ORCPT + 99 others); Fri, 20 May 2022 12:20:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351540AbiETQUu (ORCPT ); Fri, 20 May 2022 12:20:50 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E85665C4 for ; Fri, 20 May 2022 09:20:45 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id e2so531687wrc.1 for ; Fri, 20 May 2022 09:20:45 -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=GarL2Kn/zNIJwCptfjfJ4swfJzGY6bIsUnYiG/oxiuI=; b=TtgVg9kR94FReHMcINrx3ZC/s6A7a4psy4/9RGzmCb8xCqRJZPWW8LNcgsK1sWrGU5 ho2BYDZmtkjRspH22M5aAr+RU9dkyIOmWM4MwgpfWKF/iGU0tz/r5P67ilQptFsP60xT Q3gKb4yQ1eQudnLBQXSua2hijgHXcJ97MVbOBBeKTXZ3SHjyElxW0IrGEgvIles1NlSY zYVejH5s8+UGST9GpZVVizOO2UpSavsx1LEFhvf99w/sp5+VrNr/M6yaapC2S09Vbn0u YALTWwv9FeqDgRBHzzPava+DO/9LNGzsLNp0LCHcsRE5JDGH6JkMH01Az6bZ7IeMUK6f 0OUg== 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=GarL2Kn/zNIJwCptfjfJ4swfJzGY6bIsUnYiG/oxiuI=; b=RCeyL+A1+cH7WdYIQ8d1hiqn9cpSjXuLROaBxk3djiOyrv8xtUnLTh3Z4ckaFFxlct HpEgH4sCREanAY7/6IV470kesUO+uT6yuleohvezhJ3m8W40reyl2ec4iloU3qRE7Rbo xAJhdvOpoFJXJBYN72kbxBWr6sLOrOkfGXFkriscHuxGFskEYvwmvl4Z27elHP8vUATL tqCDHNqCriZIiYp2XOXHkO/LkBRvzpbbdyRP0qwSqXZ70Ov2v67NTPfaWz319OK6EHJO XURdx/o956jAOHyeqqntSX0n9cagn4CBaI6KQHOkHOzUcA9CvAIkG93iG+QjIMt4sYGW 1fMw== X-Gm-Message-State: AOAM532bM0/FtKnFGeHZDTjNiaaVvlVAxsH+LnSqdVVKyda6ojeMTBcT KtfexFi4uHuIrsLNQH9MS+pXqfucVRfMAQBukGhd2w== X-Received: by 2002:adf:f042:0:b0:20e:5be7:f473 with SMTP id t2-20020adff042000000b0020e5be7f473mr8983437wro.80.1653063643790; Fri, 20 May 2022 09:20:43 -0700 (PDT) MIME-Version: 1.0 References: <20220520012133.1217211-1-yosryahmed@google.com> <20220520012133.1217211-3-yosryahmed@google.com> In-Reply-To: From: Yosry Ahmed Date: Fri, 20 May 2022 09:20:07 -0700 Message-ID: Subject: Re: [PATCH bpf-next v1 2/5] cgroup: bpf: add cgroup_rstat_updated() and cgroup_rstat_flush() kfuncs To: Yonghong Song Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , 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=-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 9:16 AM Yonghong Song wrote: > > > > On 5/20/22 9:08 AM, Yosry Ahmed wrote: > > On Fri, May 20, 2022 at 8:15 AM Yonghong Song wrote: > >> > >> > >> > >> On 5/19/22 6:21 PM, Yosry Ahmed wrote: > >>> Add cgroup_rstat_updated() and cgroup_rstat_flush() kfuncs to bpf > >>> tracing programs. bpf programs that make use of rstat can use these > >>> functions to inform rstat when they update stats for a cgroup, and wh= en > >>> they need to flush the stats. > >>> > >>> Signed-off-by: Yosry Ahmed > >>> --- > >>> kernel/cgroup/rstat.c | 35 ++++++++++++++++++++++++++++++++++- > >>> 1 file changed, 34 insertions(+), 1 deletion(-) > >>> > >>> diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c > >>> index e7a88d2600bd..a16a851bc0a1 100644 > >>> --- a/kernel/cgroup/rstat.c > >>> +++ b/kernel/cgroup/rstat.c > >>> @@ -3,6 +3,11 @@ > >>> > >>> #include > >>> > >>> +#include > >>> +#include > >>> +#include > >>> + > >>> + > >>> static DEFINE_SPINLOCK(cgroup_rstat_lock); > >>> static DEFINE_PER_CPU(raw_spinlock_t, cgroup_rstat_cpu_lock); > >>> > >>> @@ -141,7 +146,12 @@ static struct cgroup *cgroup_rstat_cpu_pop_updat= ed(struct cgroup *pos, > >>> return pos; > >>> } > >>> > >>> -/* A hook for bpf stat collectors to attach to and flush their stats= */ > >>> +/* > >>> + * A hook for bpf stat collectors to attach to and flush their stats= . > >>> + * Together with providing bpf kfuncs for cgroup_rstat_updated() and > >>> + * cgroup_rstat_flush(), this enables a complete workflow where bpf = progs that > >>> + * collect cgroup stats can integrate with rstat for efficient flush= ing. > >>> + */ > >>> __weak noinline void bpf_rstat_flush(struct cgroup *cgrp, > >>> struct cgroup *parent, int cpu) > >>> { > >>> @@ -476,3 +486,26 @@ void cgroup_base_stat_cputime_show(struct seq_fi= le *seq) > >>> "system_usec %llu\n", > >>> usage, utime, stime); > >>> } > >>> + > >>> +/* Add bpf kfuncs for cgroup_rstat_updated() and cgroup_rstat_flush(= ) */ > >>> +BTF_SET_START(bpf_rstat_check_kfunc_ids) > >>> +BTF_ID(func, cgroup_rstat_updated) > >>> +BTF_ID(func, cgroup_rstat_flush) > >>> +BTF_SET_END(bpf_rstat_check_kfunc_ids) > >>> + > >>> +BTF_SET_START(bpf_rstat_sleepable_kfunc_ids) > >>> +BTF_ID(func, cgroup_rstat_flush) > >>> +BTF_SET_END(bpf_rstat_sleepable_kfunc_ids) > >>> + > >>> +static const struct btf_kfunc_id_set bpf_rstat_kfunc_set =3D { > >>> + .owner =3D THIS_MODULE, > >>> + .check_set =3D &bpf_rstat_check_kfunc_ids, > >>> + .sleepable_set =3D &bpf_rstat_sleepable_kfunc_ids, > >> > >> There is a compilation error here: > >> > >> kernel/cgroup/rstat.c:503:3: error: =E2=80=98const struct btf_kfunc_id= _set=E2=80=99 has > >> no member named =E2=80=98sleepable_set=E2=80=99; did you mean =E2=80= =98release_set=E2=80=99? > >> 503 | .sleepable_set =3D &bpf_rstat_sleepable_kfunc_ids, > >> | ^~~~~~~~~~~~~ > >> | release_set > >> kernel/cgroup/rstat.c:503:19: warning: excess elements in struct > >> initializer > >> 503 | .sleepable_set =3D &bpf_rstat_sleepable_kfunc_ids, > >> | ^ > >> kernel/cgroup/rstat.c:503:19: note: (near initialization for > >> =E2=80=98bpf_rstat_kfunc_set=E2=80=99) > >> make[3]: *** [scripts/Makefile.build:288: kernel/cgroup/rstat.o] E= rror 1 > >> > >> Please fix. > > > > This patch series is rebased on top of 2 patches in the mailing list: > > - bpf/btf: also allow kfunc in tracing and syscall programs > > - btf: Add a new kfunc set which allows to mark a function to be > > sleepable > > > > I specified this in the cover letter, do I need to do something else > > in this situation? Re-send the patches as part of my series? > > At least put a link in the cover letter for the above two patches? > This way, people can easily find them to double check. Right. Will do this in the next version. Sorry for the inconvenience. > > > > > > > > >> > >>> +}; > >>> + > >>> +static int __init bpf_rstat_kfunc_init(void) > >>> +{ > >>> + return register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, > >>> + &bpf_rstat_kfunc_set); > >>> +} > >>> +late_initcall(bpf_rstat_kfunc_init);