Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] add sem_is_read/write_locked()

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>

authored by

Rik Van Riel and committed by
Linus Torvalds
eb92f4ef 63f324cf

+50
+5
include/asm-alpha/rwsem.h
··· 262 262 #endif 263 263 } 264 264 265 + static inline int rwsem_is_locked(struct rw_semaphore *sem) 266 + { 267 + return (sem->count != 0); 268 + } 269 + 265 270 #endif /* __KERNEL__ */ 266 271 #endif /* _ALPHA_RWSEM_H */
+5
include/asm-i386/rwsem.h
··· 284 284 return tmp+delta; 285 285 } 286 286 287 + static inline int rwsem_is_locked(struct rw_semaphore *sem) 288 + { 289 + return (sem->count != 0); 290 + } 291 + 287 292 #endif /* __KERNEL__ */ 288 293 #endif /* _I386_RWSEM_H */
+5
include/asm-ia64/rwsem.h
··· 186 186 #define rwsem_atomic_add(delta, sem) atomic64_add(delta, (atomic64_t *)(&(sem)->count)) 187 187 #define rwsem_atomic_update(delta, sem) atomic64_add_return(delta, (atomic64_t *)(&(sem)->count)) 188 188 189 + static inline int rwsem_is_locked(struct rw_semaphore *sem) 190 + { 191 + return (sem->count != 0); 192 + } 193 + 189 194 #endif /* _ASM_IA64_RWSEM_H */
+5
include/asm-ppc/rwsem.h
··· 168 168 return atomic_add_return(delta, (atomic_t *)(&sem->count)); 169 169 } 170 170 171 + static inline int rwsem_is_locked(struct rw_semaphore *sem) 172 + { 173 + return (sem->count != 0); 174 + } 175 + 171 176 #endif /* __KERNEL__ */ 172 177 #endif /* _PPC_RWSEM_XADD_H */
+5
include/asm-ppc64/rwsem.h
··· 163 163 return atomic_add_return(delta, (atomic_t *)(&sem->count)); 164 164 } 165 165 166 + static inline int rwsem_is_locked(struct rw_semaphore *sem) 167 + { 168 + return (sem->count != 0); 169 + } 170 + 166 171 #endif /* __KERNEL__ */ 167 172 #endif /* _PPC_RWSEM_XADD_H */
+5
include/asm-s390/rwsem.h
··· 351 351 return new; 352 352 } 353 353 354 + static inline int rwsem_is_locked(struct rw_semaphore *sem) 355 + { 356 + return (sem->count != 0); 357 + } 358 + 354 359 #endif /* __KERNEL__ */ 355 360 #endif /* _S390_RWSEM_H */
+5
include/asm-sh/rwsem.h
··· 166 166 return atomic_add_return(delta, (atomic_t *)(&sem->count)); 167 167 } 168 168 169 + static inline int rwsem_is_locked(struct rw_semaphore *sem) 170 + { 171 + return (sem->count != 0); 172 + } 173 + 169 174 #endif /* __KERNEL__ */ 170 175 #endif /* _ASM_SH_RWSEM_H */
+5
include/asm-sparc64/rwsem.h
··· 56 56 atomic_add(delta, (atomic_t *)(&sem->count)); 57 57 } 58 58 59 + static inline int rwsem_is_locked(struct rw_semaphore *sem) 60 + { 61 + return (sem->count != 0); 62 + } 63 + 59 64 #endif /* __KERNEL__ */ 60 65 61 66 #endif /* _SPARC64_RWSEM_H */
+5
include/asm-x86_64/rwsem.h
··· 274 274 return tmp+delta; 275 275 } 276 276 277 + static inline int rwsem_is_locked(struct rw_semaphore *sem) 278 + { 279 + return (sem->count != 0); 280 + } 281 + 277 282 #endif /* __KERNEL__ */ 278 283 #endif /* _X8664_RWSEM_H */
+5
include/linux/rwsem-spinlock.h
··· 61 61 extern void FASTCALL(__up_write(struct rw_semaphore *sem)); 62 62 extern void FASTCALL(__downgrade_write(struct rw_semaphore *sem)); 63 63 64 + static inline int rwsem_is_locked(struct rw_semaphore *sem) 65 + { 66 + return (sem->activity != 0); 67 + } 68 + 64 69 #endif /* __KERNEL__ */ 65 70 #endif /* _LINUX_RWSEM_SPINLOCK_H */