include/vdso/helpers.h | 7 ++++++- lib/vdso/gettimeofday.c | 9 +++------ 2 files changed, 9 insertions(+), 7 deletions(-)
The following commit has been merged into the timers/vdso branch of tip:
Commit-ID: daa2b92d33a4038123598aff55240ae3c54f870c
Gitweb: https://git.kernel.org/tip/daa2b92d33a4038123598aff55240ae3c54f870c
Author: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
AuthorDate: Fri, 27 Feb 2026 07:43:22 +01:00
Committer: Thomas Gleixner <tglx@kernel.org>
CommitterDate: Wed, 11 Mar 2026 10:27:35 +01:00
vdso/gettimeofday: Add a helper to test if a clock is namespaced
Currently this logic is duplicate multiple times.
Add a helper for it to make the code more readable.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260227-vdso-cleanups-v1-3-c848b4bc4850@linutronix.de
---
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 9ccf6b5..a776554 100644
--- a/include/vdso/helpers.h
+++ b/include/vdso/helpers.h
@@ -7,6 +7,11 @@
#include <asm/barrier.h>
#include <vdso/datapage.h>
+static __always_inline bool vdso_is_timens_clock(const struct vdso_clock *vc)
+{
+ return IS_ENABLED(CONFIG_TIME_NS) && vc->clock_mode == VDSO_CLOCKMODE_TIMENS;
+}
+
static __always_inline u32 vdso_read_begin(const struct vdso_clock *vc)
{
u32 seq;
@@ -31,7 +36,7 @@ static __always_inline u32 vdso_read_begin(const struct vdso_clock *vc)
static __always_inline bool vdso_read_begin_timens(const struct vdso_clock *vc, u32 *seq)
{
while (unlikely((*seq = READ_ONCE(vc->seq)) & 1)) {
- if (IS_ENABLED(CONFIG_TIME_NS) && vc->clock_mode == VDSO_CLOCKMODE_TIMENS)
+ if (vdso_is_timens_clock(vc))
return true;
cpu_relax();
}
diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c
index e493696..2faed78 100644
--- a/lib/vdso/gettimeofday.c
+++ b/lib/vdso/gettimeofday.c
@@ -343,8 +343,7 @@ __cvdso_gettimeofday_data(const struct vdso_time_data *vd,
}
if (unlikely(tz != NULL)) {
- if (IS_ENABLED(CONFIG_TIME_NS) &&
- vc->clock_mode == VDSO_CLOCKMODE_TIMENS)
+ if (vdso_is_timens_clock(vc))
vd = __arch_get_vdso_u_timens_data(vd);
tz->tz_minuteswest = vd[CS_HRES_COARSE].tz_minuteswest;
@@ -367,8 +366,7 @@ __cvdso_time_data(const struct vdso_time_data *vd, __kernel_old_time_t *time)
const struct vdso_clock *vc = vd->clock_data;
__kernel_old_time_t t;
- if (IS_ENABLED(CONFIG_TIME_NS) &&
- vc->clock_mode == VDSO_CLOCKMODE_TIMENS) {
+ if (vdso_is_timens_clock(vc)) {
vd = __arch_get_vdso_u_timens_data(vd);
vc = 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;
- if (IS_ENABLED(CONFIG_TIME_NS) &&
- vc->clock_mode == VDSO_CLOCKMODE_TIMENS)
+ if (vdso_is_timens_clock(vc))
vd = __arch_get_vdso_u_timens_data(vd);
/*
On Wed, Mar 11, 2026 at 09:31:30AM +0000, tip-bot2 for Thomas Weißschuh wrote:
> The following commit has been merged into the timers/vdso branch of tip:
>
> Commit-ID: daa2b92d33a4038123598aff55240ae3c54f870c
> Gitweb: https://git.kernel.org/tip/daa2b92d33a4038123598aff55240ae3c54f870c
> Author: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> AuthorDate: Fri, 27 Feb 2026 07:43:22 +01:00
> Committer: Thomas Gleixner <tglx@kernel.org>
> CommitterDate: Wed, 11 Mar 2026 10:27:35 +01:00
>
> vdso/gettimeofday: Add a helper to test if a clock is namespaced
>
> Currently this logic is duplicate multiple times.
>
> Add a helper for it to make the code more readable.
>
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Link: https://patch.msgid.link/20260227-vdso-cleanups-v1-3-c848b4bc4850@linutronix.de
> ---
> 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 9ccf6b5..a776554 100644
> --- a/include/vdso/helpers.h
> +++ b/include/vdso/helpers.h
> @@ -7,6 +7,11 @@
> #include <asm/barrier.h>
> #include <vdso/datapage.h>
>
> +static __always_inline bool vdso_is_timens_clock(const struct vdso_clock *vc)
> +{
> + return IS_ENABLED(CONFIG_TIME_NS) && vc->clock_mode == VDSO_CLOCKMODE_TIMENS;
> +}
Welp, I never seem to have tested this together with my own vDSO header cleanup
series. This fails to build because VDSO_CLOCKMODE_TIMENS is not visible.
There should be an include of <vdso/clocksource.h> above.
Could you fix this up, or drop the series so I can resubmit it?
> +
> static __always_inline u32 vdso_read_begin(const struct vdso_clock *vc)
> {
> u32 seq;
(...)
On Wed, Mar 11, 2026 at 11:47:26AM +0100, Thomas Weißschuh wrote:
> > +static __always_inline bool vdso_is_timens_clock(const struct vdso_clock *vc)
> > +{
> > + return IS_ENABLED(CONFIG_TIME_NS) && vc->clock_mode == VDSO_CLOCKMODE_TIMENS;
> > +}
>
> Welp, I never seem to have tested this together with my own vDSO header cleanup
> series. This fails to build because VDSO_CLOCKMODE_TIMENS is not visible.
> There should be an include of <vdso/clocksource.h> above.
>
> Could you fix this up, or drop the series so I can resubmit it?
Lemme fix that up. I just saw it here too.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
On Wed, Mar 11, 2026 at 02:51:26PM +0100, Borislav Petkov wrote:
> On Wed, Mar 11, 2026 at 11:47:26AM +0100, Thomas Weißschuh wrote:
> > > +static __always_inline bool vdso_is_timens_clock(const struct vdso_clock *vc)
> > > +{
> > > + return IS_ENABLED(CONFIG_TIME_NS) && vc->clock_mode == VDSO_CLOCKMODE_TIMENS;
> > > +}
> >
> > Welp, I never seem to have tested this together with my own vDSO header cleanup
> > series. This fails to build because VDSO_CLOCKMODE_TIMENS is not visible.
> > There should be an include of <vdso/clocksource.h> above.
> >
> > Could you fix this up, or drop the series so I can resubmit it?
>
> Lemme fix that up. I just saw it here too.
Thanks! And sorry for the extra work.
Thomas
On Wed, Mar 11, 2026 at 03:01:05PM +0100, Thomas Weißschuh wrote:
> On Wed, Mar 11, 2026 at 02:51:26PM +0100, Borislav Petkov wrote:
> > On Wed, Mar 11, 2026 at 11:47:26AM +0100, Thomas Weißschuh wrote:
> > > > +static __always_inline bool vdso_is_timens_clock(const struct vdso_clock *vc)
> > > > +{
> > > > + return IS_ENABLED(CONFIG_TIME_NS) && vc->clock_mode == VDSO_CLOCKMODE_TIMENS;
> > > > +}
> > >
> > > Welp, I never seem to have tested this together with my own vDSO header cleanup
> > > series. This fails to build because VDSO_CLOCKMODE_TIMENS is not visible.
> > > There should be an include of <vdso/clocksource.h> above.
> > >
> > > Could you fix this up, or drop the series so I can resubmit it?
> >
> > Lemme fix that up. I just saw it here too.
>
> Thanks! And sorry for the extra work.
No worries.
Btw, this patch itself builds still, I guess the breakage is caused by one of
the following ones.
I won't chase that though because this one is using VDSO_CLOCKMODE_TIMENS and
I will simply add the clocksource.h include here.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
© 2016 - 2026 Red Hat, Inc.