linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org,
	Steven Rostedt <rostedt@goodmis.org>,
	chavey@google.com
Subject: [PATCH 2/2] vfs: add fcheck tracepoint
Date: Wed, 9 Jan 2013 09:01:37 -0800	[thread overview]
Message-ID: <20130109170137.GN3926@htj.dyndns.org> (raw)
In-Reply-To: <20130109170105.GM3926@htj.dyndns.org>

All file accesses from userland go through fcheck to map fd to struct
file, making it a very good location for peeking at what files
userland is accessing.  Add a tracepoint there.

This is part of tracepoint additions to improve visiblity into
dirtying / writeback operations for io tracer and userland.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/file.c                  |    3 +++
 fs/super.c                 |    2 ++
 include/trace/events/vfs.h |   42 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 47 insertions(+)

--- a/fs/file.c
+++ b/fs/file.c
@@ -22,6 +22,7 @@
 #include <linux/spinlock.h>
 #include <linux/rcupdate.h>
 #include <linux/workqueue.h>
+#include <trace/events/vfs.h>
 
 struct fdtable_defer {
 	spinlock_t lock;
@@ -716,6 +717,8 @@ inline struct file *fcheck_files(struct
 
 	if (fd < fdt->max_fds)
 		file = rcu_dereference_check_fdtable(files, fdt->fd[fd]);
+
+	trace_vfs_fcheck(files, fd, file, _THIS_IP_);
 	return file;
 }
 EXPORT_SYMBOL(fcheck_files);
--- a/fs/super.c
+++ b/fs/super.c
@@ -36,6 +36,8 @@
 #include <linux/lockdep.h>
 #include "internal.h"
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/vfs.h>
 
 LIST_HEAD(super_blocks);
 DEFINE_SPINLOCK(sb_lock);
--- /dev/null
+++ b/include/trace/events/vfs.h
@@ -0,0 +1,42 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM vfs
+
+#if !defined(_TRACE_VFS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_VFS_H
+
+#include <linux/tracepoint.h>
+#include <linux/fs.h>
+
+TRACE_EVENT(vfs_fcheck,
+
+	TP_PROTO(struct files_struct *files, unsigned int fd,
+		 struct file *file, unsigned long ip),
+
+	TP_ARGS(files, fd, file, ip),
+
+	TP_STRUCT__entry(
+		__field(unsigned int,	fd)
+		__field(umode_t,	mode)
+		__field(dev_t,		dev)
+		__field(ino_t,		ino)
+		__field(unsigned long,	ip)
+	),
+
+	TP_fast_assign(
+		__entry->fd = fd;
+		__entry->mode = file ? file->f_path.dentry->d_inode->i_mode : 0;
+		__entry->dev = file ? file->f_path.dentry->d_inode->i_sb->s_dev : 0;
+		__entry->ino = file ? file->f_path.dentry->d_inode->i_ino : 0;
+		__entry->ip = ip;
+	),
+
+	TP_printk("fd %u mode 0x%x dev %d,%d ino %lu caller %pF",
+		  __entry->fd, __entry->mode,
+		  MAJOR(__entry->dev), MINOR(__entry->dev),
+		  (unsigned long)__entry->ino, (void *)__entry->ip)
+);
+
+#endif /* _TRACE_VFS_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>

  reply	other threads:[~2013-01-09 17:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-09 17:01 [PATCH 1/2] vfs: make fcheck_files() an exported functions Tejun Heo
2013-01-09 17:01 ` Tejun Heo [this message]
2013-02-09 19:24 ` Tejun Heo
2013-02-10  0:18   ` Al Viro
2013-02-12 17:41     ` Tejun Heo
2013-02-12 18:21       ` Steven Rostedt
2013-02-12 20:21         ` Steven Rostedt
2013-02-12 20:44           ` Al Viro
2013-02-12 20:57             ` Steven Rostedt
2013-02-12 20:43         ` Al Viro
2013-02-12 21:03           ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130109170137.GN3926@htj.dyndns.org \
    --to=tj@kernel.org \
    --cc=chavey@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).