From: Ian Wienand <ianw@gelato.unsw.edu.au>
To: linux-ia64@vger.kernel.org
Subject: [PATCH] now < last_tick problem
Date: Fri, 10 Oct 2003 00:52:21 +0000 [thread overview]
Message-ID: <marc-linux-ia64-106574725701696@msgid-missing> (raw)
[-- Attachment #1: Type: text/plain, Size: 1189 bytes --]
Hi,
I started hitting this problem when using httperf, upon investigation
it seems to be easily triggered when you make gettimeofday() calls in
very close succession (just doing them in a tight loop easily
replicates the problem).
I think the problem is that in itc_get_offset() there is a race
between getting the now value and calculating the last_tick from
itm_next; if we are interrupted between the two itm_next will be set
after now.
Suggested patch attached; note the fsyscall implementation does not
appear to have this problem.
-i
ianw@gelato.unsw.edu.au
http://www.gelato.unsw.edu.au
[-- Attachment #2: time.c.diff --]
[-- Type: text/plain, Size: 726 bytes --]
===== arch/ia64/kernel/time.c 1.35 vs edited =====
--- 1.35/arch/ia64/kernel/time.c Wed Oct 8 12:53:38 2003
+++ edited/arch/ia64/kernel/time.c Fri Oct 10 09:49:37 2003
@@ -72,10 +72,16 @@
itc_get_offset (void)
{
unsigned long elapsed_cycles, lost = jiffies - wall_jiffies;
- unsigned long now = ia64_get_itc(), last_tick;
+ unsigned long now, last_tick;
last_tick = (cpu_data(TIME_KEEPER_ID)->itm_next
- (lost + 1)*cpu_data(TIME_KEEPER_ID)->itm_delta);
+
+ /*
+ * get now after last_tick to avoid race condition where
+ * itm_next might be updated.
+ */
+ now = ia64_get_itc();
if (unlikely((long) (now - last_tick) < 0)) {
printk(KERN_ERR "CPU %d: now < last_tick (now=0x%lx,last_tick=0x%lx)!\n",
reply other threads:[~2003-10-10 0:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=marc-linux-ia64-106574725701696@msgid-missing \
--to=ianw@gelato.unsw.edu.au \
--cc=linux-ia64@vger.kernel.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.