# Re: \[PATCH RFC 1/2\] arch: Introduce ARCH\_HAS\_HW\_XCHG\_SMALL

- From: Arnd Bergmann \<arnd@arndb.de\>
- Date: 2021-07-24 19:24:31 
- List: linux-arch
- Page: https://ratatoskr.run/linux-arch/2021/07/13337122
- Thread: https://ratatoskr.run/linux-arch/2021/07/13337119/t.md

```text
On Sat, Jul 24, 2021 at 2:36 PM Huacai Chen [ref] wrote:
>
> Introduce a new Kconfig option ARCH_HAS_HW_XCHG_SMALL, which means arch
> has hardware sub-word xchg/cmpxchg support. This option will be used as
> an indicator to select the bit-field definition in the qspinlock data
> structure.
>
> Signed-off-by: Huacai Chen <redacted>

Adding a Kconfig conditional sounds like a good idea, but I have two
concerns about the specific implementation:

- I think we should have separate symbols for 8-bit, 16-bit and 64-bit
  cmpxchg(). I think every architecture needs to support at least 32-bit
  cmpxchg() and 64-bit architectures also need to support cmpxchg64().
  I actually have a prototype patch that introduces cmpxchg8() and
  cmpxchg16() helpers with the purpose of no longer supporting these
  width in the normal cmpxchg(), but that is mostly independent of
  whether we want a conditional or not.

- If I remember correctly, there were some concerns about whether using
  this information for picking the qspinlock implementation is a good idea.

         Arnd
```
