• Steven Rostedt's avatar
    btrfs: Use trace condition for get_extent tracepoint · 4cd8587c
    Steven Rostedt authored
    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: default avatarSteven Rostedt <rostedt@goodmis.org>
    Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
    Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
    4cd8587c
inode.c 231 KB