[PATCH 5/5] riscv: vdso: Implement __vdso_futex_robust_try_unlock()

André Almeida andrealmeid at igalia.com
Wed Jul 8 09:22:28 PDT 2026


Hi Nam Cao, thanks for your patch!

Em 19/06/2026 11:11, Nam Cao escreveu:
> This is the RISC-V port for __vdso_futex_robust_try_unlock(). It is based
> on the x86's implementation in commit 61cfc8e372d1 ("x86/vdso: Prepare for
> robust futex unlock support") and commit a2274cc0091e ("x86/vdso: Implement
> __vdso_futex_robust_try_unlock()").
> 

[...]

> 
> Signed-off-by: Nam Cao <namcao at linutronix.de>
> ---

How have you tested it?

[...]

> diff --git a/arch/riscv/include/asm/vdso/futex.h b/arch/riscv/include/asm/vdso/futex.h
> new file mode 100644
> index 000000000000..89a8c425994b
> --- /dev/null
> +++ b/arch/riscv/include/asm/vdso/futex.h
> @@ -0,0 +1,9 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +

I believe this is missing the ifdef header guard

#ifndef __ASM_VDSO_FUTEX_H
#define __ASM_VDSO_FUTEX_H

[...]

> +#if defined(CONFIG_RISCV_ISA_ZACAS) && defined(CONFIG_TOOLCHAIN_HAS_ZACAS)
> +#define FUTEX_CAS_OVERWRITE_VDSO_CS_RANGE(vdso, fd, idx, xlen, symbol)				\
> +{												\
> +	if (riscv_has_extension_unlikely(RISCV_ISA_EXT_ZACAS)) {				\
> +		void *start = symbol(vdso, CONCAT3(futex_list, xlen, _try_unlock_cs_cas_start));\
> +		void *end   = symbol(vdso, CONCAT3(futex_list, xlen, _try_unlock_cs_cas_end));	\
> +												\
> +		futex_set_vdso_cs_range(fd, idx, (uintptr_t)start, (uintptr_t)end, xlen == 32);	\
> +	}											\
> +}
> +#else
> +#define FUTEX_CAS_OVERWRITE_VDSO_CS_RANGE(...)
> +#endif
> +
> +#define FUTEX_SET_VDSO_CS_RANGE(vdso, fd, idx, xlen, symbol)					\
> +{												\
> +	void *start = symbol(vdso, CONCAT3(futex_list, xlen, _try_unlock_cs_lrsc_start));	\
> +	void *end   = symbol(vdso, CONCAT3(futex_list, xlen, _try_unlock_cs_lrsc_end));		\
> +												\
> +	futex_set_vdso_cs_range(fd, idx, (uintptr_t)start, (uintptr_t)end, xlen == 32);		\
> +												\
> +	FUTEX_CAS_OVERWRITE_VDSO_CS_RANGE(vdso, fd, idx, xlen, symbol);				\
> +												\

So if the build has support for CAS, the function overwrite what it had 
just set. Why do it even writes it in the first place then, can't this 
be an if/else?

> +}
> +
Thanks,
	André



More information about the linux-riscv mailing list