On Fri, Nov 15, 2024 at 10:40:08AM -0800, Josh Poimboeuf wrote: > On Mon, Nov 11, 2024 at 12:59:39PM +0100, Peter Zijlstra wrote: > > +++ b/include/linux/objtool.h > > @@ -51,13 +51,16 @@ > > ".long 998b\n\t" \ > > ".popsection\n\t" > > > > -#define ASM_ANNOTATE(x) \ > > - "911:\n\t" \ > > +#define __ASM_ANNOTATE(s, x) \ > > ".pushsection .discard.annotate,\"M\",@progbits,8\n\t" \ > > - ".long 911b - .\n\t" \ > > + ".long " __stringify(s) "b - .\n\t" \ > > It would probably be better for __ASM_ANNOTATE's callers to pass in the > full label name (e.g. '911b') since they know where the label is? It > could even be a named label. This seems to work. --- a/include/linux/instrumentation.h +++ b/include/linux/instrumentation.h @@ -6,11 +6,12 @@ #include <linux/objtool.h> #include <linux/stringify.h> +#include <linux/args.h> /* Begin/end of an instrumentation safe region */ #define __instrumentation_begin(c) ({ \ asm volatile(__stringify(c) ": nop\n\t" \ - __ASM_ANNOTATE(c, ANNOTYPE_INSTR_BEGIN) \ + __ASM_ANNOTATE(CONCATENATE(c, b), ANNOTYPE_INSTR_BEGIN) \ : : "i" (c)); \ }) #define instrumentation_begin() __instrumentation_begin(__COUNTER__) @@ -48,7 +49,7 @@ */ #define __instrumentation_end(c) ({ \ asm volatile(__stringify(c) ": nop\n\t" \ - __ASM_ANNOTATE(c, ANNOTYPE_INSTR_END) \ + __ASM_ANNOTATE(CONCATENATE(c, b), ANNOTYPE_INSTR_END) \ : : "i" (c)); \ }) #define instrumentation_end() __instrumentation_end(__COUNTER__) --- a/include/linux/objtool.h +++ b/include/linux/objtool.h @@ -53,13 +53,13 @@ #define __ASM_ANNOTATE(s, x) \ ".pushsection .discard.annotate,\"M\",@progbits,8\n\t" \ - ".long " __stringify(s) "b - .\n\t" \ + ".long " __stringify(s) " - .\n\t" \ ".long " __stringify(x) "\n\t" \ ".popsection\n\t" #define ASM_ANNOTATE(x) \ "911:\n\t" \ - __ASM_ANNOTATE(911, x) + __ASM_ANNOTATE(911b, x) #define ANNOTATE_NOENDBR ASM_ANNOTATE(ANNOTYPE_NOENDBR)