From owner-freebsd-hackers@FreeBSD.ORG Tue Jun 9 11:32:30 2015 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 379F8833 for ; Tue, 9 Jun 2015 11:32:30 +0000 (UTC) (envelope-from sebastian.huber@embedded-brains.de) Received: from mail.embedded-brains.de (host-82-135-62-35.customer.m-online.net [82.135.62.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D54D9120D for ; Tue, 9 Jun 2015 11:32:29 +0000 (UTC) (envelope-from sebastian.huber@embedded-brains.de) Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id EF3F32A194C; Tue, 9 Jun 2015 13:32:37 +0200 (CEST) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 8otGm-n9-o4c; Tue, 9 Jun 2015 13:32:37 +0200 (CEST) Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 95A8A2A1992; Tue, 9 Jun 2015 13:32:37 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra.eb.localhost Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id HR06oQzULysh; Tue, 9 Jun 2015 13:32:37 +0200 (CEST) Received: from [192.168.96.129] (unknown [192.168.96.129]) by mail.embedded-brains.de (Postfix) with ESMTPSA id 773E62A194C; Tue, 9 Jun 2015 13:32:37 +0200 (CEST) Message-ID: <5576CECA.7070109@embedded-brains.de> Date: Tue, 09 Jun 2015 13:32:26 +0200 From: Sebastian Huber User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Konstantin Belousov CC: freebsd-hackers@freebsd.org, phk@phk.freebsd.dk Subject: Re: [PATCH v3] timecounters: Fix timehand generation read/write References: <1433331966-27548-1-git-send-email-sebastian.huber@embedded-brains.de> <1433838715-22850-1-git-send-email-sebastian.huber@embedded-brains.de> <20150609105526.GK2499@kib.kiev.ua> <5576C90A.9010807@embedded-brains.de> <20150609112837.GL2499@kib.kiev.ua> In-Reply-To: <20150609112837.GL2499@kib.kiev.ua> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jun 2015 11:32:30 -0000 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); > } > =20 > +static u_int > +tc_getgen(struct timehands *th) > +{ > + > +#ifdef SMP > + return (atomic_load_acq_int(&th->th_generation)); > +#else > + u_int gen; > + > + gen =3D 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 =3D 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. --=20 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=E4ftliche Mitteilung im Sinne des EHUG.