/* * Must not be invoked within the sequence read section as a race inside * that loop could result in __iter_div_u64_rem() being extremely slow.
*/ static __always_inline void vdso_set_timespec(struct __kernel_timespec *ts, u64 sec, u64 ns)
{
ts->tv_sec = sec + __iter_div_u64_rem(ns, NSEC_PER_SEC, &ns);
ts->tv_nsec = ns;
}
/* Allows to compile the high resolution parts out */ if (!__arch_vdso_hres_capable()) returnfalse;
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 = READ_ONCE(vc->seq)) & 1)) { if (IS_ENABLED(CONFIG_TIME_NS) &&
vc->clock_mode == VDSO_CLOCKMODE_TIMENS) return do_hres_timens(vd, vc, clk, ts);
cpu_relax();
}
smp_rmb();
if (!vdso_get_timestamp(vd, vc, clk, &sec, &ns)) returnfalse;
} while (unlikely(vdso_read_retry(vc, seq)));
do { /* * Open coded function vdso_read_begin() to handle * VDSO_CLOCK_TIMENS. See comment in do_hres().
*/ while ((seq = READ_ONCE(vc->seq)) & 1) { if (IS_ENABLED(CONFIG_TIME_NS) &&
vc->clock_mode == VDSO_CLOCKMODE_TIMENS) return do_coarse_timens(vd, vc, clk, ts);
cpu_relax();
}
smp_rmb();
ts->tv_sec = vdso_ts->sec;
ts->tv_nsec = vdso_ts->nsec;
} while (unlikely(vdso_read_retry(vc, seq)));
do { /* * Open coded function vdso_read_begin() to handle * VDSO_CLOCK_TIMENS. See comment in do_hres().
*/ while ((seq = READ_ONCE(vc->seq)) & 1) { if (IS_ENABLED(CONFIG_TIME_NS) && vc->clock_mode == VDSO_CLOCKMODE_TIMENS) {
vd = __arch_get_vdso_u_timens_data(vd);
vc = &vd->aux_clock_data[idx]; /* Re-read from the real time data page */ continue;
}
cpu_relax();
}
smp_rmb();
/* Auxclock disabled? */ if (vc->clock_mode == VDSO_CLOCKMODE_NONE) returnfalse;
if (!vdso_get_timestamp(vd, vc, VDSO_BASE_AUX, &sec, &ns)) returnfalse;
} while (unlikely(vdso_read_retry(vc, seq)));
if (IS_ENABLED(CONFIG_TIME_NS) &&
vc->clock_mode == VDSO_CLOCKMODE_TIMENS)
vd = __arch_get_vdso_u_timens_data(vd);
/* * Convert the clockid to a bitmask and use it to check which * clocks are handled in the VDSO directly.
*/
msk = 1U << clock; if (msk & (VDSO_HRES | VDSO_RAW)) { /* * Preserves the behaviour of posix_get_hrtimer_res().
*/
ns = READ_ONCE(vd->hrtimer_res);
} elseif (msk & VDSO_COARSE) { /* * Preserves the behaviour of posix_get_coarse_res().
*/
ns = LOW_RES_NSEC;
} elseif (msk & VDSO_AUX) {
ns = aux_clock_resolution_ns();
} else { returnfalse;
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.16Bemerkung:
(vorverarbeitet am 2026-06-07)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.