From patchwork Tue Dec 1 07:46:13 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 39890 X-Patchwork-Delegate: apw@canonical.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id F0EA6B7BCC for ; Tue, 1 Dec 2009 18:46:27 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.60) (envelope-from ) id 1NFNRG-0007Kk-Hn; Tue, 01 Dec 2009 07:46:22 +0000 Received: from mail-bw0-f220.google.com ([209.85.218.220]) by chlorine.canonical.com with esmtp (Exim 4.60) (envelope-from ) id 1NFNRA-0007Hc-Oc for kernel-team@lists.ubuntu.com; Tue, 01 Dec 2009 07:46:16 +0000 Received: by bwz20 with SMTP id 20so3299053bwz.14 for ; Mon, 30 Nov 2009 23:46:16 -0800 (PST) Received: by 10.204.153.217 with SMTP id l25mr5679285bkw.108.1259653576321; Mon, 30 Nov 2009 23:46:16 -0800 (PST) Received: from localhost (a91-154-124-12.elisa-laajakaista.fi [91.154.124.12]) by mx.google.com with ESMTPS id 13sm1765676fxm.1.2009.11.30.23.46.15 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 30 Nov 2009 23:46:15 -0800 (PST) From: amit.kucheria@canonical.com To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/2] vfs: Add a trace point in the mark_inode_dirty function Date: Tue, 1 Dec 2009 09:46:13 +0200 Message-Id: <1259653573-22533-1-git-send-email-amit.kucheria@canonical.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1259653276-19566-1-git-send-email-amit.kucheria@canonical.com> References: <1259653276-19566-1-git-send-email-amit.kucheria@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.8 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com From: Arjan van de Ven 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. Note: This patch was posted to lkml and might potentially go into 2.6.33 but I have not seen which maintainer will take it. Signed-of-by: Arjan van de Ven Signed-off-by: Amit Kucheria --- 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 #include #include +#include #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..b89af38 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 + diff --git a/include/trace/events/vfs.h b/include/trace/events/vfs.h new file mode 100644 index 0000000..3c170f8 --- /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