From: Ray Bryant <raybry@sgi.com>
To: Ray Bryant <raybry@austin.rr.com>, Andrew Morton <akpm@osdl.org>
Cc: Ray Bryant <raybry@sgi.com>,
lse-tech@lists.sourceforge.net,
"Martin J. Bligh" <mbligh@aracnet.com>,
Zwane Mwaikambo <zwane@linuxpower.ca>,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] lockmeter: fixed-up: lockmeter fixes for preempt case
Date: Thu, 16 Sep 2004 16:03:51 -0700 (PDT) [thread overview]
Message-ID: <20040916230351.23023.75244.58133@tomahawk.engr.sgi.com> (raw)
In-Reply-To: <20040916230344.23023.79384.49263@tomahawk.engr.sgi.com>
Updated lockmeter-preempt-fix.patch.
Signed-off-by: Ray Bryant <raybry@sgi.com>
Index: linux-2.6.9-rc2-mm1/kernel/lockmeter.c
===================================================================
--- linux-2.6.9-rc2-mm1.orig/kernel/lockmeter.c 2004-09-16 11:03:05.000000000 -0700
+++ linux-2.6.9-rc2-mm1/kernel/lockmeter.c 2004-09-16 12:03:20.000000000 -0700
@@ -1236,18 +1236,58 @@
EXPORT_SYMBOL(_write_trylock);
#if defined(CONFIG_SMP) && defined(CONFIG_PREEMPT)
+/*
+ * This could be a long-held lock. If another CPU holds it for a long time,
+ * and that CPU is not asked to reschedule then *this* CPU will spin on the
+ * lock for a long time, even if *this* CPU is asked to reschedule.
+ *
+ * So what we do here, in the slow (contended) path is to spin on the lock by
+ * hand while permitting preemption.
+ *
+ * Called inside preempt_disable().
+ */
+static inline void __preempt_spin_lock(spinlock_t *lock, void *caller_pc)
+{
+ if (preempt_count() > 1) {
+ _metered_spin_lock(lock, caller_pc);
+ return;
+ }
+
+ do {
+ preempt_enable();
+ while (spin_is_locked(lock))
+ cpu_relax();
+ preempt_disable();
+ } while (!_metered_spin_trylock(lock, caller_pc));
+}
+
void __lockfunc _spin_lock(spinlock_t *lock)
{
preempt_disable();
if (unlikely(!_metered_spin_trylock(lock, __builtin_return_address(0))))
- __preempt_spin_lock(lock);
+ __preempt_spin_lock(lock, __builtin_return_address(0));
+}
+
+static inline void __preempt_write_lock(rwlock_t *lock, void *caller_pc)
+{
+ if (preempt_count() > 1) {
+ _metered_write_lock(lock, caller_pc);
+ return;
+ }
+
+ do {
+ preempt_enable();
+ while (rwlock_is_locked(lock))
+ cpu_relax();
+ preempt_disable();
+ } while (!_metered_write_trylock(lock,caller_pc));
}
void __lockfunc _write_lock(rwlock_t *lock)
{
preempt_disable();
if (unlikely(!_metered_write_trylock(lock, __builtin_return_address(0))))
- __preempt_write_lock(lock);
+ __preempt_write_lock(lock, __builtin_return_address(0));
}
#else
void __lockfunc _spin_lock(spinlock_t *lock)
@@ -1458,3 +1498,13 @@
return 0;
}
EXPORT_SYMBOL(_spin_trylock_bh);
+
+int in_lock_functions(unsigned long addr)
+{
+ /* Linker adds these: start and end of __lockfunc functions */
+ extern char __lock_text_start[], __lock_text_end[];
+
+ return addr >= (unsigned long)__lock_text_start
+ && addr < (unsigned long)__lock_text_end;
+}
+EXPORT_SYMBOL(in_lock_functions);
--
Best Regards,
Ray
-----------------------------------------------
Ray Bryant raybry@sgi.com
The box said: "Requires Windows 98 or better",
so I installed Linux.
-----------------------------------------------
next prev parent reply other threads:[~2004-09-16 23:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-16 23:03 [PATCH 0/3] lockmeter: fixes Ray Bryant
2004-09-16 23:03 ` Ray Bryant [this message]
2004-09-16 23:04 ` [PATCH 2/3] lockmeter: lockmeter fix for generic_read_trylock Ray Bryant
2004-09-16 19:20 ` Zwane Mwaikambo
2004-09-16 23:38 ` Ray Bryant
2004-09-16 23:04 ` [PATCH 3/3] lockmeter: lockmeter fix for inline in_lock_functions() Ray Bryant
2004-09-17 7:31 ` [PATCH 0/3] lockmeter: fixes Christoph Hellwig
2004-09-17 18:52 ` Ray Bryant
2004-09-17 19:31 ` Christoph Hellwig
2004-09-19 11:15 ` Alexander Nyberg
2004-09-19 22:39 ` Ray Bryant
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=20040916230351.23023.75244.58133@tomahawk.engr.sgi.com \
--to=raybry@sgi.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lse-tech@lists.sourceforge.net \
--cc=mbligh@aracnet.com \
--cc=raybry@austin.rr.com \
--cc=zwane@linuxpower.ca \
/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®