@@ -110,18 +110,18 @@ static inline unsigned long __xchg(unsigned long val, volatile void *ptr,
110110 sizeof(*(ptr))))
111111
112112/*
113- * On ARC700, EX insn is inherently atomic, so by default "vanilla" xchg() need
114- * not require any locking. However there's a quirk.
115- * ARC lacks native CMPXCHG, thus emulated (see above), using external locking -
116- * incidently it "reuses" the same atomic_ops_lock used by atomic APIs.
117- * Now, llist code uses cmpxchg() and xchg() on same data, so xchg() needs to
118- * abide by same serializing rules, thus ends up using atomic_ops_lock as well .
113+ * xchg() maps directly to ARC EX instruction which guarantees atomicity.
114+ * However in !LLSC config, it also needs to be use @atomic_ops_lock spinlock
115+ * due to a subtle reason:
116+ * - For !LLSC, cmpxchg() needs to use that lock (see above) and there is lot
117+ * of kernel code which calls xchg()/cmpxchg() on same data (see llist.h)
118+ * Hence xchg() needs to follow same locking rules .
119119 *
120- * This however is only relevant if SMP and/or ARC lacks LLSC
121- * if (UP or LLSC)
122- * xchg doesn't need serialization
123- * else <==> !(UP or LLSC) <==> (!UP and !LLSC) <==> (SMP and !LLSC)
124- * xchg needs serialization
120+ * Technically the lock is also needed for UP (boils down to irq save/restore)
121+ * but we can cheat a bit since cmpxchg() atomic_ops_lock() would cause irqs to
122+ * be disabled thus can't possibly be interrpted/preempted/clobbered by xchg()
123+ * Other way around, xchg is one instruction anyways, so can't be interrupted
124+ * as such
125125 */
126126
127127#if !defined(CONFIG_ARC_HAS_LLSC ) && defined(CONFIG_SMP )
0 commit comments