linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Nathan Lynch <ntl@pobox.com>
Cc: linuxppc-dev@ozlabs.org, Paul Mackerras <paulus@samba.org>
Subject: Re: [PATCH] fix gettimeofday vs. update_gtod race
Date: Thu, 17 Aug 2006 01:48:54 +0200	[thread overview]
Message-ID: <1155772134.11312.119.camel@localhost.localdomain> (raw)
In-Reply-To: <20060811204105.GK3233@localdomain>

On Fri, 2006-08-11 at 15:41 -0500, Nathan Lynch wrote:

> +	/* Sampling the time base must be done after loading
> +	 * do_gtod.varp in order to avoid racing with update_gtod.
> +	 */
> +	rmb();
> +	tb_ticks = get_tb() - temp_varp->tb_orig_stamp;

The barrier isn't necessary and the race not completely closed imho... I
need to think about it a bit more closely but what about instead just
check if tb_ticks goes negative, and if yes, just do get_tb() again ?
That might be faster than having a sync in there and should still be
correct.

>  	temp_tb_to_xs = temp_varp->tb_to_xs;
>  	temp_stamp_xsec = temp_varp->stamp_xsec;
>  	xsec = temp_stamp_xsec + mulhdu(tb_ticks, temp_tb_to_xs);
> @@ -464,7 +469,7 @@ void do_gettimeofday(struct timeval *tv)
>  		tv->tv_usec = usec;
>  		return;
>  	}
> -	__do_gettimeofday(tv, get_tb());
> +	__do_gettimeofday(tv);
>  }
>  
>  EXPORT_SYMBOL(do_gettimeofday);
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev

  reply	other threads:[~2006-08-16 23:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-11 20:41 [PATCH] fix gettimeofday vs. update_gtod race Nathan Lynch
2006-08-16 23:48 ` Benjamin Herrenschmidt [this message]
2006-08-17  0:18   ` Nathan Lynch
2006-08-17  0:27     ` Benjamin Herrenschmidt
2006-08-17 20:47       ` Nathan Lynch
2006-08-21 21:25         ` Nathan Lynch
2006-08-21 21:43           ` Benjamin Herrenschmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1155772134.11312.119.camel@localhost.localdomain \
    --to=benh@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=ntl@pobox.com \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).