lkml.org 
[lkml]   [2003]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Runtime memory barrier patching

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/

\
 
 \ /
  Last update: 2005-03-22 13:34    [W:0.051 / U:0.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site