On Thu, 3 Aug 2017 09:19:18 +0530
Madhavan Srinivasan [off-list ref] wrote:
quoted hunk ↗ jump to hunk
@@ -14,6 +17,202 @@ typedef struct
#define local_read(l) atomic_long_read(&(l)->a)
#define local_set(l,i) atomic_long_set(&(l)->a, (i))
+#ifdef CONFIG_PPC64
+
+static __inline__ void local_add(long i, local_t *l)
+{
+ long t;
+ unsigned long flags;
+
+ powerpc_local_irq_pmu_save(flags);
+ __asm__ __volatile__(
+ PPC_LL" %0,0(%2)\n\
+ add %0,%1,%0\n"
+ PPC_STL" %0,0(%2)\n"
+ : "=&r" (t)
+ : "r" (i), "r" (&(l->a.counter)));
+ powerpc_local_irq_pmu_restore(flags);
+}
Hey, so... why are any of these implemented in asm? We should
just do them all in C, right? I looked a bit harder at code gen
and a couple of them are still emitting larx/stcx.
quoted hunk ↗ jump to hunk
+
+#define local_cmpxchg(l, o, n) \
+ (cmpxchg_local(&((l)->a.counter), (o), (n)))
+#define local_xchg(l, n) (xchg_local(&((l)->a.counter), (n)))
e.g., these.
Thanks,
Nick