linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Subject: [PATCH 5/6] f2fs: add spin_lock to cover radix operations in IO tracer
Date: Thu,  8 Jan 2015 10:11:00 -0800	[thread overview]
Message-ID: <1420740661-72288-5-git-send-email-jaegeuk@kernel.org> (raw)
In-Reply-To: <1420740661-72288-1-git-send-email-jaegeuk@kernel.org>

This patch adds spin_lock to cover radix tree operations in IO tracer.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/super.c |  2 ++
 fs/f2fs/trace.c | 18 +++++++++++++++---
 fs/f2fs/trace.h |  2 ++
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 0ae6a2f..e6f035c 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1222,6 +1222,8 @@ static int __init init_f2fs_fs(void)
 {
 	int err;
 
+	f2fs_build_trace_ios();
+
 	err = init_inodecache();
 	if (err)
 		goto fail;
diff --git a/fs/f2fs/trace.c b/fs/f2fs/trace.c
index 19f5216..92fa38a 100644
--- a/fs/f2fs/trace.c
+++ b/fs/f2fs/trace.c
@@ -15,7 +15,8 @@
 #include "f2fs.h"
 #include "trace.h"
 
-RADIX_TREE(pids, GFP_NOIO);
+RADIX_TREE(pids, GFP_ATOMIC);
+spinlock_t pids_lock;
 struct last_io_info last_io;
 
 static inline void __print_last_io(void)
@@ -58,9 +59,13 @@ void f2fs_trace_pid(struct page *page)
 
 	page->private = pid;
 
+	if (radix_tree_preload(GFP_NOFS))
+		return;
+
+	spin_lock(&pids_lock);
 	p = radix_tree_lookup(&pids, pid);
 	if (p == current)
-		return;
+		goto out;
 	if (p)
 		radix_tree_delete(&pids, pid);
 
@@ -69,7 +74,9 @@ void f2fs_trace_pid(struct page *page)
 	trace_printk("%3x:%3x %4x %-16s\n",
 			MAJOR(inode->i_sb->s_dev), MINOR(inode->i_sb->s_dev),
 			pid, current->comm);
-
+out:
+	spin_unlock(&pids_lock);
+	radix_tree_preload_end();
 }
 
 void f2fs_trace_ios(struct page *page, struct f2fs_io_info *fio, int flush)
@@ -108,3 +115,8 @@ void f2fs_trace_ios(struct page *page, struct f2fs_io_info *fio, int flush)
 	last_io.len = 1;
 	return;
 }
+
+void f2fs_build_trace_ios(void)
+{
+	spin_lock_init(&pids_lock);
+}
diff --git a/fs/f2fs/trace.h b/fs/f2fs/trace.h
index aa6663b..eb39fa0 100644
--- a/fs/f2fs/trace.h
+++ b/fs/f2fs/trace.h
@@ -34,9 +34,11 @@ struct last_io_info {
 
 extern void f2fs_trace_pid(struct page *);
 extern void f2fs_trace_ios(struct page *, struct f2fs_io_info *, int);
+extern void f2fs_build_trace_ios(void);
 #else
 #define f2fs_trace_pid(p)
 #define f2fs_trace_ios(p, i, n)
+#define f2fs_build_trace_ios()
 
 #endif
 #endif /* __F2FS_TRACE_H__ */
-- 
2.1.1


------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net

  parent reply	other threads:[~2015-01-08 18:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-08 18:10 [PATCH 1/6] f2fs: fix wrong unlock_page call Jaegeuk Kim
2015-01-08 18:10 ` [PATCH 2/6] f2fs: support goingdown for fs shutdown Jaegeuk Kim
2015-01-08 19:54   ` Eric Sandeen
2015-01-08 20:18     ` Jaegeuk Kim
2015-01-08 20:33       ` Eric Sandeen
2015-01-08 20:54         ` Dave Chinner
2015-01-08 21:21           ` Jaegeuk Kim
2015-01-08 22:04             ` Dave Chinner
2015-01-08 22:16               ` Jaegeuk Kim
2015-01-09  1:40                 ` [PATCH 2/6 v2] " Jaegeuk Kim
2015-01-09  2:24                   ` [f2fs-dev] " Dave Chinner
2015-01-08 18:10 ` [PATCH 3/6] f2fs: free radix_tree_nodes used by nat_set entries Jaegeuk Kim
2015-01-08 18:10 ` [PATCH 4/6] f2fs: add nat/sit entries into status Jaegeuk Kim
2015-01-08 18:11 ` Jaegeuk Kim [this message]
2015-01-08 18:11 ` [PATCH 6/6] f2fs: add f2fs_destroy_trace_ios to free radix tree Jaegeuk Kim

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=1420740661-72288-5-git-send-email-jaegeuk@kernel.org \
    --to=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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).