aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2013-11-14 22:57:29 -0500
committerChris Mason <chris.mason@fusionio.com>2013-11-20 20:44:47 -0500
commit4cd8587ce8fb79e49d1d6d1fc065f056188fb86a (patch)
tree3139157ec70bf16dcc5a436eccd743d41397dc5e
parent52a157592140ac76d9f15637543aecc2100f95cb (diff)
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@goodmis.org> Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
-rw-r--r--fs/btrfs/inode.c3
-rw-r--r--include/trace/events/btrfs.h4
2 files changed, 4 insertions, 3 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index fd67b34e220d..f1a77449d032 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6187,8 +6187,7 @@ insert:
6187 write_unlock(&em_tree->lock); 6187 write_unlock(&em_tree->lock);
6188out: 6188out:
6189 6189
6190 if (em) 6190 trace_btrfs_get_extent(root, em);
6191 trace_btrfs_get_extent(root, em);
6192 6191
6193 if (path) 6192 if (path)
6194 btrfs_free_path(path); 6193 btrfs_free_path(path);
diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h
index f18b3b76e01e..4832d75dcbae 100644
--- a/include/trace/events/btrfs.h
+++ b/include/trace/events/btrfs.h
@@ -162,12 +162,14 @@ DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
162 { EXTENT_FLAG_LOGGING, "LOGGING" }, \ 162 { EXTENT_FLAG_LOGGING, "LOGGING" }, \
163 { EXTENT_FLAG_FILLING, "FILLING" }) 163 { EXTENT_FLAG_FILLING, "FILLING" })
164 164
165TRACE_EVENT(btrfs_get_extent, 165TRACE_EVENT_CONDITION(btrfs_get_extent,
166 166
167 TP_PROTO(struct btrfs_root *root, struct extent_map *map), 167 TP_PROTO(struct btrfs_root *root, struct extent_map *map),
168 168
169 TP_ARGS(root, map), 169 TP_ARGS(root, map),
170 170
171 TP_CONDITION(map),
172
171 TP_STRUCT__entry( 173 TP_STRUCT__entry(
172 __field( u64, root_objectid ) 174 __field( u64, root_objectid )
173 __field( u64, start ) 175 __field( u64, start )