[PATCH] um: "borrow" cmpxchg from x86 tree in UML

Anton Ivanov anton.ivanov at cambridgegreys.com
Fri Nov 13 08:48:36 EST 2020


On 13/11/2020 11:54, anton.ivanov at cambridgegreys.com wrote:
> From: Anton Ivanov <anton.ivanov at cambridgegreys.com>
>
> UML was falling back to asm-generic cmpxchg which emulates atomic
> behaviour by turning irqs on/off. On UML this means turning
> on/off signals for each cmpxchg which is expensive.
>
> Signed-off-by: Anton Ivanov <anton.ivanov at cambridgegreys.com>
> ---
>   arch/um/include/asm/cmpxchg-x86.h |  1 +
>   arch/um/include/asm/cmpxchg.h     | 13 +++++++++++++
>   arch/um/include/asm/cmpxchg_32.h  |  1 +
>   arch/um/include/asm/cmpxchg_64.h  |  1 +
>   4 files changed, 16 insertions(+)
>   create mode 120000 arch/um/include/asm/cmpxchg-x86.h
>   create mode 100644 arch/um/include/asm/cmpxchg.h
>   create mode 120000 arch/um/include/asm/cmpxchg_32.h
>   create mode 120000 arch/um/include/asm/cmpxchg_64.h
>
> diff --git a/arch/um/include/asm/cmpxchg-x86.h b/arch/um/include/asm/cmpxchg-x86.h
> new file mode 120000
> index 000000000000..a5c607edde88
> --- /dev/null
> +++ b/arch/um/include/asm/cmpxchg-x86.h
> @@ -0,0 +1 @@
> +../../../x86/include/asm/cmpxchg.h
> \ No newline at end of file
> diff --git a/arch/um/include/asm/cmpxchg.h b/arch/um/include/asm/cmpxchg.h
> new file mode 100644
> index 000000000000..c9367b37d925
> --- /dev/null
> +++ b/arch/um/include/asm/cmpxchg.h
> @@ -0,0 +1,13 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _ASM_UM_CMPXCHG_H
> +#define _ASM_UM_CMPXCHG_H
> +
> +#ifdef CONFIG_64BIT
> +#undef CONFIG_X86_32
> +#else
> +#define CONFIG_X86_32 1
> +#endif
> +
> +#include <asm/cmpxchg-x86.h>
> +
> +#endif
> diff --git a/arch/um/include/asm/cmpxchg_32.h b/arch/um/include/asm/cmpxchg_32.h
> new file mode 120000
> index 000000000000..1f360d0a9fa9
> --- /dev/null
> +++ b/arch/um/include/asm/cmpxchg_32.h
> @@ -0,0 +1 @@
> +../../../x86/include/asm/cmpxchg_32.h
> \ No newline at end of file
> diff --git a/arch/um/include/asm/cmpxchg_64.h b/arch/um/include/asm/cmpxchg_64.h
> new file mode 120000
> index 000000000000..bc09ae22b0cb
> --- /dev/null
> +++ b/arch/um/include/asm/cmpxchg_64.h
> @@ -0,0 +1 @@
> +../../../x86/include/asm/cmpxchg_64.h
> \ No newline at end of file

I think that was it. Or to be more exact, I hope that was it.

I went a few times through asm-generic and that looks like all the bits which are worth implementing for a uniprocessor architecture as a replacement for their generic equivalents.

So to recap:

string.h
xor.h
futex.h
cmpxchg.h
atomic.h

Brgds,

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/




More information about the linux-um mailing list