All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nam Cao <namcao@linutronix.de>
To: "André Almeida" <andrealmeid@igalia.com>
Cc: "Alexandre Ghiti" <alex@ghiti.fr>,
	"Paul Walmsley" <pjw@kernel.org>,
	linux-kernel@vger.kernel.org,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	linux-riscv@lists.infradead.org,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
	"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
	"Thomas Gleixner" <tglx@kernel.org>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
	kernel-dev@igalia.com
Subject: Re: [PATCH 5/5] riscv: vdso: Implement __vdso_futex_robust_try_unlock()
Date: Wed, 08 Jul 2026 19:20:39 +0200	[thread overview]
Message-ID: <874ii9pfdk.fsf@yellow.woof> (raw)
In-Reply-To: <8d1bd8fb-1c35-4944-ab77-4dfc73ae5056@igalia.com>

André Almeida <andrealmeid@igalia.com> writes:
> Hi Nam Cao, thanks for your patch!

Hi,

> How have you tested it?

With a gdb breakpoint in the critical session.

> I believe this is missing the ifdef header guard
>
> #ifndef __ASM_VDSO_FUTEX_H
> #define __ASM_VDSO_FUTEX_H

Right, thanks!

>> +#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?

Functionally speaking, an if/else makes more sense. However, I cannot
figure out how to do that without creating a complete mess, since
*_try_unlock_cs_cas_start and *_try_unlock_cs_cas_end are not always
available. If you have a suggestion, please do let me know. But doing
it this way only costs us a few more instructions.

Nam

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

WARNING: multiple messages have this Message-ID (diff)
From: Nam Cao <namcao@linutronix.de>
To: "André Almeida" <andrealmeid@igalia.com>
Cc: "Alexandre Ghiti" <alex@ghiti.fr>,
	"Paul Walmsley" <pjw@kernel.org>,
	linux-kernel@vger.kernel.org,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	linux-riscv@lists.infradead.org,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
	"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
	"Thomas Gleixner" <tglx@kernel.org>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
	kernel-dev@igalia.com
Subject: Re: [PATCH 5/5] riscv: vdso: Implement __vdso_futex_robust_try_unlock()
Date: Wed, 08 Jul 2026 19:20:39 +0200	[thread overview]
Message-ID: <874ii9pfdk.fsf@yellow.woof> (raw)
In-Reply-To: <8d1bd8fb-1c35-4944-ab77-4dfc73ae5056@igalia.com>

André Almeida <andrealmeid@igalia.com> writes:
> Hi Nam Cao, thanks for your patch!

Hi,

> How have you tested it?

With a gdb breakpoint in the critical session.

> I believe this is missing the ifdef header guard
>
> #ifndef __ASM_VDSO_FUTEX_H
> #define __ASM_VDSO_FUTEX_H

Right, thanks!

>> +#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?

Functionally speaking, an if/else makes more sense. However, I cannot
figure out how to do that without creating a complete mess, since
*_try_unlock_cs_cas_start and *_try_unlock_cs_cas_end are not always
available. If you have a suggestion, please do let me know. But doing
it this way only costs us a few more instructions.

Nam

  reply	other threads:[~2026-07-08 17:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-19 14:11 [PATCH 0/5] riscv: vdso: Implement __vdso_futex_robust_try_unlock() Nam Cao
2026-06-19 14:11 ` Nam Cao
2026-06-19 14:11 ` [PATCH 1/5] riscv: compat_vdso: switch to standard kbuild rule Nam Cao
2026-06-19 14:11   ` Nam Cao
2026-06-19 14:11 ` [PATCH 2/5] riscv: compat_vdso: Allow *.c source files Nam Cao
2026-06-19 14:11   ` Nam Cao
2026-06-19 14:11 ` [PATCH 3/5] riscv: compat_vdso: Introduce COMPAT_MARCH variable Nam Cao
2026-06-19 14:11   ` Nam Cao
2026-06-19 14:11 ` [PATCH 4/5] riscv: compat_vdso: Build with zacas if available Nam Cao
2026-06-19 14:11   ` Nam Cao
2026-06-19 14:11 ` [PATCH 5/5] riscv: vdso: Implement __vdso_futex_robust_try_unlock() Nam Cao
2026-06-19 14:11   ` Nam Cao
2026-06-30 12:11   ` Thomas Weißschuh
2026-06-30 12:11     ` Thomas Weißschuh
2026-07-08 16:22   ` André Almeida
2026-07-08 16:22     ` André Almeida
2026-07-08 17:20     ` Nam Cao [this message]
2026-07-08 17:20       ` Nam Cao
2026-07-08 20:46       ` Nam Cao
2026-07-08 20:46         ` Nam Cao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874ii9pfdk.fsf@yellow.woof \
    --to=namcao@linutronix.de \
    --cc=alex@ghiti.fr \
    --cc=andrealmeid@igalia.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=bigeasy@linutronix.de \
    --cc=kernel-dev@igalia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=palmer@dabbelt.com \
    --cc=peterz@infradead.org \
    --cc=pjw@kernel.org \
    --cc=tglx@kernel.org \
    --cc=thomas.weissschuh@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.