import CS bcc-0.25.0-5.el8

This commit is contained in:
eabdullin 2023-09-27 12:43:13 +00:00
parent c1d5e371c6
commit 827bcc87c6
6 changed files with 272 additions and 1 deletions

View File

@ -0,0 +1,43 @@
From f04aaed5402f847ea0127de7ca573d39c57da891 Mon Sep 17 00:00:00 2001
From: Yonghong Song <yhs@fb.com>
Date: Sat, 26 Nov 2022 17:41:33 -0800
Subject: [PATCH] Fix a llvm compilation error
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
With latest llvm16, I got the following compilation error:
/.../src/cc/bpf_module.cc: In member function void ebpf::BPFModule::dump_ir(llvm::Module&):
/.../src/cc/bpf_module.cc:259:15: error: PrintModulePass was not declared in this scope
MPM.addPass(PrintModulePass(errs()));
^~~~~~~~~~~~~~~
...
The error is due to the llvm patch https://reviews.llvm.org/D138081.
Fix the issue by adjust corresponding header file locaiton
as in the above llvm patch.
Signed-off-by: Yonghong Song <yhs@fb.com>
---
src/cc/bpf_module.cc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/cc/bpf_module.cc b/src/cc/bpf_module.cc
index 490fffe8..0f4a4f58 100644
--- a/src/cc/bpf_module.cc
+++ b/src/cc/bpf_module.cc
@@ -20,7 +20,11 @@
#include <llvm-c/Transforms/IPO.h>
#include <llvm/ExecutionEngine/MCJIT.h>
#include <llvm/ExecutionEngine/SectionMemoryManager.h>
+#if LLVM_MAJOR_VERSION >= 16
+#include <llvm/IRPrinter/IRPrintingPasses.h>
+#else
#include <llvm/IR/IRPrintingPasses.h>
+#endif
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/Module.h>
--
2.40.1

View File

@ -0,0 +1,42 @@
From 0d563f713780eb274ebf995660917482452c127e Mon Sep 17 00:00:00 2001
From: Yonghong Song <yhs@fb.com>
Date: Fri, 26 Aug 2022 16:34:24 -0700
Subject: [PATCH 1/2] Fix a llvm signed division error for compactsnoop tool
Fix issue #4182.
llvm doesn't support signed division and an assertion error
will happen when the IR contains sdiv. The reason is
due to code
zone - zone_pgdat->node_zones
where zone and zone_pgdat->node_zones are pointers to
struct zone (with size 1664). So effectively the above
is equivalent to
((void *)zone - (void *)zone_pgdat->node_zones)/sizeof(struct zone)
which is converted to sdiv insn.
llvm11 seems okay and I didn't investigate why. But llvm14 and
latest llvm16 failed with compiler fatal error.
To fix the issue let us replace the above '(void *)' as
'(u64)' and then the udiv will be used for the division.
Signed-off-by: Yonghong Song <yhs@fb.com>
---
tools/compactsnoop.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/compactsnoop.py b/tools/compactsnoop.py
index 9daaf485..bf3c9b4b 100755
--- a/tools/compactsnoop.py
+++ b/tools/compactsnoop.py
@@ -124,7 +124,7 @@ static inline int zone_idx_(struct zone *zone)
{
struct pglist_data *zone_pgdat = NULL;
bpf_probe_read_kernel(&zone_pgdat, sizeof(zone_pgdat), &zone->zone_pgdat);
- return zone - zone_pgdat->node_zones;
+ return ((u64)zone - (u64)zone_pgdat->node_zones)/sizeof(struct zone);
}
#ifdef EXTNEDED_FIELDS
--
2.39.2

View File

