From: ganguly.s@samsung.com (Sarbojit Ganguly)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC] arm: Add for atomic half word exchange
Date: Tue, 19 May 2015 09:39:33 +0000 (GMT) [thread overview]
Message-ID: <1122007906.400701432028368414.JavaMail.weblogic@ep2mlwas07a> (raw)
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.
--- /linux.trees.git/tip/arch/arm/include/asm/cmpxchg.h 2015-05-11 23:36:06.942583615 +0530
+++ arch/arm/include/asm/cmpxchg.h 2015-04-08 18:40:43.276255712 +0530
@@ -2,9 +2,12 @@
#define __ASM_ARM_CMPXCHG_H
#include <linux/irqflags.h>
#include <asm/barrier.h>
#if defined(CONFIG_CPU_SA1100) || defined(CONFIG_CPU_SA110)
/*
* On the StrongARM, "swp" is terminally broken since it bypasses the
@@ -36,7 +39,6 @@
#endif
smp_mb();
switch (size) {
#if __LINUX_ARM_ARCH__ >= 6
@@ -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"
+ " 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"
@@ -94,6 +113,10 @@
break;
#endif
default:
__bad_xchg(ptr, size), ret = 0;
break;
}
Regards,
Sarbojit
WARNING: multiple messages have this Message-ID (diff)
From: Sarbojit Ganguly <ganguly.s@samsung.com>
To: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com,
peterz@infradead.org, Waiman.Long@hp.com
Cc: torvalds@linux-foundation.org, raghavendra.kt@linux.vnet.ibm.com,
oleg@redhat.com, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
SHARAN ALLUR <sharan.allur@samsung.com>
Subject: [RFC] arm: Add for atomic half word exchange
Date: Tue, 19 May 2015 09:39:32 +0000 (GMT) [thread overview]
Message-ID: <1122007906.400701432028368414.JavaMail.weblogic@ep2mlwas07a> (raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=utf-8, Size: 1846 bytes --]
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.
--- /linux.trees.git/tip/arch/arm/include/asm/cmpxchg.h 2015-05-11 23:36:06.942583615 +0530
+++ arch/arm/include/asm/cmpxchg.h 2015-04-08 18:40:43.276255712 +0530
@@ -2,9 +2,12 @@
#define __ASM_ARM_CMPXCHG_H
#include <linux/irqflags.h>
#include <asm/barrier.h>
#if defined(CONFIG_CPU_SA1100) || defined(CONFIG_CPU_SA110)
/*
* On the StrongARM, "swp" is terminally broken since it bypasses the
@@ -36,7 +39,6 @@
#endif
smp_mb();
switch (size) {
#if __LINUX_ARM_ARCH__ >= 6
@@ -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"
+ " 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"
@@ -94,6 +113,10 @@
break;
#endif
default:
__bad_xchg(ptr, size), ret = 0;
break;
}
Regards,
Sarbojitÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
next reply other threads:[~2015-05-19 9:39 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-19 9:39 Sarbojit Ganguly [this message]
2015-05-19 9:39 ` [RFC] arm: Add for atomic half word exchange Sarbojit Ganguly
2015-05-19 9:51 ` Arnd Bergmann
2015-05-19 9:51 ` Arnd Bergmann
-- strict thread matches above, loose matches on Subject: below --
2015-05-19 11:20 Sarbojit Ganguly
2015-05-19 11:20 ` Sarbojit Ganguly
2015-05-19 11:42 ` Arnd Bergmann
2015-05-19 11:42 ` Arnd Bergmann
2015-05-19 12:13 ` Russell King - ARM Linux
2015-05-19 12:13 ` Russell King - ARM Linux
2015-05-19 12:43 ` Peter Zijlstra
2015-05-19 12:43 ` Peter Zijlstra
2015-05-20 5:09 Sarbojit Ganguly
2015-05-20 6:51 ` Arnd Bergmann
2015-05-20 6:51 ` Arnd Bergmann
2015-05-20 6:57 ` Peter Zijlstra
2015-06-02 5:49 Sarbojit Ganguly
2015-06-02 6:11 ` Raghavendra K T
2015-06-02 6:11 ` Raghavendra K T
2015-06-02 6:21 Sarbojit Ganguly
2015-06-02 10:49 ` Arnd Bergmann
2015-06-02 10:49 ` Arnd Bergmann
2015-06-05 1:17 Re: " Sarbojit Ganguly
2015-06-05 12:33 ` Arnd Bergmann
2015-06-05 12:33 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1122007906.400701432028368414.JavaMail.weblogic@ep2mlwas07a \
--to=ganguly.s@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.