Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1577631 > unrolled thread

[PATCH 0/2] x86/vdso: Add Hyper-V TSC page clocksource support

Started byVitaly Kuznetsov <vkuznets@redhat.com>
First post2017-02-09 15:20 +0100
Last post2017-02-10 00:20 +0100
Articles 5 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/2] x86/vdso: Add Hyper-V TSC page clocksource support Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-02-09 15:20 +0100
    [PATCH 1/2] hyperv: implement hv_get_tsc_page() Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-02-09 15:20 +0100
      RE: [PATCH 1/2] hyperv: implement hv_get_tsc_page() Stephen Hemminger <sthemmin@microsoft.com> - 2017-02-09 21:10 +0100
        RE: [PATCH 1/2] hyperv: implement hv_get_tsc_page() Thomas Gleixner <tglx@linutronix.de> - 2017-02-09 21:20 +0100
          Re: [PATCH 1/2] hyperv: implement hv_get_tsc_page() Stephen Hemminger <stephen@networkplumber.org> - 2017-02-10 00:20 +0100

#1577631 — [PATCH 0/2] x86/vdso: Add Hyper-V TSC page clocksource support

FromVitaly Kuznetsov <vkuznets@redhat.com>
Date2017-02-09 15:20 +0100
Subject[PATCH 0/2] x86/vdso: Add Hyper-V TSC page clocksource support
Message-ID<t8XJL-7cN-7@gated-at.bofh.it>
Hi,

Hyper-V TSC page clocksource is suitable for vDSO, however, the protocol
defined by the hypervisor is different from VCLOCK_PVCLOCK. Implemented the
required support. Simple sysbench test shows the following results:

Before:
# time sysbench --test=memory --max-requests=500000 run
...
real    1m22.618s
user    0m50.193s
sys     0m32.268s

After:
# time sysbench --test=memory --max-requests=500000 run
...
real	0m47.241s
user	0m47.117s
sys	0m0.008s

So it seems it is worth it. As nobody seems to be strongly offended by my RFC
I'm sending first non-RFC version. Patch 1 is made on top of K. Y.'s code
refactoring which moved tsc page clocksource to arch/x86/hyperv/hv_init.c,
this is currently present in Greg's char-misc-next tree.

Changes since RFC:
- Use mul_u64_u64_shr() instead of an open coded implementation
  [Andy Lutomirski, Thomas Gleixner]
- Don't use the same pvclock_page for both VCLOCK_PVCLOCK and
  VCLOCK_HVCLOCK, create another one [Andy Lutomirski]
- Fix issues reported by kbuild test robot.
- Rename HYPERV_CLOCK -> HYPERV_TSCPAGE to avoid the ambiguity.

I'm also going to try to optimize mul_u64_u64_shr() for 32bit but this can
be split from this series I guess.

Vitaly Kuznetsov (2):
  hyperv: implement hv_get_tsc_page()
  x86/vdso: Add VCLOCK_HVCLOCK vDSO clock read method

 arch/x86/entry/vdso/vclock_gettime.c  | 36 +++++++++++++++++++++++++++++++++++
 arch/x86/entry/vdso/vdso-layout.lds.S |  3 ++-
 arch/x86/entry/vdso/vdso2c.c          |  3 +++
 arch/x86/entry/vdso/vma.c             |  7 +++++++
 arch/x86/hyperv/hv_init.c             | 12 ++++++++++--
 arch/x86/include/asm/clocksource.h    |  3 ++-
 arch/x86/include/asm/mshyperv.h       |  8 ++++++++
 arch/x86/include/asm/vdso.h           |  1 +
 drivers/hv/Kconfig                    |  3 +++
 9 files changed, 72 insertions(+), 4 deletions(-)

-- 
2.9.3

[toc] | [next] | [standalone]


#1577638 — [PATCH 1/2] hyperv: implement hv_get_tsc_page()

