From nobody Tue Oct 7 19:56:38 2025 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 3AC3CDDA9; Mon, 7 Jul 2025 07:11:43 +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=1751872305; cv=none; b=Yz9x2y4IMIpVB0oN+JS/9JRsy6rjQHBIfpJJt7+gokLkVy4/6VqxeeVJkFQPA/jo0TkOHN3FMZ+/kfxCvE2Nu2g6HwEyknZDzD8OutklE3lHuL0g9nSrLQNQ0vC0MCtsgxoQqD5pQcpRtWSqyczZ4v+/Ra2poAk4JxTDPx+TKVI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751872305; c=relaxed/simple; bh=uLxeOM+etaHGUjx+2ZrAsCOdFcNwKHnHqHFH5hQN3hw=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=oGFGOa6tXHpOSKV73CSrAKUVzPptVod7USSQppLJ47uMzg6zMW14/NBKE2zQVUoequOji1IgL3PDXnPv7LRhWXLYl8i4POgFD98eCs5MI4aOuLqqXurhUjIJRZ+0QyD/2QXdHfiP/pbQxlwi758C1FyR9KT9N2sEDh250+MV2HE= 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=j6+Jj5ZY; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=gvqer0NS; 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="j6+Jj5ZY"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="gvqer0NS" Date: Mon, 07 Jul 2025 07:11:41 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1751872302; h=from:from:sender:sender:reply-to: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=NpgJ+V6JDK/jrHXe1NWBI7RzL9IjWRyxBHhjGPKrhVI=; b=j6+Jj5ZYUmW+sxlXpaGqMbZLRpCJklt37ridmT//hdzk1jHhiQztHqiHWaHwxZ0PYtn1cj ZoU2Tdj4Rwhtu9BFWFVXpEWNl5Lnv79ZF5js5sJjFw83XAGU+qupJmoToitfvQqimKZkzp L5WZJs3JPyycLLo8GTqUOeQFKD7+HuReId4nBVEsUoje2v0KE5fJNBUTwEvSQQFRScUSSx B972WmDaz4Qp+GxskIhN1F6ZhbV/pVAXtCSIxQ+u5GWXlpP7rzEEodtijze8kTdGkMAlyK u8Xr2fnE2xcCWaP24gPCVKx25N361Y+qoYk4RoGTnmO7C14F1hbPeP71/sYifg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1751872302; h=from:from:sender:sender:reply-to: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=NpgJ+V6JDK/jrHXe1NWBI7RzL9IjWRyxBHhjGPKrhVI=; b=gvqer0NSgj8FypIgqqWnJ3haXaSlf0YsJM+oWlZJGghF4gYUztJpWoTcpQQRsEnbnWex6k LK2uUmuof+N/fiDQ== From: tip-bot2 for Thomas =?utf-8?q?Wei=C3=9Fschuh?= Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/ptp] vdso/gettimeofday: Add support for auxiliary clocks Cc: thomas.weissschuh@linutronix.de, Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20250701-vdso-auxclock-v1-12-df7d9f87b9b8@linutronix.de> References: <20250701-vdso-auxclock-v1-12-df7d9f87b9b8@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <175187230133.406.14766599474126564979.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the timers/ptp branch of tip: Commit-ID: 7893ea1006fcbb876ddf53ad4ebba4a054add4b2 Gitweb: https://git.kernel.org/tip/7893ea1006fcbb876ddf53ad4ebba4a05= 4add4b2 Author: Thomas Wei=C3=9Fschuh AuthorDate: Tue, 01 Jul 2025 10:58:06 +02:00 Committer: Thomas Gleixner CommitterDate: Mon, 07 Jul 2025 08:58:54 +02:00 vdso/gettimeofday: Add support for auxiliary clocks Expose the auxiliary clocks through the vDSO. Architectures not using the generic vDSO time framework, namely SPARC64, are not supported. Signed-off-by: Thomas Wei=C3=9Fschuh Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/all/20250701-vdso-auxclock-v1-12-df7d9f87b9b8= @linutronix.de --- include/vdso/datapage.h | 2 ++- lib/vdso/gettimeofday.c | 49 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h index f4c96d9..0253303 100644 --- a/include/vdso/datapage.h +++ b/include/vdso/datapage.h @@ -5,6 +5,7 @@ #ifndef __ASSEMBLY__ =20 #include +#include #include #include #include @@ -46,6 +47,7 @@ struct vdso_arch_data { #define VDSO_COARSE (BIT(CLOCK_REALTIME_COARSE) | \ BIT(CLOCK_MONOTONIC_COARSE)) #define VDSO_RAW (BIT(CLOCK_MONOTONIC_RAW)) +#define VDSO_AUX __GENMASK(CLOCK_AUX_LAST, CLOCK_AUX) =20 #define CS_HRES_COARSE 0 #define CS_RAW 1 diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c index c383878..d6743ed 100644 --- a/lib/vdso/gettimeofday.c +++ b/lib/vdso/gettimeofday.c @@ -2,6 +2,7 @@ /* * Generic userspace implementations of gettimeofday() and similar. */ +#include #include #include =20 @@ -74,7 +75,7 @@ static inline bool vdso_cycles_ok(u64 cycles) static __always_inline bool vdso_clockid_valid(clockid_t clock) { /* Check for negative values or invalid clocks */ - return likely((u32) clock < MAX_CLOCKS); + return likely((u32) clock < CLOCK_AUX_LAST); } =20 /* @@ -268,6 +269,48 @@ bool do_coarse(const struct vdso_time_data *vd, const = struct vdso_clock *vc, return true; } =20 +static __always_inline +bool do_aux(const struct vdso_time_data *vd, clockid_t clock, struct __ker= nel_timespec *ts) +{ + const struct vdso_clock *vc; + u32 seq, idx; + u64 sec, ns; + + if (!IS_ENABLED(CONFIG_POSIX_AUX_CLOCKS)) + return false; + + idx =3D clock - CLOCK_AUX; + vc =3D &vd->aux_clock_data[idx]; + + 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(); + } + smp_rmb(); + + /* Auxclock disabled? */ + if (vc->clock_mode =3D=3D VDSO_CLOCKMODE_NONE) + return false; + + if (!vdso_get_timestamp(vd, vc, VDSO_BASE_AUX, &sec, &ns)) + return false; + } while (unlikely(vdso_read_retry(vc, seq))); + + vdso_set_timespec(ts, sec, ns); + + return true; +} + static __always_inline bool __cvdso_clock_gettime_common(const struct vdso_time_data *vd, clockid_t cl= ock, struct __kernel_timespec *ts) @@ -289,6 +332,8 @@ __cvdso_clock_gettime_common(const struct vdso_time_dat= a *vd, clockid_t clock, return do_coarse(vd, &vc[CS_HRES_COARSE], clock, ts); else if (msk & VDSO_RAW) vc =3D &vc[CS_RAW]; + else if (msk & VDSO_AUX) + return do_aux(vd, clock, ts); else return false; =20 @@ -433,6 +478,8 @@ bool __cvdso_clock_getres_common(const struct vdso_time= _data *vd, clockid_t cloc * Preserves the behaviour of posix_get_coarse_res(). */ ns =3D LOW_RES_NSEC; + } else if (msk & VDSO_AUX) { + ns =3D aux_clock_resolution_ns(); } else { return false; }