Jump label reworked
There were a number of complaints about the initial jump label implementation, including the fact that it was somewhat awkward to use. In response, a reworked version has been posted which changes the interface considerably. One starts by declaring a "jump key":
#include <linux/jump_label.h>
struct jump_label_key my_key;
Enabling and disabling the key is a simple matter of calling:
jump_label_inc(struct jump_label_key *key);
jump_label_dec(struct jump_label_key *key);
And using the key to control the execution of rarely-needed code becomes:
if (static_branch(&my_key)) {
/* Unlikely stuff happens here */
}
In the absence of full jump label support, a jump key is represented by an atomic_t value. jump_label_inc() becomes atomic_inc(), jump_label_dec() becomes atomic_dec(), and static_branch() is implemented with atomic_read(). If jump label is configured into the kernel, enabling and disabling a jump key become heavier operations, while static_branch() becomes nearly free. For the intended use cases for jump labels, that is a worthwhile tradeoff.
As of this writing, these changes have not been merged for 2.6.39. There
is always a possibility that they could be pulled in before -rc2, but
chances are that, at this point, the new jump label will have to jump into
2.6.40.
| Index entries for this article | |
|---|---|
| Kernel | Jump label |
