From mboxrd@z Thu Jan 1 00:00:00 1970 From: Keir Fraser Subject: Re: [PATCH] x86/time: cleanup Date: Fri, 28 Feb 2014 16:46:24 +0000 Message-ID: <5310BD60.1070800@gmail.com> References: <5310CA680200007800120464@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5954979961175805327==" Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WJQZy-0004b5-JB for xen-devel@lists.xenproject.org; Fri, 28 Feb 2014 16:46:30 +0000 Received: by mail-we0-f173.google.com with SMTP id w61so770553wes.32 for ; Fri, 28 Feb 2014 08:46:28 -0800 (PST) In-Reply-To: <5310CA680200007800120464@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: xen-devel , Keir Fraser List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --===============5954979961175805327== Content-Type: multipart/alternative; boundary="------------040109090707030509030305" This is a multi-part message in MIME format. --------------040109090707030509030305 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Jan Beulich wrote: > > Eliminate effectively unused variables mistakenly left in place by > 9539:08aede767c63 ("Rename update_dom_time() to > update_vcpu_system_time()"). > > Drop the pointless casts. > > Use SECONDS() instead of open coding it. > > Signed-off-by: Jan Beulich Acked-by: Keir Fraser > > > --- a/xen/arch/x86/time.c > +++ b/xen/arch/x86/time.c > @@ -921,15 +921,15 @@ int cpu_frequency_change(u64 freq) > void do_settime(unsigned long secs, unsigned long nsecs, u64 > system_time_base) > { > u64 x; > - u32 y, _wc_sec, _wc_nsec; > + u32 y; > struct domain *d; > > - x = (secs * 1000000000ULL) + (u64)nsecs - system_time_base; > + x = SECONDS(secs) + (u64)nsecs - system_time_base; > y = do_div(x, 1000000000); > > spin_lock(&wc_lock); > - wc_sec = _wc_sec = (u32)x; > - wc_nsec = _wc_nsec = (u32)y; > + wc_sec = x; > + wc_nsec = y; > spin_unlock(&wc_lock); > > rcu_read_lock(&domlist_read_lock); > @@ -1548,8 +1548,8 @@ unsigned long get_localtime(struct domai > /* Return microsecs after 00:00:00 localtime, 1 January, 1970. */ > uint64_t get_localtime_us(struct domain *d) > { > - return ((wc_sec + d->time_offset_seconds) * 1000000000ULL > - + wc_nsec + NOW()) / 1000UL; > + return (SECONDS(wc_sec + d->time_offset_seconds) + wc_nsec + NOW()) > + / 1000UL; > } > > unsigned long get_sec(void) > @@ -1651,7 +1651,7 @@ struct tm wallclock_time(void) > if ( !wc_sec ) > return (struct tm) { 0 }; > > - seconds = NOW() + (wc_sec * 1000000000ull) + wc_nsec; > + seconds = NOW() + SECONDS(wc_sec) + wc_nsec; > do_div(seconds, 1000000000); > return gmtime(seconds); > } > > --------------040109090707030509030305 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Jan Beulich wrote:

Eliminate effectively unused variables mistakenly left in place by
9539:08aede767c63 ("Rename update_dom_time() to
update_vcpu_system_time()").

Drop the pointless casts.

Use SECONDS() instead of open coding it.

Signed-off-by: Jan Beulich<jbeulich@suse.com>


Acked-by: Keir Fraser <keir@xen.org>



--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -921,15 +921,15 @@ int cpu_frequency_change(u64 freq)
  void do_settime(unsigned long secs, unsigned long nsecs, u64 system_time_base)
  {
      u64 x;
-    u32 y, _wc_sec, _wc_nsec;
+    u32 y;
      struct domain *d;

-    x = (secs * 1000000000ULL) + (u64)nsecs - system_time_base;
+    x = SECONDS(secs) + (u64)nsecs - system_time_base;
      y = do_div(x, 1000000000);

      spin_lock(&wc_lock);
-    wc_sec  = _wc_sec  = (u32)x;
-    wc_nsec = _wc_nsec = (u32)y;
+    wc_sec  = x;
+    wc_nsec = y;
      spin_unlock(&wc_lock);

      rcu_read_lock(&domlist_read_lock);
@@ -1548,8 +1548,8 @@ unsigned long get_localtime(struct domai
  /* Return microsecs after 00:00:00 localtime, 1 January, 1970. */
  uint64_t get_localtime_us(struct domain *d)
  {
-    return ((wc_sec + d->time_offset_seconds) * 1000000000ULL
-        + wc_nsec + NOW()) / 1000UL;
+    return (SECONDS(wc_sec + d->time_offset_seconds) + wc_nsec + NOW())
+           / 1000UL;
  }

  unsigned long get_sec(void)
@@ -1651,7 +1651,7 @@ struct tm wallclock_time(void)
      if ( !wc_sec )
          return (struct tm) { 0 };

-    seconds = NOW() + (wc_sec * 1000000000ull) + wc_nsec;
+    seconds = NOW() + SECONDS(wc_sec) + wc_nsec;
      do_div(seconds, 1000000000);
      return gmtime(seconds);
  }


--------------040109090707030509030305-- --===============5954979961175805327== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============5954979961175805327==--