Re: [PATCH 0/3] jump label: updates for 2.6.37

From: Steven Rostedt
Date: Tue Nov 23 2010 - 19:10:25 EST


On Tue, 2010-11-23 at 15:32 -0800, H. Peter Anvin wrote:
> On 11/23/2010 03:11 PM, Steven Rostedt wrote:
> >> I would also like to see a change in the API, preferrably something
> >> closer to the "SWITCH_POINT" interface I discussed with Stephen before
> >> Kernel Summit.
> >
> > Could you explain in more detail what you would like to see.
>
> The JUMP_LABEL() macro is rather ugly, and I found from the
> static_cpu_has() work that inlines like (somewhat pseudocode here):
>
> static inline bool SWITCH_POINT(void *metadata)
> {
> asm goto("1: <5 byte nop>\n"
> ".section \".metadata\",\"a\"\n"
> ".long 1b, %p0\n"
> ".previous\n"
> : : "i" (metadata)
> : : l_yes);
> return false;
> l_yes:
> return true;
> }
>
> ... work quite well; with the resulting SWITCH_POINT() being usable like
> any other boolean expression in the kernel, i.e. as part of if, while,
> etc. Most of the time, gcc is smart enough to just use the flow of
> control provided, and it also permits backwards compatibility with older
> gcc by patching in a one-byte immediate instead.
>
> There are some instances where it double-jumps; those can be avoided by
> always jumping (allowing the patch code to replace the jump with a
> 5-byte NOP opportunistically a posteori) but unfortunately current gcc
> tends to not order the sequentially next code afterwards if one does that.
>

So you would rather have it as an if statement? Something like this:

if (unlikely(JUMP_LABEL(key)))
__DO_TRACE(....);

(Note, I like the above better too)

-- Steve


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/