btrfs: Use trace condition for get_extent tracepoint

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Nov 22 17:59:04 EST 2013


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=4cd8587ce8fb79e49d1d6d1fc065f056188fb86a
Commit:     4cd8587ce8fb79e49d1d6d1fc065f056188fb86a
Parent:     52a157592140ac76d9f15637543aecc2100f95cb
Author:     Steven Rostedt <rostedt at goodmis.org>
AuthorDate: Thu Nov 14 22:57:29 2013 -0500
Committer:  Chris Mason <chris.mason at fusionio.com>
CommitDate: Wed Nov 20 20:44:47 2013 -0500

    btrfs: Use trace condition for get_extent tracepoint
    
    Doing an if statement to test some condition to know if we should
    trigger a tracepoint is pointless when tracing is disabled. This just
    adds overhead and wastes a branch prediction. This is why the
    TRACE_EVENT_CONDITION() was created. It places the check inside the jump
    label so that the branch does not happen unless tracing is enabled.
    
    That is, instead of doing:
    
    	if (em)
    		trace_btrfs_get_extent(root, em);
    
    Which is basically this:
    
    	if (em)
    		if (static_key(trace_btrfs_get_extent)) {
    
    Using a TRACE_EVENT_CONDITION() we can just do:
    
    	trace_btrfs_get_extent(root, em);
    
    And the condition trace event will do:
    
    	if (static_key(trace_btrfs_get_extent)) {
    		if (em) {
    			...
    
    The static key is a non conditional jump (or nop) that is faster than
    having to check if em is NULL or not.
    
    Signed-off-by: Steven Rostedt <rostedt at goodmis.org>
    Signed-off-by: Josef Bacik <jbacik at fusionio.com>
    Signed-off-by: Chris Mason <chris.mason at fusionio.com>
---
 fs/btrfs/inode.c             | 3 +--
 include/trace/events/btrfs.h | 4 +++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index fd67b34..f1a7744 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6187,8 +6187,7 @@ insert:
 	write_unlock(&em_tree->lock);
 out:
 
-	if (em)
-		trace_btrfs_get_extent(root, em);
+	trace_btrfs_get_extent(root, em);
 
 	if (path)
 		btrfs_free_path(path);
diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h
index f18b3b7..4832d75 100644
--- a/include/trace/events/btrfs.h
+++ b/include/trace/events/btrfs.h
@@ -162,12 +162,14 @@ DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
 		{ EXTENT_FLAG_LOGGING,	 	"LOGGING" 	},	\
 		{ EXTENT_FLAG_FILLING,	 	"FILLING" 	})
 
-TRACE_EVENT(btrfs_get_extent,
+TRACE_EVENT_CONDITION(btrfs_get_extent,
 
 	TP_PROTO(struct btrfs_root *root, struct extent_map *map),
 
 	TP_ARGS(root, map),
 
+	TP_CONDITION(map),
+
 	TP_STRUCT__entry(
 		__field(	u64,  root_objectid	)
 		__field(	u64,  start		)



More information about the linux-mtd-cvs mailing list