Skip to content

Commit

Permalink
fs/proc: Respect boottime inside time namespace for /proc/uptime
Browse files Browse the repository at this point in the history
Make sure that /proc/uptime is adjusted to the tasks time namespace.

Co-developed-by: Andrei Vagin <avagin@openvz.org>
Signed-off-by: Andrei Vagin <avagin@openvz.org>
Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20191112012724.250792-19-dima@arista.com
  • Loading branch information
Dmitry Safonov authored and Thomas Gleixner committed Jan 14, 2020
1 parent 1f9b37b commit 0efc8bb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fs/proc/uptime.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <linux/sched.h>
#include <linux/seq_file.h>
#include <linux/time.h>
#include <linux/time_namespace.h>
#include <linux/kernel_stat.h>

static int uptime_proc_show(struct seq_file *m, void *v)
Expand All @@ -20,6 +21,8 @@ static int uptime_proc_show(struct seq_file *m, void *v)
nsec += (__force u64) kcpustat_cpu(i).cpustat[CPUTIME_IDLE];

ktime_get_boottime_ts64(&uptime);
timens_add_boottime(&uptime);

idle.tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
idle.tv_nsec = rem;
seq_printf(m, "%lu.%02lu %lu.%02lu\n",
Expand Down

0 comments on commit 0efc8bb

Please sign in to comment.