[SSI] openssi/kernel/include/asm-i386 semaphore.h,1.5,1.6
Roger Tsang <[email protected]>
| Newsgroups | gmane.linux.cluster.ssic.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/ssic-linux/openssi/kernel/include/asm-i386
In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv8553/include/asm-i386
Modified Files:
Tag: OPENSSI-FC
semaphore.h
Log Message:
Bug fixes and enhancements. (see ChangeLog)
Index: semaphore.h
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/include/asm-i386/semaphore.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- semaphore.h 10 Oct 2008 08:10:32 -0000 1.5
+++ semaphore.h 3 Feb 2009 06:18:13 -0000 1.6
@@ -49,8 +49,12 @@
int sleepers;
#ifdef CONFIG_SSI
void *owner;
-#ifdef SSI_RECURSIVE_SEMAPHORE
- atomic_t depth;
+#ifdef CFS_FILE_WRITE_LIVELOCK_FIX
+/* Support recursive non-interruptible acquired sempahore. This is needed
+ * for OpenSSI CFS client@server because in those code paths
+ * the VM revisits -eg. generic_file_writev() on memory pressure. -Roger
+ */
+ void *flusher;
#endif
#endif
wait_queue_head_t wait;
@@ -58,13 +62,13 @@
#ifdef CONFIG_SSI
-#ifdef SSI_RECURSIVE_SEMAPHORE
+#ifdef CFS_FILE_WRITE_LIVELOCK_FIX
#define __SEMAPHORE_INITIALIZER(name, n) \
{ \
.count = ATOMIC_INIT(n), \
.sleepers = 0, \
.owner = NULL, \
- .depth = ATOMIC_INIT(0), \
+ .flusher = NULL, \
.wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
}
#else
@@ -75,7 +79,7 @@
.owner = NULL, \
.wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
}
-#endif /* !SSI_RECURSIVE_SEMAPHORE */
+#endif /* !CFS_FILE_WRITE_LIVELOCK_FIX */
#else
#define __SEMAPHORE_INITIALIZER(name, n) \
{ \
@@ -106,12 +110,8 @@
sem->sleepers = 0;
#ifdef CONFIG_SSI
sem->owner = NULL;
-#ifdef SSI_RECURSIVE_SEMAPHORE
- /* Shared semaphores are not supported */
- if (val <= 1)
- atomic_set(&sem->depth, 0);
- else
- atomic_set(&sem->depth, -1);
+#ifdef CFS_FILE_WRITE_LIVELOCK_FIX
+ sem->flusher = NULL;
#endif
#endif
init_waitqueue_head(&sem->wait);
@@ -137,17 +137,32 @@
fastcall int __down_trylock(struct semaphore * sem);
fastcall void __up(struct semaphore * sem);
+#ifdef CONFIG_SSI
+static inline int sem_owned(struct semaphore *sem)
+{
+ return (sem->owner == current);
+}
+#ifdef CFS_FILE_WRITE_LIVELOCK_FIX
+static inline int sem_flushing(struct semaphore *sem)
+{
+ return (sem->flusher == current);
+}
+#endif
+#endif
+
/*
* This is ugly, but we want the default case to fall through.
* "__down_failed" is a special asm handler that calls the C
* routine that actually waits. See arch/i386/kernel/semaphore.c
*/
-#ifdef SSI_RECURSIVE_SEMAPHORE
-static inline void down_nofail(struct semaphore * sem)
-#else
static inline void down(struct semaphore * sem)
-#endif
{
+#ifdef CONFIG_SSI
+#ifdef CFS_FILE_WRITE_LIVELOCK_FIX
+ if (sem_flushing(sem))
+ return;
+#endif
+#endif
might_sleep();
__asm__ __volatile__(
"# atomic down operation\n\t"
@@ -236,8 +251,8 @@
static inline void up(struct semaphore * sem)
{
#ifdef CONFIG_SSI
-#ifdef SSI_RECURSIVE_SEMAPHORE
- if (atomic_test_and_add(-1, &sem->depth))
+#ifdef CFS_FILE_WRITE_LIVELOCK_FIX
+ if (sem_flushing(sem))
return;
#endif
set_mb(sem->owner, NULL);
@@ -258,31 +273,5 @@
:"memory","ax");
}
-#ifdef CONFIG_SSI
-#ifdef SSI_RECURSIVE_SEMAPHORE
-/* Support recursive non-interruptible acquired sempahore. This is needed
- * for OpenSSI CFS client@server because in those code paths
- * the VM revisits generic_file_writev() on memory pressure. -Roger
- * Note: Shared semaphores are not supported.
- */
-static inline void down(struct semaphore * sem)
-{
- if (down_trylock(sem)) {
- if (sem->owner == current && atomic_read(&sem->depth) >= 0) {
- atomic_inc(&sem->depth);
- WARN_ON(sem->owner != current);
- return;
- }
- down_nofail(sem);
- }
-}
-#endif
-
-static inline int sem_owned(struct semaphore *sem)
-{
- return (sem->owner == current);
-}
-#endif
-
#endif
#endif
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com