Re: [PATCH] tracing: Cleanup the convoluted softirq tracepoints

From: H. Peter Anvin
Date: Tue Oct 19 2010 - 19:40:37 EST


On 10/19/2010 03:27 PM, Peter Zijlstra wrote:
>
> Due to not actually having a sane key type the above is not easy to
> implement, but I tried:
>
> #define _SWITCH_POINT(x)\
> ({ \
> __label__ jl_enabled; \
> bool ret = true; \
> JUMP_LABEL(x, jl_enabled); \
> ret = false; \
> jl_enabled: \
> ret; })
>
> #define SWITCH_POINT(x) unlikely(_SWITCH_POINT(x))
>
> #define COND_STMT(key, stmt) \
> do { \
> if (SWITCH_POINT(key)) { \
> stmt; \
> } \
> } while (0)
>
>
> and that's still generating these double jumps.
>

I just experimented with it, and the ({...}) construct doesn't work,
because it looks like a merged flow of control to gcc.

Replacing the ({ ... }) with an inline does indeed remove the double
jumps.

diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index b67cb18..2ff829d 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -61,12 +61,22 @@ static inline int jump_label_text_reserved(void
*start, void *end)

#endif

+static __always_inline __pure bool _SWITCH_POINT(void *x)
+{
+ asm goto("# SWITCH_POINT %0\n\t"
+ ".byte 0x66,0x66,0x66,0x66,0x90\n"
+ "1:"
+ : : "i" (x) : : jl_enabled);
+ return false;
+jl_enabled:
+ return true;
+}
+
+#define SWITCH_POINT(x) unlikely(_SWITCH_POINT(x))
+
#define COND_STMT(key, stmt) \
do { \
- __label__ jl_enabled; \
- JUMP_LABEL(key, jl_enabled); \
- if (0) { \
-jl_enabled: \
+ if (SWITCH_POINT(key)) { \
stmt; \
} \
} while (0)


The key here seems to be to not use the JUMP_LABEL macro as implemented;
I have utterly failed to make JUMP_LABEL() do the right thing.


-hpa
--
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/