mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH, RESEND] sys_time: use barrier() instead of smp_rmb()
@ 2007-07-17 14:51 Oleg Nesterov
  0 siblings, 0 replies; only message in thread
From: Oleg Nesterov @ 2007-07-17 14:51 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Chris Snook, Ingo Molnar, linux-kernel

>From the recent 4e44f3497d41db4c3b9051c61410dee8ae4fb49c commit,

>  asmlinkage long sys_time(time_t __user * tloc)
>  {
> -	time_t i;
> -	struct timeval tv;
> +	/*
> +	 * We read xtime.tv_sec atomically - it's updated
> +	 * atomically by update_wall_time(), so no need to
> +	 * even read-lock the xtime seqlock:
> +	 */
> +	time_t i = xtime.tv_sec;
>  
> -	do_gettimeofday(&tv);
> -	i = tv.tv_sec;
> +	smp_rmb(); /* sys_time() results are coherent */

The is no reason to use rmb(), we don't do any LOADs which could be reordered.
What we need is a simple compiler barrier, to prevent the reading of the
"volatile" xtime.tv_sec twice.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- t/kernel/time.c~	2007-06-26 16:28:59.000000000 +0400
+++ t/kernel/time.c	2007-06-26 16:32:09.000000000 +0400
@@ -64,7 +64,7 @@ asmlinkage long sys_time(time_t __user *
 	 */
 	time_t i = xtime.tv_sec;
 
-	smp_rmb(); /* sys_time() results are coherent */
+	barrier(); /* sys_time() results are coherent */
 
 	if (tloc) {
 		if (put_user(i, tloc))



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-07-17 14:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-17 14:51 [PATCH, RESEND] sys_time: use barrier() instead of smp_rmb() Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®