* Re: [PATCH V2 00/18] *** SUBJECT HERE ***
[not found] <1484783072-32286-1-git-send-email-kys@exchange.microsoft.com>
@ 2017-01-19 7:34 ` Greg KH
2017-01-19 13:42 ` KY Srinivasan
[not found] ` <1484783117-32324-5-git-send-email-kys@exchange.microsoft.com>
1 sibling, 1 reply; 6+ messages in thread
From: Greg KH @ 2017-01-19 7:34 UTC (permalink / raw)
To: kys; +Cc: linux-kernel, devel, olaf, apw, vkuznets, jasowang, leann.ogasawara
On Wed, Jan 18, 2017 at 04:44:32PM -0700, kys@exchange.microsoft.com wrote:
> From: K. Y. Srinivasan <kys@microsoft.com>
<snip>
"interesting" subject :(
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH V2 05/18] Drivers: hv: vmbus: Consolidate all Hyper-V specific clocksource code
[not found] ` <1484783117-32324-5-git-send-email-kys@exchange.microsoft.com>
@ 2017-01-19 10:58 ` Greg KH
2017-01-19 16:49 ` KY Srinivasan
0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2017-01-19 10:58 UTC (permalink / raw)
To: kys; +Cc: linux-kernel, devel, olaf, apw, vkuznets, jasowang, leann.ogasawara
On Wed, Jan 18, 2017 at 04:45:04PM -0700, kys@exchange.microsoft.com wrote:
> From: K. Y. Srinivasan <kys@microsoft.com>
>
> As part of the effort to separate out architecture specific code,
> consolidate all Hyper-V specific clocksource code to an architecture
> specific code.
>
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> ---
> arch/x86/hyperv/hv_init.c | 104 +++++++++++++++++++++++++++++++++++++++
> arch/x86/include/asm/mshyperv.h | 12 +++++
> arch/x86/kernel/cpu/mshyperv.c | 23 ---------
> drivers/hv/hv.c | 95 -----------------------------------
> drivers/hv/hyperv_vmbus.h | 8 ---
> 5 files changed, 116 insertions(+), 126 deletions(-)
>
> diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
> index b5c8e04..691dfaf 100644
> --- a/arch/x86/hyperv/hv_init.c
> +++ b/arch/x86/hyperv/hv_init.c
> @@ -24,6 +24,79 @@
> #include <linux/version.h>
> #include <linux/vmalloc.h>
> #include <linux/mm.h>
> +#include <linux/clockchips.h>
> +
> +
> +#ifdef CONFIG_X86_64
> +
> +static struct ms_hyperv_tsc_page *tsc_pg;
> +
> +static u64 read_hv_clock_tsc(struct clocksource *arg)
> +{
> + u64 current_tick;
> +
> + if (tsc_pg->tsc_sequence != 0) {
> + /*
> + * Use the tsc page to compute the value.
> + */
> +
> + while (1) {
> + u64 tmp;
> + u32 sequence = tsc_pg->tsc_sequence;
> + u64 cur_tsc;
> + u64 scale = tsc_pg->tsc_scale;
> + s64 offset = tsc_pg->tsc_offset;
> +
> + rdtscll(cur_tsc);
> + /* current_tick = ((cur_tsc *scale) >> 64) + offset */
> + asm("mulq %3"
> + : "=d" (current_tick), "=a" (tmp)
> + : "a" (cur_tsc), "r" (scale));
> +
> + current_tick += offset;
> + if (tsc_pg->tsc_sequence == sequence)
> + return current_tick;
> +
> + if (tsc_pg->tsc_sequence != 0)
> + continue;
> + /*
> + * Fallback using MSR method.
> + */
> + break;
> + }
> + }
> + rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
> + return current_tick;
> +}
> +
> +static struct clocksource hyperv_cs_tsc = {
> + .name = "hyperv_clocksource_tsc_page",
> + .rating = 400,
> + .read = read_hv_clock_tsc,
> + .mask = CLOCKSOURCE_MASK(64),
> + .flags = CLOCK_SOURCE_IS_CONTINUOUS,
> +};
> +#endif
> +
> +static u64 read_hv_clock_msr(struct clocksource *arg)
> +{
> + u64 current_tick;
> + /*
> + * Read the partition counter to get the current tick count. This count
> + * is set to 0 when the partition is created and is incremented in
> + * 100 nanosecond units.
> + */
> + rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
> + return current_tick;
> +}
> +
> +static struct clocksource hyperv_cs_msr = {
> + .name = "hyperv_clocksource_msr",
> + .rating = 400,
> + .read = read_hv_clock_msr,
> + .mask = CLOCKSOURCE_MASK(64),
> + .flags = CLOCK_SOURCE_IS_CONTINUOUS,
> +};
>
> static void *hypercall_pg;
> /*
> @@ -31,6 +104,7 @@
> * hypervisor has been detected.
> *
> * 1. Setup the hypercall page.
> + * 2. Register Hyper-V specific clocksource.
> */
> void hyperv_init(void)
> {
> @@ -58,6 +132,36 @@ void hyperv_init(void)
> hypercall_msr.enable = 1;
> hypercall_msr.guest_physical_address = vmalloc_to_pfn(hypercall_pg);
> wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> +
> + /*
> + * Register Hyper-V specific clocksource.
> + */
> +#ifdef CONFIG_X86_64
> + if (ms_hyperv.features & HV_X64_MSR_REFERENCE_TSC_AVAILABLE) {
> + union hv_x64_msr_hypercall_contents tsc_msr;
> +
> + tsc_pg = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL);
> + if (!tsc_pg)
> + clocksource_register_hz(&hyperv_cs_msr, NSEC_PER_SEC/100);
> + return;
There's a reason you always test-build your patches and pay attention to
the warnings!
How did this pass your tests?
I've stopped applying patches here.
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH V2 00/18] *** SUBJECT HERE ***
2017-01-19 7:34 ` [PATCH V2 00/18] *** SUBJECT HERE *** Greg KH
@ 2017-01-19 13:42 ` KY Srinivasan
0 siblings, 0 replies; 6+ messages in thread
From: KY Srinivasan @ 2017-01-19 13:42 UTC (permalink / raw)
To: Greg KH
Cc: linux-kernel, devel, olaf, apw, vkuznets, jasowang, leann.ogasawara
> -----Original Message-----
> From: Greg KH [mailto:gregkh@linuxfoundation.org]
> Sent: Thursday, January 19, 2017 1:34 AM
> To: KY Srinivasan <kys@microsoft.com>
> Cc: linux-kernel@vger.kernel.org; devel@linuxdriverproject.org;
> olaf@aepfle.de; apw@canonical.com; vkuznets@redhat.com;
> jasowang@redhat.com; leann.ogasawara@canonical.com
> Subject: Re: [PATCH V2 00/18] *** SUBJECT HERE ***
>
> On Wed, Jan 18, 2017 at 04:44:32PM -0700, kys@exchange.microsoft.com
> wrote:
> > From: K. Y. Srinivasan <kys@microsoft.com>
>
> <snip>
>
> "interesting" subject :(
Greg,
Sorry about this - have been travelling back from India (too little sleep).
Regards,
K. Y
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH V2 05/18] Drivers: hv: vmbus: Consolidate all Hyper-V specific clocksource code
2017-01-19 10:58 ` [PATCH V2 05/18] Drivers: hv: vmbus: Consolidate all Hyper-V specific clocksource code Greg KH
@ 2017-01-19 16:49 ` KY Srinivasan
2017-01-19 16:51 ` Greg KH
0 siblings, 1 reply; 6+ messages in thread
From: KY Srinivasan @ 2017-01-19 16:49 UTC (permalink / raw)
To: Greg KH
Cc: linux-kernel, devel, olaf, apw, vkuznets, jasowang, leann.ogasawara
> -----Original Message-----
> From: Greg KH [mailto:gregkh@linuxfoundation.org]
> Sent: Thursday, January 19, 2017 4:59 AM
> To: KY Srinivasan <kys@microsoft.com>
> Cc: linux-kernel@vger.kernel.org; devel@linuxdriverproject.org;
> olaf@aepfle.de; apw@canonical.com; vkuznets@redhat.com;
> jasowang@redhat.com; leann.ogasawara@canonical.com
> Subject: Re: [PATCH V2 05/18] Drivers: hv: vmbus: Consolidate all Hyper-V
> specific clocksource code
>
> On Wed, Jan 18, 2017 at 04:45:04PM -0700, kys@exchange.microsoft.com
> wrote:
> > From: K. Y. Srinivasan <kys@microsoft.com>
> >
> > As part of the effort to separate out architecture specific code,
> > consolidate all Hyper-V specific clocksource code to an architecture
> > specific code.
> >
> > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > ---
> > arch/x86/hyperv/hv_init.c | 104
> +++++++++++++++++++++++++++++++++++++++
> > arch/x86/include/asm/mshyperv.h | 12 +++++
> > arch/x86/kernel/cpu/mshyperv.c | 23 ---------
> > drivers/hv/hv.c | 95 -----------------------------------
> > drivers/hv/hyperv_vmbus.h | 8 ---
> > 5 files changed, 116 insertions(+), 126 deletions(-)
> >
> > diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
> > index b5c8e04..691dfaf 100644
> > --- a/arch/x86/hyperv/hv_init.c
> > +++ b/arch/x86/hyperv/hv_init.c
> > @@ -24,6 +24,79 @@
> > #include <linux/version.h>
> > #include <linux/vmalloc.h>
> > #include <linux/mm.h>
> > +#include <linux/clockchips.h>
> > +
> > +
> > +#ifdef CONFIG_X86_64
> > +
> > +static struct ms_hyperv_tsc_page *tsc_pg;
> > +
> > +static u64 read_hv_clock_tsc(struct clocksource *arg)
> > +{
> > + u64 current_tick;
> > +
> > + if (tsc_pg->tsc_sequence != 0) {
> > + /*
> > + * Use the tsc page to compute the value.
> > + */
> > +
> > + while (1) {
> > + u64 tmp;
> > + u32 sequence = tsc_pg->tsc_sequence;
> > + u64 cur_tsc;
> > + u64 scale = tsc_pg->tsc_scale;
> > + s64 offset = tsc_pg->tsc_offset;
> > +
> > + rdtscll(cur_tsc);
> > + /* current_tick = ((cur_tsc *scale) >> 64) + offset */
> > + asm("mulq %3"
> > + : "=d" (current_tick), "=a" (tmp)
> > + : "a" (cur_tsc), "r" (scale));
> > +
> > + current_tick += offset;
> > + if (tsc_pg->tsc_sequence == sequence)
> > + return current_tick;
> > +
> > + if (tsc_pg->tsc_sequence != 0)
> > + continue;
> > + /*
> > + * Fallback using MSR method.
> > + */
> > + break;
> > + }
> > + }
> > + rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
> > + return current_tick;
> > +}
> > +
> > +static struct clocksource hyperv_cs_tsc = {
> > + .name = "hyperv_clocksource_tsc_page",
> > + .rating = 400,
> > + .read = read_hv_clock_tsc,
> > + .mask = CLOCKSOURCE_MASK(64),
> > + .flags = CLOCK_SOURCE_IS_CONTINUOUS,
> > +};
> > +#endif
> > +
> > +static u64 read_hv_clock_msr(struct clocksource *arg)
> > +{
> > + u64 current_tick;
> > + /*
> > + * Read the partition counter to get the current tick count. This count
> > + * is set to 0 when the partition is created and is incremented in
> > + * 100 nanosecond units.
> > + */
> > + rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
> > + return current_tick;
> > +}
> > +
> > +static struct clocksource hyperv_cs_msr = {
> > + .name = "hyperv_clocksource_msr",
> > + .rating = 400,
> > + .read = read_hv_clock_msr,
> > + .mask = CLOCKSOURCE_MASK(64),
> > + .flags = CLOCK_SOURCE_IS_CONTINUOUS,
> > +};
> >
> > static void *hypercall_pg;
> > /*
> > @@ -31,6 +104,7 @@
> > * hypervisor has been detected.
> > *
> > * 1. Setup the hypercall page.
> > + * 2. Register Hyper-V specific clocksource.
> > */
> > void hyperv_init(void)
> > {
> > @@ -58,6 +132,36 @@ void hyperv_init(void)
> > hypercall_msr.enable = 1;
> > hypercall_msr.guest_physical_address =
> vmalloc_to_pfn(hypercall_pg);
> > wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> > +
> > + /*
> > + * Register Hyper-V specific clocksource.
> > + */
> > +#ifdef CONFIG_X86_64
> > + if (ms_hyperv.features &
> HV_X64_MSR_REFERENCE_TSC_AVAILABLE) {
> > + union hv_x64_msr_hypercall_contents tsc_msr;
> > +
> > + tsc_pg = __vmalloc(PAGE_SIZE, GFP_KERNEL,
> PAGE_KERNEL);
> > + if (!tsc_pg)
> > + clocksource_register_hz(&hyperv_cs_msr,
> NSEC_PER_SEC/100);
> > + return;
>
> There's a reason you always test-build your patches and pay attention to
> the warnings!
>
> How did this pass your tests?
>
> I've stopped applying patches here.
Greg,
Thank you for spotting the issue; I will fix the problem and resend.
K. Y
>
> greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH V2 05/18] Drivers: hv: vmbus: Consolidate all Hyper-V specific clocksource code
2017-01-19 16:49 ` KY Srinivasan
@ 2017-01-19 16:51 ` Greg KH
2017-01-19 17:02 ` KY Srinivasan
0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2017-01-19 16:51 UTC (permalink / raw)
To: KY Srinivasan; +Cc: olaf, jasowang, linux-kernel, apw, devel, leann.ogasawara
On Thu, Jan 19, 2017 at 04:49:35PM +0000, KY Srinivasan wrote:
>
>
> > -----Original Message-----
> > From: Greg KH [mailto:gregkh@linuxfoundation.org]
> > Sent: Thursday, January 19, 2017 4:59 AM
> > To: KY Srinivasan <kys@microsoft.com>
> > Cc: linux-kernel@vger.kernel.org; devel@linuxdriverproject.org;
> > olaf@aepfle.de; apw@canonical.com; vkuznets@redhat.com;
> > jasowang@redhat.com; leann.ogasawara@canonical.com
> > Subject: Re: [PATCH V2 05/18] Drivers: hv: vmbus: Consolidate all Hyper-V
> > specific clocksource code
> >
> > On Wed, Jan 18, 2017 at 04:45:04PM -0700, kys@exchange.microsoft.com
> > wrote:
> > > From: K. Y. Srinivasan <kys@microsoft.com>
> > >
> > > As part of the effort to separate out architecture specific code,
> > > consolidate all Hyper-V specific clocksource code to an architecture
> > > specific code.
> > >
> > > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > > ---
> > > arch/x86/hyperv/hv_init.c | 104
> > +++++++++++++++++++++++++++++++++++++++
> > > arch/x86/include/asm/mshyperv.h | 12 +++++
> > > arch/x86/kernel/cpu/mshyperv.c | 23 ---------
> > > drivers/hv/hv.c | 95 -----------------------------------
> > > drivers/hv/hyperv_vmbus.h | 8 ---
> > > 5 files changed, 116 insertions(+), 126 deletions(-)
> > >
> > > diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
> > > index b5c8e04..691dfaf 100644
> > > --- a/arch/x86/hyperv/hv_init.c
> > > +++ b/arch/x86/hyperv/hv_init.c
> > > @@ -24,6 +24,79 @@
> > > #include <linux/version.h>
> > > #include <linux/vmalloc.h>
> > > #include <linux/mm.h>
> > > +#include <linux/clockchips.h>
> > > +
> > > +
> > > +#ifdef CONFIG_X86_64
> > > +
> > > +static struct ms_hyperv_tsc_page *tsc_pg;
> > > +
> > > +static u64 read_hv_clock_tsc(struct clocksource *arg)
> > > +{
> > > + u64 current_tick;
> > > +
> > > + if (tsc_pg->tsc_sequence != 0) {
> > > + /*
> > > + * Use the tsc page to compute the value.
> > > + */
> > > +
> > > + while (1) {
> > > + u64 tmp;
> > > + u32 sequence = tsc_pg->tsc_sequence;
> > > + u64 cur_tsc;
> > > + u64 scale = tsc_pg->tsc_scale;
> > > + s64 offset = tsc_pg->tsc_offset;
> > > +
> > > + rdtscll(cur_tsc);
> > > + /* current_tick = ((cur_tsc *scale) >> 64) + offset */
> > > + asm("mulq %3"
> > > + : "=d" (current_tick), "=a" (tmp)
> > > + : "a" (cur_tsc), "r" (scale));
> > > +
> > > + current_tick += offset;
> > > + if (tsc_pg->tsc_sequence == sequence)
> > > + return current_tick;
> > > +
> > > + if (tsc_pg->tsc_sequence != 0)
> > > + continue;
> > > + /*
> > > + * Fallback using MSR method.
> > > + */
> > > + break;
> > > + }
> > > + }
> > > + rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
> > > + return current_tick;
> > > +}
> > > +
> > > +static struct clocksource hyperv_cs_tsc = {
> > > + .name = "hyperv_clocksource_tsc_page",
> > > + .rating = 400,
> > > + .read = read_hv_clock_tsc,
> > > + .mask = CLOCKSOURCE_MASK(64),
> > > + .flags = CLOCK_SOURCE_IS_CONTINUOUS,
> > > +};
> > > +#endif
> > > +
> > > +static u64 read_hv_clock_msr(struct clocksource *arg)
> > > +{
> > > + u64 current_tick;
> > > + /*
> > > + * Read the partition counter to get the current tick count. This count
> > > + * is set to 0 when the partition is created and is incremented in
> > > + * 100 nanosecond units.
> > > + */
> > > + rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
> > > + return current_tick;
> > > +}
> > > +
> > > +static struct clocksource hyperv_cs_msr = {
> > > + .name = "hyperv_clocksource_msr",
> > > + .rating = 400,
> > > + .read = read_hv_clock_msr,
> > > + .mask = CLOCKSOURCE_MASK(64),
> > > + .flags = CLOCK_SOURCE_IS_CONTINUOUS,
> > > +};
> > >
> > > static void *hypercall_pg;
> > > /*
> > > @@ -31,6 +104,7 @@
> > > * hypervisor has been detected.
> > > *
> > > * 1. Setup the hypercall page.
> > > + * 2. Register Hyper-V specific clocksource.
> > > */
> > > void hyperv_init(void)
> > > {
> > > @@ -58,6 +132,36 @@ void hyperv_init(void)
> > > hypercall_msr.enable = 1;
> > > hypercall_msr.guest_physical_address =
> > vmalloc_to_pfn(hypercall_pg);
> > > wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> > > +
> > > + /*
> > > + * Register Hyper-V specific clocksource.
> > > + */
> > > +#ifdef CONFIG_X86_64
> > > + if (ms_hyperv.features &
> > HV_X64_MSR_REFERENCE_TSC_AVAILABLE) {
> > > + union hv_x64_msr_hypercall_contents tsc_msr;
> > > +
> > > + tsc_pg = __vmalloc(PAGE_SIZE, GFP_KERNEL,
> > PAGE_KERNEL);
> > > + if (!tsc_pg)
> > > + clocksource_register_hz(&hyperv_cs_msr,
> > NSEC_PER_SEC/100);
> > > + return;
> >
> > There's a reason you always test-build your patches and pay attention to
> > the warnings!
> >
> > How did this pass your tests?
> >
> > I've stopped applying patches here.
>
> Greg,
>
> Thank you for spotting the issue; I will fix the problem and resend.
Again, I have to ask, how did this past testing?
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH V2 05/18] Drivers: hv: vmbus: Consolidate all Hyper-V specific clocksource code
2017-01-19 16:51 ` Greg KH
@ 2017-01-19 17:02 ` KY Srinivasan
0 siblings, 0 replies; 6+ messages in thread
From: KY Srinivasan @ 2017-01-19 17:02 UTC (permalink / raw)
To: Greg KH; +Cc: olaf, jasowang, linux-kernel, apw, devel, leann.ogasawara
> -----Original Message-----
> From: Greg KH [mailto:gregkh@linuxfoundation.org]
> Sent: Thursday, January 19, 2017 10:52 AM
> To: KY Srinivasan <kys@microsoft.com>
> Cc: olaf@aepfle.de; jasowang@redhat.com; linux-kernel@vger.kernel.org;
> apw@canonical.com; devel@linuxdriverproject.org;
> leann.ogasawara@canonical.com
> Subject: Re: [PATCH V2 05/18] Drivers: hv: vmbus: Consolidate all Hyper-V
> specific clocksource code
>
> On Thu, Jan 19, 2017 at 04:49:35PM +0000, KY Srinivasan wrote:
> >
> >
> > > -----Original Message-----
> > > From: Greg KH [mailto:gregkh@linuxfoundation.org]
> > > Sent: Thursday, January 19, 2017 4:59 AM
> > > To: KY Srinivasan <kys@microsoft.com>
> > > Cc: linux-kernel@vger.kernel.org; devel@linuxdriverproject.org;
> > > olaf@aepfle.de; apw@canonical.com; vkuznets@redhat.com;
> > > jasowang@redhat.com; leann.ogasawara@canonical.com
> > > Subject: Re: [PATCH V2 05/18] Drivers: hv: vmbus: Consolidate all Hyper-V
> > > specific clocksource code
> > >
> > > On Wed, Jan 18, 2017 at 04:45:04PM -0700, kys@exchange.microsoft.com
> > > wrote:
> > > > From: K. Y. Srinivasan <kys@microsoft.com>
> > > >
> > > > As part of the effort to separate out architecture specific code,
> > > > consolidate all Hyper-V specific clocksource code to an architecture
> > > > specific code.
> > > >
> > > > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > > > ---
> > > > arch/x86/hyperv/hv_init.c | 104
> > > +++++++++++++++++++++++++++++++++++++++
> > > > arch/x86/include/asm/mshyperv.h | 12 +++++
> > > > arch/x86/kernel/cpu/mshyperv.c | 23 ---------
> > > > drivers/hv/hv.c | 95 -----------------------------------
> > > > drivers/hv/hyperv_vmbus.h | 8 ---
> > > > 5 files changed, 116 insertions(+), 126 deletions(-)
> > > >
> > > > diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
> > > > index b5c8e04..691dfaf 100644
> > > > --- a/arch/x86/hyperv/hv_init.c
> > > > +++ b/arch/x86/hyperv/hv_init.c
> > > > @@ -24,6 +24,79 @@
> > > > #include <linux/version.h>
> > > > #include <linux/vmalloc.h>
> > > > #include <linux/mm.h>
> > > > +#include <linux/clockchips.h>
> > > > +
> > > > +
> > > > +#ifdef CONFIG_X86_64
> > > > +
> > > > +static struct ms_hyperv_tsc_page *tsc_pg;
> > > > +
> > > > +static u64 read_hv_clock_tsc(struct clocksource *arg)
> > > > +{
> > > > + u64 current_tick;
> > > > +
> > > > + if (tsc_pg->tsc_sequence != 0) {
> > > > + /*
> > > > + * Use the tsc page to compute the value.
> > > > + */
> > > > +
> > > > + while (1) {
> > > > + u64 tmp;
> > > > + u32 sequence = tsc_pg->tsc_sequence;
> > > > + u64 cur_tsc;
> > > > + u64 scale = tsc_pg->tsc_scale;
> > > > + s64 offset = tsc_pg->tsc_offset;
> > > > +
> > > > + rdtscll(cur_tsc);
> > > > + /* current_tick = ((cur_tsc *scale) >> 64) + offset */
> > > > + asm("mulq %3"
> > > > + : "=d" (current_tick), "=a" (tmp)
> > > > + : "a" (cur_tsc), "r" (scale));
> > > > +
> > > > + current_tick += offset;
> > > > + if (tsc_pg->tsc_sequence == sequence)
> > > > + return current_tick;
> > > > +
> > > > + if (tsc_pg->tsc_sequence != 0)
> > > > + continue;
> > > > + /*
> > > > + * Fallback using MSR method.
> > > > + */
> > > > + break;
> > > > + }
> > > > + }
> > > > + rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
> > > > + return current_tick;
> > > > +}
> > > > +
> > > > +static struct clocksource hyperv_cs_tsc = {
> > > > + .name = "hyperv_clocksource_tsc_page",
> > > > + .rating = 400,
> > > > + .read = read_hv_clock_tsc,
> > > > + .mask = CLOCKSOURCE_MASK(64),
> > > > + .flags = CLOCK_SOURCE_IS_CONTINUOUS,
> > > > +};
> > > > +#endif
> > > > +
> > > > +static u64 read_hv_clock_msr(struct clocksource *arg)
> > > > +{
> > > > + u64 current_tick;
> > > > + /*
> > > > + * Read the partition counter to get the current tick count. This count
> > > > + * is set to 0 when the partition is created and is incremented in
> > > > + * 100 nanosecond units.
> > > > + */
> > > > + rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
> > > > + return current_tick;
> > > > +}
> > > > +
> > > > +static struct clocksource hyperv_cs_msr = {
> > > > + .name = "hyperv_clocksource_msr",
> > > > + .rating = 400,
> > > > + .read = read_hv_clock_msr,
> > > > + .mask = CLOCKSOURCE_MASK(64),
> > > > + .flags = CLOCK_SOURCE_IS_CONTINUOUS,
> > > > +};
> > > >
> > > > static void *hypercall_pg;
> > > > /*
> > > > @@ -31,6 +104,7 @@
> > > > * hypervisor has been detected.
> > > > *
> > > > * 1. Setup the hypercall page.
> > > > + * 2. Register Hyper-V specific clocksource.
> > > > */
> > > > void hyperv_init(void)
> > > > {
> > > > @@ -58,6 +132,36 @@ void hyperv_init(void)
> > > > hypercall_msr.enable = 1;
> > > > hypercall_msr.guest_physical_address =
> > > vmalloc_to_pfn(hypercall_pg);
> > > > wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> > > > +
> > > > + /*
> > > > + * Register Hyper-V specific clocksource.
> > > > + */
> > > > +#ifdef CONFIG_X86_64
> > > > + if (ms_hyperv.features &
> > > HV_X64_MSR_REFERENCE_TSC_AVAILABLE) {
> > > > + union hv_x64_msr_hypercall_contents tsc_msr;
> > > > +
> > > > + tsc_pg = __vmalloc(PAGE_SIZE, GFP_KERNEL,
> > > PAGE_KERNEL);
> > > > + if (!tsc_pg)
> > > > + clocksource_register_hz(&hyperv_cs_msr,
> > > NSEC_PER_SEC/100);
> > > > + return;
> > >
> > > There's a reason you always test-build your patches and pay attention to
> > > the warnings!
> > >
> > > How did this pass your tests?
> > >
> > > I've stopped applying patches here.
> >
> > Greg,
> >
> > Thank you for spotting the issue; I will fix the problem and resend.
>
> Again, I have to ask, how did this past testing?
The patches were developed on one machine and testing was done
on a different machine. While the bug was fixed on the test machine
I forgot to pick up the fix prior to posting the patches.
Regards,
K. Y
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-01-19 17:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1484783072-32286-1-git-send-email-kys@exchange.microsoft.com>
2017-01-19 7:34 ` [PATCH V2 00/18] *** SUBJECT HERE *** Greg KH
2017-01-19 13:42 ` KY Srinivasan
[not found] ` <1484783117-32324-5-git-send-email-kys@exchange.microsoft.com>
2017-01-19 10:58 ` [PATCH V2 05/18] Drivers: hv: vmbus: Consolidate all Hyper-V specific clocksource code Greg KH
2017-01-19 16:49 ` KY Srinivasan
2017-01-19 16:51 ` Greg KH
2017-01-19 17:02 ` KY Srinivasan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).