From: tony.luck@intel.com
To: Christoph Lameter <clameter@engr.sgi.com>
To: Alex Williamson <alex.williamson@hp.com>
Cc: linux-kernel@vger.kernel.org, akpm@osdl.org
Subject: Re: [PATCH] optimize writer path in time_interpolator_get_counter()
Date: Tue, 2 Aug 2005 11:37:07 -0700 [thread overview]
Message-ID: <200508021837.j72Ib7T9020681@agluck-lia64.sc.intel.com> (raw)
In-Reply-To: <Pine.LNX.4.62.0508010906250.6397@schroedinger.engr.sgi.com>
+ /* When holding the xtime write lock, there's no need
+ * to add the overhead of the cmpxchg. Readers are
+ * force to retry until the write lock is released.
+ */
+ if (writelock) {
+ time_interpolator->last_cycle = now;
+ return now;
+ }
This is lots prettier that my first suggestion (no surprise, even _I_ didn't like
my suggested patch :-)
In theory it looks like it should help a lot as it ought to prevent the worst case
spinning when one cpu has the xtime write lock.
Sadly, running my test case (running 1-4 tasks, each bound to a cpu, each pounding
on gettimeofday(2)) I'm still seeing significant time spent spinning in this loop.
Things are better: worst case time was down to just over 2ms from 34ms ... which
is a significant improvement ... but 2ms still sounds ugly.
I'm still seeing the asymmetric behavior where cpu3 sees the really high times,
while cpu0,1,2 are seeing peaks of 170us, which is still not pretty.
So this is a very half-hearted ACK for the patch. It does improve things, but I
still think that code that does:
do {
val = xxx;
// execute some stuff here
} while (cmpxchg(&xxx, val, newval) != val);
is badly flawed. If this were in some rare code path that was only likely to see
collisions when more than three planets were aligned, then it might be OK, but this
is a common path and it is easy for (malicious) users to force multiple cpus into
running this code ... making it likely that the cmpxchg will fail repeatedly.
-Tony
P.S. My ugly patch does even less to fix this problem ... times are worse than this.
next prev parent reply other threads:[~2005-08-02 18:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-01 15:52 Alex Williamson
2005-08-01 16:06 ` Christoph Lameter
2005-08-01 16:10 ` Alex Williamson
2005-08-02 18:37 ` tony.luck [this message]
2005-08-02 21:19 ` Christoph Lameter
2005-08-03 14:42 ` Alex Williamson
2005-08-03 16:10 ` Christoph Lameter
2005-08-03 16:32 ` Alex Williamson
2005-08-03 20:49 ` Christoph Lameter
2005-08-02 21:50 Luck, Tony
2005-08-02 22:09 ` Christoph Lameter
2005-08-03 17:00 Luck, Tony
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=200508021837.j72Ib7T9020681@agluck-lia64.sc.intel.com \
--to=tony.luck@intel.com \
--cc=akpm@osdl.org \
--cc=clameter@engr.sgi.com \
--cc=linux-kernel@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 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®