All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/3] time namespace aware system boot time
@ 2020-10-19 19:52 Michael Weiß
  2020-10-19 19:52 ` [PATCH v4 1/3] timens: additional helper functions for boottime offset handling Michael Weiß
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Michael Weiß @ 2020-10-19 19:52 UTC (permalink / raw)
  To: Thomas Gleixner, Andrei Vagin, Christian Brauner
  Cc: Dmitry Safonov, linux-kernel, J . Bruce Fields, Chuck Lever,
	Trond Myklebust, Anna Schumaker, Michael Weiß

Time namespaces make it possible to virtualize time inside of
containers, e.g., it is feasible to reset the uptime of a container
to zero by setting the time namespace offset for boottime to the
negated current value of the CLOCK_BOOTTIME.

However, the boot time stamp provided by getboottime64() does not
take care of time namespaces. The resulting boot time stamp 'btime'
provided by /proc/stat does not show a plausible time stamp inside
the time namespace of a container.

We address this by shifting the value returned by getboottime64()
by subtracting the boottime offset of the time namespace.
(A selftest to check the expected /proc/stat 'btime' inside the
namespace is provided.)

Further, to avoid to show processes as time travelers inside of the
time namespace the boottime offset then needs to be added to the
start_boottime provided by the task_struct.

v4 Changes:
Avoid type conversions back and forth between timespec64 and ktime_t
in 'proc/stat.c' as suggested by Andrei.
Introduced timens_sub_boottime() in 'time_namespace.h' to provide
better coder readability/consistency.

v3 Changes:
leave getboottime64() unchanged and shift the boot timestamp in
'fs/proc/stat.c' as result of the discussion with Andrei and Thomas.

v2 Changes:
Fixed compile errors with TIME_NS not set in config

Michael Weiß (3):
  timens: additional helper functions for boottime offset handling
  fs/proc: apply the time namespace offset to /proc/stat btime
  selftests/timens: added selftest for /proc/stat btime

 fs/proc/array.c                         |  6 ++-
 fs/proc/stat.c                          |  3 ++
 include/linux/time_namespace.h          | 22 ++++++++++
 tools/testing/selftests/timens/procfs.c | 58 ++++++++++++++++++++++++-
 4 files changed, 86 insertions(+), 3 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-10-27 11:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-19 19:52 [PATCH v4 0/3] time namespace aware system boot time Michael Weiß
2020-10-19 19:52 ` [PATCH v4 1/3] timens: additional helper functions for boottime offset handling Michael Weiß
2020-10-19 19:52 ` [PATCH v4 2/3] fs/proc: apply the time namespace offset to /proc/stat btime Michael Weiß
2020-10-26 10:28   ` Thomas Gleixner
2020-10-27 11:56     ` Michael Weiß
2020-10-19 19:52 ` [PATCH v4 3/3] selftests/timens: added selftest for " Michael Weiß
2020-10-22  8:36 ` [PATCH v4 0/3] time namespace aware system boot time Andrei Vagin
2020-10-26 10:27 ` Thomas Gleixner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.