]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[PATCH] add sem_is_read/write_locked()
authorRik Van Riel <riel@redhat.com>
Sun, 30 Oct 2005 01:15:44 +0000 (18:15 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sun, 30 Oct 2005 04:40:35 +0000 (21:40 -0700)
Add sem_is_read/write_locked functions to the read/write semaphores, along the
same lines of the *_is_locked spinlock functions.  The swap token tuning patch
uses sem_is_read_locked; sem_is_write_locked is added for completeness.

Signed-off-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
include/asm-alpha/rwsem.h
include/asm-i386/rwsem.h
include/asm-ia64/rwsem.h
include/asm-ppc/rwsem.h
include/asm-ppc64/rwsem.h
include/asm-s390/rwsem.h
include/asm-sh/rwsem.h
include/asm-sparc64/rwsem.h
include/asm-x86_64/rwsem.h
include/linux/rwsem-spinlock.h

index 8e058a67c9a48fdd966877daa81021c54df866ba..fafdd4f7010a821155a86302b4262b091de286f2 100644 (file)
@@ -262,5 +262,10 @@ static inline long rwsem_atomic_update(long val, struct rw_semaphore *sem)
 #endif
 }
 
+static inline int rwsem_is_locked(struct rw_semaphore *sem)
+{
+       return (sem->count != 0);
+}
+
 #endif /* __KERNEL__ */
 #endif /* _ALPHA_RWSEM_H */
index 7625a675852f811b5aab15c240e803f122168d7f..be4ab859238ec3322e44c0e221deb17e339f3b2d 100644 (file)
@@ -284,5 +284,10 @@ LOCK_PREFIX        "xadd %0,(%2)"
        return tmp+delta;
 }
 
+static inline int rwsem_is_locked(struct rw_semaphore *sem)
+{
+       return (sem->count != 0);
+}
+
 #endif /* __KERNEL__ */
 #endif /* _I386_RWSEM_H */
index e18b5ab0cb75c0cd6ee7014260cf23bdd79a59a6..1327c91ea39c77f0752c94e0a83cb49cac26089d 100644 (file)
@@ -186,4 +186,9 @@ __downgrade_write (struct rw_semaphore *sem)
 #define rwsem_atomic_add(delta, sem)   atomic64_add(delta, (atomic64_t *)(&(sem)->count))
 #define rwsem_atomic_update(delta, sem)        atomic64_add_return(delta, (atomic64_t *)(&(sem)->count))
 
+static inline int rwsem_is_locked(struct rw_semaphore *sem)
+{
+       return (sem->count != 0);
+}
+
 #endif /* _ASM_IA64_RWSEM_H */
index 3e738f483c11b1e2ccc745ec7527f5d3ee94a375..3501ea72f88ceb1c1a122aa8bf60fef570a0bdfa 100644 (file)
@@ -168,5 +168,10 @@ static inline int rwsem_atomic_update(int delta, struct rw_semaphore *sem)
        return atomic_add_return(delta, (atomic_t *)(&sem->count));
 }
 
+static inline int rwsem_is_locked(struct rw_semaphore *sem)
+{
+       return (sem->count != 0);
+}
+
 #endif /* __KERNEL__ */
 #endif /* _PPC_RWSEM_XADD_H */
index bd5c2f09357538f2dd64fdd264a9693a6cac568c..7a647fae3765bcc17fe127c915325d8b42f4f5bf 100644 (file)
@@ -163,5 +163,10 @@ static inline int rwsem_atomic_update(int delta, struct rw_semaphore *sem)
        return atomic_add_return(delta, (atomic_t *)(&sem->count));
 }
 
+static inline int rwsem_is_locked(struct rw_semaphore *sem)
+{
+       return (sem->count != 0);
+}
+
 #endif /* __KERNEL__ */
 #endif /* _PPC_RWSEM_XADD_H */
index 8c0cebbfc034e2e26c46137e62f20436b644a8f3..0422a085dd56a2d54d36cd46a190c54b7c7af4ac 100644 (file)
@@ -351,5 +351,10 @@ static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
        return new;
 }
 
+static inline int rwsem_is_locked(struct rw_semaphore *sem)
+{
+       return (sem->count != 0);
+}
+
 #endif /* __KERNEL__ */
 #endif /* _S390_RWSEM_H */
index 1be4337f525950d795d1a28c945898d20154a1e8..0262d3d1e5e018a2ddb9e7913d48124eb4311a4e 100644 (file)
@@ -166,5 +166,10 @@ static inline int rwsem_atomic_update(int delta, struct rw_semaphore *sem)
        return atomic_add_return(delta, (atomic_t *)(&sem->count));
 }
 
+static inline int rwsem_is_locked(struct rw_semaphore *sem)
+{
+       return (sem->count != 0);
+}
+
 #endif /* __KERNEL__ */
 #endif /* _ASM_SH_RWSEM_H */
index 4568ee4022df0f957fb6f42dac4e9390d579a4fa..cef5e8270421beda324419c8210b4ffa3a7e294d 100644 (file)
@@ -56,6 +56,11 @@ static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem)
        atomic_add(delta, (atomic_t *)(&sem->count));
 }
 
+static inline int rwsem_is_locked(struct rw_semaphore *sem)
+{
+       return (sem->count != 0);
+}
+
 #endif /* __KERNEL__ */
 
 #endif /* _SPARC64_RWSEM_H */
index c002175b6e82f78a3aa7fe89396a97cd4ca2b2fd..46077e9c1910b7eae6a0a58d50a5e38378bfb3e7 100644 (file)
@@ -274,5 +274,10 @@ LOCK_PREFIX        "xaddl %0,(%2)"
        return tmp+delta;
 }
 
+static inline int rwsem_is_locked(struct rw_semaphore *sem)
+{
+       return (sem->count != 0);
+}
+
 #endif /* __KERNEL__ */
 #endif /* _X8664_RWSEM_H */
index b52a2af25f1fbda660a7b7bb7e922d6a09af7b94..f30f805080ae4a883c352a97183871f6a31c1ff2 100644 (file)
@@ -61,5 +61,10 @@ 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));
 
+static inline int rwsem_is_locked(struct rw_semaphore *sem)
+{
+       return (sem->activity != 0);
+}
+
 #endif /* __KERNEL__ */
 #endif /* _LINUX_RWSEM_SPINLOCK_H */