Don't require bcc-tools by default

Also add explicit requirement for bcc-tools (silence a rpmdiff
complaint) and build from standard source (needed for gating).

Resolves: rhbz#1967550
This commit is contained in:
Jerome Marchand 2021-07-30 16:37:33 +02:00
parent bf9b748ed9
commit 649cb627d8
5 changed files with 146 additions and 8 deletions

View File

@ -0,0 +1,54 @@
From 6516fb0d00208f05b29f320176204957b02b23e3 Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
Date: Mon, 26 Jul 2021 12:05:57 +0200
Subject: [PATCH] Define KERNEL_VERSION
The libbpf version on RHEL9 doesn't define it.
---
libbpf-tools/biolatency.bpf.c | 2 ++
libbpf-tools/biosnoop.bpf.c | 2 ++
libbpf-tools/bitesize.bpf.c | 2 ++
3 files changed, 6 insertions(+)
diff --git a/libbpf-tools/biolatency.bpf.c b/libbpf-tools/biolatency.bpf.c
index 8d8fe584..8e6e81e2 100644
--- a/libbpf-tools/biolatency.bpf.c
+++ b/libbpf-tools/biolatency.bpf.c
@@ -9,6 +9,8 @@
#define MAX_ENTRIES 10240
+#define KERNEL_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
+
extern int LINUX_KERNEL_VERSION __kconfig;
const volatile bool targ_per_disk = false;
diff --git a/libbpf-tools/biosnoop.bpf.c b/libbpf-tools/biosnoop.bpf.c
index 76697967..7b7cb1a4 100644
--- a/libbpf-tools/biosnoop.bpf.c
+++ b/libbpf-tools/biosnoop.bpf.c
@@ -11,6 +11,8 @@
const volatile bool targ_queued = false;
const volatile dev_t targ_dev = -1;
+#define KERNEL_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
+
extern __u32 LINUX_KERNEL_VERSION __kconfig;
struct piddata {
diff --git a/libbpf-tools/bitesize.bpf.c b/libbpf-tools/bitesize.bpf.c
index 7b4d3f9d..5e7d9d97 100644
--- a/libbpf-tools/bitesize.bpf.c
+++ b/libbpf-tools/bitesize.bpf.c
@@ -10,6 +10,8 @@
const volatile char targ_comm[TASK_COMM_LEN] = {};
const volatile dev_t targ_dev = -1;
+#define KERNEL_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
+
extern __u32 LINUX_KERNEL_VERSION __kconfig;
struct {
--
2.31.1

View File

@ -0,0 +1,41 @@
From aaa39601b756074e9ba8b9a607102a1ae0cb4c94 Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
Date: Mon, 26 Jul 2021 14:45:37 +0200
Subject: [PATCH] Revert "libbpf-tools: remove unecessary custom NULL
definitions"
Libbpf on RHEL does not define NULL
This reverts commit a9f461d74a84be2f96fd35c02cf98c7251bd4166.
---
libbpf-tools/biostacks.bpf.c | 1 +
libbpf-tools/xfsslower.bpf.c | 2 ++
2 files changed, 3 insertions(+)
diff --git a/libbpf-tools/biostacks.bpf.c b/libbpf-tools/biostacks.bpf.c
index f02a1ac5..6ed0bda6 100644
--- a/libbpf-tools/biostacks.bpf.c
+++ b/libbpf-tools/biostacks.bpf.c
@@ -9,6 +9,7 @@
#include "maps.bpf.h"
#define MAX_ENTRIES 10240
+#define NULL 0
const volatile bool targ_ms = false;
const volatile dev_t targ_dev = -1;
diff --git a/libbpf-tools/xfsslower.bpf.c b/libbpf-tools/xfsslower.bpf.c
index 05962f46..2b1c6e4b 100644
--- a/libbpf-tools/xfsslower.bpf.c
+++ b/libbpf-tools/xfsslower.bpf.c
@@ -6,6 +6,8 @@
#include <bpf/bpf_tracing.h>
#include "xfsslower.h"
+#define NULL 0
+
const volatile pid_t targ_tgid = 0;
const volatile __u64 min_lat = 0;
--
2.31.1

View File

@ -0,0 +1,35 @@
From 4e2851687904cff7ab4f8faa862b9046e5aaab09 Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
Date: Fri, 30 Jul 2021 18:15:05 +0200
Subject: [PATCH] libbpf-tools: readahead: don't mark struct hist as static
Libbpf readahead tool does not compile with bpftool v5.14. Since
commit 31332ccb756 ("bpftool: Stop emitting static variables in BPF
skeleton"), bpftool gen skeleton does not include static variable into
the skeleton file anymore.
Fixes the following compilation error:
readahead.c: In function 'main':
readahead.c:153:26: error: 'struct readahead_bpf__bss' has no member named 'hist'
153 | histp = &obj->bss->hist;
| ^~
---
libbpf-tools/readahead.bpf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libbpf-tools/readahead.bpf.c b/libbpf-tools/readahead.bpf.c
index ba22e534..cfead704 100644
--- a/libbpf-tools/readahead.bpf.c
+++ b/libbpf-tools/readahead.bpf.c
@@ -24,7 +24,7 @@ struct {
__uint(map_flags, BPF_F_NO_PREALLOC);
} birth SEC(".maps");
-static struct hist hist;
+struct hist hist = {};
SEC("fentry/do_page_cache_ra")
int BPF_PROG(do_page_cache_ra)
--
2.31.1

View File

@ -27,14 +27,15 @@
Name: bcc
Version: 0.20.0
Release: 3%{?dist}
Release: 4%{?dist}
Summary: BPF Compiler Collection (BCC)
License: ASL 2.0
URL: https://github.com/iovisor/bcc
# Upstream now provides a release with the git submodule embedded in it
Source0: %{url}/releases/download/v%{version}/%{name}-src-with-submodule.tar.gz
#Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
Patch0: %{name}-%{version}-libbpf-tool-don-t-ignore-LDFLAGS.patch
Patch1: %{name}-%{version}-libbpf-tools-readahead-don-t-mark-struct-hist-as-sta.patch
Patch2: %{name}-%{version}-Define-KERNEL_VERSION.patch
Patch3: %{name}-%{version}-Revert-libbpf-tools-remove-unecessary-custom-NULL-de.patch
# Arches will be included as upstream support is added and dependencies are
# satisfied in the respective arches
@ -57,11 +58,12 @@ BuildRequires: pkgconfig(luajit)
%endif
BuildRequires: libbpf-devel >= 0.0.5-3, libbpf-static >= 0.0.5-3
Requires: %{name}-tools = %{version}-%{release}
Requires: libbpf >= 0.0.5-3
Requires: tar
Recommends: kernel-devel
Recommends: %{name}-tools = %{version}-%{release}
%description
BCC is a toolkit for creating efficient kernel tracing and manipulation
programs, and includes several useful tools and examples. It makes use of
@ -113,6 +115,7 @@ Standalone tool to run BCC tracers written in Lua
%package tools
Summary: Command line tools for BPF Compiler Collection (BCC)
Requires: bcc = %{version}-%{release}
Requires: python3-%{name} = %{version}-%{release}
Requires: python3-netaddr
@ -130,7 +133,7 @@ Command line libbpf tools for BPF Compiler Collection (BCC)
%endif
%prep
%autosetup -p1 -n %{name}
%autosetup -p1
%build
@ -148,7 +151,7 @@ Command line libbpf tools for BPF Compiler Collection (BCC)
# take them.
%if %{with libbpf_tools}
pushd libbpf-tools;
make BPFTOOL=bpftool CFLAGS="%{optflags}" LDFLAGS="%{build_ldflags}"
make BPFTOOL=bpftool LIBBPF_OBJ=%{_libdir}/libbpf.a CFLAGS="%{optflags}" LDFLAGS="%{build_ldflags}"
make DESTDIR=./tmp-install prefix= install
(cd tmp-install/bin; for file in *; do mv $file bpf-$file; done;)
popd
@ -227,6 +230,11 @@ install libbpf-tools/tmp-install/bin/* %{buildroot}/%{_sbindir}
%endif
%changelog
* Mon Jul 26 2021 Jerome Marchand <jmarchan@redhat.com> - 0.20.0-4
- Don't require bcc-tools by default (#1967550)
- Add explicit bcc requirement to bcc-tools
- Build bcc from standard sources
* Wed Jun 02 2021 Jerome Marchand <jmarchan@redhat.com> - 0.20.0-3
- Don't ignore LDFLAGS for libbpf-tools

View File

@ -1 +1 @@
SHA512 (bcc-src-with-submodule.tar.gz) = 60ab3e7e11015878895d009afb2290d1e677e3c7bc04f493eb586136af190d7c0930757b34e721822eaf6700ecc17edeb30a4b04ea29c4a26cb885164060030a
SHA512 (bcc-0.20.0.tar.gz) = fa7c50a4fc64846ad798b6652101aa414cda53d08779cf48bd505191189cb23da2838f7511e700d59e086d35216f4e3bc9867b614738061630984dff3c4576dc