From: Chris Snook <csnook@redhat.com>
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Ingo Molnar <mingo@elte.hu>, John Stultz <johnstul@us.ibm.com>,
Thomas Gleixner <tglx@linutronix.de>,
Roman Zippel <zippel@linux-m68k.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sys_time-speedup-small-cleanup
Date: Tue, 26 Jun 2007 12:21:48 -0400 [thread overview]
Message-ID: <46813D1C.9080107@redhat.com> (raw)
In-Reply-To: <20070626123424.GA259@tv-sign.ru>
Oleg Nesterov wrote:
> on top of sys_time-speedup.patch
>
> Ingo Molnar wrote:
>> 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 */
>
> Why do we need this barrier? My guess it is needed to prevent
> the reading of xtime.tv_sec twice, yes? In that case a simple
> barrier() should be enough.
Without the smp_rmb, you can potentially have a situation where one CPU is still
reading an old value from cache while another has the new value. It's generally
a rather small race window on most architectures, but very bad things can happen
if time ever goes backwards, so it's worth the overhead of maintaining coherence
on smp.
-- Chris
> 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))
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2007-06-26 16:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-26 12:34 [PATCH] sys_time-speedup-small-cleanup Oleg Nesterov
2007-06-26 16:21 ` Chris Snook [this message]
2007-06-27 11:29 ` Oleg Nesterov
2007-06-27 18:21 ` Chris Snook
2007-06-27 18:59 ` Oleg Nesterov
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=46813D1C.9080107@redhat.com \
--to=csnook@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=johnstul@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@tv-sign.ru \
--cc=tglx@linutronix.de \
--cc=zippel@linux-m68k.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.