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


Groups > linux.kernel > #1418277

Re: [PATCH 3/3 V2] pvclock: Get rid of __pvclock_read_cycles in function pvclock_read_flags

From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject Re: [PATCH 3/3 V2] pvclock: Get rid of __pvclock_read_cycles in function pvclock_read_flags
Date 2016-06-09 14:20 +0200
Message-ID <rI76h-6e7-13@gated-at.bofh.it> (permalink)
References <rDjhL-8fO-3@gated-at.bofh.it> <rDLxn-rd-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sat, May 28, 2016 at 08:27:43PM +0800, Minfei Huang wrote:
> +++ b/arch/x86/kernel/pvclock.c
> @@ -61,11 +61,14 @@ void pvclock_resume(void)
>  u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
>  {
>  	unsigned version;
> -	cycle_t ret;
>  	u8 flags;
>  
>  	do {
> -		version = __pvclock_read_cycles(src, &ret, &flags);
> +		version = src->version;
> +		/* Make the latest version visible */
> +		smp_rmb();
> +
> +		flags = src->flags;

Using a seqcount to load a single byte is insane ;-)

>  		/* Make sure that the version double-check is last. */
>  		smp_rmb();
>  	} while ((src->version & 1) || version != src->version);


What's wrong with:

	u8 flags = READ_ONCE(src->flags);

?

(and have the flags store be done using WRITE_ONCE() of course).

Sure, if your total state is larger than one word you need the
seqcount for integrity, but reading _one_ byte, shees.

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH 3/3 V2] pvclock: Get rid of __pvclock_read_cycles in  function pvclock_read_flags Peter Zijlstra <peterz@infradead.org> - 2016-06-09 14:20 +0200
  Re: [PATCH 3/3 V2] pvclock: Get rid of __pvclock_read_cycles in  function pvclock_read_flags Peter Zijlstra <peterz@infradead.org> - 2016-06-09 14:30 +0200
  Re: [PATCH 3/3 V2] pvclock: Get rid of __pvclock_read_cycles in  function pvclock_read_flags Paolo Bonzini <pbonzini@redhat.com> - 2016-06-09 14:30 +0200
    Re: [PATCH 3/3 V2] pvclock: Get rid of __pvclock_read_cycles in  function pvclock_read_flags Peter Zijlstra <peterz@infradead.org> - 2016-06-09 14:40 +0200

csiph-web