Re: [RFC patch 23/27] Immediate Values - Powerpc Optimization NMIMCE support

From: Paul Mackerras
Date: Wed Apr 16 2008 - 20:35:24 EST


Mathieu Desnoyers writes:

> * Paul Mackerras (paulus@xxxxxxxxx) wrote:
> > Mathieu Desnoyers writes:
> >
> > > Use an atomic update for immediate values.
> >
> > What is meant by an "atomic" update in this context? AFAICS you are
> > using memcpy, which is not in any way guaranteed to be atomic.
> >
> > Paul.
>
> I expect memcpy to perform the copy in one memory access, given I put a
>
> .align 2
>
> before the 2 bytes instruction. It makes sure the instruction modified
> fits in a single, aligned, memory write.

My original question was in the context of the powerpc architecture,
where instructions are always 4 bytes long and aligned. So that's not
an issue.

> Or maybe am I expecting too much from memcpy ?

I don't think memcpy gives you any such guarantees. It would be quite
within its rights to say "it's only a few bytes, I'll do it byte by
byte".

If you really want it to be atomic (which I agree is probably a good
idea), I think the best way to do it is to use an asm to generate a
sth (store halfword) instruction to the immediate field (instruction
address + 2). That's on powerpc of course; I don't know what you
would do on other architectures.

Paul.
--
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/