Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1035533pxb; Fri, 15 Apr 2022 19:07:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwo9iL1sVxnu3apDm/TT2ZIRSHG1NYXezlYgpkxoacrpk60d4KIeC/VKCloP+yTfasR+qSu X-Received: by 2002:a17:90a:9204:b0:1ca:8698:2470 with SMTP id m4-20020a17090a920400b001ca86982470mr1757281pjo.199.1650074688269; Fri, 15 Apr 2022 19:04:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650074688; cv=none; d=google.com; s=arc-20160816; b=oqjhfzcX0DTEE0hRRv0GvZV2bt7DUayyJnmYUMPfjkO4Ht7mMeJ+hdkRG2F7MfQXc/ gHXCgTHKwbnihZjbFLqNrO0NBfg05+8i5lDLNsLJwNJBEB5syK6RzrdG6+iNOi0emwQV 431K/Cr0A820Oh8oFUotYwDFEtJ7yGTjSrd5khqqq0PkiBy4V5v0y3prYEHdf4/LTkgy at6Dwp3Iqn0FnkWlLdNBHkkZYosytH2M7Qjaw1Ya4suhSCucOrnYEAytYCD1ouHzs3Qn fG6Yq6aqtvVMxffNKv91hH93gNfhx8Ww7VUiaYkYFHZGaNNa7NO253h+HxPpSKvJ1ek9 utWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=UjWNoSKi6ffH3nVQbcM/0km6JsmSLrClkAlgqcTqcJk=; b=a0lRQCp04JYYQakQdW8vrtt9C1wQWjo2Q1Q2UougpKMODQiwi6o5zEibHzPDEXtnkl BDe/3geKxG8IDJds8ioRHhZFe/p5lf3vhsVcjFYLljFc/gMARzmlJcihGn0bRPcqPrTx 2AAqkUS4e7Wtt8si6Iv3j7QrT4WF4asYLjOqurRaTndgUAFW2Ze/GtyAyXaVDcy8qX1M 36DZnvvKr/WMmn+NMXZmJjA6BqUt5xlGaGdU2ufe0M0IX5BIfnWeDBfUUrzr1TCYxf0q 4/RbNfLNYz0CF6NrpxSAkW9Zit2C8iPqPyudUi3xJWLirWMQ6MSM9jliXgmdJICi8Ge2 sh+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=G4T6wE40; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id o14-20020a170902d4ce00b00158dcf67f8esi2277731plg.168.2022.04.15.19.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 19:04:48 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=G4T6wE40; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 82F5C10EC43; Fri, 15 Apr 2022 18:23:49 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356478AbiDOXXa (ORCPT + 99 others); Fri, 15 Apr 2022 19:23:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356469AbiDOXX2 (ORCPT ); Fri, 15 Apr 2022 19:23:28 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE1933D494; Fri, 15 Apr 2022 16:20:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A2964B82FAE; Fri, 15 Apr 2022 23:20:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C758C385B1; Fri, 15 Apr 2022 23:20:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650064856; bh=H5LJwPbVhvyvTjl53a9PdwZH87MlV/bckKSPVid1hFM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=G4T6wE40lgyvJa3jOlMgxoai6nBzgbMje5k8IcYpW83uNnMLhXURA86/bCqrCIhU9 uYztFsyvoZ0hqpMKcJUEfvfdfxAb5e4z1ui4xXYZ+tcNmO0pLfRdVSKo8bXbNUcmK+ sW0Oi4SlL5KEWsLmqAyZsNPOQ0H5kbCYHmq4XirCYnXv+t/HGTYaEuBdz4bsiXOSJ6 +14QF1NxHMzZSooNcbFNzsMTj9Eld9hG8Vd8z7Fx0AlCpRffAibJ9OYx02VOiodjpk mEhxO+wlljqUz6lib05uSPulr8Xsa9cnHybkfosNHVPtguTDBhsk6osOMV/MeZtQU5 orB/w4FGXc+2Q== Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-2eba37104a2so95889987b3.0; Fri, 15 Apr 2022 16:20:56 -0700 (PDT) X-Gm-Message-State: AOAM5318N/yHMJFrZeYOOvLpIReAGrskfEnzXbyet0XcGNR+CMwLCjDk 6V33KhqgzZW7X8JU9KBx0xqNHUN5BFAY7kdy1aM= X-Received: by 2002:a81:14c8:0:b0:2eb:eb91:d88f with SMTP id 191-20020a8114c8000000b002ebeb91d88fmr1212396ywu.148.1650064855126; Fri, 15 Apr 2022 16:20:55 -0700 (PDT) MIME-Version: 1.0 References: <20220414223704.341028-1-alobakin@pm.me> <20220414223704.341028-2-alobakin@pm.me> In-Reply-To: From: Song Liu Date: Fri, 15 Apr 2022 16:20:44 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH bpf-next 01/11] bpf, perf: fix bpftool compilation with !CONFIG_PERF_EVENTS To: Alexander Lobakin Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Jonathan Lemon , Nathan Chancellor , Nick Desaulniers , Dmitrii Dolgov <9erthalion6@gmail.com>, Quentin Monnet , Tiezhu Yang , Kumar Kartikeya Dwivedi , Chenbo Feng , Willem de Bruijn , Daniel Wagner , Thomas Graf , Ong Boon Leong , linux-perf-users@vger.kernel.org, open list , Networking , bpf , llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 Fri, Apr 15, 2022 at 4:07 PM Song Liu wrote: > > On Thu, Apr 14, 2022 at 3:45 PM Alexander Lobakin wrote: > > > > When CONFIG_PERF_EVENTS is not set, struct perf_event remains empty. > > However, the structure is being used by bpftool indirectly via BTF. > > This leads to: > > > > skeleton/pid_iter.bpf.c:49:30: error: no member named 'bpf_cookie' in 'struct perf_event' > > return BPF_CORE_READ(event, bpf_cookie); > > ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ > > > > ... > > > > skeleton/pid_iter.bpf.c:49:9: error: returning 'void' from a function with incompatible result type '__u64' (aka 'unsigned long long') > > return BPF_CORE_READ(event, bpf_cookie); > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > Tools and samples can't use any CONFIG_ definitions, so the fields > > used there should always be present. > > Move CONFIG_BPF_SYSCALL block out of the CONFIG_PERF_EVENTS block > > to make it available unconditionally. > > > > Fixes: cbdaf71f7e65 ("bpftool: Add bpf_cookie to link output") > > Signed-off-by: Alexander Lobakin > > While I can't think of a real failure with this approach, it does feel > weird to me. Can we fix this with bpf_core_field_exists()? Hmm.. the error happens at compile time, so I guess it is not very easy. Andrii, Do you have some recommendation on this? Song