Messages in this thread | | | Date | Wed, 30 Sep 2009 17:57:25 +0200 | From | Eric Dumazet <> | Subject | Re: Linux 2.6.32-rc1 |
| |
Arjan van de Ven a écrit : > On Tue, 29 Sep 2009 14:56:28 -0700 (PDT) > Linus Torvalds <torvalds@linux-foundation.org> wrote: > >> >> On Tue, 29 Sep 2009, Arjan van de Ven wrote: >>> can't we use alternatives() for this, to patch cmpxchg64 in ? >>> I mean.. it'll be commonly supported nowadays.. the fallback to it >>> not being supported could be a bit slower by now... >> Yes, we could. It would limit us to some fixed address format, >> probably >> >> cmpxchg8b (%esi) >> >> or something. Use something like this as a starting point, perhaps? >> >> NOTE! Totally untested! And you'd actually need to implement the >> "cmpxchg8b_emu" function that takes it's arguments in %eax:%edx, >> %ebx:%ecx and %esi and doesn't trash any other registers.. > > so I debugged this guy (had a few bugs ;-) > > patch, including a new cmpxchg8b_emu below: > >>From 5a76986c5dd272ea16a9b8abb7349ff3d6791c2b Mon Sep 17 00:00:00 2001 > From: Arjan van de Ven <arjan@linux.intel.com> > Date: Wed, 30 Sep 2009 17:04:35 +0200 > Subject: [PATCH] x86: Provide an alternative() based cmpxchg64() > > Based on Linus' patch, this patch provides cmpxchg64() using > the alternative() infrastructure. > > Note: the fallback is NOT smp safe, just like the current fallback > is not SMP safe. > > Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
> +#define cmpxchg64(ptr, o, n) \ > +({ \ > + __typeof__(*(ptr)) __ret; \ > + __typeof__(*(ptr)) __old = (o); \ > + __typeof__(*(ptr)) __new = (n); \ > + alternative_io("call cmpxchg8b_emu", \ > + "lock; cmpxchg8b (%%esi)" , \ > + X86_FEATURE_CX8, \ > + "=A" (__ret), \ > + "S" ((ptr)), "0" (__old), \ > + "b" ((unsigned int)__new), \ > + "c" ((unsigned int)(__new>>32))); \
Note:
lock; cmpxchg8b (%%esi)
gives 4 bytes opcode : f0 0f c7 0e Because alternative (call cmpxchg8b_emu) uses 5 bytes, a nop will be added.
Choosing ".byte 0xf0, 0x0f, 0xc7, 0x4e, 0x00" aka "lock cmpxchg8b 0x0(%esi)" is a litle bit better ?
-- 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/
| |