@ -0,0 +1,43 @@
From 73b15c15bdf3327c86de524ded528c6c6061ff3d Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
Date: Wed, 3 May 2023 16:16:52 +0200
Subject: [PATCH] Revert "tools: Fix bindsnoop for kernel v5.6"
This reverts commit f96fed0a3b9682ce52a35a02f72880395582d855.
---
tools/bindsnoop.py | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/tools/bindsnoop.py b/tools/bindsnoop.py
index 07503352..ac3a8aa0 100755
--- a/tools/bindsnoop.py
+++ b/tools/bindsnoop.py
@@ -27,7 +27,7 @@
# 14-Feb-2020 Pavel Dubovitsky Created this.
from __future__ import print_function, absolute_import, unicode_literals
-from bcc import BPF
+from bcc import BPF, DEBUG_SOURCE
from bcc.containers import filter_by_containers
from bcc.utils import printb
import argparse
@@ -243,14 +243,10 @@ static int bindsnoop_return(struct pt_regs *ctx, short ipver)
opts.fields.reuseport = bitfield >> 4 & 0x01;
// workaround for reading the sk_protocol bitfield (from tcpaccept.py):
- u16 protocol;
+ u8 protocol;
int gso_max_segs_offset = offsetof(struct sock, sk_gso_max_segs);
int sk_lingertime_offset = offsetof(struct sock, sk_lingertime);
-
- // Since kernel v5.6 sk_protocol has its own u16 field
- if (sk_lingertime_offset - gso_max_segs_offset == 2)
- protocol = skp->sk_protocol;
- else if (sk_lingertime_offset - gso_max_segs_offset == 4)
+ if (sk_lingertime_offset - gso_max_segs_offset == 4)
// 4.10+ with little endian
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
protocol = *(u8 *)((u64)&skp->sk_gso_max_segs - 3);
--
2.40.1

View File

