From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94FA833F4 for ; Fri, 15 Apr 2022 23:20:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4762EC385BA for ; 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-f181.google.com with SMTP id 00721157ae682-2ebd70a4cf5so95601017b3.3 for ; Fri, 15 Apr 2022 16:20:56 -0700 (PDT) X-Gm-Message-State: AOAM533c488+L2FeiaWy2yTdGbIHqqY2nGfeQlb6p+B1blrxcrFfIiQn B0z1Ge9EgAc2wZXmEKEddzkcFyKnFOSj4XEYNyM= X-Google-Smtp-Source: ABdhPJxkXwLE32cy9vO7zAkTLquRKkeV5Pv4mTYQklMv/2cDtiOUZg+7j4dLOyNKcRICXvJ4LlZHOTfeJlkbxbPWvXc= 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) Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: 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" 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