vDSO

Virtual dynamic shared object — a tiny kernel-provided shared library mapped into every process that lets common read-only syscalls (clock_gettime, getpid) run without crossing into the kernel.

also known as vdso · linux-vdso

stack syscall · kernel

The vDSO (virtual dynamic shared object, linux-vdso.so.1) is a small shared library the kernel maps into every user-space process. It contains implementations of a handful of read-only syscalls that can be served entirely from user space: clock_gettime, gettimeofday, getcpu, and (architecture-dependent) time. When glibc calls clock_gettime(CLOCK_MONOTONIC, ...), it actually jumps into the vDSO, which reads a kernel-maintained shared memory region and returns — no mode transition, no syscall cost.

Why it exists: clock_gettime is called billions of times per day in server workloads (logging, tracing, timeouts). At ~50–200 ns per syscall, an unoptimized clock read would dominate some workloads. The vDSO drops the cost to a handful of nanoseconds — essentially a read from shared memory plus a counter correction.

For low-latency benchmarking and timing, understanding the vDSO matters:

  • clock_gettime(CLOCK_MONOTONIC) is the canonical monotonic clock and is served from the vDSO.
  • CLOCK_MONOTONIC_RAW used to not be served from the vDSO; newer kernels fixed this.
  • Some timer sources (non-TSC, non-HPET) force a full syscall, which is why TSC is preferred on x86.

If you see a profile dominated by __vdso_clock_gettime, you’re measuring clock-read frequency; consider caching the result or switching to rdtsc directly for sub-nanosecond timing.

sources