On Mon, 21 Apr 2003, Andi Kleen wrote:
>
> This patch implements automatic code patching of memory barriers based
> on the CPU capabilities. Normally lock ; addl $0,(%esp) barriers
> are used, but these are a bit slow on the Pentium 4.
Could you fix this part:
+ /* fill the overlap with single byte nops */
+ memset(a->instr + a->replacementlen, 0x90,
+ a->instrlen - a->replacementlen);
to use an array of replacements, something like
#define MAXSIZE 6
char *nop_sizes[MAXSIZE] = {
NULL, // "zero sized nop"? I don't think so
{ 0x90 }, // simple one-byte no-op.
{ .. whatever the two-byte NOP is .. }
...
};
and then have something like
replace = a->instrlen - a->replacementlen;
nop = a->instr + a->replacementlen;
while (replace) {
int size = replace;
if (size > MAXSIZE)
size = MAXSIZE;
memcpy(nop, nop_sizes + size, size);
nop += size;
replace -= size;
}
instead? I think it's silly to have multiple single-byte nops, when there
are well-defined multi-byte nops available.
Other than that this looks pretty good.
Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Wed Apr 23 2003 - 22:00:30 EST