From 000443a6f09dbab0f318af5378c220638523a2a0 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 26 Jan 2012 13:32:15 +0100 Subject: [PATCH] --- yaml --- r: 288623 b: refs/heads/master c: efb3040d481a1594592b1defb4526c406c7a4751 h: refs/heads/master i: 288621: 2b2f8cfed7c816f6b78aa48e98335ab181701bf2 288619: fa16a9f970536d2647103a4736451704be3a39a9 288615: 1d4699601e3ffbc63bc8849ef3d3cc8ab93392c7 288607: 3a7341be2fb273cd84e4c0279458338664e2f488 v: v3 --- [refs] | 2 +- trunk/include/linux/jump_label.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 4515d5ea3f6d..a02f3c5414be 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 44a683971119bafb5bc30778f92ee773680ebb6f +refs/heads/master: efb3040d481a1594592b1defb4526c406c7a4751 diff --git a/trunk/include/linux/jump_label.h b/trunk/include/linux/jump_label.h index 5ce8b140428f..f7c69580fea7 100644 --- a/trunk/include/linux/jump_label.h +++ b/trunk/include/linux/jump_label.h @@ -1,6 +1,38 @@ #ifndef _LINUX_JUMP_LABEL_H #define _LINUX_JUMP_LABEL_H +/* + * Jump label support + * + * Copyright (C) 2009-2012 Jason Baron + * Copyright (C) 2011-2012 Peter Zijlstra + * + * Jump labels provide an interface to generate dynamic branches using + * self-modifying code. Assuming toolchain and architecture support the result + * of a "if (static_branch(&key))" statement is a unconditional branch (which + * defaults to false - and the true block is placed out of line). + * + * However at runtime we can change the 'static' branch target using + * jump_label_{inc,dec}(). These function as a 'reference' count on the key + * object and for as long as there are references all branches referring to + * that particular key will point to the (out of line) true block. + * + * Since this relies on modifying code the jump_label_{inc,dec}() functions + * must be considered absolute slow paths (machine wide synchronization etc.). + * OTOH, since the affected branches are unconditional their runtime overhead + * will be absolutely minimal, esp. in the default (off) case where the total + * effect is a single NOP of appropriate size. The on case will patch in a jump + * to the out-of-line block. + * + * When the control is directly exposed to userspace it is prudent to delay the + * decrement to avoid high frequency code modifications which can (and do) + * cause significant performance degradation. Struct jump_label_key_deferred and + * jump_label_dec_deferred() provide for this. + * + * Lacking toolchain and or architecture support, it falls back to a simple + * conditional branch. + */ + #include #include #include