From nobody Thu Apr 9 12:08:22 2026 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 A7615308F23 for ; Fri, 27 Feb 2026 06:43:26 +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=1772174607; cv=none; b=Ipf8BZxYBeCMPj8NB+dMJ+gAfzeDteHmjvaWtdWStBKxA5cX2DShfwtzSc0c2+M7WwiFe+I+FFDAeV/RxQbLqULHwJZREDodWb8qu1DObPspTfqSAYigouStvaihJ4erwME3yHKoweFg0jvS9zdaJYQm+5OPlaXXWJ50BXV2rDE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772174607; c=relaxed/simple; bh=ckpj7fJl0KHRKshQbNRdJNZHK1c8nhK2cwWFfYVP558=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iFYZr0Pze2q9qOZc7YR427+zPVzAgCj9PpWZ1O2q1tpzr8xI3bOYpNz0vFzMb0easXzdi3MOV63G4UAQt9TKshL0cf9QePhl93BkHiIfcSprX5/c1SdFF4rF5ABlZ5JNWkqQgND3qhNc8bqzfmo5omPNYx8/9OO4Iz5OkL78sxs= 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=HrVaHh9D; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=z7w+IJcc; 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="HrVaHh9D"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="z7w+IJcc" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1772174605; 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=hYgJNwonIWQHuzRkpeF33r6VareIdzfQD/7AapvwICM=; b=HrVaHh9DUWBtEzokncsW5yiKYe5YkjHV23qg/kOwMACqA8IxPDuLoUq5uCJ6AZjMtGU4Mb TWLgk6F+bT3dA6yo1upxmASFw6DwWE5voWnie3yB+lVVbRawB0K9uJeblS07LYdh3kwZ1H OclG/eGo1nCDFTZFeCbI6W4vjOcMM4DHGItnmlTfWXDG8PML5s48yFBqcdpVbRcQ+pSJJ3 JX3zQXfYRRjbLMeRt49RfZmNVK043M6n4b95shGUHEZxd99bhEYITZHdrA5Hn2g6yHMxMN eW0PpFncfjXwbctyPjdyCixqfdo6NF5T2Ei32wiq9X7dhojSXD7lA0NODspNsQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1772174605; 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=hYgJNwonIWQHuzRkpeF33r6VareIdzfQD/7AapvwICM=; b=z7w+IJccQ2sFXcf43E95p8tYtSyR8ExwKDjqpaT1okPCuT5z621jkRJE9jhx4/XWWMGxcR WVcwnETlgoVJr0CQ== Date: Fri, 27 Feb 2026 07:43:20 +0100 Subject: [PATCH 1/4] vdso/gettimeofday: Drop a few usages of __maybe_unused 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 Message-Id: <20260227-vdso-cleanups-v1-1-c848b4bc4850@linutronix.de> References: <20260227-vdso-cleanups-v1-0-c848b4bc4850@linutronix.de> In-Reply-To: <20260227-vdso-cleanups-v1-0-c848b4bc4850@linutronix.de> To: Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1772174604; l=2228; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=ckpj7fJl0KHRKshQbNRdJNZHK1c8nhK2cwWFfYVP558=; b=Iwzob+41dyeL1Ovfy9iZ+RXAT+P9t+Bem+LA83ZQp8UsrWGEx6AcPXgqCzd2hryc8jIKT+Hhw R8wQejIZrvOBzzigNUH7Yj2I3cJuY9GSb3CnvzIymv2q+dKq7+o18L7 X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= These functions are used from the very same file, so this annotation is unnecessary. Signed-off-by: Thomas Wei=C3=9Fschuh --- lib/vdso/gettimeofday.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c index 4399e143d43a..4939ee86af65 100644 --- a/lib/vdso/gettimeofday.c +++ b/lib/vdso/gettimeofday.c @@ -313,7 +313,7 @@ __cvdso_clock_gettime_common(const struct vdso_time_dat= a *vd, clockid_t clock, return do_hres(vd, vc, clock, ts); } =20 -static __maybe_unused int +static int __cvdso_clock_gettime_data(const struct vdso_time_data *vd, clockid_t cloc= k, struct __kernel_timespec *ts) { @@ -333,7 +333,7 @@ __cvdso_clock_gettime(clockid_t clock, struct __kernel_= timespec *ts) } =20 #ifdef BUILD_VDSO32 -static __maybe_unused int +static int __cvdso_clock_gettime32_data(const struct vdso_time_data *vd, clockid_t cl= ock, struct old_timespec32 *res) { @@ -359,7 +359,7 @@ __cvdso_clock_gettime32(clockid_t clock, struct old_tim= espec32 *res) } #endif /* BUILD_VDSO32 */ =20 -static __maybe_unused int +static int __cvdso_gettimeofday_data(const struct vdso_time_data *vd, struct __kernel_old_timeval *tv, struct timezone *tz) { @@ -394,7 +394,7 @@ __cvdso_gettimeofday(struct __kernel_old_timeval *tv, s= truct timezone *tz) } =20 #ifdef VDSO_HAS_TIME -static __maybe_unused __kernel_old_time_t +static __kernel_old_time_t __cvdso_time_data(const struct vdso_time_data *vd, __kernel_old_time_t *ti= me) { const struct vdso_clock *vc =3D vd->clock_data; @@ -464,7 +464,7 @@ bool __cvdso_clock_getres_common(const struct vdso_time= _data *vd, clockid_t cloc return true; } =20 -static __maybe_unused +static int __cvdso_clock_getres_data(const struct vdso_time_data *vd, clockid_t c= lock, struct __kernel_timespec *res) { @@ -484,7 +484,7 @@ int __cvdso_clock_getres(clockid_t clock, struct __kern= el_timespec *res) } =20 #ifdef BUILD_VDSO32 -static __maybe_unused int +static int __cvdso_clock_getres_time32_data(const struct vdso_time_data *vd, clockid_= t clock, struct old_timespec32 *res) { --=20 2.53.0 From nobody Thu Apr 9 12:08:22 2026 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 60E4933372E for ; Fri, 27 Feb 2026 06:43:27 +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=1772174608; cv=none; b=tMDZPpVx0sYY7pKKCiRXWPHzKJgzqcqZNdieQvI+Fc9t3IbnFzIiR+obsKbuWM/b6Xvk+fpxDaYNmtYSpVOvXbA0gxRgq3vTEijbvO5R2n6lEsPZmptZe1AOEy8ggqgDX1gGnW1sGdH+5D9RxfPsTEmTqgm9y9kLVis69xDhRpw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772174608; c=relaxed/simple; bh=AhzHc5vSAExO+lhe/vNy090Akis21MibHZbbnMNOFJc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oKzyvplJGklVpVyWEx0Md1ae8aOgX9bZbpOTXFsUaZM47tyEKAXuRdTR4Ci/a2IPYzz1MwdV3ptrwwi9urz3bZ6aIwUPRpN0aYH0ip9MeTD+CdtpfgIjFIc04tLVsArl+IOGUjl7Fo6JHZ23GlcddRsoMcbHWd8x6ksMS4KGVYg= 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=djOz3uw+; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=gmTi5yPn; 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="djOz3uw+"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="gmTi5yPn" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1772174605; 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=cczvBqSJPGWBfMRVBlyOa4GrbDaWpXXnucPOrVseTLA=; b=djOz3uw+JgerefZis0QkJ6XN1G6QqfbxSX5ZohitLKMj1Dlr7Ho0OdOWImhUw83lzg9aXF Q28kR6UZIpqq83Mv1mp6v1k/hC15JTgOdFuSZ7XIUbVIoOE4kO3huacmky/SsrG3ky7zs4 3Ky0pvGB2F+46aCKiQ0nuycVxEJwF6+YVS2ZzkbqfCM84qTjDuyyWwzxO1C3JRk+T7gJcP b9CSN7xjARiezSffdMCBnQyXu4LCFRNJLIS6hsNDomreIftm1v7HqcR1GB1G2g5UC5YONf MKkupb8LDP+KXcemXboOqnA3tBd2pyoIgr0+uy07rXGtzY9cDGhXISpcN/1Ugg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1772174605; 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=cczvBqSJPGWBfMRVBlyOa4GrbDaWpXXnucPOrVseTLA=; b=gmTi5yPnlRsnOzskdDQNj18/scosuVmLeihmRjiMSN1EmDPHmV0dwkWSTslotw09PG2lm/ Vb+kUT3OejPk6/CA== Date: Fri, 27 Feb 2026 07:43:21 +0100 Subject: [PATCH 2/4] vdso/gettimeofday: Add a helper to read the sequence lock of a time namespace aware clock 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 Message-Id: <20260227-vdso-cleanups-v1-2-c848b4bc4850@linutronix.de> References: <20260227-vdso-cleanups-v1-0-c848b4bc4850@linutronix.de> In-Reply-To: <20260227-vdso-cleanups-v1-0-c848b4bc4850@linutronix.de> To: Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1772174604; l=4589; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=AhzHc5vSAExO+lhe/vNy090Akis21MibHZbbnMNOFJc=; b=ZirS7cGQtuyA6LTPAEnfZ/fJURK6KxOM6X8iwG6UOU24jeiKyKPHarrlcSvovc+iy6jvsNXop 60lMxatQuFBAwfIqBHq7NRKkWUWqpp7T1Lwk7ujWxoGGBS1q32a8UcU X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Currently there are three different open-coded variants of a time namespace aware variant of vdso_read_begin(). They make the code hard to read and introduce an inconsistency, as only the first copy uses unlikely(). Split the code into a shared helper function. Move that next to the definition of the regular vdso_read_begin(), so that any future changes can be kept in sync easily. Signed-off-by: Thomas Wei=C3=9Fschuh --- include/vdso/helpers.h | 23 ++++++++++++++++++++++ lib/vdso/gettimeofday.c | 51 +++++++++------------------------------------= ---- 2 files changed, 32 insertions(+), 42 deletions(-) diff --git a/include/vdso/helpers.h b/include/vdso/helpers.h index 1a5ee9d9052c..0064c30cc40c 100644 --- a/include/vdso/helpers.h +++ b/include/vdso/helpers.h @@ -18,6 +18,29 @@ static __always_inline u32 vdso_read_begin(const struct = vdso_clock *vc) return seq; } =20 +/* + * Variant of vdso_read_begin() to handle + * VDSO_CLOCKMODE_TIMENS. Time namespace enabled tasks have a + * special VVAR page installed which has vc->seq set to 1 and + * vc->clock_mode set to VDSO_CLOCKMODE_TIMENS. For non time + * namespace affected tasks this does not affect performance + * because if vc->seq is odd, i.e. a concurrent update is in + * progress the extra check for vc->clock_mode is just a few + * extra instructions while spin waiting for vc->seq to become + * even again. + */ +static __always_inline bool vdso_read_begin_timens(const struct vdso_clock= *vc, u32 *seq) +{ + while (unlikely((*seq =3D READ_ONCE(vc->seq)) & 1)) { + if (IS_ENABLED(CONFIG_TIME_NS) && vc->clock_mode =3D=3D VDSO_CLOCKMODE_T= IMENS) + return true; + cpu_relax(); + } + smp_rmb(); + + return false; +} + static __always_inline u32 vdso_read_retry(const struct vdso_clock *vc, u32 start) { diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c index 4939ee86af65..e49369676928 100644 --- a/lib/vdso/gettimeofday.c +++ b/lib/vdso/gettimeofday.c @@ -158,24 +158,8 @@ bool do_hres(const struct vdso_time_data *vd, const st= ruct vdso_clock *vc, return false; =20 do { - /* - * Open coded function vdso_read_begin() to handle - * VDSO_CLOCKMODE_TIMENS. Time namespace enabled tasks have a - * special VVAR page installed which has vc->seq set to 1 and - * vc->clock_mode set to VDSO_CLOCKMODE_TIMENS. For non time - * namespace affected tasks this does not affect performance - * because if vc->seq is odd, i.e. a concurrent update is in - * progress the extra check for vc->clock_mode is just a few - * extra instructions while spin waiting for vc->seq to become - * even again. - */ - while (unlikely((seq =3D READ_ONCE(vc->seq)) & 1)) { - if (IS_ENABLED(CONFIG_TIME_NS) && - vc->clock_mode =3D=3D VDSO_CLOCKMODE_TIMENS) - return do_hres_timens(vd, vc, clk, ts); - cpu_relax(); - } - smp_rmb(); + if (vdso_read_begin_timens(vc, &seq)) + return do_hres_timens(vd, vc, clk, ts); =20 if (!vdso_get_timestamp(vd, vc, clk, &sec, &ns)) return false; @@ -223,17 +207,8 @@ bool do_coarse(const struct vdso_time_data *vd, const = struct vdso_clock *vc, u32 seq; =20 do { - /* - * Open coded function vdso_read_begin() to handle - * VDSO_CLOCK_TIMENS. See comment in do_hres(). - */ - while ((seq =3D READ_ONCE(vc->seq)) & 1) { - if (IS_ENABLED(CONFIG_TIME_NS) && - vc->clock_mode =3D=3D VDSO_CLOCKMODE_TIMENS) - return do_coarse_timens(vd, vc, clk, ts); - cpu_relax(); - } - smp_rmb(); + if (vdso_read_begin_timens(vc, &seq)) + return do_coarse_timens(vd, vc, clk, ts); =20 ts->tv_sec =3D vdso_ts->sec; ts->tv_nsec =3D vdso_ts->nsec; @@ -256,20 +231,12 @@ bool do_aux(const struct vdso_time_data *vd, clockid_= t clock, struct __kernel_ti vc =3D &vd->aux_clock_data[idx]; =20 do { - /* - * Open coded function vdso_read_begin() to handle - * VDSO_CLOCK_TIMENS. See comment in do_hres(). - */ - while ((seq =3D READ_ONCE(vc->seq)) & 1) { - if (IS_ENABLED(CONFIG_TIME_NS) && vc->clock_mode =3D=3D VDSO_CLOCKMODE_= TIMENS) { - vd =3D __arch_get_vdso_u_timens_data(vd); - vc =3D &vd->aux_clock_data[idx]; - /* Re-read from the real time data page */ - continue; - } - cpu_relax(); + if (vdso_read_begin_timens(vc, &seq)) { + vd =3D __arch_get_vdso_u_timens_data(vd); + vc =3D &vd->aux_clock_data[idx]; + /* Re-read from the real time data page */ + continue; } - smp_rmb(); =20 /* Auxclock disabled? */ if (vc->clock_mode =3D=3D VDSO_CLOCKMODE_NONE) --=20 2.53.0 From nobody Thu Apr 9 12:08:22 2026 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 D5EE63815E8 for ; Fri, 27 Feb 2026 06:43:28 +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=1772174610; cv=none; b=GijbawT8k1qgcH3K8EjykPZo9RTtjopbMo1v4AADzlEf1ojn4H/FRG+oJ5/KRQ2k2fkUibsYhtYI1UDC21hiS4WXpdak3J/17KSx30Lg4l/76WQ03b44XtxXQ3n4AV+Yk2wh9CcLgQLQzssalo9p2DBvvmLLrxpgy+Co5Ifvxo8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772174610; c=relaxed/simple; bh=FWGn65km4mZGmqXRzZnz9sDOew6o+2aJLfEuo+bn3UI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rGLct1aIisWayWYXuE2mM6IndNWKH2BW5b1aJVw/434yk5TfjdqhuXbK/bHlHDp6X6gaMdZiBvkVXZqYnmqHnrba7Vgv9SBMNyB0GsaxuGQ/S2/B6hW/GZHa9bUTDG+IozwBNHpX/1l4S0+FsFaUbsKZgMdNW6J5jtl10AUiLGI= 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=NE1SRM7M; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=xQxDSbgX; 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="NE1SRM7M"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="xQxDSbgX" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1772174606; 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=u7q4giRSxVgb3vhRVyBnmqHJAlGmF9q7NXovmHnnyhg=; b=NE1SRM7Mw2uGk71myIBLZMwBsiYv8OJYBuKJW1GaAiBDyprRhJUmcDdLZbRKmMtKyBWuuk rdVLC8UAVZ78lIEQTLmMj49mXv4W6rHm1Gqz1DFKkMjqJaTTMiI60L/xuZQc1aOENZQoOM xGGCVCfSS1to6MRHhdPejIEfLjr/xYDw+yNCZUsaG3n4SMqm2Xz8aJMVp1sr98Z8EXrh+w t+vSAV2OS+fnY/B5VkRdepvj4B3rNrnfrFM75GC0NFj58yofYY/jW0ajTkXyupApw6QLiy IhwOzn5WzuplZeeX0j9WanhW4d9mhv7FR4yY5bPoac8REwaEJfzplTi3ybJuNA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1772174606; 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=u7q4giRSxVgb3vhRVyBnmqHJAlGmF9q7NXovmHnnyhg=; b=xQxDSbgXen0rL3P4kVgWWSHzb28Ok4mFXeFGzv3Zi603zoQzNenadlWdjGyfu/FpNcfiIU EMqT1mwu9eTEFcCw== Date: Fri, 27 Feb 2026 07:43:22 +0100 Subject: [PATCH 3/4] vdso/gettimeofday: Add a helper to test if a clock is namespaced 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 Message-Id: <20260227-vdso-cleanups-v1-3-c848b4bc4850@linutronix.de> References: <20260227-vdso-cleanups-v1-0-c848b4bc4850@linutronix.de> In-Reply-To: <20260227-vdso-cleanups-v1-0-c848b4bc4850@linutronix.de> To: Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1772174604; l=2441; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=FWGn65km4mZGmqXRzZnz9sDOew6o+2aJLfEuo+bn3UI=; b=ObndgDaqQaieXld2J+oirgcjwxWoY0+SQORO9DeDr0J4bolYXqP6udVo8ueITgn0wG4f5OgUR 3NAYRxv1XcHAojQ80fsExkS8XZfbCOP0y/5VYE4PcOGujQqdJpKh/kG X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Currently this logic is duplicate multiple times. Add a helper for it to make the code more readable. Signed-off-by: Thomas Wei=C3=9Fschuh --- include/vdso/helpers.h | 7 ++++++- lib/vdso/gettimeofday.c | 9 +++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/vdso/helpers.h b/include/vdso/helpers.h index 0064c30cc40c..3dd67ed85c2e 100644 --- a/include/vdso/helpers.h +++ b/include/vdso/helpers.h @@ -7,6 +7,11 @@ #include #include =20 +static __always_inline bool vdso_is_timens_clock(const struct vdso_clock *= vc) +{ + return IS_ENABLED(CONFIG_TIME_NS) && vc->clock_mode =3D=3D VDSO_CLOCKMODE= _TIMENS; +} + static __always_inline u32 vdso_read_begin(const struct vdso_clock *vc) { u32 seq; @@ -32,7 +37,7 @@ static __always_inline u32 vdso_read_begin(const struct v= dso_clock *vc) static __always_inline bool vdso_read_begin_timens(const struct vdso_clock= *vc, u32 *seq) { while (unlikely((*seq =3D READ_ONCE(vc->seq)) & 1)) { - if (IS_ENABLED(CONFIG_TIME_NS) && vc->clock_mode =3D=3D VDSO_CLOCKMODE_T= IMENS) + if (vdso_is_timens_clock(vc)) return true; cpu_relax(); } diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c index e49369676928..2faed7851635 100644 --- a/lib/vdso/gettimeofday.c +++ b/lib/vdso/gettimeofday.c @@ -343,8 +343,7 @@ __cvdso_gettimeofday_data(const struct vdso_time_data *= vd, } =20 if (unlikely(tz !=3D NULL)) { - if (IS_ENABLED(CONFIG_TIME_NS) && - vc->clock_mode =3D=3D VDSO_CLOCKMODE_TIMENS) + if (vdso_is_timens_clock(vc)) vd =3D __arch_get_vdso_u_timens_data(vd); =20 tz->tz_minuteswest =3D vd[CS_HRES_COARSE].tz_minuteswest; @@ -367,8 +366,7 @@ __cvdso_time_data(const struct vdso_time_data *vd, __ke= rnel_old_time_t *time) const struct vdso_clock *vc =3D vd->clock_data; __kernel_old_time_t t; =20 - if (IS_ENABLED(CONFIG_TIME_NS) && - vc->clock_mode =3D=3D VDSO_CLOCKMODE_TIMENS) { + if (vdso_is_timens_clock(vc)) { vd =3D __arch_get_vdso_u_timens_data(vd); vc =3D vd->clock_data; } @@ -399,8 +397,7 @@ bool __cvdso_clock_getres_common(const struct vdso_time= _data *vd, clockid_t cloc if (!vdso_clockid_valid(clock)) return false; =20 - if (IS_ENABLED(CONFIG_TIME_NS) && - vc->clock_mode =3D=3D VDSO_CLOCKMODE_TIMENS) + if (vdso_is_timens_clock(vc)) vd =3D __arch_get_vdso_u_timens_data(vd); =20 /* --=20 2.53.0 From nobody Thu Apr 9 12:08:22 2026 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 CC2DD36BCFB for ; Fri, 27 Feb 2026 06:43:29 +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=1772174611; cv=none; b=Qp/OaCVNMfCysEmgzu+x+0pgeMLtJq1b/ZOXRsyLd1uH8ONjLAsxmuVwLoykjloWN9JtP5///h8+KtTZRB65Gtcjx1rMf9WUnV6tp1+0xQZ8WCvJ7EQsWoOVSBTkneJ3kWHxPmtSrvzVd4i+Rkos5S3aRCu9iJZcahmQeNBUSfI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772174611; c=relaxed/simple; bh=B728YZhNcQvokXW742SAlvfLm7RygQwiwjUvQYwGf8c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=A516FmfiHPiP0ID+KLSSPxaGVz/oZPgvSoAKK0wTzvwGoB2JTtC7T8D7xXcjuErxJIMItRYHanZLSVUIku9IKJqXiXHaXkSj2oaJ6LWZU4/S7muGzpDQ0hgzzqdy3Z5v5Q6CnocIHy/mWG1GMoL33by07/cACCiRbkIROn7yKqE= 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=FX3SsBcZ; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ottWXq27; 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="FX3SsBcZ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ottWXq27" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1772174608; 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=LjM8Alndx+Wez0AGXYd0pbIxbZzf0Fg1Fhsub7+n4I8=; b=FX3SsBcZgcFl759LZXKMCEQOTdEw7DWReT6ts4KCvEi15Av7R5iuKyU4mt9HLZuYd2tfV9 4B+iSPyw9OQvxkwOAuVi/84RxAf35Ud8TiFX2LWEWnffZ304FywJJTGtpY3Kq9/XX+LgD0 3e8t/ocGuvXEvMkCSMpJZ7uRFYUpzQAxvxIJXAf/J+0SDspRbmwbGF46ck6XYCDyqxZnOT j3N/ANwBcy1d8pV7tUw2vajXMzlaJ0WTyvgyXVsvg3Bf36KtF0nocjlUhct1Wrw4s2A5Dr 0/bjxR8tBe2+AdfTXOsEcy0fCboHg0/SHVCp35hb7/KSg3qOV7+VmgFmKFFOtQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1772174608; 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=LjM8Alndx+Wez0AGXYd0pbIxbZzf0Fg1Fhsub7+n4I8=; b=ottWXq27KqkuhupCjCMXF5RF3e59ZAuV4HGzNICDKjzWYcY6ZqatoqRtGP+BlRoeitQxLf gWD3GO00t7y5SXDA== Date: Fri, 27 Feb 2026 07:43:23 +0100 Subject: [PATCH 4/4] vdso/gettimeofday: Move the unlikely() into vdso_read_retry() 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 Message-Id: <20260227-vdso-cleanups-v1-4-c848b4bc4850@linutronix.de> References: <20260227-vdso-cleanups-v1-0-c848b4bc4850@linutronix.de> In-Reply-To: <20260227-vdso-cleanups-v1-0-c848b4bc4850@linutronix.de> To: Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1772174604; l=2574; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=B728YZhNcQvokXW742SAlvfLm7RygQwiwjUvQYwGf8c=; b=1kTbqImzaDlvx3uzl0XB8gKmpSEIskfBXpSS52zpPq5SfPtloRda3JyfBZSHpSUJoB8NfBWni 3m4nDEvtmMGDGaYJhrFC0p5DOSzhWan4P7CoRBf5SpQcTSlAVf1tqSO X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= All callers of vdso_read_retry() test its return value with unlikely(). Move the unlikely into the helper to make the code easier to read. This is equivalent to the retry function of non-vDSO seqlocks. Signed-off-by: Thomas Wei=C3=9Fschuh --- include/vdso/helpers.h | 2 +- lib/vdso/gettimeofday.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/vdso/helpers.h b/include/vdso/helpers.h index 3dd67ed85c2e..9e967c2c6d20 100644 --- a/include/vdso/helpers.h +++ b/include/vdso/helpers.h @@ -53,7 +53,7 @@ static __always_inline u32 vdso_read_retry(const struct v= dso_clock *vc, =20 smp_rmb(); seq =3D READ_ONCE(vc->seq); - return seq !=3D start; + return unlikely(seq !=3D start); } =20 static __always_inline void vdso_write_seq_begin(struct vdso_clock *vc) diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c index 2faed7851635..efd1b82af614 100644 --- a/lib/vdso/gettimeofday.c +++ b/lib/vdso/gettimeofday.c @@ -135,7 +135,7 @@ bool do_hres_timens(const struct vdso_time_data *vdns, = const struct vdso_clock * =20 if (!vdso_get_timestamp(vd, vc, clk, &sec, &ns)) return false; - } while (unlikely(vdso_read_retry(vc, seq))); + } while (vdso_read_retry(vc, seq)); =20 /* Add the namespace offset */ sec +=3D offs->sec; @@ -163,7 +163,7 @@ bool do_hres(const struct vdso_time_data *vd, const str= uct vdso_clock *vc, =20 if (!vdso_get_timestamp(vd, vc, clk, &sec, &ns)) return false; - } while (unlikely(vdso_read_retry(vc, seq))); + } while (vdso_read_retry(vc, seq)); =20 vdso_set_timespec(ts, sec, ns); =20 @@ -188,7 +188,7 @@ bool do_coarse_timens(const struct vdso_time_data *vdns= , const struct vdso_clock seq =3D vdso_read_begin(vc); sec =3D vdso_ts->sec; nsec =3D vdso_ts->nsec; - } while (unlikely(vdso_read_retry(vc, seq))); + } while (vdso_read_retry(vc, seq)); =20 /* Add the namespace offset */ sec +=3D offs->sec; @@ -212,7 +212,7 @@ bool do_coarse(const struct vdso_time_data *vd, const s= truct vdso_clock *vc, =20 ts->tv_sec =3D vdso_ts->sec; ts->tv_nsec =3D vdso_ts->nsec; - } while (unlikely(vdso_read_retry(vc, seq))); + } while (vdso_read_retry(vc, seq)); =20 return true; } @@ -244,7 +244,7 @@ bool do_aux(const struct vdso_time_data *vd, clockid_t = clock, struct __kernel_ti =20 if (!vdso_get_timestamp(vd, vc, VDSO_BASE_AUX, &sec, &ns)) return false; - } while (unlikely(vdso_read_retry(vc, seq))); + } while (vdso_read_retry(vc, seq)); =20 vdso_set_timespec(ts, sec, ns); =20 --=20 2.53.0