All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@citrix.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	xen-devel@lists.xensource.com
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>,
	Jan Beulich <jbeulich@suse.com>
Subject: Re: [PATCH 1/2] xen: move wallclock functions from x86 to common
Date: Thu, 5 Nov 2015 17:17:29 +0000	[thread overview]
Message-ID: <563B8F29.7090605@citrix.com> (raw)
In-Reply-To: <1446742638-12385-1-git-send-email-stefano.stabellini@eu.citrix.com>

Hi,

You forgot to CC the x86 maintainers.

Regards,

On 05/11/15 16:57, Stefano Stabellini wrote:
> Remove dummy arm implementation of wallclock_time.
> Use shared_info() in common code rather than x86-ism to access it.
> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> ---
>  xen/arch/arm/time.c |    5 ---
>  xen/arch/x86/time.c |   92 +------------------------------------------------
>  xen/common/time.c   |   94 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 95 insertions(+), 96 deletions(-)
> 
> diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c
> index 5ded30c..6207615 100644
> --- a/xen/arch/arm/time.c
> +++ b/xen/arch/arm/time.c
> @@ -280,11 +280,6 @@ void domain_set_time_offset(struct domain *d, int64_t time_offset_seconds)
>      /* XXX update guest visible wallclock time */
>  }
>  
> -struct tm wallclock_time(uint64_t *ns)
> -{
> -    return (struct tm) { 0 };
> -}
> -
>  /*
>   * Local variables:
>   * mode: C
> diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
> index bbb7e6c..764d7dc 100644
> --- a/xen/arch/x86/time.c
> +++ b/xen/arch/x86/time.c
> @@ -47,9 +47,6 @@ string_param("clocksource", opt_clocksource);
>  unsigned long __read_mostly cpu_khz;  /* CPU clock frequency in kHz. */
>  DEFINE_SPINLOCK(rtc_lock);
>  unsigned long pit0_ticks;
> -static unsigned long wc_sec; /* UTC time at last 'time update'. */
> -static unsigned int wc_nsec;
> -static DEFINE_SPINLOCK(wc_lock);
>  
>  struct cpu_time {
>      u64 local_tsc_stamp;
> @@ -900,37 +897,6 @@ void force_update_vcpu_system_time(struct vcpu *v)
>      __update_vcpu_system_time(v, 1);
>  }
>  
> -void update_domain_wallclock_time(struct domain *d)
> -{
> -    uint32_t *wc_version;
> -    unsigned long sec;
> -
> -    spin_lock(&wc_lock);
> -
> -    wc_version = &shared_info(d, wc_version);
> -    *wc_version = version_update_begin(*wc_version);
> -    wmb();
> -
> -    sec = wc_sec + d->time_offset_seconds;
> -    if ( likely(!has_32bit_shinfo(d)) )
> -    {
> -        d->shared_info->native.wc_sec    = sec;
> -        d->shared_info->native.wc_nsec   = wc_nsec;
> -        d->shared_info->native.wc_sec_hi = sec >> 32;
> -    }
> -    else
> -    {
> -        d->shared_info->compat.wc_sec         = sec;
> -        d->shared_info->compat.wc_nsec        = wc_nsec;
> -        d->shared_info->compat.arch.wc_sec_hi = sec >> 32;
> -    }
> -
> -    wmb();
> -    *wc_version = version_update_end(*wc_version);
> -
> -    spin_unlock(&wc_lock);
> -}
> -
>  static void update_domain_rtc(void)
>  {
>      struct domain *d;
> @@ -988,27 +954,6 @@ int cpu_frequency_change(u64 freq)
>      return 0;
>  }
>  
> -/* Set clock to <secs,usecs> after 00:00:00 UTC, 1 January, 1970. */
> -void do_settime(unsigned long secs, unsigned int nsecs, u64 system_time_base)
> -{
> -    u64 x;
> -    u32 y;
> -    struct domain *d;
> -
> -    x = SECONDS(secs) + nsecs - system_time_base;
> -    y = do_div(x, 1000000000);
> -
> -    spin_lock(&wc_lock);
> -    wc_sec  = x;
> -    wc_nsec = y;
> -    spin_unlock(&wc_lock);
> -
> -    rcu_read_lock(&domlist_read_lock);
> -    for_each_domain ( d )
> -        update_domain_wallclock_time(d);
> -    rcu_read_unlock(&domlist_read_lock);
> -}
> -
>  /* Per-CPU communication between rendezvous IRQ and softirq handler. */
>  struct cpu_calibration {
>      u64 local_tsc_stamp;
> @@ -1608,25 +1553,6 @@ void send_timer_event(struct vcpu *v)
>      send_guest_vcpu_virq(v, VIRQ_TIMER);
>  }
>  
> -/* Return secs after 00:00:00 localtime, 1 January, 1970. */
> -unsigned long get_localtime(struct domain *d)
> -{
> -    return wc_sec + (wc_nsec + NOW()) / 1000000000ULL 
> -        + d->time_offset_seconds;
> -}
> -
> -/* Return microsecs after 00:00:00 localtime, 1 January, 1970. */
> -uint64_t get_localtime_us(struct domain *d)
> -{
> -    return (SECONDS(wc_sec + d->time_offset_seconds) + wc_nsec + NOW())
> -           / 1000UL;
> -}
> -
> -unsigned long get_sec(void)
> -{
> -    return wc_sec + (wc_nsec + NOW()) / 1000000000ULL;
> -}
> -
>  /* "cmos_utc_offset" is the difference between UTC time and CMOS time. */
>  static long cmos_utc_offset; /* in seconds */
>  
> @@ -1635,7 +1561,7 @@ int time_suspend(void)
>      if ( smp_processor_id() == 0 )
>      {
>          cmos_utc_offset = -get_cmos_time();
> -        cmos_utc_offset += (wc_sec + (wc_nsec + NOW()) / 1000000000ULL);
> +        cmos_utc_offset += get_sec();
>          kill_timer(&calibration_timer);
>  
>          /* Sync platform timer stamps. */
> @@ -1715,22 +1641,6 @@ int hwdom_pit_access(struct ioreq *ioreq)
>      return 0;
>  }
>  
> -struct tm wallclock_time(uint64_t *ns)
> -{
> -    uint64_t seconds, nsec;
> -
> -    if ( !wc_sec )
> -        return (struct tm) { 0 };
> -
> -    seconds = NOW() + SECONDS(wc_sec) + wc_nsec;
> -    nsec = do_div(seconds, 1000000000);
> -
> -    if ( ns )
> -        *ns = nsec;
> -
> -    return gmtime(seconds);
> -}
> -
>  /*
>   * PV SoftTSC Emulation.
>   */
> diff --git a/xen/common/time.c b/xen/common/time.c
> index 29fdf52..306c5dc 100644
> --- a/xen/common/time.c
> +++ b/xen/common/time.c
> @@ -16,7 +16,13 @@
>   */
>  
>  #include <xen/config.h>
> +#include <xen/sched.h>
> +#include <xen/shared.h>
> +#include <xen/spinlock.h>
>  #include <xen/time.h>
> +#include <asm/div64.h>
> +#include <asm/domain.h>
> +
>  
>  /* Nonzero if YEAR is a leap year (every 4 years,
>     except every 100th isn't, and every 400th is).  */
> @@ -34,6 +40,10 @@ const unsigned short int __mon_lengths[2][12] = {
>  #define SECS_PER_HOUR (60 * 60)
>  #define SECS_PER_DAY  (SECS_PER_HOUR * 24)
>  
> +static unsigned long wc_sec; /* UTC time at last 'time update'. */
> +static unsigned int wc_nsec;
> +static DEFINE_SPINLOCK(wc_lock);
> +
>  struct tm gmtime(unsigned long t)
>  {
>      struct tm tbuf;
> @@ -85,3 +95,87 @@ struct tm gmtime(unsigned long t)
>  
>      return tbuf;
>  }
> +
> +/* Explicitly OR with 1 just in case version number gets out of sync. */
> +#define version_update_begin(v) (((v)+1)|1)
> +#define version_update_end(v)   ((v)+1)
> +
> +void update_domain_wallclock_time(struct domain *d)
> +{
> +    uint32_t *wc_version;
> +    unsigned long sec;
> +
> +    spin_lock(&wc_lock);
> +
> +    wc_version = &shared_info(d, wc_version);
> +    *wc_version = version_update_begin(*wc_version);
> +    wmb();
> +
> +    sec = wc_sec + d->time_offset_seconds;
> +    shared_info(d, wc_sec)    = sec;
> +    shared_info(d, wc_nsec)   = wc_nsec;
> +    shared_info(d, wc_sec_hi) = sec >> 32;
> +
> +    wmb();
> +    *wc_version = version_update_end(*wc_version);
> +
> +    spin_unlock(&wc_lock);
> +}
> +
> +/* Set clock to <secs,usecs> after 00:00:00 UTC, 1 January, 1970. */
> +void do_settime(unsigned long secs, unsigned int nsecs, u64 system_time_base)
> +{
> +    u64 x;
> +    u32 y;
> +    struct domain *d;
> +
> +    x = SECONDS(secs) + nsecs - system_time_base;
> +    y = do_div(x, 1000000000);
> +
> +    spin_lock(&wc_lock);
> +    wc_sec  = x;
> +    wc_nsec = y;
> +    spin_unlock(&wc_lock);
> +
> +    rcu_read_lock(&domlist_read_lock);
> +    for_each_domain ( d )
> +        update_domain_wallclock_time(d);
> +    rcu_read_unlock(&domlist_read_lock);
> +}
> +
> +/* Return secs after 00:00:00 localtime, 1 January, 1970. */
> +unsigned long get_localtime(struct domain *d)
> +{
> +    return wc_sec + (wc_nsec + NOW()) / 1000000000ULL 
> +        + d->time_offset_seconds;
> +}
> +
> +/* Return microsecs after 00:00:00 localtime, 1 January, 1970. */
> +uint64_t get_localtime_us(struct domain *d)
> +{
> +    return (SECONDS(wc_sec + d->time_offset_seconds) + wc_nsec + NOW())
> +           / 1000UL;
> +}
> +
> +unsigned long get_sec(void)
> +{
> +    return wc_sec + (wc_nsec + NOW()) / 1000000000ULL;
> +}
> +
> +struct tm wallclock_time(uint64_t *ns)
> +{
> +    uint64_t seconds, nsec;
> +
> +    if ( !wc_sec )
> +        return (struct tm) { 0 };
> +
> +    seconds = NOW() + SECONDS(wc_sec) + wc_nsec;
> +    nsec = do_div(seconds, 1000000000);
> +
> +    if ( ns )
> +        *ns = nsec;
> +
> +    return gmtime(seconds);
> +}
> +
> +
> 


-- 
Julien Grall

  reply	other threads:[~2015-11-05 17:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-05 16:56 [PATCH 0/2] wallclock time on arm Stefano Stabellini
2015-11-05 16:57 ` [PATCH 1/2] xen: move wallclock functions from x86 to common Stefano Stabellini
2015-11-05 17:17   ` Julien Grall [this message]
2015-11-05 17:18   ` Jan Beulich
2015-11-06 17:45     ` Stefano Stabellini
2015-11-05 16:57 ` [PATCH 2/2] arm: export platform_op XENPF_settime Stefano Stabellini
2015-11-05 17:04   ` David Vrabel
2015-11-06 12:21     ` Stefano Stabellini
2015-11-05 17:34   ` Julien Grall
2015-11-05 18:00     ` Andrew Cooper
2015-11-09 17:09     ` Stefano Stabellini
2015-11-10 14:11       ` Julien Grall
2015-11-10 14:27         ` Stefano Stabellini
2015-11-10 14:41           ` Julien Grall
2015-11-11 17:09             ` Stefano Stabellini

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=563B8F29.7090605@citrix.com \
    --to=julien.grall@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xensource.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.