arm: Add for atomic half word exchange
Yes, I will try to do that. OTOH, I saw that there was a discussion on removal of bad_xchg() altogether. Perhaps that approach be better than adding this half word exchange?
Regards,
Sarbojit
------- Original Message -------
Sender : Arnd Bergmann<[email protected]>
Date : May 19, 2015 18:51 (GMT+09:00)
Title : Re: [RFC] arm: Add for atomic half word exchange
Quoted 2 lines · On Tuesday 19 May 2015 09:39:33 Sarbojit Ganguly wrote:
Since 16 bit half word exchange was not there and MCS based qspinlock by Waiman's
xchg_tail()requires an atomic exchange on a half word, here is a small modification to__xchg()code.
We have discussed a similar patch before, see
https://lkml.org/lkml/2015/2/25/390
Quoted 13 lines
#if
__LINUX_ARM_ARCH__>= 6(quoted diff) +8
-0@@ -50,6 +52,23 @@ : "r" (x), "r" (ptr) : "memory", "cc"); break; + /* + * halfword exclusive exchange + * This is new implementation as qspinlock + * wants 16 bit atomic CAS. + */ + case 2: + asm volatile("@ __xchg2\n" + "1: ldrexh %0, [%3]\n"
Review line 72
Quoted 10 lines
(quoted diff) +7
-0+ " strexh %1, %2, [%3]\n" + " teq %1, #0\n" + " bne 1b" + : "=&r" (ret), "=&r" (tmp) + : "r" (x), "r" (ptr) + : "memory", "cc"); + break; case 4: asm volatile("@ __xchg4\n" "1: ldrex %0, [%3]\n"
Please try to find a way to make this compile when CONFIG_CPU_V6 is set.
Arnd
Quoted 3 lines · On Tuesday 19 May 2015 11:20:11 Sarbojit Ganguly wrote:
Yes, I will try to do that. OTOH, I saw that there was a discussion on removal of
bad_xchg()altogether. Perhaps that approach be better than adding this half word exchange?
Removing bad_xchg() only helps insofar as we get a link-time error instead of a run-time error. That is certainly a good idea, but it does not solve your problem.
Arnd
Quoted 3 lines · Sarbojit Ganguly
Yes, I will try to do that. OTOH, I saw that there was a discussion on removal of
bad_xchg()altogether. Perhaps that approach be better than adding this half word exchange?
The only possibility for removal of __bad_xchg() is to remove it's _definition_ only, not its callsite, so that we get a _link_ time error for use cases we don't support.
Removing its callsite leaves us open to code malfunction: xchg() effectively becomes a no-op for sizes which are not supported, and that's a _very_ bad thing to happen.
Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up according to speedtest.net.
Quoted 4 lines · Sarbojit Ganguly
Quoted 3 lines · On Tuesday 19 May 2015 09:39:33 Sarbojit Ganguly wrote:
Since 16 bit half word exchange was not there and MCS based qspinlock by Waiman's
xchg_tail()requires an atomic exchange on a half word, here is a small modification to__xchg()code.
Can you actually see a performance improvement with the qspinlock code on ARM ?
The real improvements on x86 were on NUMA systems; although there were real improvements on light loads as well.
Note that ARM (or any load-store arch) could get rid of all the cmpxchg loops in that code. Although I suppose we replaced the most common ones with these unconditional atomics already -- like that xchg16 -- so implementing those with ll/sc, as you did, should be near optimal.