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 8048FCCA47E for ; Tue, 7 Jun 2022 18:07:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349498AbiFGSHI (ORCPT ); Tue, 7 Jun 2022 14:07:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351330AbiFGSB5 (ORCPT ); Tue, 7 Jun 2022 14:01:57 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFA1E12E80D for ; Tue, 7 Jun 2022 10:44:14 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id h5so25214670wrb.0 for ; Tue, 07 Jun 2022 10:44:14 -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=Avvoh8CnIiqiG7pt5w+f0B0Z6X7OPhtWirg6KypOnRk=; b=VJgCpuVqKSXl0XX58PrPxmWGKDkQdIE6BEthpBh1qGGSHXZS3+YISNnwTYkYarnho9 MvxMYs2TMqZiGshTbPZ0zIzK1VVVXZpVgaziJrABATtPimx965adbeB6GqOUlTuNnyhz NPWJKmZexcPAKl4rzq3JtNd9/PXX0JeVvORheEEpbcyms/Ra+vjsuG5Kqeil6AQzy6/V KHCGQPlibPQzrK3H2wed7BEJ3UlHPtrRePVo21DyyddSbOjiJ+ttt3X/L876GbyiyvAw UJZAGIQaLuw88L2APyzR3tLX+5EFi65VfUbyfbBKfXfwkl++cELNNBZ8yhYU7i7NZ9fd 954g== 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=Avvoh8CnIiqiG7pt5w+f0B0Z6X7OPhtWirg6KypOnRk=; b=kXcYddCsVLBv8aEbu0fIRKAQNHU4N8OpWIFc1LIP4J8aeB5JZeQg4YtZLnBKsI6S6b 2IRuJ2x3+oGlydRH8btAjzxtZDccKNTPZmA3JkUV3h2/jFYsMlbzDmGiU9uL7V+7iuG0 2wOKORho9z+dnbPO+Eh47pTU+otsif6dYHah1itCKoNThd+3hm+S2eUazRpMIYb2Z9Jl P5RdCzr2CpDWBizfrAba6Si0gpo9cqB6qOp3P1QJE8fv40o2Ljwkh4VqfaAhjcNT6SdH 8TXZgx5YoCYrdqZde4TwGs+u90KTSXkHtrLwjhsW0Sklnwtq8pApA8lbTF6YCRX9iTp9 UD6g== X-Gm-Message-State: AOAM533Vl8SBPQht94lO/67ixyZRj2FaUbVrfPmtXc1lYsFZoa1jETAX ddIIxKV7d2sRMp1QKE+/LHDHpPR+OaoTB6gsunhcYg== X-Google-Smtp-Source: ABdhPJyFuoW87JmCWjoEcQfJUeb0WIaes2z5fAnqfq4EfroINBdg/KTV/oyVRDvIVcWJxGZ+BbW1f/v1QcNJHtOHOBw= X-Received: by 2002:adf:eeca:0:b0:217:56ae:c657 with SMTP id a10-20020adfeeca000000b0021756aec657mr15290057wrp.210.1654623852628; Tue, 07 Jun 2022 10:44:12 -0700 (PDT) MIME-Version: 1.0 References: <20220520012133.1217211-1-yosryahmed@google.com> <20220520012133.1217211-6-yosryahmed@google.com> <20220603162339.GA25043@blackbody.suse.cz> <20220606123222.GA4377@blackbody.suse.cz> <20220607121237.GC31717@blackbody.suse.cz> In-Reply-To: <20220607121237.GC31717@blackbody.suse.cz> From: Yosry Ahmed Date: Tue, 7 Jun 2022 10:43:35 -0700 Message-ID: Subject: Re: [PATCH bpf-next v1 5/5] bpf: add a selftest for cgroup hierarchical stats collection 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: netdev@vger.kernel.org On Tue, Jun 7, 2022 at 5:12 AM Michal Koutn=C3=BD wrote: > > On Mon, Jun 06, 2022 at 12:41:06PM -0700, Yosry Ahmed wrote: > > I don't know if there is a standard way to handle this, but I think > > you should know the configs of your kernel when you are loading a bpf > > program? > > Isn't this one of purposes of BTF? (I don't know, I'm genuinely asking.) > > > If the CONFIG_CGROUPS=3D1 but CONFIG_MEMCG=3D0 I think everything will > > work normally except that task_memcg() will always return NULL so no > > stats will be collected, which makes sense. > > I was not able to track down what is the include chain to > tools/testing/selftests/bpf/progs/cgroup_vmscan.c, i.e. how is the enum > value memory_cgrp_id defined. memory_cgrp_id is defined in "vmlinux.h" (generated from BTF) which is included through "bpf_iter.h". If the kernel is not compiled with CONFIG_MEMCG then this enum value will not be defined and the bpf prog should not compile. > > (A custom kernel module build requires target kernel's header files, I > could understand that compiling a BPF program requires them likewise and > that's how this could work. > Although, it goes against my undestanding of the CO-RE principle.) > > > There will be some overhead to running bpf programs that will always > > do nothing, but I would argue that it's the userspace's fault here for > > loading bpf programs on a non-compatible kernel. > > Yeah, running an empty program is non-issue in my eyes, I was rather > considering whether the program uses proper offsets. > > Michal >