All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrei Vagin <avagin@gmail.com>
To: "Michael Weiß" <michael.weiss@aisec.fraunhofer.de>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Christian Brauner <christian.brauner@ubuntu.com>,
	Dmitry Safonov <0x7f454c46@gmail.com>,
	linux-kernel@vger.kernel.org,
	"J . Bruce Fields" <bfields@fieldses.org>,
	Chuck Lever <chuck.lever@oracle.com>,
	Trond Myklebust <trond.myklebust@hammerspace.com>,
	Anna Schumaker <anna.schumaker@netapp.com>
Subject: Re: [PATCH v3 2/3] fs/proc: apply the time namespace offset to /proc/stat btime
Date: Thu, 15 Oct 2020 00:53:19 -0700	[thread overview]
Message-ID: <20201015075319.GA271498@gmail.com> (raw)
In-Reply-To: <20201011145924.6554-3-michael.weiss@aisec.fraunhofer.de>

On Sun, Oct 11, 2020 at 04:59:23PM +0200, Michael Weiß wrote:
> @@ -79,6 +80,20 @@ static u64 get_iowait_time(struct kernel_cpustat *kcs, int cpu)
>  
>  #endif
>  
> +static void get_boottime(struct timespec64 *ts)
> +{

> +	ktime_t boottime;
> +
> +	/* get kernel internal system boot timestamp */
> +	getboottime64(ts);
> +
> +	/* shift boot timestamp according to the timens offset */
> +	boottime = timespec64_to_ktime(*ts);
> +	boottime = timens_ktime_to_host(CLOCK_BOOTTIME, boottime);

timens_ktime_to_host is used to convert timens' time to host's time.
Here it looks like we are using it in the opposite direction. I spent
some time to figure out what is going on here. I think it worth to add a
comment here.

> +
> +	*ts = ktime_to_timespec64(boottime);

I don't like all these conversions back and forth. Maybe something like
this will look better:

#ifdef CONFIG_TIME_NS
	if (current->nsproxy->time_ns != init_time_ns) {
		struct timens_offsets *ns_offsets;
		ns_offsets = &current->nsproxy->time_ns->offsets;
		ts = timespec64_sub(ts, timens_offsets->boottime);
	}
#endif


Thanks,
Andrei

  reply	other threads:[~2020-10-15  7:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-11 14:59 [PATCH v3 0/3] time namespace aware system boot time Michael Weiß
2020-10-11 14:59 ` [PATCH v3 1/3] timens: additional helper function to add boottime in nsec Michael Weiß
2020-10-11 14:59 ` [PATCH v3 2/3] fs/proc: apply the time namespace offset to /proc/stat btime Michael Weiß
2020-10-15  7:53   ` Andrei Vagin [this message]
2020-10-15 11:26     ` Michael Weiß
2020-10-11 14:59 ` [PATCH v3 3/3] selftests/timens: added selftest for " Michael Weiß

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201015075319.GA271498@gmail.com \
    --to=avagin@gmail.com \
    --cc=0x7f454c46@gmail.com \
    --cc=anna.schumaker@netapp.com \
    --cc=bfields@fieldses.org \
    --cc=christian.brauner@ubuntu.com \
    --cc=chuck.lever@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.weiss@aisec.fraunhofer.de \
    --cc=tglx@linutronix.de \
    --cc=trond.myklebust@hammerspace.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.