* [PATCH] Cleanup __pvclock_read_cycles to remove useless variables
@ 2016-04-25 6:53 Minfei Huang
2016-04-30 10:12 ` Minfei Huang
2016-04-30 13:24 ` Borislav Petkov
0 siblings, 2 replies; 8+ messages in thread
From: Minfei Huang @ 2016-04-25 6:53 UTC (permalink / raw)
To: tglx, mingo, hpa, luto, pbonzini, bp, mtosatti
Cc: x86, linux-kernel, Minfei Huang
The value of cycles and flags can be assigned directly without
intermediate variables.
Remove the useless variables.
Signed-off-by: Minfei Huang <mnghuan@gmail.com>
---
arch/x86/include/asm/pvclock.h | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/arch/x86/include/asm/pvclock.h b/arch/x86/include/asm/pvclock.h
index fdcc040..fb95dac 100644
--- a/arch/x86/include/asm/pvclock.h
+++ b/arch/x86/include/asm/pvclock.h
@@ -80,19 +80,12 @@ static __always_inline
unsigned __pvclock_read_cycles(const struct pvclock_vcpu_time_info *src,
cycle_t *cycles, u8 *flags)
{
- unsigned version;
- cycle_t ret, offset;
- u8 ret_flags;
-
- version = src->version;
+ cycle_t offset;
offset = pvclock_get_nsec_offset(src);
- ret = src->system_time + offset;
- ret_flags = src->flags;
-
- *cycles = ret;
- *flags = ret_flags;
- return version;
+ *cycles = src->system_time + offset;
+ *flags = src->flags;
+ return src->version;
}
struct pvclock_vsyscall_time_info {
--
2.6.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] Cleanup __pvclock_read_cycles to remove useless variables
2016-04-25 6:53 [PATCH] Cleanup __pvclock_read_cycles to remove useless variables Minfei Huang
@ 2016-04-30 10:12 ` Minfei Huang
2016-04-30 13:24 ` Borislav Petkov
1 sibling, 0 replies; 8+ messages in thread
From: Minfei Huang @ 2016-04-30 10:12 UTC (permalink / raw)
To: tglx, mingo, hpa, luto, pbonzini, bp, mtosatti; +Cc: x86, linux-kernel
ping.
Any comment is appreciate.
Thanks
Minfei
On 04/25/16 at 02:53P, Minfei Huang wrote:
> The value of cycles and flags can be assigned directly without
> intermediate variables.
>
> Remove the useless variables.
>
> Signed-off-by: Minfei Huang <mnghuan@gmail.com>
> ---
> arch/x86/include/asm/pvclock.h | 15 ++++-----------
> 1 file changed, 4 insertions(+), 11 deletions(-)
>
> diff --git a/arch/x86/include/asm/pvclock.h b/arch/x86/include/asm/pvclock.h
> index fdcc040..fb95dac 100644
> --- a/arch/x86/include/asm/pvclock.h
> +++ b/arch/x86/include/asm/pvclock.h
> @@ -80,19 +80,12 @@ static __always_inline
> unsigned __pvclock_read_cycles(const struct pvclock_vcpu_time_info *src,
> cycle_t *cycles, u8 *flags)
> {
> - unsigned version;
> - cycle_t ret, offset;
> - u8 ret_flags;
> -
> - version = src->version;
> + cycle_t offset;
>
> offset = pvclock_get_nsec_offset(src);
> - ret = src->system_time + offset;
> - ret_flags = src->flags;
> -
> - *cycles = ret;
> - *flags = ret_flags;
> - return version;
> + *cycles = src->system_time + offset;
> + *flags = src->flags;
> + return src->version;
> }
>
> struct pvclock_vsyscall_time_info {
> --
> 2.6.3
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Cleanup __pvclock_read_cycles to remove useless variables
2016-04-25 6:53 [PATCH] Cleanup __pvclock_read_cycles to remove useless variables Minfei Huang
2016-04-30 10:12 ` Minfei Huang
@ 2016-04-30 13:24 ` Borislav Petkov
2016-04-30 17:47 ` Andy Lutomirski
1 sibling, 1 reply; 8+ messages in thread
From: Borislav Petkov @ 2016-04-30 13:24 UTC (permalink / raw)
To: Minfei Huang
Cc: tglx, mingo, hpa, luto, pbonzini, mtosatti, x86, linux-kernel
On Mon, Apr 25, 2016 at 02:53:14PM +0800, Minfei Huang wrote:
> The value of cycles and flags can be assigned directly without
> intermediate variables.
>
> Remove the useless variables.
>
> Signed-off-by: Minfei Huang <mnghuan@gmail.com>
> ---
> arch/x86/include/asm/pvclock.h | 15 ++++-----------
> 1 file changed, 4 insertions(+), 11 deletions(-)
>
> diff --git a/arch/x86/include/asm/pvclock.h b/arch/x86/include/asm/pvclock.h
> index fdcc040..fb95dac 100644
> --- a/arch/x86/include/asm/pvclock.h
> +++ b/arch/x86/include/asm/pvclock.h
> @@ -80,19 +80,12 @@ static __always_inline
> unsigned __pvclock_read_cycles(const struct pvclock_vcpu_time_info *src,
> cycle_t *cycles, u8 *flags)
> {
> - unsigned version;
> - cycle_t ret, offset;
> - u8 ret_flags;
> -
> - version = src->version;
> + cycle_t offset;
>
> offset = pvclock_get_nsec_offset(src);
You could go a step further and get rid of that
pvclock_get_nsec_offset() simple wrapper too and move its meat into
__pvclock_read_cycles()...
--
Regards/Gruss,
Boris.
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
--
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Cleanup __pvclock_read_cycles to remove useless variables
2016-04-30 13:24 ` Borislav Petkov
@ 2016-04-30 17:47 ` Andy Lutomirski
2016-04-30 19:17 ` Borislav Petkov
0 siblings, 1 reply; 8+ messages in thread
From: Andy Lutomirski @ 2016-04-30 17:47 UTC (permalink / raw)
To: Borislav Petkov
Cc: Minfei Huang, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
Andrew Lutomirski, Paolo Bonzini, Marcelo Tosatti, X86 ML,
linux-kernel@vger.kernel.org
On Sat, Apr 30, 2016 at 6:24 AM, Borislav Petkov <bp@suse.de> wrote:
> On Mon, Apr 25, 2016 at 02:53:14PM +0800, Minfei Huang wrote:
>> The value of cycles and flags can be assigned directly without
>> intermediate variables.
>>
>> Remove the useless variables.
>>
>> Signed-off-by: Minfei Huang <mnghuan@gmail.com>
>> ---
>> arch/x86/include/asm/pvclock.h | 15 ++++-----------
>> 1 file changed, 4 insertions(+), 11 deletions(-)
>>
>> diff --git a/arch/x86/include/asm/pvclock.h b/arch/x86/include/asm/pvclock.h
>> index fdcc040..fb95dac 100644
>> --- a/arch/x86/include/asm/pvclock.h
>> +++ b/arch/x86/include/asm/pvclock.h
>> @@ -80,19 +80,12 @@ static __always_inline
>> unsigned __pvclock_read_cycles(const struct pvclock_vcpu_time_info *src,
>> cycle_t *cycles, u8 *flags)
>> {
>> - unsigned version;
>> - cycle_t ret, offset;
>> - u8 ret_flags;
>> -
>> - version = src->version;
>> + cycle_t offset;
>>
>> offset = pvclock_get_nsec_offset(src);
>
> You could go a step further and get rid of that
> pvclock_get_nsec_offset() simple wrapper too and move its meat into
> __pvclock_read_cycles()...
>
Take a look at vread_pvclock. I decided that __pvclock_read_cycles
was too ugly to use and was very slow and I just gave up and rewrote
it.
> --
> Regards/Gruss,
> Boris.
>
> SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
> --
--
Andy Lutomirski
AMA Capital Management, LLC
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Cleanup __pvclock_read_cycles to remove useless variables
2016-04-30 17:47 ` Andy Lutomirski
@ 2016-04-30 19:17 ` Borislav Petkov
2016-04-30 21:57 ` Andy Lutomirski
0 siblings, 1 reply; 8+ messages in thread
From: Borislav Petkov @ 2016-04-30 19:17 UTC (permalink / raw)
To: Andy Lutomirski
Cc: Minfei Huang, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
Andrew Lutomirski, Paolo Bonzini, Marcelo Tosatti, X86 ML,
linux-kernel@vger.kernel.org
On Sat, Apr 30, 2016 at 10:47:49AM -0700, Andy Lutomirski wrote:
> Take a look at vread_pvclock. I decided that __pvclock_read_cycles
> was too ugly to use and was very slow and I just gave up and rewrote
> it.
Should we kill __pvclock_read_cycles in favor of vread_pvclock? It looks
doable at a quick scan...
--
Regards/Gruss,
Boris.
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
--
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Cleanup __pvclock_read_cycles to remove useless variables
2016-04-30 19:17 ` Borislav Petkov
@ 2016-04-30 21:57 ` Andy Lutomirski
2016-05-11 14:24 ` Paolo Bonzini
0 siblings, 1 reply; 8+ messages in thread
From: Andy Lutomirski @ 2016-04-30 21:57 UTC (permalink / raw)
To: Borislav Petkov
Cc: Paolo Bonzini, Thomas Gleixner, Ingo Molnar, X86 ML, Minfei Huang,
Marcelo Tosatti, linux-kernel@vger.kernel.org, H. Peter Anvin
On Apr 30, 2016 12:17 PM, "Borislav Petkov" <bp@suse.de> wrote:
>
> On Sat, Apr 30, 2016 at 10:47:49AM -0700, Andy Lutomirski wrote:
> > Take a look at vread_pvclock. I decided that __pvclock_read_cycles
> > was too ugly to use and was very slow and I just gave up and rewrote
> > it.
>
> Should we kill __pvclock_read_cycles in favor of vread_pvclock? It looks
> doable at a quick scan...
>
The in-kernel version might have to be a bit different because it
needs to handle the !stable case. If !stable, it should just use the
current CPU's copy which means that, realistically, it should just
get_cpu and use the local copy unconditionally. Other than that, it
could look a lot like the vread_pvclock variant.
But I agree, the current thing is incomprehensible.
--Andy
> --
> Regards/Gruss,
> Boris.
>
> SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
> --
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Cleanup __pvclock_read_cycles to remove useless variables
2016-04-30 21:57 ` Andy Lutomirski
@ 2016-05-11 14:24 ` Paolo Bonzini
2016-05-11 15:19 ` Minfei Huang
0 siblings, 1 reply; 8+ messages in thread
From: Paolo Bonzini @ 2016-05-11 14:24 UTC (permalink / raw)
To: Andy Lutomirski, Borislav Petkov
Cc: Thomas Gleixner, Ingo Molnar, X86 ML, Minfei Huang,
Marcelo Tosatti, linux-kernel@vger.kernel.org, H. Peter Anvin
On 30/04/2016 23:57, Andy Lutomirski wrote:
>> > Should we kill __pvclock_read_cycles in favor of vread_pvclock? It looks
>> > doable at a quick scan...
>> >
> The in-kernel version might have to be a bit different because it
> needs to handle the !stable case. If !stable, it should just use the
> current CPU's copy which means that, realistically, it should just
> get_cpu and use the local copy unconditionally. Other than that, it
> could look a lot like the vread_pvclock variant.
>
> But I agree, the current thing is incomprehensible.
It also lacks smp_rmb()s. One is more or less implicit in rdtsc, but
you need one to separate __pvclock_read_cycles's reads of src->foo from
pvclock_read_flags's read of src->version.
Minfei, would you like to take a look?
Paolo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Cleanup __pvclock_read_cycles to remove useless variables
2016-05-11 14:24 ` Paolo Bonzini
@ 2016-05-11 15:19 ` Minfei Huang
0 siblings, 0 replies; 8+ messages in thread
From: Minfei Huang @ 2016-05-11 15:19 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Andy Lutomirski, Borislav Petkov, Thomas Gleixner, Ingo Molnar,
X86 ML, Marcelo Tosatti, linux-kernel@vger.kernel.org,
H. Peter Anvin
On 05/11/16 at 04:24P, Paolo Bonzini wrote:
>
>
> On 30/04/2016 23:57, Andy Lutomirski wrote:
> >> > Should we kill __pvclock_read_cycles in favor of vread_pvclock? It looks
> >> > doable at a quick scan...
> >> >
> > The in-kernel version might have to be a bit different because it
> > needs to handle the !stable case. If !stable, it should just use the
> > current CPU's copy which means that, realistically, it should just
> > get_cpu and use the local copy unconditionally. Other than that, it
> > could look a lot like the vread_pvclock variant.
> >
> > But I agree, the current thing is incomprehensible.
>
> It also lacks smp_rmb()s. One is more or less implicit in rdtsc, but
> you need one to separate __pvclock_read_cycles's reads of src->foo from
> pvclock_read_flags's read of src->version.
>
> Minfei, would you like to take a look?
Sure. I will take a look about this issue.
Thanks
Minfei
>
> Paolo
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-05-11 15:20 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-25 6:53 [PATCH] Cleanup __pvclock_read_cycles to remove useless variables Minfei Huang
2016-04-30 10:12 ` Minfei Huang
2016-04-30 13:24 ` Borislav Petkov
2016-04-30 17:47 ` Andy Lutomirski
2016-04-30 19:17 ` Borislav Petkov
2016-04-30 21:57 ` Andy Lutomirski
2016-05-11 14:24 ` Paolo Bonzini
2016-05-11 15:19 ` Minfei Huang
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).