From: Anton Blanchard <anton@samba.org>
To: torvalds@transmeta.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] fix livelock in non atomic brlocks
Date: Thu, 15 Nov 2001 15:03:03 +1100 [thread overview]
Message-ID: <20011115150303.D22552@krispykreme> (raw)
Hi,
One characteristic of brlocks is that you must be able to take recursive
read locks (sparc64, ppc64 interrupt handling and netfilter make use of
this property). On a 16 cpu ppc64 machine I have seen the following
scenario:
cpu 1 (in br_write_lock)
again:
spin_lock(&__br_write_locks[idx].lock);
/* discover reader is present so backoff */
spin_unlock(&__br_write_locks[idx].lock);
goto again;
cpu 2 (in br_read_lock)
again:
read_count++;
mb();
/* discover __br_write_locks[idx].lock is locked */
read_count--;
wmb();
goto again;
If the read retry path is much slower than the write retry path (in this
case mb(); read_count--; wmb(); is quite slow), then both cpus will spin
forever and get nowhere.
We need to make sure the write retry path backs off long enough to
ensure forward progress. A udelay(1) is a rather large hammer but a
br_write_lock is known to be very slow and should not be called much.
Anton
--- 2.4.15-pre4/lib/brlock.c Thu Nov 15 13:38:04 2001
+++ linuxppc64_2_4_rochester/lib/brlock.c Thu Nov 15 13:33:35 2001
@@ -14,6 +14,7 @@
#include <linux/sched.h>
#include <linux/brlock.h>
+#include <linux/delay.h>
#ifdef __BRLOCK_USE_ATOMICS
@@ -54,7 +55,8 @@
if (__brlock_array[cpu_logical_map(i)][idx] != 0) {
spin_unlock(&__br_write_locks[idx].lock);
barrier();
- cpu_relax();
+ /* We must allow recursive readers to make progress */
+ udelay(1);
goto again;
}
}
reply other threads:[~2001-11-15 4:06 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=20011115150303.D22552@krispykreme \
--to=anton@samba.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/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®