|
|
2a0312 |
From ac5050ea551af40b47bf2010e179e9020acada69 Mon Sep 17 00:00:00 2001
|
|
|
80cbd0 |
From: Jerome Marchand <jmarchan@redhat.com>
|
|
|
80cbd0 |
Date: Thu, 16 Aug 2018 14:58:56 +0200
|
|
|
80cbd0 |
Subject: [PATCH] Fix tools for RHEL 7
|
|
|
80cbd0 |
|
|
|
80cbd0 |
There some differences on RHEL 7 that make some tools fail. This patch
|
|
|
80cbd0 |
fixes the following:
|
|
|
80cbd0 |
- missing /sys/kernel/debug/kprobes/blacklist file
|
|
|
80cbd0 |
- missing __vfs_read() function
|
|
|
80cbd0 |
- aio_read/write methods replaced by read/write_iter in file_operations
|
|
|
80cbd0 |
- changes in mnt_namespace structure
|
|
|
80cbd0 |
- change in finish_task_switch() argument list
|
|
|
80cbd0 |
- changes in sock_common struct
|
|
|
80cbd0 |
- missing TCP_NEW_SYN_RECV TCP state
|
|
|
80cbd0 |
- mm_page_alloc tracepoint returns page struct instead of PFN
|
|
|
80cbd0 |
- iocb argument removed from tcp_sendmsg()
|
|
|
80cbd0 |
---
|
|
|
80cbd0 |
src/python/bcc/__init__.py | 7 +++++--
|
|
|
80cbd0 |
tools/btrfsdist.py | 13 +++++++------
|
|
|
80cbd0 |
tools/btrfsslower.py | 13 +++++++------
|
|
|
80cbd0 |
tools/cpudist.py | 4 +++-
|
|
|
80cbd0 |
tools/ext4dist.py | 11 ++++++-----
|
|
|
80cbd0 |
tools/ext4slower.py | 13 +++++++------
|
|
|
80cbd0 |
tools/fileslower.py | 13 +++++++++----
|
|
|
80cbd0 |
tools/memleak.py | 12 ++++++++++--
|
|
|
80cbd0 |
tools/mountsnoop.py | 9 ++++-----
|
|
|
80cbd0 |
tools/nfsslower.py | 1 +
|
|
|
80cbd0 |
tools/offcputime.py | 4 +++-
|
|
|
80cbd0 |
tools/offwaketime.py | 4 +++-
|
|
|
2a0312 |
tools/oomkill.py | 8 ++++----
|
|
|
80cbd0 |
tools/runqlat.py | 2 +-
|
|
|
80cbd0 |
tools/runqslower.py | 2 +-
|
|
|
80cbd0 |
tools/solisten.py | 2 +-
|
|
|
80cbd0 |
tools/tcpsubnet.py | 4 ++--
|
|
|
80cbd0 |
tools/tcptracer.py | 9 ++++-----
|
|
|
80cbd0 |
tools/xfsdist.py | 8 ++++----
|
|
|
80cbd0 |
tools/xfsslower.py | 11 ++++++-----
|
|
|
2a0312 |
20 files changed, 88 insertions(+), 62 deletions(-)
|
|
|
80cbd0 |
|
|
|
80cbd0 |
diff --git a/src/python/bcc/__init__.py b/src/python/bcc/__init__.py
|
|
|
2a0312 |
index 1d99afd..f38d23f 100644
|
|
|
80cbd0 |
--- a/src/python/bcc/__init__.py
|
|
|
80cbd0 |
+++ b/src/python/bcc/__init__.py
|
|
|
2a0312 |
@@ -511,8 +511,11 @@ DEBUG_BPF_REGISTER_STATE = 0x10
|
|
|
80cbd0 |
|
|
|
80cbd0 |
@staticmethod
|
|
|
80cbd0 |
def get_kprobe_functions(event_re):
|
|
|
80cbd0 |
- with open("%s/../kprobes/blacklist" % TRACEFS, "rb") as blacklist_f:
|
|
|
80cbd0 |
- blacklist = set([line.rstrip().split()[1] for line in blacklist_f])
|
|
|
80cbd0 |
+ try:
|
|
|
80cbd0 |
+ with open("%s/../kprobes/blacklist" % TRACEFS, "rb") as blacklist_f:
|
|
|
80cbd0 |
+ blacklist = set([line.rstrip().split()[1] for line in blacklist_f])
|
|
|
80cbd0 |
+ except:
|
|
|
80cbd0 |
+ blacklist = set()
|
|
|
80cbd0 |
fns = []
|
|
|
80cbd0 |
|
|
|
80cbd0 |
in_init_section = 0
|
|
|
80cbd0 |
diff --git a/tools/btrfsdist.py b/tools/btrfsdist.py
|
|
|
2a0312 |
index a0aeb24..3f179d0 100755
|
|
|
80cbd0 |
--- a/tools/btrfsdist.py
|
|
|
80cbd0 |
+++ b/tools/btrfsdist.py
|
|
|
80cbd0 |
@@ -60,6 +60,7 @@ debug = 0
|
|
|
80cbd0 |
bpf_text = """
|
|
|
80cbd0 |
#include <uapi/linux/ptrace.h>
|
|
|
80cbd0 |
#include <linux/fs.h>
|
|
|
80cbd0 |
+#include <linux/aio.h>
|
|
|
80cbd0 |
#include <linux/sched.h>
|
|
|
80cbd0 |
|
|
|
80cbd0 |
#define OP_NAME_LEN 8
|
|
|
80cbd0 |
@@ -81,7 +82,7 @@ int trace_entry(struct pt_regs *ctx)
|
|
|
80cbd0 |
return 0;
|
|
|
80cbd0 |
}
|
|
|
80cbd0 |
|
|
|
80cbd0 |
-// The current btrfs (Linux 4.5) uses generic_file_read_iter() instead of it's
|
|
|
80cbd0 |
+// btrfs uses generic_file_aio_read() instead of it's
|
|
|
80cbd0 |
// own read function. So we need to trace that and then filter on btrfs, which
|
|
|
80cbd0 |
// I do by checking file->f_op.
|
|
|
80cbd0 |
int trace_read_entry(struct pt_regs *ctx, struct kiocb *iocb)
|
|
|
80cbd0 |
@@ -193,13 +194,13 @@ bpf_text = bpf_text.replace('FACTOR', str(factor))
|
|
|
80cbd0 |
# load BPF program
|
|
|
80cbd0 |
b = BPF(text=bpf_text)
|
|
|
80cbd0 |
|
|
|
80cbd0 |
-# Common file functions. See earlier comment about generic_file_read_iter().
|
|
|
80cbd0 |
-b.attach_kprobe(event="generic_file_read_iter", fn_name="trace_read_entry")
|
|
|
80cbd0 |
-b.attach_kprobe(event="btrfs_file_write_iter", fn_name="trace_entry")
|
|
|
80cbd0 |
+# Common file functions. See earlier comment about generic_file_aio_read().
|
|
|
80cbd0 |
+b.attach_kprobe(event="generic_file_aio_read", fn_name="trace_read_entry")
|
|
|
80cbd0 |
+b.attach_kprobe(event="btrfs_file_aio_write", fn_name="trace_entry")
|
|
|
80cbd0 |
b.attach_kprobe(event="generic_file_open", fn_name="trace_open_entry")
|
|
|
80cbd0 |
b.attach_kprobe(event="btrfs_sync_file", fn_name="trace_entry")
|
|
|
80cbd0 |
-b.attach_kretprobe(event="generic_file_read_iter", fn_name="trace_read_return")
|
|
|
80cbd0 |
-b.attach_kretprobe(event="btrfs_file_write_iter", fn_name="trace_write_return")
|
|
|
80cbd0 |
+b.attach_kretprobe(event="generic_file_aio_read", fn_name="trace_read_return")
|
|
|
80cbd0 |
+b.attach_kretprobe(event="btrfs_file_aio_write", fn_name="trace_write_return")
|
|
|
80cbd0 |
b.attach_kretprobe(event="generic_file_open", fn_name="trace_open_return")
|
|
|
80cbd0 |
b.attach_kretprobe(event="btrfs_sync_file", fn_name="trace_fsync_return")
|
|
|
80cbd0 |
|
|
|
80cbd0 |
diff --git a/tools/btrfsslower.py b/tools/btrfsslower.py
|
|
|
2a0312 |
index cff61b8..26aff65 100755
|
|
|
80cbd0 |
--- a/tools/btrfsslower.py
|
|
|
80cbd0 |
+++ b/tools/btrfsslower.py
|
|
|
80cbd0 |
@@ -63,6 +63,7 @@ debug = 0
|
|
|
80cbd0 |
bpf_text = """
|
|
|
80cbd0 |
#include <uapi/linux/ptrace.h>
|
|
|
80cbd0 |
#include <linux/fs.h>
|
|
|
80cbd0 |
+#include <linux/aio.h>
|
|
|
80cbd0 |
#include <linux/sched.h>
|
|
|
80cbd0 |
#include <linux/dcache.h>
|
|
|
80cbd0 |
|
|
|
80cbd0 |
@@ -97,7 +98,7 @@ BPF_PERF_OUTPUT(events);
|
|
|
80cbd0 |
// Store timestamp and size on entry
|
|
|
80cbd0 |
//
|
|
|
80cbd0 |
|
|
|
80cbd0 |
-// The current btrfs (Linux 4.5) uses generic_file_read_iter() instead of it's
|
|
|
80cbd0 |
+// btrfs uses generic_file_aio_read() instead of it's
|
|
|
80cbd0 |
// own read function. So we need to trace that and then filter on btrfs, which
|
|
|
80cbd0 |
// I do by checking file->f_op.
|
|
|
80cbd0 |
int trace_read_entry(struct pt_regs *ctx, struct kiocb *iocb)
|
|
|
80cbd0 |
@@ -124,7 +125,7 @@ int trace_read_entry(struct pt_regs *ctx, struct kiocb *iocb)
|
|
|
80cbd0 |
return 0;
|
|
|
80cbd0 |
}
|
|
|
80cbd0 |
|
|
|
80cbd0 |
-// btrfs_file_write_iter():
|
|
|
80cbd0 |
+// btrfs_file_aio_write():
|
|
|
80cbd0 |
int trace_write_entry(struct pt_regs *ctx, struct kiocb *iocb)
|
|
|
80cbd0 |
{
|
|
|
80cbd0 |
u64 id = bpf_get_current_pid_tgid();
|
|
|
2a0312 |
@@ -329,12 +330,12 @@ TASK_COMM_LEN = 16 # linux/sched.h
|
|
|
80cbd0 |
b = BPF(text=bpf_text)
|
|
|
80cbd0 |
|
|
|
80cbd0 |
# Common file functions. See earlier comment about generic_*().
|
|
|
80cbd0 |
-b.attach_kprobe(event="generic_file_read_iter", fn_name="trace_read_entry")
|
|
|
80cbd0 |
-b.attach_kprobe(event="btrfs_file_write_iter", fn_name="trace_write_entry")
|
|
|
80cbd0 |
+b.attach_kprobe(event="generic_file_aio_read", fn_name="trace_read_entry")
|
|
|
80cbd0 |
+b.attach_kprobe(event="btrfs_file_aio_write", fn_name="trace_write_entry")
|
|
|
80cbd0 |
b.attach_kprobe(event="generic_file_open", fn_name="trace_open_entry")
|
|
|
80cbd0 |
b.attach_kprobe(event="btrfs_sync_file", fn_name="trace_fsync_entry")
|
|
|
80cbd0 |
-b.attach_kretprobe(event="generic_file_read_iter", fn_name="trace_read_return")
|
|
|
80cbd0 |
-b.attach_kretprobe(event="btrfs_file_write_iter", fn_name="trace_write_return")
|
|
|
80cbd0 |
+b.attach_kretprobe(event="generic_file_aio_read", fn_name="trace_read_return")
|
|
|
80cbd0 |
+b.attach_kretprobe(event="btrfs_file_aio_write", fn_name="trace_write_return")
|
|
|
80cbd0 |
b.attach_kretprobe(event="generic_file_open", fn_name="trace_open_return")
|
|
|
80cbd0 |
b.attach_kretprobe(event="btrfs_sync_file", fn_name="trace_fsync_return")
|
|
|
80cbd0 |
|
|
|
80cbd0 |
diff --git a/tools/cpudist.py b/tools/cpudist.py
|
|
|
2a0312 |
index 9e61341..e5fd550 100755
|
|
|
80cbd0 |
--- a/tools/cpudist.py
|
|
|
80cbd0 |
+++ b/tools/cpudist.py
|
|
|
80cbd0 |
@@ -94,7 +94,9 @@ static inline void update_hist(u32 tgid, u32 pid, u64 ts)
|
|
|
80cbd0 |
STORE
|
|
|
80cbd0 |
}
|
|
|
80cbd0 |
|
|
|
80cbd0 |
-int sched_switch(struct pt_regs *ctx, struct task_struct *prev)
|
|
|
80cbd0 |
+struct rq;
|
|
|
80cbd0 |
+
|
|
|
80cbd0 |
+int sched_switch(struct pt_regs *ctx, struct rq *rq, struct task_struct *prev)
|
|
|
80cbd0 |
{
|
|
|
80cbd0 |
u64 ts = bpf_ktime_get_ns();
|
|
|
80cbd0 |
u64 pid_tgid = bpf_get_current_pid_tgid();
|
|
|
80cbd0 |
diff --git a/tools/ext4dist.py b/tools/ext4dist.py
|
|
|
2a0312 |
index b71cfda..a6a7e55 100755
|
|
|
80cbd0 |
--- a/tools/ext4dist.py
|
|
|
80cbd0 |
+++ b/tools/ext4dist.py
|
|
|
80cbd0 |
@@ -60,6 +60,7 @@ debug = 0
|
|
|
80cbd0 |
bpf_text = """
|
|
|
80cbd0 |
#include <uapi/linux/ptrace.h>
|
|
|
80cbd0 |
#include <linux/fs.h>
|
|
|
80cbd0 |
+#include <linux/aio.h>
|
|
|
80cbd0 |
#include <linux/sched.h>
|
|
|
80cbd0 |
|
|
|
80cbd0 |
#define OP_NAME_LEN 8
|
|
|
80cbd0 |
@@ -81,7 +82,7 @@ int trace_entry(struct pt_regs *ctx)
|
|
|
80cbd0 |
return 0;
|
|
|
80cbd0 |
}
|
|
|
80cbd0 |
|
|
|
80cbd0 |
-// The current ext4 (Linux 4.5) uses generic_file_read_iter(), instead of it's
|
|
|
80cbd0 |
+// ext4 uses generic_file_aio_read(), instead of it's
|
|
|
80cbd0 |
// own function, for reads. So we need to trace that and then filter on ext4,
|
|
|
80cbd0 |
// which I do by checking file->f_op.
|
|
|
80cbd0 |
int trace_read_entry(struct pt_regs *ctx, struct kiocb *iocb)
|
|
|
2a0312 |
@@ -189,12 +190,12 @@ b = BPF(text=bpf_text)
|
|
|
2a0312 |
if BPF.get_kprobe_functions(b'ext4_file_read_iter'):
|
|
|
80cbd0 |
b.attach_kprobe(event="ext4_file_read_iter", fn_name="trace_entry")
|
|
|
80cbd0 |
else:
|
|
|
80cbd0 |
- b.attach_kprobe(event="generic_file_read_iter", fn_name="trace_read_entry")
|
|
|
80cbd0 |
-b.attach_kprobe(event="ext4_file_write_iter", fn_name="trace_entry")
|
|
|
80cbd0 |
+ b.attach_kprobe(event="generic_file_aio_read", fn_name="trace_read_entry")
|
|
|
80cbd0 |
+b.attach_kprobe(event="ext4_file_write", fn_name="trace_entry")
|
|
|
80cbd0 |
b.attach_kprobe(event="ext4_file_open", fn_name="trace_entry")
|
|
|
80cbd0 |
b.attach_kprobe(event="ext4_sync_file", fn_name="trace_entry")
|
|
|
80cbd0 |
-b.attach_kretprobe(event="generic_file_read_iter", fn_name="trace_read_return")
|
|
|
80cbd0 |
-b.attach_kretprobe(event="ext4_file_write_iter", fn_name="trace_write_return")
|
|
|
80cbd0 |
+b.attach_kretprobe(event="generic_file_aio_read", fn_name="trace_read_return")
|
|
|
80cbd0 |
+b.attach_kretprobe(event="ext4_file_write", fn_name="trace_write_return")
|
|
|
80cbd0 |
b.attach_kretprobe(event="ext4_file_open", fn_name="trace_open_return")
|
|
|
80cbd0 |
b.attach_kretprobe(event="ext4_sync_file", fn_name="trace_fsync_return")
|
|
|
80cbd0 |
|
|
|
80cbd0 |
diff --git a/tools/ext4slower.py b/tools/ext4slower.py
|
|
|
2a0312 |
index 344e68f..fe90046 100755
|
|
|
80cbd0 |
--- a/tools/ext4slower.py
|
|
|
80cbd0 |
+++ b/tools/ext4slower.py
|
|
|
80cbd0 |
@@ -64,6 +64,7 @@ debug = 0
|
|
|
80cbd0 |
bpf_text = """
|
|
|
80cbd0 |
#include <uapi/linux/ptrace.h>
|
|
|
80cbd0 |
#include <linux/fs.h>
|
|
|
80cbd0 |
+#include <linux/aio.h>
|
|
|
80cbd0 |
#include <linux/sched.h>
|
|
|
80cbd0 |
#include <linux/dcache.h>
|
|
|
80cbd0 |
|
|
|
80cbd0 |
@@ -98,7 +99,7 @@ BPF_PERF_OUTPUT(events);
|
|
|
80cbd0 |
// Store timestamp and size on entry
|
|
|
80cbd0 |
//
|
|
|
80cbd0 |
|
|
|
80cbd0 |
-// The current ext4 (Linux 4.5) uses generic_file_read_iter(), instead of it's
|
|
|
80cbd0 |
+// ext4 uses generic_file_aio_read(), instead of it's
|
|
|
80cbd0 |
// own function, for reads. So we need to trace that and then filter on ext4,
|
|
|
80cbd0 |
// which I do by checking file->f_op.
|
|
|
80cbd0 |
// The new Linux version (since form 4.10) uses ext4_file_read_iter(), And if the 'CONFIG_FS_DAX'
|
|
|
80cbd0 |
@@ -128,7 +129,7 @@ int trace_read_entry(struct pt_regs *ctx, struct kiocb *iocb)
|
|
|
80cbd0 |
return 0;
|
|
|
80cbd0 |
}
|
|
|
80cbd0 |
|
|
|
80cbd0 |
-// ext4_file_write_iter():
|
|
|
80cbd0 |
+// ext4_file_write():
|
|
|
80cbd0 |
int trace_write_entry(struct pt_regs *ctx, struct kiocb *iocb)
|
|
|
80cbd0 |
{
|
|
|
80cbd0 |
u64 id = bpf_get_current_pid_tgid();
|
|
|
2a0312 |
@@ -330,15 +331,15 @@ b = BPF(text=bpf_text)
|
|
|
80cbd0 |
if BPF.get_kprobe_functions(b'ext4_file_read_iter'):
|
|
|
80cbd0 |
b.attach_kprobe(event="ext4_file_read_iter", fn_name="trace_read_entry")
|
|
|
80cbd0 |
else:
|
|
|
80cbd0 |
- b.attach_kprobe(event="generic_file_read_iter", fn_name="trace_read_entry")
|
|
|
80cbd0 |
-b.attach_kprobe(event="ext4_file_write_iter", fn_name="trace_write_entry")
|
|
|
80cbd0 |
+ b.attach_kprobe(event="generic_file_aio_read", fn_name="trace_read_entry")
|
|
|
80cbd0 |
+b.attach_kprobe(event="ext4_file_write", fn_name="trace_write_entry")
|
|
|
80cbd0 |
b.attach_kprobe(event="ext4_file_open", fn_name="trace_open_entry")
|
|
|
80cbd0 |
b.attach_kprobe(event="ext4_sync_file", fn_name="trace_fsync_entry")
|
|
|
80cbd0 |
if BPF.get_kprobe_functions(b'ext4_file_read_iter'):
|
|
|
80cbd0 |
b.attach_kretprobe(event="ext4_file_read_iter", fn_name="trace_read_return")
|
|
|
80cbd0 |
else:
|
|
|
80cbd0 |
- b.attach_kretprobe(event="generic_file_read_iter", fn_name="trace_read_return")
|
|
|
80cbd0 |
-b.attach_kretprobe(event="ext4_file_write_iter", fn_name="trace_write_return")
|
|
|
80cbd0 |
+ b.attach_kretprobe(event="generic_file_aio_read", fn_name="trace_read_return")
|
|
|
80cbd0 |
+b.attach_kretprobe(event="ext4_file_write", fn_name="trace_write_return")
|
|
|
80cbd0 |
b.attach_kretprobe(event="ext4_file_open", fn_name="trace_open_return")
|
|
|
80cbd0 |
b.attach_kretprobe(event="ext4_sync_file", fn_name="trace_fsync_return")
|
|
|
80cbd0 |
|
|
|
80cbd0 |
diff --git a/tools/fileslower.py b/tools/fileslower.py
|
|
|
2a0312 |
index 219a94a..46ead05 100755
|
|
|
80cbd0 |
--- a/tools/fileslower.py
|
|
|
80cbd0 |
+++ b/tools/fileslower.py
|
|
|
80cbd0 |
@@ -124,7 +124,7 @@ int trace_read_entry(struct pt_regs *ctx, struct file *file,
|
|
|
80cbd0 |
char __user *buf, size_t count)
|
|
|
80cbd0 |
{
|
|
|
80cbd0 |
// skip non-sync I/O; see kernel code for __vfs_read()
|
|
|
80cbd0 |
- if (!(file->f_op->read_iter))
|
|
|
80cbd0 |
+ if (!(file->f_op->aio_read))
|
|
|
80cbd0 |
return 0;
|
|
|
80cbd0 |
return trace_rw_entry(ctx, file, buf, count);
|
|
|
80cbd0 |
}
|
|
|
80cbd0 |
@@ -133,7 +133,7 @@ int trace_write_entry(struct pt_regs *ctx, struct file *file,
|
|
|
80cbd0 |
char __user *buf, size_t count)
|
|
|
80cbd0 |
{
|
|
|
80cbd0 |
// skip non-sync I/O; see kernel code for __vfs_write()
|
|
|
80cbd0 |
- if (!(file->f_op->write_iter))
|
|
|
80cbd0 |
+ if (!(file->f_op->aio_write))
|
|
|
80cbd0 |
return 0;
|
|
|
80cbd0 |
return trace_rw_entry(ctx, file, buf, count);
|
|
|
80cbd0 |
}
|
|
|
80cbd0 |
@@ -200,8 +200,13 @@ b = BPF(text=bpf_text)
|
|
|
80cbd0 |
# do_sync_read/do_sync_write), but those became static. So trace these from
|
|
|
80cbd0 |
# the parent functions, at the cost of more overhead, instead.
|
|
|
80cbd0 |
# Ultimately, we should be using [V]FS tracepoints.
|
|
|
80cbd0 |
-b.attach_kprobe(event="__vfs_read", fn_name="trace_read_entry")
|
|
|
80cbd0 |
-b.attach_kretprobe(event="__vfs_read", fn_name="trace_read_return")
|
|
|
80cbd0 |
+try:
|
|
|
80cbd0 |
+ b.attach_kprobe(event="__vfs_read", fn_name="trace_read_entry")
|
|
|
80cbd0 |
+ b.attach_kretprobe(event="__vfs_read", fn_name="trace_read_return")
|
|
|
80cbd0 |
+except:
|
|
|
80cbd0 |
+ # older kernels don't have __vfs_read so try vfs_read instead
|
|
|
80cbd0 |
+ b.attach_kprobe(event="vfs_read", fn_name="trace_read_entry")
|
|
|
80cbd0 |
+ b.attach_kretprobe(event="vfs_read", fn_name="trace_read_return")
|
|
|
80cbd0 |
try:
|
|
|
80cbd0 |
b.attach_kprobe(event="__vfs_write", fn_name="trace_write_entry")
|
|
|
80cbd0 |
b.attach_kretprobe(event="__vfs_write", fn_name="trace_write_return")
|
|
|
80cbd0 |
diff --git a/tools/memleak.py b/tools/memleak.py
|
|
|
2a0312 |
index 4021bf8..7e70af4 100755
|
|
|
80cbd0 |
--- a/tools/memleak.py
|
|
|
80cbd0 |
+++ b/tools/memleak.py
|
|
|
2a0312 |
@@ -355,13 +355,21 @@ TRACEPOINT_PROBE(kmem, kmem_cache_free) {
|
|
|
80cbd0 |
return gen_free_enter((struct pt_regs *)args, (void *)args->ptr);
|
|
|
80cbd0 |
}
|
|
|
80cbd0 |
|
|
|
80cbd0 |
+/*
|
|
|
80cbd0 |
+ * Upstream reads the PFN here, but on RHEL7 kernel this is not available
|
|
|
80cbd0 |
+ * and the address of the pages struct is returned instead. This value is
|
|
|
80cbd0 |
+ * used as the key in a hash to identify each allocation. No other allocation
|
|
|
80cbd0 |
+ * should return an address belonging to mem_map, so there's no risk of
|
|
|
80cbd0 |
+ * colision
|
|
|
80cbd0 |
+ */
|
|
|
80cbd0 |
+
|
|
|
80cbd0 |
TRACEPOINT_PROBE(kmem, mm_page_alloc) {
|
|
|
80cbd0 |
gen_alloc_enter((struct pt_regs *)args, PAGE_SIZE << args->order);
|
|
|
80cbd0 |
- return gen_alloc_exit2((struct pt_regs *)args, args->pfn);
|
|
|
80cbd0 |
+ return gen_alloc_exit2((struct pt_regs *)args, (size_t)args->page);
|
|
|
80cbd0 |
}
|
|
|
80cbd0 |
|
|
|
80cbd0 |
TRACEPOINT_PROBE(kmem, mm_page_free) {
|
|
|
80cbd0 |
- return gen_free_enter((struct pt_regs *)args, (void *)args->pfn);
|
|
|
80cbd0 |
+ return gen_free_enter((struct pt_regs *)args, (void *)args->page);
|
|
|
80cbd0 |
}
|
|
|
80cbd0 |
"""
|
|
|
80cbd0 |
|
|
|
80cbd0 |
diff --git a/tools/mountsnoop.py b/tools/mountsnoop.py
|
|
|
2a0312 |
index b6f96ca..e2956f8 100755
|
|
|
80cbd0 |
--- a/tools/mountsnoop.py
|
|
|
80cbd0 |
+++ b/tools/mountsnoop.py
|
|
|
80cbd0 |
@@ -24,7 +24,6 @@ bpf_text = r"""
|
|
|
80cbd0 |
#include <linux/sched.h>
|
|
|
80cbd0 |
|
|
|
80cbd0 |
#include <linux/nsproxy.h>
|
|
|
80cbd0 |
-#include <linux/ns_common.h>
|
|
|
80cbd0 |
|
|
|
80cbd0 |
/*
|
|
|
80cbd0 |
* XXX: struct mnt_namespace is defined in fs/mount.h, which is private to the
|
|
|
80cbd0 |
@@ -34,7 +33,7 @@ bpf_text = r"""
|
|
|
80cbd0 |
*/
|
|
|
80cbd0 |
struct mnt_namespace {
|
|
|
80cbd0 |
atomic_t count;
|
|
|
80cbd0 |
- struct ns_common ns;
|
|
|
80cbd0 |
+ unsigned int proc_inum;
|
|
|
80cbd0 |
};
|
|
|
80cbd0 |
|
|
|
80cbd0 |
/*
|
|
|
80cbd0 |
@@ -69,7 +68,7 @@ struct data_t {
|
|
|
80cbd0 |
union {
|
|
|
80cbd0 |
/* EVENT_MOUNT, EVENT_UMOUNT */
|
|
|
80cbd0 |
struct {
|
|
|
80cbd0 |
- /* current->nsproxy->mnt_ns->ns.inum */
|
|
|
80cbd0 |
+ /* current->nsproxy->proc_inum */
|
|
|
80cbd0 |
unsigned int mnt_ns;
|
|
|
80cbd0 |
char comm[TASK_COMM_LEN];
|
|
|
80cbd0 |
unsigned long flags;
|
|
|
80cbd0 |
@@ -106,7 +105,7 @@ int syscall__mount(struct pt_regs *ctx, char __user *source,
|
|
|
80cbd0 |
task = (struct task_struct *)bpf_get_current_task();
|
|
|
80cbd0 |
nsproxy = task->nsproxy;
|
|
|
80cbd0 |
mnt_ns = nsproxy->mnt_ns;
|
|
|
80cbd0 |
- event.enter.mnt_ns = mnt_ns->ns.inum;
|
|
|
80cbd0 |
+ event.enter.mnt_ns = mnt_ns->proc_inum;
|
|
|
80cbd0 |
events.perf_submit(ctx, &event, sizeof(event));
|
|
|
80cbd0 |
|
|
|
80cbd0 |
event.type = EVENT_MOUNT_SOURCE;
|
|
|
80cbd0 |
@@ -161,7 +160,7 @@ int syscall__umount(struct pt_regs *ctx, char __user *target, int flags)
|
|
|
80cbd0 |
task = (struct task_struct *)bpf_get_current_task();
|
|
|
80cbd0 |
nsproxy = task->nsproxy;
|
|
|
80cbd0 |
mnt_ns = nsproxy->mnt_ns;
|
|
|
80cbd0 |
- event.enter.mnt_ns = mnt_ns->ns.inum;
|
|
|
80cbd0 |
+ event.enter.mnt_ns = mnt_ns->proc_inum;
|
|
|
80cbd0 |
events.perf_submit(ctx, &event, sizeof(event));
|
|
|
80cbd0 |
|
|
|
80cbd0 |
event.type = EVENT_UMOUNT_TARGET;
|
|
|
80cbd0 |
diff --git a/tools/nfsslower.py b/tools/nfsslower.py
|
|
|
2a0312 |
index 8113eff..e6c62ba 100755
|
|
|
80cbd0 |
--- a/tools/nfsslower.py
|
|
|
80cbd0 |
+++ b/tools/nfsslower.py
|
|
|
80cbd0 |
@@ -65,6 +65,7 @@ bpf_text = """
|
|
|
80cbd0 |
|
|
|
80cbd0 |
#include <uapi/linux/ptrace.h>
|
|
|
80cbd0 |
#include <linux/fs.h>
|
|
|
80cbd0 |
+#include <linux/aio.h>
|
|
|
80cbd0 |
#include <linux/sched.h>
|
|
|
80cbd0 |
#include <linux/dcache.h>
|
|
|
80cbd0 |
|
|
|
80cbd0 |
diff --git a/tools/offcputime.py b/tools/offcputime.py
|
|
|
2a0312 |
index 6440260..ef328c1 100755
|
|
|
80cbd0 |
--- a/tools/offcputime.py
|
|
|
80cbd0 |
+++ b/tools/offcputime.py
|
|
|
80cbd0 |
@@ -128,7 +128,9 @@ BPF_HASH(counts, struct key_t);
|
|
|
80cbd0 |
BPF_HASH(start, u32);
|
|
|
80cbd0 |
BPF_STACK_TRACE(stack_traces, STACK_STORAGE_SIZE);
|
|
|
80cbd0 |
|
|
|
80cbd0 |
-int oncpu(struct pt_regs *ctx, struct task_struct *prev) {
|
|
|
80cbd0 |
+struct rq;
|
|
|
80cbd0 |
+
|
|
|
80cbd0 |
+int oncpu(struct pt_regs *ctx, struct rq *rq, struct task_struct *prev) {
|
|
|
80cbd0 |
u32 pid = prev->pid;
|
|
|
80cbd0 |
u32 tgid = prev->tgid;
|
|
|
80cbd0 |
u64 ts, *tsp;
|
|
|
80cbd0 |
diff --git a/tools/offwaketime.py b/tools/offwaketime.py
|
|
|
2a0312 |
index 3c4f0f3..89e7b60 100755
|
|
|
80cbd0 |
--- a/tools/offwaketime.py
|
|
|
80cbd0 |
+++ b/tools/offwaketime.py
|
|
|
80cbd0 |
@@ -163,7 +163,9 @@ int waker(struct pt_regs *ctx, struct task_struct *p) {
|
|
|
80cbd0 |
return 0;
|
|
|
80cbd0 |
}
|
|
|
80cbd0 |
|
|
|
80cbd0 |
-int oncpu(struct pt_regs *ctx, struct task_struct *p) {
|
|
|
80cbd0 |
+struct rq;
|
|
|
80cbd0 |
+
|
|
|
80cbd0 |
+int oncpu(struct pt_regs *ctx, struct rq *rq, struct task_struct *p) {
|
|
|
80cbd0 |
// PID and TGID of the previous Process (Process going into waiting)
|
|
|
80cbd0 |
u32 pid = p->pid;
|
|
|
80cbd0 |
u32 tgid = p->tgid;
|
|
|
2a0312 |
diff --git a/tools/oomkill.py b/tools/oomkill.py
|
|
|
2a0312 |
index db3a537..5357d9f 100755
|
|
|
2a0312 |
--- a/tools/oomkill.py
|
|
|
2a0312 |
+++ b/tools/oomkill.py
|
|
|
2a0312 |
@@ -36,15 +36,15 @@ struct data_t {
|
|
|
2a0312 |
|
|
|
2a0312 |
BPF_PERF_OUTPUT(events);
|
|
|
2a0312 |
|
|
|
2a0312 |
-void kprobe__oom_kill_process(struct pt_regs *ctx, struct oom_control *oc, const char *message)
|
|
|
2a0312 |
+void kprobe__oom_kill_process(struct pt_regs *ctx, struct task_struct *p,
|
|
|
2a0312 |
+ gfp_t gfp_mask, int order, unsigned int points,
|
|
|
2a0312 |
+ unsigned long totalpages, struct mem_cgroup *memcg)
|
|
|
2a0312 |
{
|
|
|
2a0312 |
- unsigned long totalpages;
|
|
|
2a0312 |
- struct task_struct *p = oc->chosen;
|
|
|
2a0312 |
struct data_t data = {};
|
|
|
2a0312 |
u32 pid = bpf_get_current_pid_tgid();
|
|
|
2a0312 |
data.fpid = pid;
|
|
|
2a0312 |
data.tpid = p->pid;
|
|
|
2a0312 |
- data.pages = oc->totalpages;
|
|
|
2a0312 |
+ data.pages = totalpages;
|
|
|
2a0312 |
bpf_get_current_comm(&data.fcomm, sizeof(data.fcomm));
|
|
|
2a0312 |
bpf_probe_read(&data.tcomm, sizeof(data.tcomm), p->comm);
|
|
|
2a0312 |
events.perf_submit(ctx, &data, sizeof(data));
|
|
|
80cbd0 |
diff --git a/tools/runqlat.py b/tools/runqlat.py
|
|
|
2a0312 |
index 9c56d22..3a56d56 100755
|
|
|
80cbd0 |
--- a/tools/runqlat.py
|
|
|
80cbd0 |
+++ b/tools/runqlat.py
|
|
|
80cbd0 |
@@ -111,7 +111,7 @@ int trace_ttwu_do_wakeup(struct pt_regs *ctx, struct rq *rq, struct task_struct
|
|
|
80cbd0 |
}
|
|
|
80cbd0 |
|
|
|
80cbd0 |
// calculate latency
|
|
|
80cbd0 |
-int trace_run(struct pt_regs *ctx, struct task_struct *prev)
|
|
|
80cbd0 |
+int trace_run(struct pt_regs *ctx, struct rq *rq, struct task_struct *prev)
|
|
|
80cbd0 |
{
|
|
|
80cbd0 |
u32 pid, tgid;
|
|
|
80cbd0 |
|
|
|
80cbd0 |
diff --git a/tools/runqslower.py b/tools/runqslower.py
|
|
|
2a0312 |
index 0b3e1c1..8be9ef0 100755
|
|
|
80cbd0 |
--- a/tools/runqslower.py
|
|
|
80cbd0 |
+++ b/tools/runqslower.py
|
|
|
80cbd0 |
@@ -98,7 +98,7 @@ int trace_ttwu_do_wakeup(struct pt_regs *ctx, struct rq *rq, struct task_struct
|
|
|
80cbd0 |
}
|
|
|
80cbd0 |
|
|
|
80cbd0 |
// calculate latency
|
|
|
80cbd0 |
-int trace_run(struct pt_regs *ctx, struct task_struct *prev)
|
|
|
80cbd0 |
+int trace_run(struct pt_regs *ctx, struct rq *rq, struct task_struct *prev)
|
|
|
80cbd0 |
{
|
|
|
80cbd0 |
u32 pid, tgid;
|
|
|
80cbd0 |
|
|
|
80cbd0 |
diff --git a/tools/solisten.py b/tools/solisten.py
|
|
|
2a0312 |
index 81e82e0..f30a23f 100755
|
|
|
80cbd0 |
--- a/tools/solisten.py
|
|
|
80cbd0 |
+++ b/tools/solisten.py
|
|
|
2a0312 |
@@ -101,7 +101,7 @@ int kprobe__inet_listen(struct pt_regs *ctx, struct socket *sock, int backlog)
|
|
|
80cbd0 |
|
|
|
80cbd0 |
// Get network namespace id, if kernel supports it
|
|
|
80cbd0 |
#ifdef CONFIG_NET_NS
|
|
|
80cbd0 |
- evt.netns = sk->__sk_common.skc_net.net->ns.inum;
|
|
|
80cbd0 |
+ evt.netns = sk->__sk_common.skc_net->proc_inum;
|
|
|
80cbd0 |
#else
|
|
|
80cbd0 |
evt.netns = 0;
|
|
|
80cbd0 |
#endif
|
|
|
80cbd0 |
diff --git a/tools/tcpsubnet.py b/tools/tcpsubnet.py
|
|
|
2a0312 |
index bf944e1..a054a7d 100755
|
|
|
80cbd0 |
--- a/tools/tcpsubnet.py
|
|
|
80cbd0 |
+++ b/tools/tcpsubnet.py
|
|
|
80cbd0 |
@@ -110,8 +110,8 @@ struct index_key_t {
|
|
|
80cbd0 |
|
|
|
80cbd0 |
BPF_HASH(ipv4_send_bytes, struct index_key_t);
|
|
|
80cbd0 |
|
|
|
80cbd0 |
-int kprobe__tcp_sendmsg(struct pt_regs *ctx, struct sock *sk,
|
|
|
80cbd0 |
- struct msghdr *msg, size_t size)
|
|
|
80cbd0 |
+int kprobe__tcp_sendmsg(struct pt_regs *ctx, struct kiocb *iocb,
|
|
|
80cbd0 |
+ struct sock *sk, struct msghdr *msg, size_t size)
|
|
|
80cbd0 |
{
|
|
|
80cbd0 |
u16 family = sk->__sk_common.skc_family;
|
|
|
2a0312 |
|
|
|
80cbd0 |
diff --git a/tools/tcptracer.py b/tools/tcptracer.py
|
|
|
2a0312 |
index 8f272eb..021803a 100755
|
|
|
80cbd0 |
--- a/tools/tcptracer.py
|
|
|
80cbd0 |
+++ b/tools/tcptracer.py
|
|
|
80cbd0 |
@@ -116,7 +116,7 @@ static int read_ipv4_tuple(struct ipv4_tuple_t *tuple, struct sock *skp)
|
|
|
80cbd0 |
u16 sport = sockp->inet_sport;
|
|
|
80cbd0 |
u16 dport = skp->__sk_common.skc_dport;
|
|
|
80cbd0 |
#ifdef CONFIG_NET_NS
|
|
|
80cbd0 |
- net_ns_inum = skp->__sk_common.skc_net.net->ns.inum;
|
|
|
80cbd0 |
+ net_ns_inum = skp->__sk_common.skc_net->proc_inum;
|
|
|
80cbd0 |
#endif
|
|
|
80cbd0 |
|
|
|
80cbd0 |
##FILTER_NETNS##
|
|
|
80cbd0 |
@@ -143,7 +143,7 @@ static int read_ipv6_tuple(struct ipv6_tuple_t *tuple, struct sock *skp)
|
|
|
80cbd0 |
u16 sport = sockp->inet_sport;
|
|
|
80cbd0 |
u16 dport = skp->__sk_common.skc_dport;
|
|
|
80cbd0 |
#ifdef CONFIG_NET_NS
|
|
|
80cbd0 |
- net_ns_inum = skp->__sk_common.skc_net.net->ns.inum;
|
|
|
80cbd0 |
+ net_ns_inum = skp->__sk_common.skc_net->proc_inum;
|
|
|
80cbd0 |
#endif
|
|
|
80cbd0 |
bpf_probe_read(&saddr, sizeof(saddr),
|
|
|
80cbd0 |
skp->__sk_common.skc_v6_rcv_saddr.in6_u.u6_addr32);
|
|
|
80cbd0 |
@@ -361,8 +361,7 @@ int trace_close_entry(struct pt_regs *ctx, struct sock *skp)
|
|
|
80cbd0 |
// Don't generate close events for connections that were never
|
|
|
80cbd0 |
// established in the first place.
|
|
|
80cbd0 |
if (oldstate == TCP_SYN_SENT ||
|
|
|
80cbd0 |
- oldstate == TCP_SYN_RECV ||
|
|
|
80cbd0 |
- oldstate == TCP_NEW_SYN_RECV)
|
|
|
80cbd0 |
+ oldstate == TCP_SYN_RECV )
|
|
|
80cbd0 |
return 0;
|
|
|
80cbd0 |
|
|
|
80cbd0 |
u8 ipver = 0;
|
|
|
80cbd0 |
@@ -433,7 +432,7 @@ int trace_accept_return(struct pt_regs *ctx)
|
|
|
80cbd0 |
|
|
|
80cbd0 |
// Get network namespace id, if kernel supports it
|
|
|
80cbd0 |
#ifdef CONFIG_NET_NS
|
|
|
80cbd0 |
- net_ns_inum = newsk->__sk_common.skc_net.net->ns.inum;
|
|
|
80cbd0 |
+ net_ns_inum = newsk->__sk_common.skc_net->proc_inum;
|
|
|
80cbd0 |
#endif
|
|
|
80cbd0 |
|
|
|
80cbd0 |
##FILTER_NETNS##
|
|
|
80cbd0 |
diff --git a/tools/xfsdist.py b/tools/xfsdist.py
|
|
|
2a0312 |
index 1a7fdd9..8f2ab46 100755
|
|
|
80cbd0 |
--- a/tools/xfsdist.py
|
|
|
80cbd0 |
+++ b/tools/xfsdist.py
|
|
|
80cbd0 |
@@ -137,12 +137,12 @@ bpf_text = bpf_text.replace('FACTOR', str(factor))
|
|
|
80cbd0 |
b = BPF(text=bpf_text)
|
|
|
80cbd0 |
|
|
|
80cbd0 |
# common file functions
|
|
|
80cbd0 |
-b.attach_kprobe(event="xfs_file_read_iter", fn_name="trace_entry")
|
|
|
80cbd0 |
-b.attach_kprobe(event="xfs_file_write_iter", fn_name="trace_entry")
|
|
|
80cbd0 |
+b.attach_kprobe(event="xfs_file_aio_read", fn_name="trace_entry")
|
|
|
80cbd0 |
+b.attach_kprobe(event="xfs_file_aio_write", fn_name="trace_entry")
|
|
|
80cbd0 |
b.attach_kprobe(event="xfs_file_open", fn_name="trace_entry")
|
|
|
80cbd0 |
b.attach_kprobe(event="xfs_file_fsync", fn_name="trace_entry")
|
|
|
80cbd0 |
-b.attach_kretprobe(event="xfs_file_read_iter", fn_name="trace_read_return")
|
|
|
80cbd0 |
-b.attach_kretprobe(event="xfs_file_write_iter", fn_name="trace_write_return")
|
|
|
80cbd0 |
+b.attach_kretprobe(event="xfs_file_aio_read", fn_name="trace_read_return")
|
|
|
80cbd0 |
+b.attach_kretprobe(event="xfs_file_aio_write", fn_name="trace_write_return")
|
|
|
80cbd0 |
b.attach_kretprobe(event="xfs_file_open", fn_name="trace_open_return")
|
|
|
80cbd0 |
b.attach_kretprobe(event="xfs_file_fsync", fn_name="trace_fsync_return")
|
|
|
80cbd0 |
|
|
|
80cbd0 |
diff --git a/tools/xfsslower.py b/tools/xfsslower.py
|
|
|
2a0312 |
index 5b4e0a2..0dd75b6 100755
|
|
|
80cbd0 |
--- a/tools/xfsslower.py
|
|
|
80cbd0 |
+++ b/tools/xfsslower.py
|
|
|
80cbd0 |
@@ -60,6 +60,7 @@ debug = 0
|
|
|
80cbd0 |
bpf_text = """
|
|
|
80cbd0 |
#include <uapi/linux/ptrace.h>
|
|
|
80cbd0 |
#include <linux/fs.h>
|
|
|
80cbd0 |
+#include <linux/aio.h>
|
|
|
80cbd0 |
#include <linux/sched.h>
|
|
|
80cbd0 |
#include <linux/dcache.h>
|
|
|
80cbd0 |
|
|
|
80cbd0 |
@@ -94,7 +95,7 @@ BPF_PERF_OUTPUT(events);
|
|
|
80cbd0 |
// Store timestamp and size on entry
|
|
|
80cbd0 |
//
|
|
|
80cbd0 |
|
|
|
80cbd0 |
-// xfs_file_read_iter(), xfs_file_write_iter():
|
|
|
80cbd0 |
+// xfs_file_aio_read(), xfs_file_aio_write():
|
|
|
80cbd0 |
int trace_rw_entry(struct pt_regs *ctx, struct kiocb *iocb)
|
|
|
80cbd0 |
{
|
|
|
80cbd0 |
u64 id = bpf_get_current_pid_tgid();
|
|
|
2a0312 |
@@ -280,12 +281,12 @@ TASK_COMM_LEN = 16 # linux/sched.h
|
|
|
80cbd0 |
b = BPF(text=bpf_text)
|
|
|
80cbd0 |
|
|
|
80cbd0 |
# common file functions
|
|
|
80cbd0 |
-b.attach_kprobe(event="xfs_file_read_iter", fn_name="trace_rw_entry")
|
|
|
80cbd0 |
-b.attach_kprobe(event="xfs_file_write_iter", fn_name="trace_rw_entry")
|
|
|
80cbd0 |
+b.attach_kprobe(event="xfs_file_aio_read", fn_name="trace_rw_entry")
|
|
|
80cbd0 |
+b.attach_kprobe(event="xfs_file_aio_write", fn_name="trace_rw_entry")
|
|
|
80cbd0 |
b.attach_kprobe(event="xfs_file_open", fn_name="trace_open_entry")
|
|
|
80cbd0 |
b.attach_kprobe(event="xfs_file_fsync", fn_name="trace_fsync_entry")
|
|
|
80cbd0 |
-b.attach_kretprobe(event="xfs_file_read_iter", fn_name="trace_read_return")
|
|
|
80cbd0 |
-b.attach_kretprobe(event="xfs_file_write_iter", fn_name="trace_write_return")
|
|
|
80cbd0 |
+b.attach_kretprobe(event="xfs_file_aio_read", fn_name="trace_read_return")
|
|
|
80cbd0 |
+b.attach_kretprobe(event="xfs_file_aio_write", fn_name="trace_write_return")
|
|
|
80cbd0 |
b.attach_kretprobe(event="xfs_file_open", fn_name="trace_open_return")
|
|
|
80cbd0 |
b.attach_kretprobe(event="xfs_file_fsync", fn_name="trace_fsync_return")
|
|
|
80cbd0 |
|
|
|
80cbd0 |
--
|
|
|
2a0312 |
2.20.1
|
|
|
80cbd0 |
|