lkml.org 
[lkml]   [2023]   [Jan]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v3 1/2] perf build: Properly guard libbpf includes
On Fri, 6 Jan 2023 at 15:13, Ian Rogers <irogers@google.com> wrote:
>
> Including libbpf header files should be guarded by
> HAVE_LIBBPF_SUPPORT. In bpf_counter.h, move the skeleton utilities
> under HAVE_BPF_SKEL.
>
> Fixes: d6a735ef3277 ("perf bpf_counter: Move common functions to bpf_counter.h")
> Reported-by: Mike Leach <mike.leach@linaro.org>
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> tools/perf/builtin-trace.c | 2 ++
> tools/perf/util/bpf_counter.h | 6 ++++++
> 2 files changed, 8 insertions(+)
>
> diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> index 86e06f136f40..d21fe0f32a6d 100644
> --- a/tools/perf/builtin-trace.c
> +++ b/tools/perf/builtin-trace.c
> @@ -16,7 +16,9 @@
>
> #include "util/record.h"
> #include <api/fs/tracing_path.h>
> +#ifdef HAVE_LIBBPF_SUPPORT
> #include <bpf/bpf.h>
> +#endif
> #include "util/bpf_map.h"
> #include "util/rlimit.h"
> #include "builtin.h"
> diff --git a/tools/perf/util/bpf_counter.h b/tools/perf/util/bpf_counter.h
> index 4dbf26408b69..c6d21c07b14c 100644
> --- a/tools/perf/util/bpf_counter.h
> +++ b/tools/perf/util/bpf_counter.h
> @@ -4,9 +4,12 @@
>
> #include <linux/list.h>
> #include <sys/resource.h>
> +
> +#ifdef HAVE_LIBBPF_SUPPORT
> #include <bpf/bpf.h>
> #include <bpf/btf.h>
> #include <bpf/libbpf.h>
> +#endif
>
> struct evsel;
> struct target;
> @@ -87,6 +90,8 @@ static inline void set_max_rlimit(void)
> setrlimit(RLIMIT_MEMLOCK, &rinf);
> }
>
> +#ifdef HAVE_BPF_SKEL
> +
> static inline __u32 bpf_link_get_id(int fd)
> {
> struct bpf_link_info link_info = { .id = 0, };
> @@ -127,5 +132,6 @@ static inline int bperf_trigger_reading(int prog_fd, int cpu)
>
> return bpf_prog_test_run_opts(prog_fd, &opts);
> }
> +#endif /* HAVE_BPF_SKEL */
>
> #endif /* __PERF_BPF_COUNTER_H */
> --
> 2.39.0.314.g84b9a713c41-goog
>


This version builds fine too.

Mike
--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK

\
 
 \ /
  Last update: 2023-03-26 23:31    [W:0.067 / U:1.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site