blob: 7ae006c21ab5e1b9e9f20633a3f8bc5349ec72ab [file] [log] [blame]
From 2cb78abaaacf16f325a3985e44d6169996584f7d Mon Sep 17 00:00:00 2001
From: Scott James Remnant <scott@ubuntu.com>
Date: Tue, 27 Oct 2009 10:05:32 +0000
Subject: [PATCH] UBUNTU: SAUCE: trace: add trace events for open(), exec() and
uselib()
BugLink: http://bugs.launchpad.net/bugs/462111
This patch uses TRACE_EVENT to add tracepoints for the open(),
exec() and uselib() syscalls so that ureadahead can cheaply trace
the boot sequence to determine what to read to speed up the next.
It's not upstream because it will need to be rebased onto the syscall
trace events whenever that gets merged, and is a stop-gap.
[benzh: 3.14 rebase. Squashed 2 warning fixes. Fixed a new incompatible
pointer type error for trace_open_exec() due to upstream change]
Change-Id: I3bb5c3f6c2b4b7cfbe7045e342092a4d652bcef2
Signed-off-by: Scott James Remnant <scott@ubuntu.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Andy Whitcroft <andy.whitcroft@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Ben Zhang <benzh@chromium.org>
Conflicts:
fs/exec.c
[rebase44(filbranden): Moved the trace_open_exec call to the block where
fsnotify_open was.]
Signed-off-by: Filipe Brandenburger <filbranden@chromium.org>
Conflicts:
fs/open.c
fs/exec.c
[rebase412(groeck): Resolved conflicts]
Signed-off-by: Guenter Roeck <groeck@chromium.org>
[rebase510(groeck): Context conflicts (open syscalls rearranged)]
Signed-off-by: Guenter Roeck <groeck@chromium.org>
Change-Id: I81ae7cf6bc8e435829666fdf21d13c7fd2c5eba5
Kcr-patch: 965306a68a505c20bb4e3fb614682065b4f38da5d909335cba72cd2a.patch
---
fs/exec.c | 7 +++++
fs/open.c | 4 +++
include/trace/events/fs_trace.h | 53 +++++++++++++++++++++++++++++++++
3 files changed, 64 insertions(+)
create mode 100644 include/trace/events/fs_trace.h
diff --git a/fs/exec.c b/fs/exec.c
index a126e3d1cacb01174fec72d4211bff2a4cd9f52a..f2599bca207b9e6ff7b0f52eead3a7391a316359 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -73,6 +73,7 @@
#include <asm/mmu_context.h>
#include <asm/tlb.h>
+#include <trace/events/fs_trace.h>
#include <trace/events/task.h>
#include "internal.h"
@@ -983,6 +984,12 @@ static struct file *do_open_execat(int fd, struct filename *name, int flags)
path_noexec(&file->f_path)))
goto exit;
+ if (name->name[0] != '\0') {
+ fsnotify_open(file);
+
+ trace_open_exec(name->name);
+ }
+
out:
return file;
diff --git a/fs/open.c b/fs/open.c
index 22adbef7ecc2a6af5e28aa75de7df30385843408..3f1c13b3802d790e78688b25493017714cf21b9d 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -36,6 +36,9 @@
#include "internal.h"
+#define CREATE_TRACE_POINTS
+#include <trace/events/fs_trace.h>
+
int do_truncate(struct mnt_idmap *idmap, struct dentry *dentry,
loff_t length, unsigned int time_attrs, struct file *filp)
{
@@ -1419,6 +1422,7 @@ static long do_sys_openat2(int dfd, const char __user *filename,
fd = PTR_ERR(f);
} else {
fd_install(fd, f);
+ trace_do_sys_open(tmp->name, how->flags, how->mode);
}
}
putname(tmp);
diff --git a/include/trace/events/fs_trace.h b/include/trace/events/fs_trace.h
new file mode 100644
index 0000000000000000000000000000000000000000..d450ea162e62a0568e5f35c61a6a46ab438824b2
--- /dev/null
+++ b/include/trace/events/fs_trace.h
@@ -0,0 +1,53 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM fs_trace
+
+#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_FS_H
+
+#include <linux/fs.h>
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(do_sys_open,
+
+ TP_PROTO(const char *filename, int flags, int mode),
+
+ TP_ARGS(filename, flags, mode),
+
+ TP_STRUCT__entry(
+ __string( filename, filename )
+ __field( int, flags )
+ __field( int, mode )
+ ),
+
+ TP_fast_assign(
+ __assign_str(filename, filename);
+ __entry->flags = flags;
+ __entry->mode = mode;
+ ),
+
+ TP_printk("\"%s\" %x %o",
+ __get_str(filename), __entry->flags, __entry->mode)
+);
+
+TRACE_EVENT(open_exec,
+
+ TP_PROTO(const char *filename),
+
+ TP_ARGS(filename),
+
+ TP_STRUCT__entry(
+ __string( filename, filename )
+ ),
+
+ TP_fast_assign(
+ __assign_str(filename, filename);
+ ),
+
+ TP_printk("\"%s\"",
+ __get_str(filename))
+);
+
+#endif /* _TRACE_FS_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
--
2.46.0.rc2.264.g509ed76dc8-goog