Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1028676pxb; Fri, 15 Apr 2022 18:53:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOCnZq9QbhXChTtZqVnezZyYqGxeXvwii1E8xWAo05Y9boAxDSwFovcvYE4BRR9FIcIXHl X-Received: by 2002:a05:6a00:8c6:b0:4fe:10df:1cfe with SMTP id s6-20020a056a0008c600b004fe10df1cfemr1806378pfu.18.1650073985833; Fri, 15 Apr 2022 18:53:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650073985; cv=none; d=google.com; s=arc-20160816; b=mrEKLGpYbJgbLG3xBe1x79kR/RYaY+zoho2pk5t5eihIJsJLW6t1X8eUyZ1guj7Iii CG71fhqXb/YmkpdVWIuByFeo10+HIdNVrNyCqAbaHQZKvO0qSRuqyCR6wgnHAosN8Bgm u/QzHiEchbWcksgCyz4WfurQibZsvzxoEbGLgM8YvZPtI95zb2uyWQLmV3wLALt3HPWi Vq1Oxyp5NgYZIt6OdU0Ze0Ugxoj9OmRpSjBvVwN/Efa+WAKQhCg7UKDH1Fhhjf0S79i/ drmcVzDBUwa9M9ACLFAjDM/9gWZkAyPHZaUPnpXL06YTxx/vwkzlRgrLoyx4Z9DhJ2r0 TjQg== 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=LPYj/DjEs15r53iZss3mXY59mrCJr0nSsnxpqNRvrJQ=; b=i3RxZDZip1ZVyu0VoZk0AwnJXf1ak9/A81yb4Gus66fyzFOCXkoGgtCY+kKfwW/Iey DIdzUBtxlWjT8WD6PU0qUsd73gxVCAfSHVsht5HZSXAL3NnZqgPaeEs6cpNR9H3hGbqb Hnon6fFtmNf7SOiWSXVNAYcqzOKPExYOidn3rnkmmCamCVEWl4Jo1f1j6i3x/REDP7nx gZfDBo2UfEn3wj8XI1ICjNjXucaTbOjhF86iRwfYS1ugf8++csK8XVfc5C8apMD5HPnv FeXAZRkQb36XgOtxprY3RLpzOLLwNR+cAOmVCGNvXnC/v9Gdb1U8GG+kI5v6i5PVmR08 qHDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Kx2EbsKW; 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 x20-20020a633114000000b0039cc30b7ca3si3095405pgx.534.2022.04.15.18.53.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 18:53:05 -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=Kx2EbsKW; 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 D5745A7766; Fri, 15 Apr 2022 18:14:15 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237238AbiDOXKo (ORCPT + 99 others); Fri, 15 Apr 2022 19:10:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229560AbiDOXKn (ORCPT ); Fri, 15 Apr 2022 19:10:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60006183BE; Fri, 15 Apr 2022 16:08:13 -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 0B0D3B831BB; Fri, 15 Apr 2022 23:08:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D519C385AF; Fri, 15 Apr 2022 23:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650064090; bh=bun1UW6dQN+eeylN7K4W70rNw5ZTuBxbCaji7Cqa870=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Kx2EbsKWUajlN+9EYTClzJvSsIYSC0HMbpGZJ+ViEb6kodJh4fqPQAafSm+RNgDyY UD5s7AzJmqA4r/G5RGaG6yMqa+SBGNxlSotO8THxVSeIeEXnnf0ZuynU28sa3oicyC IGc/GOGHFZe05gBPClMuGve0nkZ00NXKVv1beymT0WVvzlnXjIkCObGjHkboA+UfRL j5UZsaRvZM1eY02Vv7aE+eaLwlkg30VQ2hybLCDwIDQTPH58qWHccOtOXCFTXbAyG9 JPBwM0TPIzODSx3pqPfRF7LEm6xYOSCceYrjHY/ZpDYJoOogFqwOTd4GCDI5eNOLfS bEo9m5ZHCFNWw== Received: by mail-yb1-f173.google.com with SMTP id t67so16608290ybi.2; Fri, 15 Apr 2022 16:08:10 -0700 (PDT) X-Gm-Message-State: AOAM530y8pse7f21Iqhf5l9O4k5JLtanBK0CPOKKp15Y1z9uw6DCGsvA HUN+5VnOloum4YqU/Xq4BZmfDZLht1GBIV/dPqU= X-Received: by 2002:a05:6902:1506:b0:63e:4f1b:40ae with SMTP id q6-20020a056902150600b0063e4f1b40aemr1355690ybu.322.1650064089602; Fri, 15 Apr 2022 16:08:09 -0700 (PDT) MIME-Version: 1.0 References: <20220414223704.341028-1-alobakin@pm.me> <20220414223704.341028-2-alobakin@pm.me> In-Reply-To: <20220414223704.341028-2-alobakin@pm.me> From: Song Liu Date: Fri, 15 Apr 2022 16:07:58 -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 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()? Thanks, Song > --- > include/linux/perf_event.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h > index af97dd427501..b1d5715b8b34 100644 > --- a/include/linux/perf_event.h > +++ b/include/linux/perf_event.h > @@ -762,12 +762,14 @@ struct perf_event { > u64 (*clock)(void); > perf_overflow_handler_t overflow_handler; > void *overflow_handler_context; > +#endif /* CONFIG_PERF_EVENTS */ > #ifdef CONFIG_BPF_SYSCALL > perf_overflow_handler_t orig_overflow_handler; > struct bpf_prog *prog; > u64 bpf_cookie; > #endif > > +#ifdef CONFIG_PERF_EVENTS > #ifdef CONFIG_EVENT_TRACING > struct trace_event_call *tp_event; > struct event_filter *filter; > -- > 2.35.2 > >