Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1266433 > unrolled thread
| Started by | Stefano Stabellini <stefano.stabellini@eu.citrix.com> |
|---|---|
| First post | 2015-11-10 13:00 +0100 |
| Last post | 2015-11-10 13:00 +0100 |
| Articles | 20 on this page of 23 — 5 participants |
Back to article view | Back to linux.kernel
[PATCH v2 0/7] Xen wallclock on arm and arm64 Stefano Stabellini <stefano.stabellini@eu.citrix.com> - 2015-11-10 13:00 +0100
[PATCH v2 3/7] xen/arm: introduce HYPERVISOR_platform_op on arm and arm64 Stefano Stabellini <stefano.stabellini@eu.citrix.com> - 2015-11-10 13:00 +0100
[PATCH v2 1/7] timekeeping: introduce __current_kernel_time64 Stefano Stabellini <stefano.stabellini@eu.citrix.com> - 2015-11-10 13:00 +0100
Re: [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64 Peter Zijlstra <peterz@infradead.org> - 2015-11-10 13:30 +0100
Re: [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64 Stefano Stabellini <stefano.stabellini@eu.citrix.com> - 2015-11-10 15:40 +0100
Re: [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64 Arnd Bergmann <arnd@arndb.de> - 2015-11-10 13:40 +0100
Re: [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64 Stefano Stabellini <stefano.stabellini@eu.citrix.com> - 2015-11-10 16:20 +0100
Re: [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64 John Stultz <john.stultz@linaro.org> - 2015-11-10 16:30 +0100
Re: [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64 Thomas Gleixner <tglx@linutronix.de> - 2015-11-10 16:40 +0100
Re: [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64 John Stultz <john.stultz@linaro.org> - 2015-11-10 16:50 +0100
Re: [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64 Thomas Gleixner <tglx@linutronix.de> - 2015-11-10 17:00 +0100
Re: [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64 Stefano Stabellini <stefano.stabellini@eu.citrix.com> - 2015-11-11 13:00 +0100
Re: [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64 Arnd Bergmann <arnd@arndb.de> - 2015-11-11 14:40 +0100
[PATCH v2 4/7] xen: introduce XENPF_settime64 Stefano Stabellini <stefano.stabellini@eu.citrix.com> - 2015-11-10 13:00 +0100
Re: [PATCH v2 4/7] xen: introduce XENPF_settime64 Arnd Bergmann <arnd@arndb.de> - 2015-11-10 13:40 +0100
Re: [PATCH v2 4/7] xen: introduce XENPF_settime64 Arnd Bergmann <arnd@arndb.de> - 2015-11-10 15:50 +0100
Re: [PATCH v2 4/7] xen: introduce XENPF_settime64 Stefano Stabellini <stefano.stabellini@eu.citrix.com> - 2015-11-10 15:50 +0100
[PATCH v2 6/7] xen/arm: introduce xen_read_wallclock Stefano Stabellini <stefano.stabellini@eu.citrix.com> - 2015-11-10 13:00 +0100
Re: [PATCH v2 6/7] xen/arm: introduce xen_read_wallclock Arnd Bergmann <arnd@arndb.de> - 2015-11-10 13:40 +0100
[PATCH v2 7/7] xen/arm: set the system time in Xen via the XENPF_settime64 hypercall Stefano Stabellini <stefano.stabellini@eu.citrix.com> - 2015-11-10 13:00 +0100
Re: [PATCH v2 7/7] xen/arm: set the system time in Xen via the XENPF_settime64 hypercall Arnd Bergmann <arnd@arndb.de> - 2015-11-10 13:50 +0100
Re: [PATCH v2 7/7] xen/arm: set the system time in Xen via the XENPF_settime64 hypercall Stefano Stabellini <stefano.stabellini@eu.citrix.com> - 2015-11-10 17:00 +0100
[PATCH v2 2/7] xen: rename dom0_op to platform_op Stefano Stabellini <stefano.stabellini@eu.citrix.com> - 2015-11-10 13:00 +0100
Page 1 of 2 [1] 2 Next page →
| From | Stefano Stabellini <stefano.stabellini@eu.citrix.com> |
|---|---|
| Date | 2015-11-10 13:00 +0100 |
| Subject | [PATCH v2 0/7] Xen wallclock on arm and arm64 |
| Message-ID | <qtfKF-4Aq-5@gated-at.bofh.it> |
Hi all,
this series introduces PV wallclock time support on arm and arm64.
Changes in v2:
- introduce __current_kernel_time64
- rename dom0_op to platform_op
- introduce XENPF_settime64
- extend pvclock_wall_clock with sec_hi
- properly convert arch_timer ticker to nsec
- use timespec64 interfaces
- use sec_hi to get a 64-bit seconds value
- use XENPF_settime64
- rename dom0_op to platform_op
Stefano Stabellini (7):
timekeeping: introduce __current_kernel_time64
xen: rename dom0_op to platform_op
xen/arm: introduce HYPERVISOR_platform_op on arm and arm64
xen: introduce XENPF_settime64
arm: extend pvclock_wall_clock with sec_hi
xen/arm: introduce xen_read_wallclock
xen/arm: set the system time in Xen via the XENPF_settime64 hypercall
arch/arm/Kconfig | 1 +
arch/arm/include/asm/xen/hypercall.h | 2 +
arch/arm/include/asm/xen/interface.h | 1 +
arch/arm/xen/enlighten.c | 86 ++++++++++++++++++++++++++++++++++
arch/arm/xen/hypercall.S | 1 +
arch/arm64/xen/hypercall.S | 1 +
arch/x86/include/asm/xen/hypercall.h | 6 +--
arch/x86/xen/apic.c | 2 +-
arch/x86/xen/enlighten.c | 8 ++--
arch/x86/xen/time.c | 10 ++--
drivers/xen/acpi.c | 2 +-
drivers/xen/efi.c | 30 ++++++------
drivers/xen/pcpu.c | 8 ++--
drivers/xen/xen-acpi-cpuhotplug.c | 2 +-
drivers/xen/xen-acpi-pad.c | 4 +-
drivers/xen/xen-acpi-processor.c | 8 ++--
drivers/xen/xenfs/xensyms.c | 4 +-
include/linux/timekeeping.h | 3 +-
include/xen/interface/platform.h | 18 +++++--
include/xen/interface/xen.h | 2 +-
kernel/time/timekeeping.c | 7 +++
21 files changed, 158 insertions(+), 48 deletions(-)
Cheers,
Stefano
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Stefano Stabellini <stefano.stabellini@eu.citrix.com> |
|---|---|
| Date | 2015-11-10 13:00 +0100 |
| Subject | [PATCH v2 3/7] xen/arm: introduce HYPERVISOR_platform_op on arm and arm64 |
| Message-ID | <qtfKF-4Aq-11@gated-at.bofh.it> |
| In reply to | #1266433 |
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> --- Changes in v2: - rename dom0_op to platform_op --- arch/arm/include/asm/xen/hypercall.h | 2 ++ arch/arm/xen/enlighten.c | 1 + arch/arm/xen/hypercall.S | 1 + arch/arm64/xen/hypercall.S | 1 + 4 files changed, 5 insertions(+) diff --git a/arch/arm/include/asm/xen/hypercall.h b/arch/arm/include/asm/xen/hypercall.h index 712b50e..c3e00d0 100644 --- a/arch/arm/include/asm/xen/hypercall.h +++ b/arch/arm/include/asm/xen/hypercall.h @@ -35,6 +35,7 @@ #include <xen/interface/xen.h> #include <xen/interface/sched.h> +#include <xen/interface/platform.h> long privcmd_call(unsigned call, unsigned long a1, unsigned long a2, unsigned long a3, @@ -49,6 +50,7 @@ int HYPERVISOR_memory_op(unsigned int cmd, void *arg); int HYPERVISOR_physdev_op(int cmd, void *arg); int HYPERVISOR_vcpu_op(int cmd, int vcpuid, void *extra_args); int HYPERVISOR_tmem_op(void *arg); +int HYPERVISOR_platform_op(void *arg); int HYPERVISOR_multicall(struct multicall_entry *calls, uint32_t nr); static inline int diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 15621b1..2f57ba3 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -328,5 +328,6 @@ EXPORT_SYMBOL_GPL(HYPERVISOR_memory_op); EXPORT_SYMBOL_GPL(HYPERVISOR_physdev_op); EXPORT_SYMBOL_GPL(HYPERVISOR_vcpu_op); EXPORT_SYMBOL_GPL(HYPERVISOR_tmem_op); +EXPORT_SYMBOL_GPL(HYPERVISOR_platform_op); EXPORT_SYMBOL_GPL(HYPERVISOR_multicall); EXPORT_SYMBOL_GPL(privcmd_call); diff --git a/arch/arm/xen/hypercall.S b/arch/arm/xen/hypercall.S index 10fd99c..d4539f4 100644 --- a/arch/arm/xen/hypercall.S +++ b/arch/arm/xen/hypercall.S @@ -89,6 +89,7 @@ HYPERCALL2(memory_op); HYPERCALL2(physdev_op); HYPERCALL3(vcpu_op); HYPERCALL1(tmem_op); +HYPERCALL1(platform_op); HYPERCALL2(multicall); ENTRY(privcmd_call) diff --git a/arch/arm64/xen/hypercall.S b/arch/arm64/xen/hypercall.S index 8bbe940..f7d5724 100644 --- a/arch/arm64/xen/hypercall.S +++ b/arch/arm64/xen/hypercall.S @@ -80,6 +80,7 @@ HYPERCALL2(memory_op); HYPERCALL2(physdev_op); HYPERCALL3(vcpu_op); HYPERCALL1(tmem_op); +HYPERCALL1(platform_op); HYPERCALL2(multicall); ENTRY(privcmd_call) -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Stefano Stabellini <stefano.stabellini@eu.citrix.com> |
|---|---|
| Date | 2015-11-10 13:00 +0100 |
| Subject | [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64 |
| Message-ID | <qtfKF-4Aq-7@gated-at.bofh.it> |
| In reply to | #1266433 |
__current_kernel_time64 returns a struct timespec64, without taking the
xtime lock. Mirrors __current_kernel_time/current_kernel_time.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
CC: arnd@arndb.de
CC: john.stultz@linaro.org
CC: tglx@linutronix.de
CC: mingo@kernel.org
CC: peterz@infradead.org
---
include/linux/timekeeping.h | 3 ++-
kernel/time/timekeeping.c | 7 +++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index ec89d84..b5802bf 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -19,7 +19,8 @@ extern int do_sys_settimeofday(const struct timespec *tv,
*/
unsigned long get_seconds(void);
struct timespec64 current_kernel_time64(void);
-/* does not take xtime_lock */
+/* do not take xtime_lock */
+struct timespec64 __current_kernel_time64(void);
struct timespec __current_kernel_time(void);
static inline struct timespec current_kernel_time(void)
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index b1356b7..c1221c2 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -1881,6 +1881,13 @@ struct timespec __current_kernel_time(void)
return timespec64_to_timespec(tk_xtime(tk));
}
+struct timespec64 __current_kernel_time64(void)
+{
+ struct timekeeper *tk = &tk_core.timekeeper;
+
+ return tk_xtime(tk);
+}
+
struct timespec64 current_kernel_time64(void)
{
struct timekeeper *tk = &tk_core.timekeeper;
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2015-11-10 13:30 +0100 |
| Subject | Re: [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64 |
| Message-ID | <qtgdI-505-23@gated-at.bofh.it> |
| In reply to | #1266437 |
On Tue, Nov 10, 2015 at 11:57:49AM +0000, Stefano Stabellini wrote: > __current_kernel_time64 returns a struct timespec64, without taking the > xtime lock. Mirrors __current_kernel_time/current_kernel_time. It always helps if you include a reason why you want a patch. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Stefano Stabellini <stefano.stabellini@eu.citrix.com> |
|---|---|
| Date | 2015-11-10 15:40 +0100 |
| Subject | Re: [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64 |
| Message-ID | <qtifw-6eV-5@gated-at.bofh.it> |
| In reply to | #1266458 |
On Tue, 10 Nov 2015, Peter Zijlstra wrote: > On Tue, Nov 10, 2015 at 11:57:49AM +0000, Stefano Stabellini wrote: > > __current_kernel_time64 returns a struct timespec64, without taking the > > xtime lock. Mirrors __current_kernel_time/current_kernel_time. > > It always helps if you include a reason why you want a patch. You are right, sorry. I need to get the current_kernel_time from a pvclock_gtod callback function, which cannot take the lock again. On x86 we are just calling __current_kernel_time() (see arch/x86/xen/time.c:xen_pvclock_gtod_notify). I was introducing the same functionality on ARM, when the maintainers pointed out that it might be better to use struct timespec64 and related functions for future-proofness. To do that I need a version of __current_kernel_time which returns a struct timespec64. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2015-11-10 13:40 +0100 |
| Subject | Re: [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64 |
| Message-ID | <qtgno-53E-13@gated-at.bofh.it> |
| In reply to | #1266437 |
On Tuesday 10 November 2015 11:57:49 Stefano Stabellini wrote: > __current_kernel_time64 returns a struct timespec64, without taking the > xtime lock. Mirrors __current_kernel_time/current_kernel_time. > Actually it doesn't mirror __current_kernel_time/current_kernel_time > diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h > index ec89d84..b5802bf 100644 > --- a/include/linux/timekeeping.h > +++ b/include/linux/timekeeping.h > @@ -19,7 +19,8 @@ extern int do_sys_settimeofday(const struct timespec *tv, > */ > unsigned long get_seconds(void); > struct timespec64 current_kernel_time64(void); > -/* does not take xtime_lock */ > +/* do not take xtime_lock */ > +struct timespec64 __current_kernel_time64(void); > struct timespec __current_kernel_time(void); Please change __current_kernel_time into a static inline function while you are introducing the new one, to match the patch description ;-) Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Stefano Stabellini <stefano.stabellini@eu.citrix.com> |
|---|---|
| Date | 2015-11-10 16:20 +0100 |
| Subject | Re: [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64 |
| Message-ID | <qtiSe-6IY-11@gated-at.bofh.it> |
| In reply to | #1266464 |
On Tue, 10 Nov 2015, Arnd Bergmann wrote: > On Tuesday 10 November 2015 11:57:49 Stefano Stabellini wrote: > > __current_kernel_time64 returns a struct timespec64, without taking the > > xtime lock. Mirrors __current_kernel_time/current_kernel_time. > > > > Actually it doesn't mirror __current_kernel_time/current_kernel_time > > > diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h > > index ec89d84..b5802bf 100644 > > --- a/include/linux/timekeeping.h > > +++ b/include/linux/timekeeping.h > > @@ -19,7 +19,8 @@ extern int do_sys_settimeofday(const struct timespec *tv, > > */ > > unsigned long get_seconds(void); > > struct timespec64 current_kernel_time64(void); > > -/* does not take xtime_lock */ > > +/* do not take xtime_lock */ > > +struct timespec64 __current_kernel_time64(void); > > struct timespec __current_kernel_time(void); > > Please change __current_kernel_time into a static inline function > while you are introducing the new one, to match the patch description ;-) The implementation is: struct timekeeper *tk = &tk_core.timekeeper; return timespec64_to_timespec(tk_xtime(tk)); which cannot be easily made into a static inline, unless we start exporting tk_core. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | John Stultz <john.stultz@linaro.org> |
|---|---|
| Date | 2015-11-10 16:30 +0100 |
| Subject | Re: [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64 |
| Message-ID | <qtj1U-6MH-25@gated-at.bofh.it> |
| In reply to | #1266571 |
On Tue, Nov 10, 2015 at 7:10 AM, Stefano Stabellini
<stefano.stabellini@eu.citrix.com> wrote:
> On Tue, 10 Nov 2015, Arnd Bergmann wrote:
>> On Tuesday 10 November 2015 11:57:49 Stefano Stabellini wrote:
>> > __current_kernel_time64 returns a struct timespec64, without taking the
>> > xtime lock. Mirrors __current_kernel_time/current_kernel_time.
>> >
>>
>> Actually it doesn't mirror __current_kernel_time/current_kernel_time
>>
>> > diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
>> > index ec89d84..b5802bf 100644
>> > --- a/include/linux/timekeeping.h
>> > +++ b/include/linux/timekeeping.h
>> > @@ -19,7 +19,8 @@ extern int do_sys_settimeofday(const struct timespec *tv,
>> > */
>> > unsigned long get_seconds(void);
>> > struct timespec64 current_kernel_time64(void);
>> > -/* does not take xtime_lock */
>> > +/* do not take xtime_lock */
>> > +struct timespec64 __current_kernel_time64(void);
>> > struct timespec __current_kernel_time(void);
>>
>> Please change __current_kernel_time into a static inline function
>> while you are introducing the new one, to match the patch description ;-)
>
> The implementation is:
>
> struct timekeeper *tk = &tk_core.timekeeper;
>
> return timespec64_to_timespec(tk_xtime(tk));
>
> which cannot be easily made into a static inline, unless we start
> exporting tk_core.
So the timekeeper is passed to the notifier. So you probably want something like
struct timespec64 __current_kernel_time64(struct timekeeper *tk)
{
return timespec64_to_timespec(tk_xtime(tk));
}
Then you can cast the priv pointer in the notifier to a timekeeper and
use it that way?
thanks
-john
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2015-11-10 16:40 +0100 |
| Subject | Re: [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64 |
| Message-ID | <qtjbz-6QE-3@gated-at.bofh.it> |
| In reply to | #1266574 |
On Tue, 10 Nov 2015, John Stultz wrote:
> On Tue, Nov 10, 2015 at 7:10 AM, Stefano Stabellini
> <stefano.stabellini@eu.citrix.com> wrote:
> > On Tue, 10 Nov 2015, Arnd Bergmann wrote:
> >> On Tuesday 10 November 2015 11:57:49 Stefano Stabellini wrote:
> >> > __current_kernel_time64 returns a struct timespec64, without taking the
> >> > xtime lock. Mirrors __current_kernel_time/current_kernel_time.
> >> >
> >>
> >> Actually it doesn't mirror __current_kernel_time/current_kernel_time
> >>
> >> > diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
> >> > index ec89d84..b5802bf 100644
> >> > --- a/include/linux/timekeeping.h
> >> > +++ b/include/linux/timekeeping.h
> >> > @@ -19,7 +19,8 @@ extern int do_sys_settimeofday(const struct timespec *tv,
> >> > */
> >> > unsigned long get_seconds(void);
> >> > struct timespec64 current_kernel_time64(void);
> >> > -/* does not take xtime_lock */
> >> > +/* do not take xtime_lock */
> >> > +struct timespec64 __current_kernel_time64(void);
> >> > struct timespec __current_kernel_time(void);
> >>
> >> Please change __current_kernel_time into a static inline function
> >> while you are introducing the new one, to match the patch description ;-)
> >
> > The implementation is:
> >
> > struct timekeeper *tk = &tk_core.timekeeper;
> >
> > return timespec64_to_timespec(tk_xtime(tk));
> >
> > which cannot be easily made into a static inline, unless we start
> > exporting tk_core.
>
> So the timekeeper is passed to the notifier. So you probably want something like
>
> struct timespec64 __current_kernel_time64(struct timekeeper *tk)
> {
> return timespec64_to_timespec(tk_xtime(tk));
> }
>
> Then you can cast the priv pointer in the notifier to a timekeeper and
> use it that way?
Err no. Look at commit 8758a240e2d74c5932ab51a73377e6507b7fd441
i.e. Add the new 64bit function and make the existing one a static
inline which does the timespec64 to timespec conversion.
Thanks,
tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | John Stultz <john.stultz@linaro.org> |
|---|---|
| Date | 2015-11-10 16:50 +0100 |
| Subject | Re: [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64 |
| Message-ID | <qtjlg-6UG-19@gated-at.bofh.it> |
| In reply to | #1266579 |
On Tue, Nov 10, 2015 at 7:31 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> On Tue, 10 Nov 2015, John Stultz wrote:
>> On Tue, Nov 10, 2015 at 7:10 AM, Stefano Stabellini
>> <stefano.stabellini@eu.citrix.com> wrote:
>> > On Tue, 10 Nov 2015, Arnd Bergmann wrote:
>> >> On Tuesday 10 November 2015 11:57:49 Stefano Stabellini wrote:
>> >> > __current_kernel_time64 returns a struct timespec64, without taking the
>> >> > xtime lock. Mirrors __current_kernel_time/current_kernel_time.
>> >> >
>> >>
>> >> Actually it doesn't mirror __current_kernel_time/current_kernel_time
>> >>
>> >> > diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
>> >> > index ec89d84..b5802bf 100644
>> >> > --- a/include/linux/timekeeping.h
>> >> > +++ b/include/linux/timekeeping.h
>> >> > @@ -19,7 +19,8 @@ extern int do_sys_settimeofday(const struct timespec *tv,
>> >> > */
>> >> > unsigned long get_seconds(void);
>> >> > struct timespec64 current_kernel_time64(void);
>> >> > -/* does not take xtime_lock */
>> >> > +/* do not take xtime_lock */
>> >> > +struct timespec64 __current_kernel_time64(void);
>> >> > struct timespec __current_kernel_time(void);
>> >>
>> >> Please change __current_kernel_time into a static inline function
>> >> while you are introducing the new one, to match the patch description ;-)
>> >
>> > The implementation is:
>> >
>> > struct timekeeper *tk = &tk_core.timekeeper;
>> >
>> > return timespec64_to_timespec(tk_xtime(tk));
>> >
>> > which cannot be easily made into a static inline, unless we start
>> > exporting tk_core.
>>
>> So the timekeeper is passed to the notifier. So you probably want something like
>>
>> struct timespec64 __current_kernel_time64(struct timekeeper *tk)
>> {
>> return timespec64_to_timespec(tk_xtime(tk));
>> }
>>
>> Then you can cast the priv pointer in the notifier to a timekeeper and
>> use it that way?
>
> Err no. Look at commit 8758a240e2d74c5932ab51a73377e6507b7fd441
>
> i.e. Add the new 64bit function and make the existing one a static
> inline which does the timespec64 to timespec conversion.
So yea. The style there is what should be done.
I'm sort of objecting to a different issue, where the
__current_kernel_time() implementation probably shouldn't be grabbing
the tk_core.timekeeper directly, and instead should take a passed
pointer to a timekeeper. The vdso/pv_clock usage should have a
timekeeper passed to them that they could use.
There's one useage in kdb thats maybe problematic, so maybe this will
need a deeper cleanup.
thanks
-john
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2015-11-10 17:00 +0100 |
| Subject | Re: [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64 |
| Message-ID | <qtjuX-6Yy-25@gated-at.bofh.it> |
| In reply to | #1266585 |
On Tue, 10 Nov 2015, John Stultz wrote: > I'm sort of objecting to a different issue, where the > __current_kernel_time() implementation probably shouldn't be grabbing > the tk_core.timekeeper directly, and instead should take a passed > pointer to a timekeeper. The vdso/pv_clock usage should have a > timekeeper passed to them that they could use. That usage of __current_kernel_time() in that xen notifier is silly to begin with. The notifier gets already called with a pointer to the time keeper. That xen implementation just does not use it. We extract exactly that information in the vdso updates without calling back into the core code. So for solving that xen thing we do not need a 64 bit variant of __current_kernel_time() at all. The notifier has the pointer to the timekeeper and can just grab data from there. > There's one useage in kdb thats maybe problematic, so maybe this will > need a deeper cleanup. That one is silly as well. It only wants to know the seconds portion. Thanks, tglx -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Stefano Stabellini <stefano.stabellini@eu.citrix.com> |
|---|---|
| Date | 2015-11-11 13:00 +0100 |
| Subject | Re: [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64 |
| Message-ID | <qtCee-2hA-3@gated-at.bofh.it> |
| In reply to | #1266593 |
On Tue, 10 Nov 2015, Thomas Gleixner wrote: > On Tue, 10 Nov 2015, John Stultz wrote: > > I'm sort of objecting to a different issue, where the > > __current_kernel_time() implementation probably shouldn't be grabbing > > the tk_core.timekeeper directly, and instead should take a passed > > pointer to a timekeeper. The vdso/pv_clock usage should have a > > timekeeper passed to them that they could use. > > That usage of __current_kernel_time() in that xen notifier is silly to > begin with. The notifier gets already called with a pointer to the > time keeper. That xen implementation just does not use it. > > We extract exactly that information in the vdso updates without > calling back into the core code. So for solving that xen thing we do > not need a 64 bit variant of __current_kernel_time() at all. The > notifier has the pointer to the timekeeper and can just grab data from > there. Many thanks for the suggestion, I'll do that. Should I open code tk_xtime in the xen notifier, or should I export it in timekeeper_internal.h? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2015-11-11 14:40 +0100 |
| Subject | Re: [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64 |
| Message-ID | <qtDN1-3mL-27@gated-at.bofh.it> |
| In reply to | #1267118 |
On Wednesday 11 November 2015 11:51:26 Stefano Stabellini wrote: > On Tue, 10 Nov 2015, Thomas Gleixner wrote: > > On Tue, 10 Nov 2015, John Stultz wrote: > > > I'm sort of objecting to a different issue, where the > > > __current_kernel_time() implementation probably shouldn't be grabbing > > > the tk_core.timekeeper directly, and instead should take a passed > > > pointer to a timekeeper. The vdso/pv_clock usage should have a > > > timekeeper passed to them that they could use. > > > > That usage of __current_kernel_time() in that xen notifier is silly to > > begin with. The notifier gets already called with a pointer to the > > time keeper. That xen implementation just does not use it. > > > > We extract exactly that information in the vdso updates without > > calling back into the core code. So for solving that xen thing we do > > not need a 64 bit variant of __current_kernel_time() at all. The > > notifier has the pointer to the timekeeper and can just grab data from > > there. > > Many thanks for the suggestion, I'll do that. > Should I open code tk_xtime in the xen notifier, or should I export it > in timekeeper_internal.h? tk_xtime is a 'static inline' function, I don't see a good way to make that accessible, and you really want the elements separately, so I'd open-code it without going through timespec64. Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Stefano Stabellini <stefano.stabellini@eu.citrix.com> |
|---|---|
| Date | 2015-11-10 13:00 +0100 |
| Subject | [PATCH v2 4/7] xen: introduce XENPF_settime64 |
| Message-ID | <qtfKG-4Aq-27@gated-at.bofh.it> |
| In reply to | #1266433 |
Rename the current XENPF_settime hypercall and related struct to
XENPF_settime32.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
CC: konrad.wilk@oracle.com
CC: david.vrabel@citrix.com
CC: boris.ostrovsky@oracle.com
---
arch/x86/xen/time.c | 8 ++++----
include/xen/interface/platform.h | 18 ++++++++++++++----
2 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 663c2ea..3bbd377 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -134,10 +134,10 @@ static int xen_pvclock_gtod_notify(struct notifier_block *nb,
if (!was_set && timespec_compare(&now, &next_sync) < 0)
return NOTIFY_OK;
- op.cmd = XENPF_settime;
- op.u.settime.secs = now.tv_sec;
- op.u.settime.nsecs = now.tv_nsec;
- op.u.settime.system_time = xen_clocksource_read();
+ op.cmd = XENPF_settime32;
+ op.u.settime32.secs = now.tv_sec;
+ op.u.settime32.nsecs = now.tv_nsec;
+ op.u.settime32.system_time = xen_clocksource_read();
(void)HYPERVISOR_platform_op(&op);
diff --git a/include/xen/interface/platform.h b/include/xen/interface/platform.h
index 8e03587..732efb0 100644
--- a/include/xen/interface/platform.h
+++ b/include/xen/interface/platform.h
@@ -35,14 +35,23 @@
* Set clock such that it would read <secs,nsecs> after 00:00:00 UTC,
* 1 January, 1970 if the current system time was <system_time>.
*/
-#define XENPF_settime 17
-struct xenpf_settime {
+#define XENPF_settime32 17
+struct xenpf_settime32 {
/* IN variables. */
uint32_t secs;
uint32_t nsecs;
uint64_t system_time;
};
-DEFINE_GUEST_HANDLE_STRUCT(xenpf_settime_t);
+DEFINE_GUEST_HANDLE_STRUCT(xenpf_settime32_t);
+#define XENPF_settime64 62
+struct xenpf_settime64 {
+ /* IN variables. */
+ uint64_t secs;
+ uint32_t nsecs;
+ uint32_t mbz;
+ uint64_t system_time;
+};
+DEFINE_GUEST_HANDLE_STRUCT(xenpf_settime64_t);
/*
* Request memory range (@mfn, @mfn+@nr_mfns-1) to have type @type.
@@ -495,7 +504,8 @@ struct xen_platform_op {
uint32_t cmd;
uint32_t interface_version; /* XENPF_INTERFACE_VERSION */
union {
- struct xenpf_settime settime;
+ struct xenpf_settime32 settime32;
+ struct xenpf_settime64 settime64;
struct xenpf_add_memtype add_memtype;
struct xenpf_del_memtype del_memtype;
struct xenpf_read_memtype read_memtype;
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2015-11-10 13:40 +0100 |
| Subject | Re: [PATCH v2 4/7] xen: introduce XENPF_settime64 |
| Message-ID | <qtgnp-53E-33@gated-at.bofh.it> |
| In reply to | #1266442 |
On Tuesday 10 November 2015 11:57:52 Stefano Stabellini wrote: > Rename the current XENPF_settime hypercall and related struct to > XENPF_settime32. > > Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> > CC: konrad.wilk@oracle.com > CC: david.vrabel@citrix.com > CC: boris.ostrovsky@oracle.com Looks good. > --- > arch/x86/xen/time.c | 8 ++++---- > include/xen/interface/platform.h | 18 ++++++++++++++---- > 2 files changed, 18 insertions(+), 8 deletions(-) > > diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c > index 663c2ea..3bbd377 100644 > --- a/arch/x86/xen/time.c > +++ b/arch/x86/xen/time.c > @@ -134,10 +134,10 @@ static int xen_pvclock_gtod_notify(struct notifier_block *nb, > if (!was_set && timespec_compare(&now, &next_sync) < 0) > return NOTIFY_OK; > > - op.cmd = XENPF_settime; > - op.u.settime.secs = now.tv_sec; > - op.u.settime.nsecs = now.tv_nsec; > - op.u.settime.system_time = xen_clocksource_read(); > + op.cmd = XENPF_settime32; > + op.u.settime32.secs = now.tv_sec; > + op.u.settime32.nsecs = now.tv_nsec; > + op.u.settime32.system_time = xen_clocksource_read(); > > (void)HYPERVISOR_platform_op(&op); I suppose someone will have to get back to this eventually and change the code to try XENPF_settime64 first. Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2015-11-10 15:50 +0100 |
| Subject | Re: [PATCH v2 4/7] xen: introduce XENPF_settime64 |
| Message-ID | <qtipc-6iz-7@gated-at.bofh.it> |
| In reply to | #1266467 |
On Tuesday 10 November 2015 14:43:26 Stefano Stabellini wrote: > On Tue, 10 Nov 2015, Arnd Bergmann wrote: > > On Tuesday 10 November 2015 11:57:52 Stefano Stabellini wrote: > > > Rename the current XENPF_settime hypercall and related struct to > > > XENPF_settime32. > > > > > > Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> > > > CC: konrad.wilk@oracle.com > > > CC: david.vrabel@citrix.com > > > CC: boris.ostrovsky@oracle.com > > > > Looks good. > > Can I add your acked-by? > > Yes, please do. Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Stefano Stabellini <stefano.stabellini@eu.citrix.com> |
|---|---|
| Date | 2015-11-10 15:50 +0100 |
| Subject | Re: [PATCH v2 4/7] xen: introduce XENPF_settime64 |
| Message-ID | <qtipc-6iz-9@gated-at.bofh.it> |
| In reply to | #1266467 |
On Tue, 10 Nov 2015, Arnd Bergmann wrote: > On Tuesday 10 November 2015 11:57:52 Stefano Stabellini wrote: > > Rename the current XENPF_settime hypercall and related struct to > > XENPF_settime32. > > > > Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> > > CC: konrad.wilk@oracle.com > > CC: david.vrabel@citrix.com > > CC: boris.ostrovsky@oracle.com > > Looks good. Can I add your acked-by? > > --- > > arch/x86/xen/time.c | 8 ++++---- > > include/xen/interface/platform.h | 18 ++++++++++++++---- > > 2 files changed, 18 insertions(+), 8 deletions(-) > > > > diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c > > index 663c2ea..3bbd377 100644 > > --- a/arch/x86/xen/time.c > > +++ b/arch/x86/xen/time.c > > @@ -134,10 +134,10 @@ static int xen_pvclock_gtod_notify(struct notifier_block *nb, > > if (!was_set && timespec_compare(&now, &next_sync) < 0) > > return NOTIFY_OK; > > > > - op.cmd = XENPF_settime; > > - op.u.settime.secs = now.tv_sec; > > - op.u.settime.nsecs = now.tv_nsec; > > - op.u.settime.system_time = xen_clocksource_read(); > > + op.cmd = XENPF_settime32; > > + op.u.settime32.secs = now.tv_sec; > > + op.u.settime32.nsecs = now.tv_nsec; > > + op.u.settime32.system_time = xen_clocksource_read(); > > > > (void)HYPERVISOR_platform_op(&op); > > I suppose someone will have to get back to this eventually and > change the code to try XENPF_settime64 first. I'll leave that to the x86 maintainers -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Stefano Stabellini <stefano.stabellini@eu.citrix.com> |
|---|---|
| Date | 2015-11-10 13:00 +0100 |
| Subject | [PATCH v2 6/7] xen/arm: introduce xen_read_wallclock |
| Message-ID | <qtfKG-4Aq-31@gated-at.bofh.it> |
| In reply to | #1266433 |
Read the wallclock from the shared info page at boot time.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
Changes in v2:
- properly convert arch_timer ticker to nsec
- use timespec64 interfaces
- use sec_hi to get a 64-bit seconds value
---
arch/arm/Kconfig | 1 +
arch/arm/xen/enlighten.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 60be104..a9de420 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1852,6 +1852,7 @@ config XEN
depends on CPU_V7 && !CPU_V6
depends on !GENERIC_ATOMIC64
depends on MMU
+ depends on HAVE_ARM_ARCH_TIMER
select ARCH_DMA_ADDR_T_64BIT
select ARM_PSCI
select SWIOTLB_XEN
diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 2f57ba3..32675b5 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -28,6 +28,8 @@
#include <linux/cpufreq.h>
#include <linux/cpu.h>
#include <linux/console.h>
+#include <linux/timekeeping.h>
+#include <clocksource/arm_arch_timer.h>
#include <linux/mm.h>
@@ -95,6 +97,34 @@ static unsigned long long xen_stolen_accounting(int cpu)
return state.time[RUNSTATE_runnable] + state.time[RUNSTATE_offline];
}
+static void xen_read_wallclock(struct timespec64 *ts)
+{
+ u32 version;
+ u64 delta;
+ struct timespec64 now;
+ struct shared_info *s = HYPERVISOR_shared_info;
+ struct pvclock_wall_clock *wall_clock = &(s->wc);
+
+ /* get wallclock at system boot */
+ do {
+ version = wall_clock->version;
+ rmb(); /* fetch version before time */
+ now.tv_sec = ((uint64_t)wall_clock->sec_hi << 32) | wall_clock->sec;
+ now.tv_nsec = wall_clock->nsec;
+ rmb(); /* fetch time before checking version */
+ } while ((wall_clock->version & 1) || (version != wall_clock->version));
+
+ delta = arch_timer_read_counter() * (u64)NSEC_PER_SEC;
+ do_div(delta, arch_timer_get_rate()); /* time since system boot */
+ delta += now.tv_sec * (u64)NSEC_PER_SEC + now.tv_nsec;
+
+ now.tv_nsec = do_div(delta, NSEC_PER_SEC);
+ now.tv_sec = delta;
+
+ set_normalized_timespec64(ts, now.tv_sec, now.tv_nsec);
+
+}
+
static void xen_percpu_init(void)
{
struct vcpu_register_vcpu_info info;
@@ -218,6 +248,7 @@ static int __init xen_guest_init(void)
struct shared_info *shared_info_page = NULL;
struct resource res;
phys_addr_t grant_frames;
+ struct timespec64 ts;
if (!xen_domain())
return 0;
@@ -291,6 +322,8 @@ static int __init xen_guest_init(void)
pv_time_ops.steal_clock = xen_stolen_accounting;
static_key_slow_inc(¶virt_steal_enabled);
+ xen_read_wallclock(&ts);
+ do_settimeofday64(&ts);
return 0;
}
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2015-11-10 13:40 +0100 |
| Subject | Re: [PATCH v2 6/7] xen/arm: introduce xen_read_wallclock |
| Message-ID | <qtgno-53E-15@gated-at.bofh.it> |
| In reply to | #1266443 |
On Tuesday 10 November 2015 11:57:54 Stefano Stabellini wrote:
> +static void xen_read_wallclock(struct timespec64 *ts)
> +{
> + u32 version;
> + u64 delta;
> + struct timespec64 now;
> + struct shared_info *s = HYPERVISOR_shared_info;
> + struct pvclock_wall_clock *wall_clock = &(s->wc);
> +
> + /* get wallclock at system boot */
> + do {
> + version = wall_clock->version;
> + rmb(); /* fetch version before time */
> + now.tv_sec = ((uint64_t)wall_clock->sec_hi << 32) | wall_clock->sec;
> + now.tv_nsec = wall_clock->nsec;
> + rmb(); /* fetch time before checking version */
> + } while ((wall_clock->version & 1) || (version != wall_clock->version));
> +
> + delta = arch_timer_read_counter() * (u64)NSEC_PER_SEC;
> + do_div(delta, arch_timer_get_rate()); /* time since system boot */
> + delta += now.tv_sec * (u64)NSEC_PER_SEC + now.tv_nsec;
> +
> + now.tv_nsec = do_div(delta, NSEC_PER_SEC);
> + now.tv_sec = delta;
> +
> + set_normalized_timespec64(ts, now.tv_sec, now.tv_nsec);
> +
> +}
Instead of the two do_div(), I would do the entire calculation in
terms of nanoseconds and then call ns_to_timespec64() in the end
instead of set_normalized_timespec64(). That is just an optimization
though, your version looks correct as well.
Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Stefano Stabellini <stefano.stabellini@eu.citrix.com> |
|---|---|
| Date | 2015-11-10 13:00 +0100 |
| Subject | [PATCH v2 7/7] xen/arm: set the system time in Xen via the XENPF_settime64 hypercall |
| Message-ID | <qtfKG-4Aq-35@gated-at.bofh.it> |
| In reply to | #1266433 |
If Linux is running as dom0, call XENPF_settime64 to update the system
time in Xen on pvclock_gtod notifications.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
Changes in v2:
- properly convert arch_timer ticker to nsec
- rename dom0_op to platform_op
- use timespec64 interfaces
- use XENPF_settime64
---
arch/arm/xen/enlighten.c | 54 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 53 insertions(+), 1 deletion(-)
diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 32675b5..a991b25 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -28,6 +28,7 @@
#include <linux/cpufreq.h>
#include <linux/cpu.h>
#include <linux/console.h>
+#include <linux/pvclock_gtod.h>
#include <linux/timekeeping.h>
#include <clocksource/arm_arch_timer.h>
@@ -125,6 +126,52 @@ static void xen_read_wallclock(struct timespec64 *ts)
}
+static int xen_pvclock_gtod_notify(struct notifier_block *nb,
+ unsigned long was_set, void *priv)
+{
+ /* Protected by the calling core code serialization */
+ static struct timespec64 next_sync;
+
+ struct xen_platform_op op;
+ struct timespec64 now;
+
+ now = __current_kernel_time64();
+
+ /*
+ * We only take the expensive HV call when the clock was set
+ * or when the 11 minutes RTC synchronization time elapsed.
+ */
+ if (!was_set && timespec64_compare(&now, &next_sync) < 0)
+ return NOTIFY_OK;
+
+ op.interface_version = XENPF_INTERFACE_VERSION;
+ op.cmd = XENPF_settime64;
+ op.u.settime64.mbz = 0;
+ op.u.settime64.secs = now.tv_sec;
+ op.u.settime64.nsecs = now.tv_nsec;
+ op.u.settime64.system_time = arch_timer_read_counter() * (u64)NSEC_PER_SEC;
+ do_div(op.u.settime64.system_time, arch_timer_get_rate());
+ printk("GTOD: Setting to %llu.%u at %llu\n",
+ op.u.settime64.secs,
+ op.u.settime64.nsecs,
+ op.u.settime64.system_time);
+ (void)HYPERVISOR_platform_op(&op);
+
+ /*
+ * Move the next drift compensation time 11 minutes
+ * ahead. That's emulating the sync_cmos_clock() update for
+ * the hardware RTC.
+ */
+ next_sync = now;
+ next_sync.tv_sec += 11 * 60;
+
+ return NOTIFY_OK;
+}
+
+static struct notifier_block xen_pvclock_gtod_notifier = {
+ .notifier_call = xen_pvclock_gtod_notify,
+};
+
static void xen_percpu_init(void)
{
struct vcpu_register_vcpu_info info;
@@ -323,7 +370,12 @@ static int __init xen_guest_init(void)
pv_time_ops.steal_clock = xen_stolen_accounting;
static_key_slow_inc(¶virt_steal_enabled);
xen_read_wallclock(&ts);
- do_settimeofday64(&ts);
+ if (xen_initial_domain())
+ pvclock_gtod_register_notifier(&xen_pvclock_gtod_notifier);
+ else {
+ xen_read_wallclock(&ts);
+ do_settimeofday64(&ts);
+ }
return 0;
}
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | linux.kernel
csiph-web