diff options
author | Rik Van Riel <riel@redhat.com> | 2005-10-29 21:15:44 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-10-30 00:40:35 -0400 |
commit | eb92f4ef320b738e41ad43476a5d05c8a20d5cc7 (patch) | |
tree | f9a6bb78a0561587f142b2b1208819f6cffe9835 /include | |
parent | 63f324cf0792ed69089b79d6921ba3aaea97af50 (diff) |
[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>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-alpha/rwsem.h | 5 | ||||
-rw-r--r-- | include/asm-i386/rwsem.h | 5 | ||||
-rw-r--r-- | include/asm-ia64/rwsem.h | 5 | ||||
-rw-r--r-- | include/asm-ppc/rwsem.h | 5 | ||||
-rw-r--r-- | include/asm-ppc64/rwsem.h | 5 | ||||
-rw-r--r-- | include/asm-s390/rwsem.h | 5 | ||||
-rw-r--r-- | include/asm-sh/rwsem.h | 5 | ||||
-rw-r--r-- | include/asm-sparc64/rwsem.h | 5 | ||||
-rw-r--r-- | include/asm-x86_64/rwsem.h | 5 | ||||
-rw-r--r-- | include/linux/rwsem-spinlock.h | 5 |
10 files changed, 50 insertions, 0 deletions
diff --git a/include/asm-alpha/rwsem.h b/include/asm-alpha/rwsem.h index 8e058a67c9a4..fafdd4f7010a 100644 --- a/include/asm-alpha/rwsem.h +++ b/include/asm-alpha/rwsem.h | |||
@@ -262,5 +262,10 @@ static inline long rwsem_atomic_update(long val, struct rw_semaphore *sem) | |||
262 | #endif | 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 | #endif /* __KERNEL__ */ | 270 | #endif /* __KERNEL__ */ |
266 | #endif /* _ALPHA_RWSEM_H */ | 271 | #endif /* _ALPHA_RWSEM_H */ |
diff --git a/include/asm-i386/rwsem.h b/include/asm-i386/rwsem.h index 7625a675852f..be4ab859238e 100644 --- a/include/asm-i386/rwsem.h +++ b/include/asm-i386/rwsem.h | |||
@@ -284,5 +284,10 @@ LOCK_PREFIX "xadd %0,(%2)" | |||
284 | return tmp+delta; | 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 | #endif /* __KERNEL__ */ | 292 | #endif /* __KERNEL__ */ |
288 | #endif /* _I386_RWSEM_H */ | 293 | #endif /* _I386_RWSEM_H */ |
diff --git a/include/asm-ia64/rwsem.h b/include/asm-ia64/rwsem.h index e18b5ab0cb75..1327c91ea39c 100644 --- a/include/asm-ia64/rwsem.h +++ b/include/asm-ia64/rwsem.h | |||
@@ -186,4 +186,9 @@ __downgrade_write (struct rw_semaphore *sem) | |||
186 | #define rwsem_atomic_add(delta, sem) atomic64_add(delta, (atomic64_t *)(&(sem)->count)) | 186 | #define rwsem_atomic_add(delta, sem) atomic64_add(delta, (atomic64_t *)(&(sem)->count)) |
187 | #define rwsem_atomic_update(delta, sem) atomic64_add_return(delta, (atomic64_t *)(&(sem)->count)) | 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 | #endif /* _ASM_IA64_RWSEM_H */ | 194 | #endif /* _ASM_IA64_RWSEM_H */ |
diff --git a/include/asm-ppc/rwsem.h b/include/asm-ppc/rwsem.h index 3e738f483c11..3501ea72f88c 100644 --- a/include/asm-ppc/rwsem.h +++ b/include/asm-ppc/rwsem.h | |||
@@ -168,5 +168,10 @@ static inline int rwsem_atomic_update(int delta, struct rw_semaphore *sem) | |||
168 | return atomic_add_return(delta, (atomic_t *)(&sem->count)); | 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 | #endif /* __KERNEL__ */ | 176 | #endif /* __KERNEL__ */ |
172 | #endif /* _PPC_RWSEM_XADD_H */ | 177 | #endif /* _PPC_RWSEM_XADD_H */ |
diff --git a/include/asm-ppc64/rwsem.h b/include/asm-ppc64/rwsem.h index bd5c2f093575..7a647fae3765 100644 --- a/include/asm-ppc64/rwsem.h +++ b/include/asm-ppc64/rwsem.h | |||
@@ -163,5 +163,10 @@ static inline int rwsem_atomic_update(int delta, struct rw_semaphore *sem) | |||
163 | return atomic_add_return(delta, (atomic_t *)(&sem->count)); | 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 | #endif /* __KERNEL__ */ | 171 | #endif /* __KERNEL__ */ |
167 | #endif /* _PPC_RWSEM_XADD_H */ | 172 | #endif /* _PPC_RWSEM_XADD_H */ |
diff --git a/include/asm-s390/rwsem.h b/include/asm-s390/rwsem.h index 8c0cebbfc034..0422a085dd56 100644 --- a/include/asm-s390/rwsem.h +++ b/include/asm-s390/rwsem.h | |||
@@ -351,5 +351,10 @@ static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem) | |||
351 | return new; | 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 | #endif /* __KERNEL__ */ | 359 | #endif /* __KERNEL__ */ |
355 | #endif /* _S390_RWSEM_H */ | 360 | #endif /* _S390_RWSEM_H */ |
diff --git a/include/asm-sh/rwsem.h b/include/asm-sh/rwsem.h index 1be4337f5259..0262d3d1e5e0 100644 --- a/include/asm-sh/rwsem.h +++ b/include/asm-sh/rwsem.h | |||
@@ -166,5 +166,10 @@ static inline int rwsem_atomic_update(int delta, struct rw_semaphore *sem) | |||
166 | return atomic_add_return(delta, (atomic_t *)(&sem->count)); | 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 | #endif /* __KERNEL__ */ | 174 | #endif /* __KERNEL__ */ |
170 | #endif /* _ASM_SH_RWSEM_H */ | 175 | #endif /* _ASM_SH_RWSEM_H */ |
diff --git a/include/asm-sparc64/rwsem.h b/include/asm-sparc64/rwsem.h index 4568ee4022df..cef5e8270421 100644 --- a/include/asm-sparc64/rwsem.h +++ b/include/asm-sparc64/rwsem.h | |||
@@ -56,6 +56,11 @@ static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem) | |||
56 | atomic_add(delta, (atomic_t *)(&sem->count)); | 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 | #endif /* __KERNEL__ */ | 64 | #endif /* __KERNEL__ */ |
60 | 65 | ||
61 | #endif /* _SPARC64_RWSEM_H */ | 66 | #endif /* _SPARC64_RWSEM_H */ |
diff --git a/include/asm-x86_64/rwsem.h b/include/asm-x86_64/rwsem.h index c002175b6e82..46077e9c1910 100644 --- a/include/asm-x86_64/rwsem.h +++ b/include/asm-x86_64/rwsem.h | |||
@@ -274,5 +274,10 @@ LOCK_PREFIX "xaddl %0,(%2)" | |||
274 | return tmp+delta; | 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 | #endif /* __KERNEL__ */ | 282 | #endif /* __KERNEL__ */ |
278 | #endif /* _X8664_RWSEM_H */ | 283 | #endif /* _X8664_RWSEM_H */ |
diff --git a/include/linux/rwsem-spinlock.h b/include/linux/rwsem-spinlock.h index b52a2af25f1f..f30f805080ae 100644 --- a/include/linux/rwsem-spinlock.h +++ b/include/linux/rwsem-spinlock.h | |||
@@ -61,5 +61,10 @@ extern void FASTCALL(__up_read(struct rw_semaphore *sem)); | |||
61 | extern void FASTCALL(__up_write(struct rw_semaphore *sem)); | 61 | extern void FASTCALL(__up_write(struct rw_semaphore *sem)); |
62 | extern void FASTCALL(__downgrade_write(struct rw_semaphore *sem)); | 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 | #endif /* __KERNEL__ */ | 69 | #endif /* __KERNEL__ */ |
65 | #endif /* _LINUX_RWSEM_SPINLOCK_H */ | 70 | #endif /* _LINUX_RWSEM_SPINLOCK_H */ |