parent
97a3296918
commit
ce9f4e1249
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in new issue