linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vfs: Add a trace point in the mark_inode_dirty function
@ 2010-11-26 20:56 Arjan van de Ven
  2010-11-28 17:52 ` Christoph Hellwig
  0 siblings, 1 reply; 38+ messages in thread
From: Arjan van de Ven @ 2010-11-26 20:56 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Christoph Hellwig, Al Viro

long time overdue to clean this guy up;
this patch adds a very basic trace point for tracking who dirties an inode
(this is the guy who is the real cause for a disk to spin up, so PowerTOP would
like to know this...)

compared to earlier patches the trace point is done a lot simpler, and consistent with how others
(ext4 etc) do their vfs level tracepoints; with a device number and inode number


>From 880a17e27f0b90d32c0c0b9cf4cd9b4e5d779c73 Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <arjan@linux.intel.com>
Date: Fri, 26 Nov 2010 12:18:03 -0800
Subject: [PATCH] vfs: Add a trace point in the mark_inode_dirty function

PowerTOP would like to be able to show who is keeping the disk
busy by dirtying data. The most logical spot for this is in the vfs
in the mark_inode_dirty() function, doing this on the block level
is not possible because by the time the IO hits the block layer the
guilty party can no longer be found ("kjournald" and "pdflush" are not
useful answers to "who caused this file to be dirty).

The trace point follows the same logic/style as the block_dump code
and pretty much dumps the same data, just not to dmesg (and thus to
/var/log/messages) but via the trace events streams.

Eventually we should be able to phase out the block dump code, but that's
for later on after a transition time.

Signed-of-by: Arjan van de Ven <arjan@linux.intel.com>
---
 fs/fs-writeback.c          |    4 ++++
 fs/inode.c                 |    4 ++++
 include/trace/events/vfs.h |   35 +++++++++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+), 0 deletions(-)
 create mode 100644 include/trace/events/vfs.h

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 3d06ccc..6c93517 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -27,6 +27,7 @@
 #include <linux/backing-dev.h>
 #include <linux/buffer_head.h>
 #include <linux/tracepoint.h>
+#include <trace/events/vfs.h>
 #include "internal.h"
 
 /*
@@ -942,6 +943,9 @@ void __mark_inode_dirty(struct inode *inode, int flags)
 			sb->s_op->dirty_inode(inode);
 	}
 
+	if (flags & (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES))
+		trace_inode_dirty(inode);
+
 	/*
 	 * make sure that changes are seen by all cpus before we test i_state
 	 * -- mikulas
diff --git a/fs/inode.c b/fs/inode.c
index ae2727a..e8b1d42 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1708,3 +1708,7 @@ void inode_init_owner(struct inode *inode, const struct inode *dir,
 	inode->i_mode = mode;
 }
 EXPORT_SYMBOL(inode_init_owner);
+
+#define CREATE_TRACE_POINTS
+#include <trace/events/vfs.h>
+
diff --git a/include/trace/events/vfs.h b/include/trace/events/vfs.h
new file mode 100644
index 0000000..7e5c135
--- /dev/null
+++ b/include/trace/events/vfs.h
@@ -0,0 +1,35 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM vfs
+
+#if !defined(_TRACE_VFS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_VFS_H
+
+/*
+ * Tracepoint for dirtying an inode:
+ */
+TRACE_EVENT(inode_dirty,
+
+	TP_PROTO(struct inode *inode),
+
+	TP_ARGS(inode),
+
+	TP_STRUCT__entry(
+		__field(	int,	dev_major		)
+		__field(	int,	dev_minor		)
+		__field(	ino_t,	ino			)
+	),
+
+	TP_fast_assign(
+		__entry->dev_major = MAJOR(inode->i_sb->s_dev);
+		__entry->dev_minor = MINOR(inode->i_sb->s_dev);
+		__entry->ino	   = inode->i_ino;
+	),
+
+	TP_printk("dev %d,%d ino %lu ", __entry->dev_major, __entry->dev_minor,
+		  (unsigned long) __entry->ino)
+);
+
+#endif /* _TRACE_VFS_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
-- 
1.7.2.3


-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org

^ permalink raw reply related	[flat|nested] 38+ messages in thread
* [PATCH] vfs: Add a trace point in the mark_inode_dirty function
@ 2009-10-26  5:53 Arjan van de Ven
  2009-10-26  6:03 ` Andrew Morton
                   ` (3 more replies)
  0 siblings, 4 replies; 38+ messages in thread
From: Arjan van de Ven @ 2009-10-26  5:53 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-fsdevel, Christoph Hellwig, Al Viro, mingo,
	Frederic Weisbecker, auke-jan.h.kok

>From b894af8a33bec621dd1a4126603a3ca372bf0643 Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <arjan@linux.intel.com>
Date: Sun, 25 Oct 2009 15:37:04 -0700
Subject: [PATCH] vfs: Add a trace point in the mark_inode_dirty function

PowerTOP would like to be able to show who is keeping the disk
busy by dirtying data. The most logical spot for this is in the vfs
in the mark_inode_dirty() function. Doing this on the block level
is not possible because by the time the IO hits the block layer the
guilty party can no longer be found ("kjournald" and "pdflush" are not
useful answers to "who caused this file to be dirty).

The trace point follows the same logic/style as the block_dump code
and pretty much dumps the same data, just not to dmesg (and thus to
/var/log/messages) but via the trace events streams.

Signed-of-by: Arjan van de Ven <arjan@linux.intel.com>
---
 fs/fs-writeback.c          |    3 ++
 fs/inode.c                 |    4 +++
 include/trace/events/vfs.h |   53 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+), 0 deletions(-)
 create mode 100644 include/trace/events/vfs.h

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 9d5360c..4102f20 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -25,6 +25,7 @@
 #include <linux/blkdev.h>
 #include <linux/backing-dev.h>
 #include <linux/buffer_head.h>
+#include <trace/events/vfs.h>
 #include "internal.h"
 
 #define inode_to_bdi(inode)	((inode)->i_mapping->backing_dev_info)
@@ -1071,6 +1072,8 @@ void __mark_inode_dirty(struct inode *inode, int flags)
 	if ((inode->i_state & flags) == flags)
 		return;
 
+	trace_dirty_inode(inode, current);
+
 	if (unlikely(block_dump))
 		block_dump___mark_inode_dirty(inode);
 
diff --git a/fs/inode.c b/fs/inode.c
index 4d8e3be..a61e8ba 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1624,3 +1624,7 @@ void init_special_inode(struct inode *inode, umode_t mode, dev_t rdev)
 				  inode->i_ino);
 }
 EXPORT_SYMBOL(init_special_inode);
+
+#define CREATE_TRACE_POINTS  
+#include <trace/events/vfs.h>
+
diff --git a/include/trace/events/vfs.h b/include/trace/events/vfs.h
new file mode 100644
index 0000000..21cf9fb
--- /dev/null
+++ b/include/trace/events/vfs.h
@@ -0,0 +1,53 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM vfs
+
+#if !defined(_TRACE_VFS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_VFS_H
+
+/*
+ * Tracepoint for dirtying an inode:
+ */
+TRACE_EVENT(dirty_inode,
+
+	TP_PROTO(struct inode *inode, struct task_struct *task),
+
+	TP_ARGS(inode, task),
+
+	TP_STRUCT__entry(
+		__array( char,	comm,	TASK_COMM_LEN	)
+		__field( pid_t,	pid			)
+		__array( char,  dev,    16		)
+		__array( char,  file,   32		)
+	),
+
+	TP_fast_assign(
+		if (inode->i_ino || strcmp(inode->i_sb->s_id, "bdev")) {
+                	struct dentry *dentry;
+                	const char *name = "?";
+
+			dentry = d_find_alias(inode);
+			if (dentry) {
+				spin_lock(&dentry->d_lock);
+				name = (const char *) dentry->d_name.name;
+			}
+
+			memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
+			__entry->pid = task->pid;
+			strlcpy(__entry->file, name, 32);
+			strlcpy(__entry->dev, inode->i_sb->s_id, 16);
+
+			if (dentry) {
+				spin_unlock(&dentry->d_lock);
+				dput(dentry);
+			}
+		}
+	),
+
+	TP_printk("task=%i (%s) file=%s dev=%s",
+		__entry->pid, __entry->comm, __entry->file, __entry->dev)
+);
+
+#endif /* _TRACE_VFS_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
-- 
1.6.2.5



-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org

^ permalink raw reply related	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2010-11-30  0:37 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-26 20:56 [PATCH] vfs: Add a trace point in the mark_inode_dirty function Arjan van de Ven
2010-11-28 17:52 ` Christoph Hellwig
2010-11-28 18:43   ` Arjan van de Ven
2010-11-29  1:41     ` KOSAKI Motohiro
2010-11-29  4:54       ` Arjan van de Ven
2010-11-29  5:15         ` KOSAKI Motohiro
2010-11-29 14:21           ` Steven Rostedt
2010-11-29 14:41             ` Mathieu Desnoyers
2010-11-29 16:31               ` Steven Rostedt
2010-11-30  0:37             ` KOSAKI Motohiro
2010-11-29  3:53     ` Nick Piggin
  -- strict thread matches above, loose matches on Subject: below --
2009-10-26  5:53 Arjan van de Ven
2009-10-26  6:03 ` Andrew Morton
2009-10-26  6:55   ` Arjan van de Ven
2009-10-27 16:01 ` Jason Baron
2009-11-11  2:01 ` Wu Fengguang
2009-11-11  6:34   ` Arjan van de Ven
2009-11-11  6:40     ` Wu Fengguang
2009-11-11  7:42     ` Jeff Garzik
2009-11-11  7:45       ` Ingo Molnar
2009-11-11  7:56         ` Jeff Garzik
2009-11-11 11:15           ` Ingo Molnar
2009-11-11 17:27         ` Kok, Auke
2009-11-11 18:29         ` Theodore Tso
2009-11-11 18:56           ` Ingo Molnar
2009-11-12  2:15           ` Arjan van de Ven
2009-11-11 16:19       ` Arjan van de Ven
2009-11-11 23:10         ` Frank Ch. Eigler
2009-11-11 23:37           ` Kok, Auke
2009-11-12  7:22             ` Ingo Molnar
2009-11-20 10:43               ` Christoph Hellwig
2009-11-20 10:51                 ` Ingo Molnar
2009-11-20 14:45                 ` Arjan van de Ven
2009-11-20 16:05                   ` Jamie Lokier
2009-11-20 16:45                     ` Arjan van de Ven
2009-11-11  2:33 ` Li Zefan
2009-11-15 19:00   ` Arjan van de Ven
2009-11-16  0:56     ` Li Zefan

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).