Re: [PATCH 0/4] jump label patches
From: Roland McGrath
Date: Tue Oct 06 2009 - 20:16:18 EST
> At present, the asm goto extension gives no prediction weights to any
> path. I had hoped that the -freorder-blocks pass (enabled with -O2)
> would automatically place the relevant fallthrough blocks immediately
> after the asm goto. It did happen for small test cases, but a message
> from Jason downthread indicates that it doesn't always happen.
Kernel builds usually use -Os. Is there anything else we can do now (4.4)
to influence this placement (while keeping the unlikely target block inside
a scope, i.e. macro, with the asm goto)?
Also note that another usage pattern I'm considering for the general case
would (via fancy macros) look something like:
if (({ __label__ yes; int maybe = 0;
asm goto ("jmp %l[yes]" ::: yes);
if (0) yes: maybe = 1;
maybe; }))
doit();
else
dontit();
So please also advise on making something of that character come out optimal.
> > if (__builtin_expect(0,0)) do_trace: __attribute__((cold)) { ... }
>
> An attribute cold on a label is something that I've suggested, but have
> not yet implemented. I think that might be the easiest way to add
> prediction weights to an asm goto.
Ok. That syntax is accepted already now (4.4.1 anyway) but always generates:
warning: ?cold? attribute ignored
so it would be annoying to start using it now before compiler-version
conditionals for a version where it does at most nothing.
Btw, if you do make that work I think it would be nice (and seems like it
would be not much different internally) to make:
label: __attribute__ ((cold, section (".text.lukewarm")))
work too. I can see this being used for a few different kinds of things,
where a specialized user like the kernel might want to segregate multiple
different kinds of text. e.g., "really cold" for rare exception stuff,
"tracepoint warm" for stuff that's cold by default but actually hot if
lots of tracing is enabled, etc.
Thanks,
Roland
--
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/