[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-hackers
Subject:    Re: [PATCH v3] timecounters: Fix timehand generation read/write
From:       Sebastian Huber <sebastian.huber () embedded-brains ! de>
Date:       2015-06-09 11:32:26
Message-ID: 5576CECA.7070109 () embedded-brains ! de
[Download RAW message or body]



On 09/06/15 13:28, Konstantin Belousov wrote:
> On Tue, Jun 09, 2015 at 01:07:54PM +0200, Sebastian Huber wrote:
>> You still need the compiler memory barriers in the UP case (at least
>> with GCC 4.9 on PowerPC), e.g. something like this:
> Fair.
>
> diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
> index 9dca0e8..01c61bd 100644
> --- a/sys/kern/kern_tc.c
> +++ b/sys/kern/kern_tc.c
> @@ -189,6 +190,33 @@ tc_delta(struct timehands *th)
>   	    tc->tc_counter_mask);
>   }
>   
> +static u_int
> +tc_getgen(struct timehands *th)
> +{
> +
> +#ifdef SMP
> +	return (atomic_load_acq_int(&th->th_generation));
> +#else
> +	u_int gen;
> +
> +	gen = th->th_generation;
> +	__compiler_membar();
> +	return (gen);
> +#endif
> +}
> +
> +static void
> +tc_setgen(struct timehands *th, u_int newgen)
> +{
> +
> +#ifdef SMP
> +	atomic_store_rel_int(&th->th_generation, newgen);
> +#else
> +	__compiler_membar();
> +	th->th_generation = newgen;
> +#endif
> +}
> +
>   /*
>    * Functions for reading the time.  We have to loop until we are sure that
>    * the timehands that we operated on was not updated under our feet.  See

Thanks, this looks good to me.

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic