Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2175433iof; Tue, 7 Jun 2022 22:13:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwr/jsWe/Bp5xTwZeM0K8UDUKiG08xLlyBFA/9U0Cte7LKjgyM/jZVJhVAyy/2m2yzt10Sr X-Received: by 2002:a17:90a:cf0f:b0:1e2:e62b:fd3 with SMTP id h15-20020a17090acf0f00b001e2e62b0fd3mr36382321pju.107.1654665196878; Tue, 07 Jun 2022 22:13:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654665196; cv=none; d=google.com; s=arc-20160816; b=vt76R37dIHrdQpjacP0TUZTWlJ3+bNZCZiK2RwLcmryDAjThLqB4VSBtmPcz9EEdta J4TlH5nTBs/7XnODwSSn9L6IjKZc4muzrusjmt7hZ9hy3mvf2/1TH4gwRxxJloSWMmF4 d7d6niJPFzdd/sxk1QEglhYqBoY+LZ0eEt0wlMaKBoTfgcyhjin3D01agMIDFVJVr79N 4VZu31qxHGzmG1hkwVcBUuf20s/ukrJ46mAb9+eX+QzJub7YAuOYcQmex3DyEn0SchD3 niet/Txoe/5/EHjE1Y4/R93tH2NIijjxVee3N0t2HyYKueBXDMghXyVxrCD6MpTrxRVq fCbA== 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=Avvoh8CnIiqiG7pt5w+f0B0Z6X7OPhtWirg6KypOnRk=; b=DzMUoPvRiGJF61RTGyakRrlETMK/NF1CWGIOdgVYDeaHEUvCTIaVXFexH1bZavgMph 796Co1zFjVdb+6KQXulSg4RQuiiXG1RZYxrX4qV7VlMLh5CjMsBRDiyFbq2UQ9Uapbp0 BTvqcUhuGIB79IYezKutQ4cGwEtYyln/ArOzgUM8YE2DZ9+O1UkL96IjELUZwU6qaxA9 wzbfv2alpDT/F3YdDX+eAyDn0lARfekVPKTTQch5oWrSR08x4Pxup6/RHluDt9AZu8TC UyPz88mhKTT+zIkNOZW49Ld9f2VC17wnoKvKnfG6CR1yBFOviyEBq3QNkSE/S2mj4DLE ZtVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=VJgCpuVq; 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 ji12-20020a170903324c00b0016163a204cfsi24203724plb.334.2022.06.07.22.13.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:13:16 -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=VJgCpuVq; 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 CD0A0E1145; Tue, 7 Jun 2022 21:43:35 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353237AbiFGSgg (ORCPT + 99 others); Tue, 7 Jun 2022 14:36:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351312AbiFGSB4 (ORCPT ); Tue, 7 Jun 2022 14:01:56 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7BC9151FC6 for ; Tue, 7 Jun 2022 10:44:14 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id s1so2061598wra.9 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=k1aHnMh4mIluG84ICYJRDgDK4i7dqXd/A1Ng6+F+/upNaPUKLJhDb+owqDKc4rs+pW dhF2lGrFNuQTDRbiL0qjbT33uqF8H2GUcnL4B/50YcUQzZ+OR5WzYC1E+ngvj8Wbx2nV ooiGe8C9EpIgZ/MlYcAdIYq9RZIkbDgi2UAoePxEm6w9vp21DqBKrC+JzNiFUhpyf9/Y nlGjXeNl7l+lYiZNgI9T9ch8L+gjs46Yc8M3O/B1c+qFQphnT8fyJ6hB7YuTmm0QRP4i 5W2DcxIJ9RnJQ2Vt3HQpIklqZfvhlvyTtAoxePqLrkDCkat2SDqFPSdMONrZRsuDOsz+ 7gaw== X-Gm-Message-State: AOAM5310YczAEu2995XXhr0o9BzG/LcQWaMvRv6+fdn+uNtC0ONLBSL6 x/UDE4tIYAKQWCQxDKDHOsp30471UWhj0PJ2YqMEVA== 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 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 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 >