@ -0,0 +1,71 @@
From 2fd4457e52d56825e12a4037630aea3f82241a02 Mon Sep 17 00:00:00 2001
From: Rong Tao <rongtao@cestc.cn>
Date: Fri, 10 Feb 2023 23:28:55 +0800
Subject: [PATCH 2/2] tools/compactsnoop.py: Fix raw_tracepoint Invalid
argument error
kernel commit abd4349ff9b8("mm: compaction: cleanup the compaction trace
events") change the arguments of 'mm_compaction_begin' from (start_pfn,
migrate_pfn, free_pfn, end_pfn, sync) to (cc, start_pfn, end_pfn, sync),
and change the arguments of 'mm_compaction_end' from (start_pfn,
migrate_pfn, free_pfn, end_pfn, sync, ret) to (cc, start_pfn, end_pfn,
sync, ret).
Replacing RAW_TRACEPOINT_PROBE with TRACEPOINT_PROBE solves this problem
and guarantees compatibility.
$ sudo ./compactsnoop.py
bpf_attach_raw_tracepoint (mm_compaction_begin): Invalid argument
Traceback (most recent call last):
File "/home/sdb/Git/bcc/tools/./compactsnoop.py", line 292, in <module>
b = BPF(text=bpf_text)
^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/bcc/__init__.py", line 483, in __init__
self._trace_autoload()
File "/usr/lib/python3.11/site-packages/bcc/__init__.py", line 1462, in _trace_autoload
self.attach_raw_tracepoint(tp=tp, fn_name=fn.name)
File "/usr/lib/python3.11/site-packages/bcc/__init__.py", line 1055, in attach_raw_tracepoint
raise Exception("Failed to attach BPF to raw tracepoint")
Exception: Failed to attach BPF to raw tracepoint
Signed-off-by: Rong Tao <rongtao@cestc.cn>
---
tools/compactsnoop.py | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/tools/compactsnoop.py b/tools/compactsnoop.py
index bf3c9b4b..e9baa9b4 100755
--- a/tools/compactsnoop.py
+++ b/tools/compactsnoop.py
@@ -237,11 +237,9 @@ RAW_TRACEPOINT_PROBE(mm_compaction_suitable)
return 0;
}
-RAW_TRACEPOINT_PROBE(mm_compaction_begin)
+TRACEPOINT_PROBE(compaction, mm_compaction_begin)
{
- // TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn,
- // unsigned long free_pfn, unsigned long zone_end, bool sync)
- bool sync = (bool)ctx->args[4];
+ bool sync = args->sync;
u64 id = bpf_get_current_pid_tgid();
struct val_t *valp = start.lookup(&id);
@@ -255,12 +253,9 @@ RAW_TRACEPOINT_PROBE(mm_compaction_begin)
return 0;
}
-RAW_TRACEPOINT_PROBE(mm_compaction_end)
+TRACEPOINT_PROBE(compaction, mm_compaction_end)
{
- // TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn,
- // unsigned long free_pfn, unsigned long zone_end, bool sync,
- // int status)
- submit_event(ctx, ctx->args[5]);
+ submit_event(args, args->status);
return 0;
}
"""
--
2.39.2

View File

@ -0,0 +1,49 @@
From 1d8419056e128ae49107d27e5f55d1bfa8134e3a Mon Sep 17 00:00:00 2001
From: Rong Tao <rongtao@cestc.cn>
Date: Fri, 10 Feb 2023 22:16:56 +0800
Subject: [PATCH] tools/nfsslower.py: Fix uninitialized struct pad error
The verifier is unhappy, if data struct _pad_ is not initialized, see [0][1].
$ sudo ./nfsslower.py
...
; bpf_perf_event_output(ctx, (void *)bpf_pseudo_fd(1, -2), CUR_CPU_IDENTIFIER, &data, sizeof(data));
83: (79) r1 = *(u64 *)(r10 -144) ; R1_w=ctx(off=0,imm=0) R10=fp0
84: (18) r3 = 0xffffffff ; R3_w=4294967295
86: (b7) r5 = 96 ; R5_w=96
87: (85) call bpf_perf_event_output#25
invalid indirect read from stack R4 off -136+92 size 96
processed 84 insns (limit 1000000) max_states_per_insn 0 total_states 4 peak_states 4 mark_read 4
...
raise Exception("Failed to load BPF program %s: %s" %
Exception: Failed to load BPF program b'raw_tracepoint__nfs_commit_done': Permission denied
[0] https://github.com/iovisor/bcc/issues/2623
[1] https://github.com/iovisor/bcc/pull/4453
Signed-off-by: Rong Tao <rongtao@cestc.cn>
---
tools/nfsslower.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/nfsslower.py b/tools/nfsslower.py
index b5df8f19..c2c243b3 100755
--- a/tools/nfsslower.py
+++ b/tools/nfsslower.py
@@ -179,8 +179,11 @@ static int trace_exit(struct pt_regs *ctx, int type)
// populate output struct
u32 size = PT_REGS_RC(ctx);
- struct data_t data = {.type = type, .size = size, .delta_us = delta_us,
- .pid = pid};
+ struct data_t data = {};
+ data.type = type;
+ data.size = size;
+ data.delta_us = delta_us;
+ data.pid = pid;
data.ts_us = ts / 1000;
data.offset = valp->offset;
bpf_get_current_comm(&data.task, sizeof(data.task));
--
2.40.1

View File

@ -9,7 +9,7 @@
Name: bcc
Version: 0.25.0
Release: 2%{?dist}
Release: 5%{?dist}
Summary: BPF Compiler Collection (BCC)
License: ASL 2.0
URL: https://github.com/iovisor/bcc
@ -21,6 +21,11 @@ Patch3: %{name}-%{version}-Fix-bpf_pseudo_fd-type-conversion-error.patch
Patch4: %{name}-%{version}-Fix-clang-15-int-to-pointer-conversion-errors.patch
Patch5: %{name}-%{version}-Revert-tools-tcpaccept-Fix-support-for-v5.6-kernels.patch
Patch6: %{name}-%{version}-Fix-get_kprobe_functions.patch
Patch7: %{name}-%{version}-Fix-a-llvm-signed-division-error-for-compactsnoop-to.patch
Patch8: %{name}-%{version}-tools-compactsnoop.py-Fix-raw_tracepoint-Invalid-arg.patch
Patch9: %{name}-%{version}-Revert-tools-Fix-bindsnoop-for-kernel-v5.6.patch
Patch10: %{name}-%{version}-tools-nfsslower.py-Fix-uninitialized-struct-pad-erro.patch
Patch11: %{name}-%{version}-Fix-a-llvm-compilation-error.patch
# Arches will be included as upstream support is added and dependencies are
# satisfied in the respective arches
@ -218,6 +223,24 @@ done
%changelog
* Mon Jun 12 2023 Jerome Marchand <jmarchan@redhat.com> - 0.25.0-5
- Fix LLVM 16 build
* Thu Jun 08 2023 Jerome Marchand <jmarchan@redhat.com> - 0.25.0-4
- Add missing patch.
* Mon May 15 2023 Jerome Marchand <jmarchan@redhat.com> - 0.25.0-3
- Rebuild with llvm 16 (RHBZ#2192949)
- Fix compactsnoop (RHBZ#2042238)
- Fix bindsnoop (RHBZ#2155200)
- Fix nfsslower (RHBZ#2155163)
* Fri Mar 03 2023 bstinson@redhat.com - 0.25.0-2.0.2
- One final rebuild in CentOS Stream only
* Wed Mar 01 2023 bstinson@redhat.com - 0.25.0-2.0.1
- Rebuild in CentOS Stream only for library link issue
* Tue Jan 10 2023 Jerome Marchand <jmarchan@redhat.com> - 0.25.0-2
- Fix tcpdrop tool