From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 523EA3E4C87 for ; Wed, 8 Jul 2026 20:46:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783543599; cv=none; b=EiBg3AmTnshTMUtPFhjuXHlG5WhqU2kmhXJs2BUSnawlhxhU0bhT2iqTEmE2th+8AySOfpAR7AWq2Y1AsYP4LQfcvZ80Qvflxzs/fnB/dChioG5c4RxgNlz840WLsflghGkluAWfngyxkxZn8jrd5AzLhITyJRh4oE8pdqJqOIA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783543599; c=relaxed/simple; bh=xSTSrIhg7icvIM1YBdRSGyZKvSZk4cOw9cq+0Ddxoqk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=tx8iVi6uxRxqaWYplg06oEfeh3l99pmB21CHz11gV+E4WAtOx9NwhfpxoWU0K8WRv6tndpyBBZE64HYm7CZ8PbKrAoH/P9+v+6ZJ8CJ1UhcNERWJXU0Zm+OHuQWxm8Y5oaurA1HB2/yZlz6OevjjX3Zhcl/wiXomYJ5wKVoJ5jQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=a1Sv7OnD; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=+9W5dv9n; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="a1Sv7OnD"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="+9W5dv9n" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1783543596; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BeW1+Lt2glRO2nTqrw43wBscOwCulbV/mgu0vr5CnuU=; b=a1Sv7OnDaEKCbTte5CK6LT5lDadqMP4utWZx2C5wHU4I/tzVvrG8ihPQVFt0CRnhu7Dear Uo6xi9+xQ8JY3DRpC6EYZZvh19E3UoCx4Lv2KJH5zGwKnkMg+H3F+1k0oV8Yzfz6/hn8cS l5oRACu9vujSD2Bc/No2ADfW0tA1WiWDM+5fpMciN9IiPKzO7lwX7pprL2+G+fqWgU7mk6 5foNtFVwg4FqvR3iybUKaNrViyCOu2YUROMQp86GLktW9z18s6taZy0YBJO8Gr4rlQeUQc /uPOEf6LHEqrdp/wt1sUhbtqKwoP4ml0kIKe0+wEVX7mdQEwTlmgUuUggdI6VQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1783543596; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BeW1+Lt2glRO2nTqrw43wBscOwCulbV/mgu0vr5CnuU=; b=+9W5dv9nePX/QkLL4mwBBpmPKM8sBfNUvizJP9+XRolt7ODtMSu8mfpoR0bed8BaWITeRv wqBVMJMk57Q+kOAw== To: =?utf-8?Q?Andr=C3=A9?= Almeida Cc: Alexandre Ghiti , Paul Walmsley , linux-kernel@vger.kernel.org, Palmer Dabbelt , linux-riscv@lists.infradead.org, Albert Ou , Thomas =?utf-8?Q?Wei=C3=9Fschuh?= , Mathieu Desnoyers , Thomas Gleixner , Peter Zijlstra , Sebastian Andrzej Siewior , kernel-dev@igalia.com Subject: Re: [PATCH 5/5] riscv: vdso: Implement __vdso_futex_robust_try_unlock() In-Reply-To: <874ii9pfdk.fsf@yellow.woof> References: <7e567e288f9ddeb2128f5d7ed83a518945fb50d9.1781876501.git.namcao@linutronix.de> <8d1bd8fb-1c35-4944-ab77-4dfc73ae5056@igalia.com> <874ii9pfdk.fsf@yellow.woof> Date: Wed, 08 Jul 2026 22:46:34 +0200 Message-ID: <87pl0xdxat.fsf@yellow.woof> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Nam Cao writes: > Andr=C3=A9 Almeida writes: >> So if the build has support for CAS, the function overwrite what it had= =20 >> just set. Why do it even writes it in the first place then, can't this=20 >> 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. Look at this again, we can do something like below. Let me send v3. #if defined(CONFIG_RISCV_ISA_ZACAS) && defined(CONFIG_TOOLCHAIN_HAS_ZACAS) #define FUTEX_CAS_SET_VDSO_CS_RANGE(vdso, fd, idx, xlen, symbol) = \ { = \ void *start =3D symbol(vdso, CONCAT3(futex_list, xlen, _try_unlock_= cs_cas_start)); \ void *end =3D 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 =3D=3D 32); \ } #else #define FUTEX_CAS_SET_VDSO_CS_RANGE(...) BUILD_BUG() #endif #define FUTEX_LRSC_SET_VDSO_CS_RANGE(vdso, fd, idx, xlen, symbol) = \ { = \ void *start =3D symbol(vdso, CONCAT3(futex_list, xlen, _try_unlock_= cs_lrsc_start)); \ void *end =3D 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 =3D=3D 32); \ } #define FUTEX_SET_VDSO_CS_RANGE(vdso, fd, idx, xlen, symbol) = \ { = \ if (cpu_supports_zacas()) { = \ FUTEX_CAS_SET_VDSO_CS_RANGE(vdso, fd, idx, xlen, symbol); = \ } else { = \ FUTEX_LRSC_SET_VDSO_CS_RANGE(vdso, fd, idx, xlen, symbol); = \ } = \ }