FromVitaly Kuznetsov <vkuznets@redhat.com>
Date2017-02-09 15:20 +0100
Subject[PATCH 1/2] hyperv: implement hv_get_tsc_page()
Message-ID<t8XJM-7cN-27@gated-at.bofh.it>
In reply to#1577631
To use Hyper-V TSC page clocksource from vDSO we need to make tsc_pg
available. Implement hv_get_tsc_page() and add CONFIG_HYPERV_TSCPAGE to
make #ifdef-s simple.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 arch/x86/hyperv/hv_init.c       | 9 +++++++--
 arch/x86/include/asm/mshyperv.h | 8 ++++++++
 drivers/hv/Kconfig              | 3 +++
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index b371d0e..0ce8485 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -27,10 +27,15 @@
 #include <linux/clockchips.h>
 
 
-#ifdef CONFIG_X86_64
+#ifdef CONFIG_HYPERV_TSCPAGE
 
 static struct ms_hyperv_tsc_page *tsc_pg;
 
+struct ms_hyperv_tsc_page *hv_get_tsc_page(void)
+{
+	return tsc_pg;
+}
+
 static u64 read_hv_clock_tsc(struct clocksource *arg)
 {
 	u64 current_tick;
@@ -136,7 +141,7 @@ void hyperv_init(void)
 	/*
 	 * Register Hyper-V specific clocksource.
 	 */
-#ifdef CONFIG_X86_64
+#ifdef CONFIG_HYPERV_TSCPAGE
 	if (ms_hyperv.features & HV_X64_MSR_REFERENCE_TSC_AVAILABLE) {
 		union hv_x64_msr_hypercall_contents tsc_msr;
 
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index f8dc370..14dd92c 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -173,4 +173,12 @@ void hyperv_report_panic(struct pt_regs *regs);
 bool hv_is_hypercall_page_setup(void);
 void hyperv_cleanup(void);
 #endif
+#ifdef CONFIG_HYPERV_TSCPAGE
+struct ms_hyperv_tsc_page *hv_get_tsc_page(void);
+#else
+static inline struct ms_hyperv_tsc_page *hv_get_tsc_page(void)
+{
+	return NULL;
+}
+#endif
 #endif
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index 0403b51..c29cd53 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -7,6 +7,9 @@ config HYPERV
 	  Select this option to run Linux as a Hyper-V client operating
 	  system.
 
+config HYPERV_TSCPAGE
+       def_bool HYPERV && X86_64
+
 config HYPERV_UTILS
 	tristate "Microsoft Hyper-V Utilities driver"
 	depends on HYPERV && CONNECTOR && NLS
-- 
2.9.3

[toc] | [prev] | [next] | [standalone]


#1577915 — RE: [PATCH 1/2] hyperv: implement hv_get_tsc_page()

FromStephen Hemminger <sthemmin@microsoft.com>
Date2017-02-09 21:10 +0100
SubjectRE: [PATCH 1/2] hyperv: implement hv_get_tsc_page()
Message-ID<t93ct-2cm-5@gated-at.bofh.it>
In reply to#1577638
The actual code looks fine, but the style police will not like you.
{ should be at start of line on functions.
And #else should be at start of line,

But maybe this was just more of exchange mangling the mail.

-----Original Message-----
From: Vitaly Kuznetsov [mailto:vkuznets@redhat.com] 
Sent: Thursday, February 9, 2017 6:11 AM
To: x86@kernel.org; Andy Lutomirski <luto@amacapital.net>
Cc: Thomas Gleixner <tglx@linutronix.de>; Ingo Molnar <mingo@redhat.com>; H. Peter Anvin <hpa@zytor.com>; KY Srinivasan <kys@microsoft.com>; Haiyang Zhang <haiyangz@microsoft.com>; Stephen Hemminger <sthemmin@microsoft.com>; Dexuan Cui <decui@microsoft.com>; linux-kernel@vger.kernel.org; devel@linuxdriverproject.org; virtualization@lists.linux-foundation.org
Subject: [PATCH 1/2] hyperv: implement hv_get_tsc_page()

To use Hyper-V TSC page clocksource from vDSO we need to make tsc_pg available. Implement hv_get_tsc_page() and add CONFIG_HYPERV_TSCPAGE to make #ifdef-s simple.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 arch/x86/hyperv/hv_init.c       | 9 +++++++--
 arch/x86/include/asm/mshyperv.h | 8 ++++++++
 drivers/hv/Kconfig              | 3 +++
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c index b371d0e..0ce8485 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -27,10 +27,15 @@
 #include <linux/clockchips.h>
 
 
-#ifdef CONFIG_X86_64
+#ifdef CONFIG_HYPERV_TSCPAGE
 
 static struct ms_hyperv_tsc_page *tsc_pg;
 
+struct ms_hyperv_tsc_page *hv_get_tsc_page(void) {
+	return tsc_pg;
+}
+
 static u64 read_hv_clock_tsc(struct clocksource *arg)  {
 	u64 current_tick;
@@ -136,7 +141,7 @@ void hyperv_init(void)
 	/*
 	 * Register Hyper-V specific clocksource.
 	 */
-#ifdef CONFIG_X86_64
+#ifdef CONFIG_HYPERV_TSCPAGE
 	if (ms_hyperv.features & HV_X64_MSR_REFERENCE_TSC_AVAILABLE) {
 		union hv_x64_msr_hypercall_contents tsc_msr;
 
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h index f8dc370..14dd92c 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -173,4 +173,12 @@ void hyperv_report_panic(struct pt_regs *regs);  bool hv_is_hypercall_page_setup(void);  void hyperv_cleanup(void);  #endif
+#ifdef CONFIG_HYPERV_TSCPAGE
+struct ms_hyperv_tsc_page *hv_get_tsc_page(void); #else static inline 
+struct ms_hyperv_tsc_page *hv_get_tsc_page(void) {
+	return NULL;
+}
+#endif
 #endif
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig index 0403b51..c29cd53 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -7,6 +7,9 @@ config HYPERV
 	  Select this option to run Linux as a Hyper-V client operating
 	  system.
 
+config HYPERV_TSCPAGE
+       def_bool HYPERV && X86_64
+
 config HYPERV_UTILS
 	tristate "Microsoft Hyper-V Utilities driver"
 	depends on HYPERV && CONNECTOR && NLS
--
2.9.3

[toc] | [prev] | [next] | [standalone]


#1577926 — RE: [PATCH 1/2] hyperv: implement hv_get_tsc_page()

FromThomas Gleixner <tglx@linutronix.de>
Date2017-02-09 21:20 +0100
SubjectRE: [PATCH 1/2] hyperv: implement hv_get_tsc_page()
Message-ID<t93ma-2fX-21@gated-at.bofh.it>
In reply to#1577915
On Thu, 9 Feb 2017, Stephen Hemminger wrote:

> The actual code looks fine, but the style police will not like you.
> { should be at start of line on functions.
> And #else should be at start of line,
> 
> But maybe this was just more of exchange mangling the mail.

Looks like.

> +struct ms_hyperv_tsc_page *hv_get_tsc_page(void) {
> +	return tsc_pg;
> +}
> +

That's how it reads in a proper mail client connected to a proper mail
server:

> +struct ms_hyperv_tsc_page *hv_get_tsc_page(void)
> +{
> +       return tsc_pg;
> +}

:)

[toc] | [prev] | [next] | [standalone]


#1578032 — Re: [PATCH 1/2] hyperv: implement hv_get_tsc_page()

FromStephen Hemminger <stephen@networkplumber.org>
Date2017-02-10 00:20 +0100
SubjectRe: [PATCH 1/2] hyperv: implement hv_get_tsc_page()
Message-ID<t96am-42G-33@gated-at.bofh.it>
In reply to#1577926
On Thu, 9 Feb 2017 21:14:25 +0100 (CET)
Thomas Gleixner <tglx@linutronix.de> wrote:

> On Thu, 9 Feb 2017, Stephen Hemminger wrote:
> 
> > The actual code looks fine, but the style police will not like you.
> > { should be at start of line on functions.
> > And #else should be at start of line,
> > 
> > But maybe this was just more of exchange mangling the mail.  
> 
> Looks like.
> 
> > +struct ms_hyperv_tsc_page *hv_get_tsc_page(void) {
> > +	return tsc_pg;
> > +}
> > +  
> 
> That's how it reads in a proper mail client connected to a proper mail
> server:
> 
> > +struct ms_hyperv_tsc_page *hv_get_tsc_page(void)
> > +{
> > +       return tsc_pg;
> > +}  
> 
> :)


Yup. it looks like the mail server is trying to be "helpful" by eliminating extra white space.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web