|
|
1910f2 |
From 5848b9fe9ad49151492cb2652a06921fa4b49031 Mon Sep 17 00:00:00 2001
|
|
|
1910f2 |
From: Jerome Marchand <jmarchan@redhat.com>
|
|
|
1910f2 |
Date: Thu, 16 Aug 2018 14:58:56 +0200
|
|
|
1910f2 |
Subject: [PATCH] Fix tools for RHEL 7
|
|
|
1910f2 |
|
|
|
1910f2 |
There some differences on RHEL 7 that make some tools fail. This patch
|
|
|
1910f2 |
fixes the following:
|
|
|
1910f2 |
- missing /sys/kernel/debug/kprobes/blacklist file
|
|
|
1910f2 |
- missing __vfs_read() function
|
|
|
1910f2 |
- aio_read/write methods replaced by read/write_iter in file_operations
|
|
|
1910f2 |
- changes in mnt_namespace structure
|
|
|
1910f2 |
- change in finish_task_switch() argument list
|
|
|
1910f2 |
- changes in sock_common struct
|
|
|
1910f2 |
- missing TCP_NEW_SYN_RECV TCP state
|
|
|
1910f2 |
- mm_page_alloc tracepoint returns page struct instead of PFN
|
|
|
1910f2 |
- iocb argument removed from tcp_sendmsg()
|
|
|
1910f2 |
---
|
|
|
1910f2 |
src/python/bcc/__init__.py | 7 +++++--
|
|
|
1910f2 |
tools/btrfsdist.py | 13 +++++++------
|
|
|
1910f2 |
tools/btrfsslower.py | 13 +++++++------
|
|
|
1910f2 |
tools/cpudist.py | 4 +++-
|
|
|
1910f2 |
tools/ext4dist.py | 11 ++++++-----
|
|
|
1910f2 |
tools/ext4slower.py | 13 +++++++------
|
|
|
1910f2 |
tools/fileslower.py | 13 +++++++++----
|
|
|
1910f2 |
tools/memleak.py | 12 ++++++++++--
|
|
|
1910f2 |
tools/mountsnoop.py | 9 ++++-----
|
|
|
1910f2 |
tools/nfsslower.py | 1 +
|
|
|
1910f2 |
tools/offcputime.py | 4 +++-
|
|
|
1910f2 |
tools/offwaketime.py | 4 +++-
|
|
|
1910f2 |
tools/oomkill.py | 8 ++++----
|
|
|
1910f2 |
tools/runqlat.py | 2 +-
|
|
|
1910f2 |
tools/runqslower.py | 2 +-
|
|
|
1910f2 |
tools/solisten.py | 2 +-
|
|
|
1910f2 |
tools/tcpsubnet.py | 4 ++--
|
|
|
1910f2 |
tools/tcptracer.py | 9 ++++-----
|
|
|
1910f2 |
tools/xfsdist.py | 8 ++++----
|
|
|
1910f2 |
tools/xfsslower.py | 11 ++++++-----
|
|
|
1910f2 |
20 files changed, 88 insertions(+), 62 deletions(-)
|
|
|
1910f2 |
|
|
|
1910f2 |
diff --git a/src/python/bcc/__init__.py b/src/python/bcc/__init__.py
|
|
|
1910f2 |
index bff5f282..19933cf7 100644
|
|
|
1910f2 |
--- a/src/python/bcc/__init__.py
|
|
|
1910f2 |
+++ b/src/python/bcc/__init__.py
|
|
|
1910f2 |
@@ -525,8 +525,11 @@ DEBUG_BTF = 0x20
|
|
|
1910f2 |
|
|
|
1910f2 |
@staticmethod
|
|
|
1910f2 |
def get_kprobe_functions(event_re):
|
|
|
1910f2 |
- with open("%s/../kprobes/blacklist" % TRACEFS, "rb") as blacklist_f:
|
|
|
1910f2 |
- blacklist = set([line.rstrip().split()[1] for line in blacklist_f])
|
|
|
1910f2 |
+ try:
|
|
|
1910f2 |
+ with open("%s/../kprobes/blacklist" % TRACEFS, "rb") as blacklist_f:
|
|
|
1910f2 |
+ blacklist = set([line.rstrip().split()[1] for line in blacklist_f])
|
|
|
1910f2 |
+ except:
|
|
|
1910f2 |
+ blacklist = set()
|
|
|
1910f2 |
fns = []
|
|
|
1910f2 |
|
|
|
1910f2 |
in_init_section = 0
|
|
|
1910f2 |
diff --git a/tools/btrfsdist.py b/tools/btrfsdist.py
|
|
|
1910f2 |
index 4659ab46..3326b67a 100755
|
|
|
1910f2 |
--- a/tools/btrfsdist.py
|
|
|
1910f2 |
+++ b/tools/btrfsdist.py
|
|
|
1910f2 |
@@ -60,6 +60,7 @@ debug = 0
|
|
|
1910f2 |
bpf_text = """
|
|
|
1910f2 |
#include <uapi/linux/ptrace.h>
|
|
|
1910f2 |
#include <linux/fs.h>
|
|
|
1910f2 |
+#include <linux/aio.h>
|
|
|
1910f2 |
#include <linux/sched.h>
|
|
|
1910f2 |
|
|
|
1910f2 |
#define OP_NAME_LEN 8
|
|
|
1910f2 |
@@ -81,7 +82,7 @@ int trace_entry(struct pt_regs *ctx)
|
|
|
1910f2 |
return 0;
|
|
|
1910f2 |
}
|
|
|
1910f2 |
|
|
|
1910f2 |
-// The current btrfs (Linux 4.5) uses generic_file_read_iter() instead of it's
|
|
|
1910f2 |
+// btrfs uses generic_file_aio_read() instead of it's
|
|
|
1910f2 |
// own read function. So we need to trace that and then filter on btrfs, which
|
|
|
1910f2 |
// I do by checking file->f_op.
|
|
|
1910f2 |
int trace_read_entry(struct pt_regs *ctx, struct kiocb *iocb)
|
|
|
1910f2 |
@@ -193,13 +194,13 @@ bpf_text = bpf_text.replace('FACTOR', str(factor))
|
|
|
1910f2 |
# load BPF program
|
|
|
1910f2 |
b = BPF(text=bpf_text)
|
|
|
1910f2 |
|
|
|
1910f2 |
-# Common file functions. See earlier comment about generic_file_read_iter().
|
|
|
1910f2 |
-b.attach_kprobe(event="generic_file_read_iter", fn_name="trace_read_entry")
|
|
|
1910f2 |
-b.attach_kprobe(event="btrfs_file_write_iter", fn_name="trace_entry")
|
|
|
1910f2 |
+# Common file functions. See earlier comment about generic_file_aio_read().
|
|
|
1910f2 |
+b.attach_kprobe(event="generic_file_aio_read", fn_name="trace_read_entry")
|
|
|
1910f2 |
+b.attach_kprobe(event="btrfs_file_aio_write", fn_name="trace_entry")
|
|
|
1910f2 |
b.attach_kprobe(event="generic_file_open", fn_name="trace_open_entry")
|
|
|
1910f2 |
b.attach_kprobe(event="btrfs_sync_file", fn_name="trace_entry")
|
|
|
1910f2 |
-b.attach_kretprobe(event="generic_file_read_iter", fn_name="trace_read_return")
|
|
|
1910f2 |
-b.attach_kretprobe(event="btrfs_file_write_iter", fn_name="trace_write_return")
|
|
|
1910f2 |
+b.attach_kretprobe(event="generic_file_aio_read", fn_name="trace_read_return")
|
|
|
1910f2 |
+b.attach_kretprobe(event="btrfs_file_aio_write", fn_name="trace_write_return")
|
|
|
1910f2 |
b.attach_kretprobe(event="generic_file_open", fn_name="trace_open_return")
|
|
|
1910f2 |
b.attach_kretprobe(event="btrfs_sync_file", fn_name="trace_fsync_return")
|
|
|
1910f2 |
|
|
|
1910f2 |
diff --git a/tools/btrfsslower.py b/tools/btrfsslower.py
|
|
|
1910f2 |
index bacbc06a..b650cea0 100755
|
|
|
1910f2 |
--- a/tools/btrfsslower.py
|
|
|
1910f2 |
+++ b/tools/btrfsslower.py
|
|
|
1910f2 |
@@ -62,6 +62,7 @@ debug = 0
|
|
|
1910f2 |
bpf_text = """
|
|
|
1910f2 |
#include <uapi/linux/ptrace.h>
|
|
|
1910f2 |
#include <linux/fs.h>
|
|
|
1910f2 |
+#include <linux/aio.h>
|
|
|
1910f2 |
#include <linux/sched.h>
|
|
|
1910f2 |
#include <linux/dcache.h>
|
|
|
1910f2 |
|
|
|
1910f2 |
@@ -96,7 +97,7 @@ BPF_PERF_OUTPUT(events);
|
|
|
1910f2 |
// Store timestamp and size on entry
|
|
|
1910f2 |
//
|
|
|
1910f2 |
|
|
|
1910f2 |
-// The current btrfs (Linux 4.5) uses generic_file_read_iter() instead of it's
|
|
|
1910f2 |
+// btrfs uses generic_file_aio_read() instead of it's
|
|
|
1910f2 |
// own read function. So we need to trace that and then filter on btrfs, which
|
|
|
1910f2 |
// I do by checking file->f_op.
|
|
|
1910f2 |
int trace_read_entry(struct pt_regs *ctx, struct kiocb *iocb)
|
|
|
1910f2 |
@@ -123,7 +124,7 @@ int trace_read_entry(struct pt_regs *ctx, struct kiocb *iocb)
|
|
|
1910f2 |
return 0;
|
|
|
1910f2 |
}
|
|
|
1910f2 |
|
|
|
1910f2 |
-// btrfs_file_write_iter():
|
|
|
1910f2 |
+// btrfs_file_aio_write():
|
|
|
1910f2 |
int trace_write_entry(struct pt_regs *ctx, struct kiocb *iocb)
|
|
|
1910f2 |
{
|
|
|
1910f2 |
u64 id = bpf_get_current_pid_tgid();
|
|
|
1910f2 |
@@ -313,12 +314,12 @@ int trace_fsync_return(struct pt_regs *ctx)
|
|
|
1910f2 |
b = BPF(text=bpf_text)
|
|
|
1910f2 |
|
|
|
1910f2 |
# Common file functions. See earlier comment about generic_*().
|
|
|
1910f2 |
-b.attach_kprobe(event="generic_file_read_iter", fn_name="trace_read_entry")
|
|
|
1910f2 |
-b.attach_kprobe(event="btrfs_file_write_iter", fn_name="trace_write_entry")
|
|
|
1910f2 |
+b.attach_kprobe(event="generic_file_aio_read", fn_name="trace_read_entry")
|
|
|
1910f2 |
+b.attach_kprobe(event="btrfs_file_aio_write", fn_name="trace_write_entry")
|
|
|
1910f2 |
b.attach_kprobe(event="generic_file_open", fn_name="trace_open_entry")
|
|
|
1910f2 |
b.attach_kprobe(event="btrfs_sync_file", fn_name="trace_fsync_entry")
|
|
|
1910f2 |
-b.attach_kretprobe(event="generic_file_read_iter", fn_name="trace_read_return")
|
|
|
1910f2 |
-b.attach_kretprobe(event="btrfs_file_write_iter", fn_name="trace_write_return")
|
|
|
1910f2 |
+b.attach_kretprobe(event="generic_file_aio_read", fn_name="trace_read_return")
|
|
|
1910f2 |
+b.attach_kretprobe(event="btrfs_file_aio_write", fn_name="trace_write_return")
|
|
|
1910f2 |
b.attach_kretprobe(event="generic_file_open", fn_name="trace_open_return")
|
|
|
1910f2 |
b.attach_kretprobe(event="btrfs_sync_file", fn_name="trace_fsync_return")
|
|
|
1910f2 |
|
|
|
1910f2 |
diff --git a/tools/cpudist.py b/tools/cpudist.py
|
|
|
1910f2 |
index 4d7c9eb4..ddb675e2 100755
|
|
|
1910f2 |
--- a/tools/cpudist.py
|
|
|
1910f2 |
+++ b/tools/cpudist.py
|
|
|
1910f2 |
@@ -94,7 +94,9 @@ static inline void update_hist(u32 tgid, u32 pid, u64 ts)
|
|
|
1910f2 |
STORE
|
|
|
1910f2 |
}
|
|
|
1910f2 |
|
|
|
1910f2 |
-int sched_switch(struct pt_regs *ctx, struct task_struct *prev)
|
|
|
1910f2 |
+struct rq;
|
|
|
1910f2 |
+
|
|
|
1910f2 |
+int sched_switch(struct pt_regs *ctx, struct rq *rq, struct task_struct *prev)
|
|
|
1910f2 |
{
|
|
|
1910f2 |
u64 ts = bpf_ktime_get_ns();
|
|
|
1910f2 |
u64 pid_tgid = bpf_get_current_pid_tgid();
|
|
|
1910f2 |
diff --git a/tools/ext4dist.py b/tools/ext4dist.py
|
|
|
1910f2 |
index 384a4c14..559e4a5f 100755
|
|
|
1910f2 |
--- a/tools/ext4dist.py
|
|
|
1910f2 |
+++ b/tools/ext4dist.py
|
|
|
1910f2 |
@@ -60,6 +60,7 @@ debug = 0
|
|
|
1910f2 |
bpf_text = """
|
|
|
1910f2 |
#include <uapi/linux/ptrace.h>
|
|
|
1910f2 |
#include <linux/fs.h>
|
|
|
1910f2 |
+#include <linux/aio.h>
|
|
|
1910f2 |
#include <linux/sched.h>
|
|
|
1910f2 |
|
|
|
1910f2 |
#define OP_NAME_LEN 8
|
|
|
1910f2 |
@@ -136,18 +137,18 @@ int trace_fsync_return(struct pt_regs *ctx)
|
|
|
1910f2 |
"""
|
|
|
1910f2 |
|
|
|
1910f2 |
# Starting from Linux 4.10 ext4_file_operations.read_iter has been changed from
|
|
|
1910f2 |
-# using generic_file_read_iter() to its own ext4_file_read_iter().
|
|
|
1910f2 |
+# using generic_file_aio_read() to its own ext4_file_read_iter().
|
|
|
1910f2 |
#
|
|
|
1910f2 |
# To detect the proper function to trace check if ext4_file_read_iter() is
|
|
|
1910f2 |
# defined in /proc/kallsyms, if it's defined attach to that function, otherwise
|
|
|
1910f2 |
-# use generic_file_read_iter() and inside the trace hook filter on ext4 read
|
|
|
1910f2 |
+# use generic_file_aio_read() and inside the trace hook filter on ext4 read
|
|
|
1910f2 |
# events (checking if file->f_op == ext4_file_operations).
|
|
|
1910f2 |
if BPF.get_kprobe_functions(b'ext4_file_read_iter'):
|
|
|
1910f2 |
ext4_read_fn = 'ext4_file_read_iter'
|
|
|
1910f2 |
ext4_trace_read_fn = 'trace_entry'
|
|
|
1910f2 |
ext4_trace_read_code = ''
|
|
|
1910f2 |
else:
|
|
|
1910f2 |
- ext4_read_fn = 'generic_file_read_iter'
|
|
|
1910f2 |
+ ext4_read_fn = 'generic_file_aio_read'
|
|
|
1910f2 |
ext4_trace_read_fn = 'trace_read_entry'
|
|
|
1910f2 |
ext4_file_ops_addr = ''
|
|
|
1910f2 |
with open(kallsyms) as syms:
|
|
|
1910f2 |
@@ -194,11 +195,11 @@ bpf_text = bpf_text.replace('FACTOR', str(factor))
|
|
|
1910f2 |
b = BPF(text=bpf_text)
|
|
|
1910f2 |
|
|
|
1910f2 |
b.attach_kprobe(event=ext4_read_fn, fn_name=ext4_trace_read_fn)
|
|
|
1910f2 |
-b.attach_kprobe(event="ext4_file_write_iter", fn_name="trace_entry")
|
|
|
1910f2 |
+b.attach_kprobe(event="ext4_file_write", fn_name="trace_entry")
|
|
|
1910f2 |
b.attach_kprobe(event="ext4_file_open", fn_name="trace_entry")
|
|
|
1910f2 |
b.attach_kprobe(event="ext4_sync_file", fn_name="trace_entry")
|
|
|
1910f2 |
b.attach_kretprobe(event=ext4_read_fn, fn_name='trace_read_return')
|
|
|
1910f2 |
-b.attach_kretprobe(event="ext4_file_write_iter", fn_name="trace_write_return")
|
|
|
1910f2 |
+b.attach_kretprobe(event="ext4_file_write", fn_name="trace_write_return")
|
|
|
1910f2 |
b.attach_kretprobe(event="ext4_file_open", fn_name="trace_open_return")
|
|
|
1910f2 |
b.attach_kretprobe(event="ext4_sync_file", fn_name="trace_fsync_return")
|
|
|
1910f2 |
|
|
|
1910f2 |
diff --git a/tools/ext4slower.py b/tools/ext4slower.py
|
|
|
1910f2 |
index 0524f22e..d5fbb661 100755
|
|
|
1910f2 |
--- a/tools/ext4slower.py
|
|
|
1910f2 |
+++ b/tools/ext4slower.py
|
|
|
1910f2 |
@@ -63,6 +63,7 @@ debug = 0
|
|
|
1910f2 |
bpf_text = """
|
|
|
1910f2 |
#include <uapi/linux/ptrace.h>
|
|
|
1910f2 |
#include <linux/fs.h>
|
|
|
1910f2 |
+#include <linux/aio.h>
|
|
|
1910f2 |
#include <linux/sched.h>
|
|
|
1910f2 |
#include <linux/dcache.h>
|
|
|
1910f2 |
|
|
|
1910f2 |
@@ -97,7 +98,7 @@ BPF_PERF_OUTPUT(events);
|
|
|
1910f2 |
// Store timestamp and size on entry
|
|
|
1910f2 |
//
|
|
|
1910f2 |
|
|
|
1910f2 |
-// The current ext4 (Linux 4.5) uses generic_file_read_iter(), instead of it's
|
|
|
1910f2 |
+// ext4 uses generic_file_aio_read(), instead of it's
|
|
|
1910f2 |
// own function, for reads. So we need to trace that and then filter on ext4,
|
|
|
1910f2 |
// which I do by checking file->f_op.
|
|
|
1910f2 |
// The new Linux version (since form 4.10) uses ext4_file_read_iter(), And if the 'CONFIG_FS_DAX'
|
|
|
1910f2 |
@@ -127,7 +128,7 @@ int trace_read_entry(struct pt_regs *ctx, struct kiocb *iocb)
|
|
|
1910f2 |
return 0;
|
|
|
1910f2 |
}
|
|
|
1910f2 |
|
|
|
1910f2 |
-// ext4_file_write_iter():
|
|
|
1910f2 |
+// ext4_file_write():
|
|
|
1910f2 |
int trace_write_entry(struct pt_regs *ctx, struct kiocb *iocb)
|
|
|
1910f2 |
{
|
|
|
1910f2 |
u64 id = bpf_get_current_pid_tgid();
|
|
|
1910f2 |
@@ -314,15 +315,15 @@ b = BPF(text=bpf_text)
|
|
|
1910f2 |
if BPF.get_kprobe_functions(b'ext4_file_read_iter'):
|
|
|
1910f2 |
b.attach_kprobe(event="ext4_file_read_iter", fn_name="trace_read_entry")
|
|
|
1910f2 |
else:
|
|
|
1910f2 |
- b.attach_kprobe(event="generic_file_read_iter", fn_name="trace_read_entry")
|
|
|
1910f2 |
-b.attach_kprobe(event="ext4_file_write_iter", fn_name="trace_write_entry")
|
|
|
1910f2 |
+ b.attach_kprobe(event="generic_file_aio_read", fn_name="trace_read_entry")
|
|
|
1910f2 |
+b.attach_kprobe(event="ext4_file_write", fn_name="trace_write_entry")
|
|
|
1910f2 |
b.attach_kprobe(event="ext4_file_open", fn_name="trace_open_entry")
|
|
|
1910f2 |
b.attach_kprobe(event="ext4_sync_file", fn_name="trace_fsync_entry")
|
|
|
1910f2 |
if BPF.get_kprobe_functions(b'ext4_file_read_iter'):
|
|
|
1910f2 |
b.attach_kretprobe(event="ext4_file_read_iter", fn_name="trace_read_return")
|
|
|
1910f2 |
else:
|
|
|
1910f2 |
- b.attach_kretprobe(event="generic_file_read_iter", fn_name="trace_read_return")
|
|
|
1910f2 |
-b.attach_kretprobe(event="ext4_file_write_iter", fn_name="trace_write_return")
|
|
|
1910f2 |
+ b.attach_kretprobe(event="generic_file_aio_read", fn_name="trace_read_return")
|
|
|
1910f2 |
+b.attach_kretprobe(event="ext4_file_write", fn_name="trace_write_return")
|
|
|
1910f2 |
b.attach_kretprobe(event="ext4_file_open", fn_name="trace_open_return")
|
|
|
1910f2 |
b.attach_kretprobe(event="ext4_sync_file", fn_name="trace_fsync_return")
|
|
|
1910f2 |
|
|
|
1910f2 |
diff --git a/tools/fileslower.py b/tools/fileslower.py
|
|
|
1910f2 |
index 31e3adf9..05582c9e 100755
|
|
|
1910f2 |
--- a/tools/fileslower.py
|
|
|
1910f2 |
+++ b/tools/fileslower.py
|
|
|
1910f2 |
@@ -123,7 +123,7 @@ int trace_read_entry(struct pt_regs *ctx, struct file *file,
|
|
|
1910f2 |
char __user *buf, size_t count)
|
|
|
1910f2 |
{
|
|
|
1910f2 |
// skip non-sync I/O; see kernel code for __vfs_read()
|
|
|
1910f2 |
- if (!(file->f_op->read_iter))
|
|
|
1910f2 |
+ if (!(file->f_op->aio_read))
|
|
|
1910f2 |
return 0;
|
|
|
1910f2 |
return trace_rw_entry(ctx, file, buf, count);
|
|
|
1910f2 |
}
|
|
|
1910f2 |
@@ -132,7 +132,7 @@ int trace_write_entry(struct pt_regs *ctx, struct file *file,
|
|
|
1910f2 |
char __user *buf, size_t count)
|
|
|
1910f2 |
{
|
|
|
1910f2 |
// skip non-sync I/O; see kernel code for __vfs_write()
|
|
|
1910f2 |
- if (!(file->f_op->write_iter))
|
|
|
1910f2 |
+ if (!(file->f_op->aio_write))
|
|
|
1910f2 |
return 0;
|
|
|
1910f2 |
return trace_rw_entry(ctx, file, buf, count);
|
|
|
1910f2 |
}
|
|
|
1910f2 |
@@ -199,8 +199,13 @@ b = BPF(text=bpf_text)
|
|
|
1910f2 |
# do_sync_read/do_sync_write), but those became static. So trace these from
|
|
|
1910f2 |
# the parent functions, at the cost of more overhead, instead.
|
|
|
1910f2 |
# Ultimately, we should be using [V]FS tracepoints.
|
|
|
1910f2 |
-b.attach_kprobe(event="__vfs_read", fn_name="trace_read_entry")
|
|
|
1910f2 |
-b.attach_kretprobe(event="__vfs_read", fn_name="trace_read_return")
|
|
|
1910f2 |
+try:
|
|
|
1910f2 |
+ b.attach_kprobe(event="__vfs_read", fn_name="trace_read_entry")
|
|
|
1910f2 |
+ b.attach_kretprobe(event="__vfs_read", fn_name="trace_read_return")
|
|
|
1910f2 |
+except:
|
|
|
1910f2 |
+ # older kernels don't have __vfs_read so try vfs_read instead
|
|
|
1910f2 |
+ b.attach_kprobe(event="vfs_read", fn_name="trace_read_entry")
|
|
|
1910f2 |
+ b.attach_kretprobe(event="vfs_read", fn_name="trace_read_return")
|
|
|
1910f2 |
try:
|
|
|
1910f2 |
b.attach_kprobe(event="__vfs_write", fn_name="trace_write_entry")
|
|
|
1910f2 |
b.attach_kretprobe(event="__vfs_write", fn_name="trace_write_return")
|
|
|
1910f2 |
diff --git a/tools/memleak.py b/tools/memleak.py
|
|
|
1910f2 |
index fd08bc4d..db8b927a 100755
|
|
|
1910f2 |
--- a/tools/memleak.py
|
|
|
1910f2 |
+++ b/tools/memleak.py
|
|
|
1910f2 |
@@ -357,13 +357,21 @@ TRACEPOINT_PROBE(kmem, kmem_cache_free) {
|
|
|
1910f2 |
return gen_free_enter((struct pt_regs *)args, (void *)args->ptr);
|
|
|
1910f2 |
}
|
|
|
1910f2 |
|
|
|
1910f2 |
+/*
|
|
|
1910f2 |
+ * Upstream reads the PFN here, but on RHEL7 kernel this is not available
|
|
|
1910f2 |
+ * and the address of the pages struct is returned instead. This value is
|
|
|
1910f2 |
+ * used as the key in a hash to identify each allocation. No other allocation
|
|
|
1910f2 |
+ * should return an address belonging to mem_map, so there's no risk of
|
|
|
1910f2 |
+ * colision
|
|
|
1910f2 |
+ */
|
|
|
1910f2 |
+
|
|
|
1910f2 |
TRACEPOINT_PROBE(kmem, mm_page_alloc) {
|
|
|
1910f2 |
gen_alloc_enter((struct pt_regs *)args, PAGE_SIZE << args->order);
|
|
|
1910f2 |
- return gen_alloc_exit2((struct pt_regs *)args, args->pfn);
|
|
|
1910f2 |
+ return gen_alloc_exit2((struct pt_regs *)args, (size_t)args->page);
|
|
|
1910f2 |
}
|
|
|
1910f2 |
|
|
|
1910f2 |
TRACEPOINT_PROBE(kmem, mm_page_free) {
|
|
|
1910f2 |
- return gen_free_enter((struct pt_regs *)args, (void *)args->pfn);
|
|
|
1910f2 |
+ return gen_free_enter((struct pt_regs *)args, (void *)args->page);
|
|
|
1910f2 |
}
|
|
|
1910f2 |
"""
|
|
|
1910f2 |
|
|
|
1910f2 |
diff --git a/tools/mountsnoop.py b/tools/mountsnoop.py
|
|
|
1910f2 |
index eefb4ec7..5f3678b3 100755
|
|
|
1910f2 |
--- a/tools/mountsnoop.py
|
|
|
1910f2 |
+++ b/tools/mountsnoop.py
|
|
|
1910f2 |
@@ -24,7 +24,6 @@ bpf_text = r"""
|
|
|
1910f2 |
#include <linux/sched.h>
|
|
|
1910f2 |
|
|
|
1910f2 |
#include <linux/nsproxy.h>
|
|
|
1910f2 |
-#include <linux/ns_common.h>
|
|
|
1910f2 |
|
|
|
1910f2 |
/*
|
|
|
1910f2 |
* XXX: struct mnt_namespace is defined in fs/mount.h, which is private to the
|
|
|
1910f2 |
@@ -34,7 +33,7 @@ bpf_text = r"""
|
|
|
1910f2 |
*/
|
|
|
1910f2 |
struct mnt_namespace {
|
|
|
1910f2 |
atomic_t count;
|
|
|
1910f2 |
- struct ns_common ns;
|
|
|
1910f2 |
+ unsigned int proc_inum;
|
|
|
1910f2 |
};
|
|
|
1910f2 |
|
|
|
1910f2 |
/*
|
|
|
1910f2 |
@@ -69,7 +68,7 @@ struct data_t {
|
|
|
1910f2 |
union {
|
|
|
1910f2 |
/* EVENT_MOUNT, EVENT_UMOUNT */
|
|
|
1910f2 |
struct {
|
|
|
1910f2 |
- /* current->nsproxy->mnt_ns->ns.inum */
|
|
|
1910f2 |
+ /* current->nsproxy->proc_inum */
|
|
|
1910f2 |
unsigned int mnt_ns;
|
|
|
1910f2 |
char comm[TASK_COMM_LEN];
|
|
|
1910f2 |
unsigned long flags;
|
|
|
1910f2 |
@@ -106,7 +105,7 @@ int syscall__mount(struct pt_regs *ctx, char __user *source,
|
|
|
1910f2 |
task = (struct task_struct *)bpf_get_current_task();
|
|
|
1910f2 |
nsproxy = task->nsproxy;
|
|
|
1910f2 |
mnt_ns = nsproxy->mnt_ns;
|
|
|
1910f2 |
- event.enter.mnt_ns = mnt_ns->ns.inum;
|
|
|
1910f2 |
+ event.enter.mnt_ns = mnt_ns->proc_inum;
|
|
|
1910f2 |
events.perf_submit(ctx, &event, sizeof(event));
|
|
|
1910f2 |
|
|
|
1910f2 |
event.type = EVENT_MOUNT_SOURCE;
|
|
|
1910f2 |
@@ -161,7 +160,7 @@ int syscall__umount(struct pt_regs *ctx, char __user *target, int flags)
|
|
|
1910f2 |
task = (struct task_struct *)bpf_get_current_task();
|
|
|
1910f2 |
nsproxy = task->nsproxy;
|
|
|
1910f2 |
mnt_ns = nsproxy->mnt_ns;
|
|
|
1910f2 |
- event.enter.mnt_ns = mnt_ns->ns.inum;
|
|
|
1910f2 |
+ event.enter.mnt_ns = mnt_ns->proc_inum;
|
|
|
1910f2 |
events.perf_submit(ctx, &event, sizeof(event));
|
|
|
1910f2 |
|
|
|
1910f2 |
event.type = EVENT_UMOUNT_TARGET;
|
|
|
1910f2 |
diff --git a/tools/nfsslower.py b/tools/nfsslower.py
|
|
|
1910f2 |
index 36918ca0..9c6d8f6c 100755
|
|
|
1910f2 |
--- a/tools/nfsslower.py
|
|
|
1910f2 |
+++ b/tools/nfsslower.py
|
|
|
1910f2 |
@@ -64,6 +64,7 @@ bpf_text = """
|
|
|
1910f2 |
|
|
|
1910f2 |
#include <uapi/linux/ptrace.h>
|
|
|
1910f2 |
#include <linux/fs.h>
|
|
|
1910f2 |
+#include <linux/aio.h>
|
|
|
1910f2 |
#include <linux/sched.h>
|
|
|
1910f2 |
#include <linux/dcache.h>
|
|
|
1910f2 |
|
|
|
1910f2 |
diff --git a/tools/offcputime.py b/tools/offcputime.py
|
|
|
1910f2 |
index ac3b7281..ea36b264 100755
|
|
|
1910f2 |
--- a/tools/offcputime.py
|
|
|
1910f2 |
+++ b/tools/offcputime.py
|
|
|
1910f2 |
@@ -128,7 +128,9 @@ BPF_HASH(counts, struct key_t);
|
|
|
1910f2 |
BPF_HASH(start, u32);
|
|
|
1910f2 |
BPF_STACK_TRACE(stack_traces, STACK_STORAGE_SIZE);
|
|
|
1910f2 |
|
|
|
1910f2 |
-int oncpu(struct pt_regs *ctx, struct task_struct *prev) {
|
|
|
1910f2 |
+struct rq;
|
|
|
1910f2 |
+
|
|
|
1910f2 |
+int oncpu(struct pt_regs *ctx, struct rq *rq, struct task_struct *prev) {
|
|
|
1910f2 |
u32 pid = prev->pid;
|
|
|
1910f2 |
u32 tgid = prev->tgid;
|
|
|
1910f2 |
u64 ts, *tsp;
|
|
|
1910f2 |
diff --git a/tools/offwaketime.py b/tools/offwaketime.py
|
|
|
1910f2 |
index 4a1cebab..baa28801 100755
|
|
|
1910f2 |
--- a/tools/offwaketime.py
|
|
|
1910f2 |
+++ b/tools/offwaketime.py
|
|
|
1910f2 |
@@ -163,7 +163,9 @@ int waker(struct pt_regs *ctx, struct task_struct *p) {
|
|
|
1910f2 |
return 0;
|
|
|
1910f2 |
}
|
|
|
1910f2 |
|
|
|
1910f2 |
-int oncpu(struct pt_regs *ctx, struct task_struct *p) {
|
|
|
1910f2 |
+struct rq;
|
|
|
1910f2 |
+
|
|
|
1910f2 |
+int oncpu(struct pt_regs *ctx, struct rq *rq, struct task_struct *p) {
|
|
|
1910f2 |
// PID and TGID of the previous Process (Process going into waiting)
|
|
|
1910f2 |
u32 pid = p->pid;
|
|
|
1910f2 |
u32 tgid = p->tgid;
|
|
|
1910f2 |
diff --git a/tools/oomkill.py b/tools/oomkill.py
|
|
|
1910f2 |
index 4f3b6ce7..546c2dc6 100755
|
|
|
1910f2 |
--- a/tools/oomkill.py
|
|
|
1910f2 |
+++ b/tools/oomkill.py
|
|
|
1910f2 |
@@ -35,15 +35,15 @@ struct data_t {
|
|
|
1910f2 |
|
|
|
1910f2 |
BPF_PERF_OUTPUT(events);
|
|
|
1910f2 |
|
|
|
1910f2 |
-void kprobe__oom_kill_process(struct pt_regs *ctx, struct oom_control *oc, const char *message)
|
|
|
1910f2 |
+void kprobe__oom_kill_process(struct pt_regs *ctx, struct task_struct *p,
|
|
|
1910f2 |
+ gfp_t gfp_mask, int order, unsigned int points,
|
|
|
1910f2 |
+ unsigned long totalpages, struct mem_cgroup *memcg)
|
|
|
1910f2 |
{
|
|
|
1910f2 |
- unsigned long totalpages;
|
|
|
1910f2 |
- struct task_struct *p = oc->chosen;
|
|
|
1910f2 |
struct data_t data = {};
|
|
|
1910f2 |
u32 pid = bpf_get_current_pid_tgid();
|
|
|
1910f2 |
data.fpid = pid;
|
|
|
1910f2 |
data.tpid = p->pid;
|
|
|
1910f2 |
- data.pages = oc->totalpages;
|
|
|
1910f2 |
+ data.pages = totalpages;
|
|
|
1910f2 |
bpf_get_current_comm(&data.fcomm, sizeof(data.fcomm));
|
|
|
1910f2 |
bpf_probe_read(&data.tcomm, sizeof(data.tcomm), p->comm);
|
|
|
1910f2 |
events.perf_submit(ctx, &data, sizeof(data));
|
|
|
1910f2 |
diff --git a/tools/runqlat.py b/tools/runqlat.py
|
|
|
1910f2 |
index 9fd40642..0c9bb1c4 100755
|
|
|
1910f2 |
--- a/tools/runqlat.py
|
|
|
1910f2 |
+++ b/tools/runqlat.py
|
|
|
1910f2 |
@@ -111,7 +111,7 @@ int trace_ttwu_do_wakeup(struct pt_regs *ctx, struct rq *rq, struct task_struct
|
|
|
1910f2 |
}
|
|
|
1910f2 |
|
|
|
1910f2 |
// calculate latency
|
|
|
1910f2 |
-int trace_run(struct pt_regs *ctx, struct task_struct *prev)
|
|
|
1910f2 |
+int trace_run(struct pt_regs *ctx, struct rq *rq, struct task_struct *prev)
|
|
|
1910f2 |
{
|
|
|
1910f2 |
u32 pid, tgid;
|
|
|
1910f2 |
|
|
|
1910f2 |
diff --git a/tools/runqslower.py b/tools/runqslower.py
|
|
|
1910f2 |
index 1d48be8a..16a5a4c2 100755
|
|
|
1910f2 |
--- a/tools/runqslower.py
|
|
|
1910f2 |
+++ b/tools/runqslower.py
|
|
|
1910f2 |
@@ -97,7 +97,7 @@ int trace_ttwu_do_wakeup(struct pt_regs *ctx, struct rq *rq, struct task_struct
|
|
|
1910f2 |
}
|
|
|
1910f2 |
|
|
|
1910f2 |
// calculate latency
|
|
|
1910f2 |
-int trace_run(struct pt_regs *ctx, struct task_struct *prev)
|
|
|
1910f2 |
+int trace_run(struct pt_regs *ctx, struct rq *rq, struct task_struct *prev)
|
|
|
1910f2 |
{
|
|
|
1910f2 |
u32 pid, tgid;
|
|
|
1910f2 |
|
|
|
1910f2 |
diff --git a/tools/solisten.py b/tools/solisten.py
|
|
|
1910f2 |
index f2a0a342..16872212 100755
|
|
|
1910f2 |
--- a/tools/solisten.py
|
|
|
1910f2 |
+++ b/tools/solisten.py
|
|
|
1910f2 |
@@ -100,7 +100,7 @@ int kprobe__inet_listen(struct pt_regs *ctx, struct socket *sock, int backlog)
|
|
|
1910f2 |
|
|
|
1910f2 |
// Get network namespace id, if kernel supports it
|
|
|
1910f2 |
#ifdef CONFIG_NET_NS
|
|
|
1910f2 |
- evt.netns = sk->__sk_common.skc_net.net->ns.inum;
|
|
|
1910f2 |
+ evt.netns = sk->__sk_common.skc_net->proc_inum;
|
|
|
1910f2 |
#else
|
|
|
1910f2 |
evt.netns = 0;
|
|
|
1910f2 |
#endif
|
|
|
1910f2 |
diff --git a/tools/tcpsubnet.py b/tools/tcpsubnet.py
|
|
|
1910f2 |
index 5f2a8062..1ba275bc 100755
|
|
|
1910f2 |
--- a/tools/tcpsubnet.py
|
|
|
1910f2 |
+++ b/tools/tcpsubnet.py
|
|
|
1910f2 |
@@ -110,8 +110,8 @@ struct index_key_t {
|
|
|
1910f2 |
|
|
|
1910f2 |
BPF_HASH(ipv4_send_bytes, struct index_key_t);
|
|
|
1910f2 |
|
|
|
1910f2 |
-int kprobe__tcp_sendmsg(struct pt_regs *ctx, struct sock *sk,
|
|
|
1910f2 |
- struct msghdr *msg, size_t size)
|
|
|
1910f2 |
+int kprobe__tcp_sendmsg(struct pt_regs *ctx, struct kiocb *iocb,
|
|
|
1910f2 |
+ struct sock *sk, struct msghdr *msg, size_t size)
|
|
|
1910f2 |
{
|
|
|
1910f2 |
u16 family = sk->__sk_common.skc_family;
|
|
|
1910f2 |
|
|
|
1910f2 |
diff --git a/tools/tcptracer.py b/tools/tcptracer.py
|
|
|
1910f2 |
index e61fe9ba..f00f0d19 100755
|
|
|
1910f2 |
--- a/tools/tcptracer.py
|
|
|
1910f2 |
+++ b/tools/tcptracer.py
|
|
|
1910f2 |
@@ -115,7 +115,7 @@ static int read_ipv4_tuple(struct ipv4_tuple_t *tuple, struct sock *skp)
|
|
|
1910f2 |
u16 sport = sockp->inet_sport;
|
|
|
1910f2 |
u16 dport = skp->__sk_common.skc_dport;
|
|
|
1910f2 |
#ifdef CONFIG_NET_NS
|
|
|
1910f2 |
- net_ns_inum = skp->__sk_common.skc_net.net->ns.inum;
|
|
|
1910f2 |
+ net_ns_inum = skp->__sk_common.skc_net->proc_inum;
|
|
|
1910f2 |
#endif
|
|
|
1910f2 |
|
|
|
1910f2 |
##FILTER_NETNS##
|
|
|
1910f2 |
@@ -142,7 +142,7 @@ static int read_ipv6_tuple(struct ipv6_tuple_t *tuple, struct sock *skp)
|
|
|
1910f2 |
u16 sport = sockp->inet_sport;
|
|
|
1910f2 |
u16 dport = skp->__sk_common.skc_dport;
|
|
|
1910f2 |
#ifdef CONFIG_NET_NS
|
|
|
1910f2 |
- net_ns_inum = skp->__sk_common.skc_net.net->ns.inum;
|
|
|
1910f2 |
+ net_ns_inum = skp->__sk_common.skc_net->proc_inum;
|
|
|
1910f2 |
#endif
|
|
|
1910f2 |
bpf_probe_read(&saddr, sizeof(saddr),
|
|
|
1910f2 |
skp->__sk_common.skc_v6_rcv_saddr.in6_u.u6_addr32);
|
|
|
1910f2 |
@@ -360,8 +360,7 @@ int trace_close_entry(struct pt_regs *ctx, struct sock *skp)
|
|
|
1910f2 |
// Don't generate close events for connections that were never
|
|
|
1910f2 |
// established in the first place.
|
|
|
1910f2 |
if (oldstate == TCP_SYN_SENT ||
|
|
|
1910f2 |
- oldstate == TCP_SYN_RECV ||
|
|
|
1910f2 |
- oldstate == TCP_NEW_SYN_RECV)
|
|
|
1910f2 |
+ oldstate == TCP_SYN_RECV )
|
|
|
1910f2 |
return 0;
|
|
|
1910f2 |
|
|
|
1910f2 |
u8 ipver = 0;
|
|
|
1910f2 |
@@ -432,7 +431,7 @@ int trace_accept_return(struct pt_regs *ctx)
|
|
|
1910f2 |
|
|
|
1910f2 |
// Get network namespace id, if kernel supports it
|
|
|
1910f2 |
#ifdef CONFIG_NET_NS
|
|
|
1910f2 |
- net_ns_inum = newsk->__sk_common.skc_net.net->ns.inum;
|
|
|
1910f2 |
+ net_ns_inum = newsk->__sk_common.skc_net->proc_inum;
|
|
|
1910f2 |
#endif
|
|
|
1910f2 |
|
|
|
1910f2 |
##FILTER_NETNS##
|
|
|
1910f2 |
diff --git a/tools/xfsdist.py b/tools/xfsdist.py
|
|
|
1910f2 |
index f409f90d..2976f9e2 100755
|
|
|
1910f2 |
--- a/tools/xfsdist.py
|
|
|
1910f2 |
+++ b/tools/xfsdist.py
|
|
|
1910f2 |
@@ -137,12 +137,12 @@ bpf_text = bpf_text.replace('FACTOR', str(factor))
|
|
|
1910f2 |
b = BPF(text=bpf_text)
|
|
|
1910f2 |
|
|
|
1910f2 |
# common file functions
|
|
|
1910f2 |
-b.attach_kprobe(event="xfs_file_read_iter", fn_name="trace_entry")
|
|
|
1910f2 |
-b.attach_kprobe(event="xfs_file_write_iter", fn_name="trace_entry")
|
|
|
1910f2 |
+b.attach_kprobe(event="xfs_file_aio_read", fn_name="trace_entry")
|
|
|
1910f2 |
+b.attach_kprobe(event="xfs_file_aio_write", fn_name="trace_entry")
|
|
|
1910f2 |
b.attach_kprobe(event="xfs_file_open", fn_name="trace_entry")
|
|
|
1910f2 |
b.attach_kprobe(event="xfs_file_fsync", fn_name="trace_entry")
|
|
|
1910f2 |
-b.attach_kretprobe(event="xfs_file_read_iter", fn_name="trace_read_return")
|
|
|
1910f2 |
-b.attach_kretprobe(event="xfs_file_write_iter", fn_name="trace_write_return")
|
|
|
1910f2 |
+b.attach_kretprobe(event="xfs_file_aio_read", fn_name="trace_read_return")
|
|
|
1910f2 |
+b.attach_kretprobe(event="xfs_file_aio_write", fn_name="trace_write_return")
|
|
|
1910f2 |
b.attach_kretprobe(event="xfs_file_open", fn_name="trace_open_return")
|
|
|
1910f2 |
b.attach_kretprobe(event="xfs_file_fsync", fn_name="trace_fsync_return")
|
|
|
1910f2 |
|
|
|
1910f2 |
diff --git a/tools/xfsslower.py b/tools/xfsslower.py
|
|
|
1910f2 |
index 9fa12566..0ef50f6e 100755
|
|
|
1910f2 |
--- a/tools/xfsslower.py
|
|
|
1910f2 |
+++ b/tools/xfsslower.py
|
|
|
1910f2 |
@@ -59,6 +59,7 @@ debug = 0
|
|
|
1910f2 |
bpf_text = """
|
|
|
1910f2 |
#include <uapi/linux/ptrace.h>
|
|
|
1910f2 |
#include <linux/fs.h>
|
|
|
1910f2 |
+#include <linux/aio.h>
|
|
|
1910f2 |
#include <linux/sched.h>
|
|
|
1910f2 |
#include <linux/dcache.h>
|
|
|
1910f2 |
|
|
|
1910f2 |
@@ -93,7 +94,7 @@ BPF_PERF_OUTPUT(events);
|
|
|
1910f2 |
// Store timestamp and size on entry
|
|
|
1910f2 |
//
|
|
|
1910f2 |
|
|
|
1910f2 |
-// xfs_file_read_iter(), xfs_file_write_iter():
|
|
|
1910f2 |
+// xfs_file_aio_read(), xfs_file_aio_write():
|
|
|
1910f2 |
int trace_rw_entry(struct pt_regs *ctx, struct kiocb *iocb)
|
|
|
1910f2 |
{
|
|
|
1910f2 |
u64 id = bpf_get_current_pid_tgid();
|
|
|
1910f2 |
@@ -264,12 +265,12 @@ int trace_fsync_return(struct pt_regs *ctx)
|
|
|
1910f2 |
b = BPF(text=bpf_text)
|
|
|
1910f2 |
|
|
|
1910f2 |
# common file functions
|
|
|
1910f2 |
-b.attach_kprobe(event="xfs_file_read_iter", fn_name="trace_rw_entry")
|
|
|
1910f2 |
-b.attach_kprobe(event="xfs_file_write_iter", fn_name="trace_rw_entry")
|
|
|
1910f2 |
+b.attach_kprobe(event="xfs_file_aio_read", fn_name="trace_rw_entry")
|
|
|
1910f2 |
+b.attach_kprobe(event="xfs_file_aio_write", fn_name="trace_rw_entry")
|
|
|
1910f2 |
b.attach_kprobe(event="xfs_file_open", fn_name="trace_open_entry")
|
|
|
1910f2 |
b.attach_kprobe(event="xfs_file_fsync", fn_name="trace_fsync_entry")
|
|
|
1910f2 |
-b.attach_kretprobe(event="xfs_file_read_iter", fn_name="trace_read_return")
|
|
|
1910f2 |
-b.attach_kretprobe(event="xfs_file_write_iter", fn_name="trace_write_return")
|
|
|
1910f2 |
+b.attach_kretprobe(event="xfs_file_aio_read", fn_name="trace_read_return")
|
|
|
1910f2 |
+b.attach_kretprobe(event="xfs_file_aio_write", fn_name="trace_write_return")
|
|
|
1910f2 |
b.attach_kretprobe(event="xfs_file_open", fn_name="trace_open_return")
|
|
|
1910f2 |
b.attach_kretprobe(event="xfs_file_fsync", fn_name="trace_fsync_return")
|
|
|
1910f2 |
|
|
|
1910f2 |
--
|
|
|
1910f2 |
2.20.1
|
|
|
1910f2 |
|