public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Patch: linux-2.5.29 __downgrade_write() for CONFIG_RWSEM_GENERIC_SPINLOCK
@ 2002-07-28 17:50 Adam J. Richter
  2002-07-28 18:07 ` Roman Zippel
  2002-07-28 18:08 ` Christoph Hellwig
  0 siblings, 2 replies; 11+ messages in thread
From: Adam J. Richter @ 2002-07-28 17:50 UTC (permalink / raw)
  To: dhowells; +Cc: linux-kernel

	linux-2.5.29 lacks __downgrade_write() platforms that use
CONFIG_RWSEM_GENERIC_SPINLOCK, such as i386 (as opposed to later x86
processors).  This causes a compiler warnings for compilations
of numerous files.

	Although noting in 2.5.29 appears to use downgrade_write(),
I assume that the facility was added because it is going to be used
in the near future.  So, I've added what I think is an implementation
of __downgrade_write for lib/rwsem-spinlock.c.  It is the same as
__up_write, except that it sets sem->activity to 1.  Since nothing
uses it yet, I haven't tested it.

	David, please let me know if you are going to forward this
to Linus, if you want me to submit it to Linus, or if you want to
do something else.

Adam J. Richter     __     ______________   575 Oroville Road
adam@yggdrasil.com     \ /                  Milpitas, California 95035
+1 408 309-6081         | g g d r a s i l   United States of America
                         "Free Software For The Rest Of Us."

--- linux-2.5.29/include/linux/rwsem-spinlock.h	2002-07-26 19:58:39.000000000 -0700
+++ linux/include/linux/rwsem-spinlock.h	2002-07-28 10:38:59.000000000 -0700
@@ -57,6 +57,7 @@
 extern void FASTCALL(__down_write(struct rw_semaphore *sem));
 extern void FASTCALL(__up_read(struct rw_semaphore *sem));
 extern void FASTCALL(__up_write(struct rw_semaphore *sem));
+extern void FASTCALL(__downgrade_write(struct rw_semaphore *sem));
 
 #endif /* __KERNEL__ */
 #endif /* _LINUX_RWSEM_SPINLOCK_H */
--- linux-2.5.29/lib/rwsem-spinlock.c	2002-07-26 19:58:30.000000000 -0700
+++ linux/lib/rwsem-spinlock.c	2002-07-28 10:49:30.000000000 -0700
@@ -229,11 +229,30 @@
 	rwsemtrace(sem,"Leaving __up_write");
 }
 
+/*
+ * downgrade a write lock into a read lock
+ */
+void __downgrade_write(struct rw_semaphore *sem)
+{
+	rwsemtrace(sem,"Entering __downgrade_write");
+
+	spin_lock(&sem->wait_lock);
+
+	sem->activity = 1;
+	if (!list_empty(&sem->wait_list))
+		sem = __rwsem_do_wake(sem);
+
+	spin_unlock(&sem->wait_lock);
+
+	rwsemtrace(sem,"Leaving __downgrade_write");
+}
+
 EXPORT_SYMBOL(init_rwsem);
 EXPORT_SYMBOL(__down_read);
 EXPORT_SYMBOL(__down_write);
 EXPORT_SYMBOL(__up_read);
 EXPORT_SYMBOL(__up_write);
+EXPORT_SYMBOL(__downgrade_write);
 #if RWSEM_DEBUG
 EXPORT_SYMBOL(rwsemtrace);
 #endif

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2002-07-29 12:42 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-07-28 17:50 Patch: linux-2.5.29 __downgrade_write() for CONFIG_RWSEM_GENERIC_SPINLOCK Adam J. Richter
2002-07-28 18:07 ` Roman Zippel
2002-07-28 18:08 ` Christoph Hellwig
2002-07-28 22:55   ` Roman Zippel
2002-07-29  7:42     ` David Howells
2002-07-29  8:01       ` Roman Zippel
2002-07-29  8:31         ` David Howells
2002-07-29  9:13           ` David Howells
2002-07-29 11:42             ` Roman Zippel
2002-07-29 12:08               ` David Howells
2002-07-29 12:46                 ` Roman Zippel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox