lkml.org 
[lkml]   [2002]   [Jul]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
SubjectPatch: linux-2.5.29 __downgrade_write() for CONFIG_RWSEM_GENERIC_SPINLOCK
	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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 13:22    [W:0.165 / U:9.292 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site