lkml.org 
[lkml]   [2005]   [Sep]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patches in this message
/
Date
From
Subject[PATCH][3/2] also fix rwsem-spinlock.h
Hi Andrew,

I forgot to also update rwsem-spinlock.h. Here is the equivalent
change for that file.

These patches simplify the code and should not have much, if any,
difference on the behaviour of the system, compared with the
patches currently in -mm.

Signed-off-by: Rik van Riel <riel@redhat.com>

Index: linux-2.6.13/include/linux/rwsem-spinlock.h
===================================================================
--- linux-2.6.13.orig/include/linux/rwsem-spinlock.h
+++ linux-2.6.13/include/linux/rwsem-spinlock.h
@@ -61,14 +61,9 @@ extern void FASTCALL(__up_read(struct rw
extern void FASTCALL(__up_write(struct rw_semaphore *sem));
extern void FASTCALL(__downgrade_write(struct rw_semaphore *sem));

-static inline int sem_is_read_locked(struct rw_semaphore *sem)
+static inline int rwsem_is_locked(struct rw_semaphore *sem)
{
- return (sem->activity > 0);
-}
-
-static inline int sem_is_write_locked(struct rw_semaphore *sem)
-{
- return (sem->activity < 0);
+ return (sem->activity != 0);
}

#endif /* __KERNEL__ */
From: Rik Van Riel <riel@redhat.com>

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>
Index: linux-2.6.13/include/asm-alpha/rwsem.h
===================================================================
--- linux-2.6.13.orig/include/asm-alpha/rwsem.h
+++ linux-2.6.13/include/asm-alpha/rwsem.h
@@ -262,5 +262,10 @@ static inline long rwsem_atomic_update(l
#endif
}

+static inline int rwsem_is_locked(struct rw_semaphore *sem)
+{
+ return (sem->count != 0);
+}
+
#endif /* __KERNEL__ */
#endif /* _ALPHA_RWSEM_H */
Index: linux-2.6.13/include/asm-i386/rwsem.h
===================================================================
--- linux-2.6.13.orig/include/asm-i386/rwsem.h
+++ linux-2.6.13/include/asm-i386/rwsem.h
@@ -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: linux-2.6.13/include/asm-ia64/rwsem.h
===================================================================
--- linux-2.6.13.orig/include/asm-ia64/rwsem.h
+++ linux-2.6.13/include/asm-ia64/rwsem.h
@@ -186,4 +186,9 @@ __downgrade_write (struct rw_semaphore *
#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: linux-2.6.13/include/asm-ppc64/rwsem.h
===================================================================
--- linux-2.6.13.orig/include/asm-ppc64/rwsem.h
+++ linux-2.6.13/include/asm-ppc64/rwsem.h
@@ -163,5 +163,10 @@ static inline int rwsem_atomic_update(in
return atomic_add_return(delta, (atomic_t *)(&sem->count));
}

+static inline int sem_is_read_locked(struct rw_semaphore *sem)
+{
+ return (sem->count != 0);
+}
+
#endif /* __KERNEL__ */
#endif /* _PPC_RWSEM_XADD_H */
Index: linux-2.6.13/include/asm-ppc/rwsem.h
===================================================================
--- linux-2.6.13.orig/include/asm-ppc/rwsem.h
+++ linux-2.6.13/include/asm-ppc/rwsem.h
@@ -168,5 +168,10 @@ static inline int rwsem_atomic_update(in
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: linux-2.6.13/include/asm-s390/rwsem.h
===================================================================
--- linux-2.6.13.orig/include/asm-s390/rwsem.h
+++ linux-2.6.13/include/asm-s390/rwsem.h
@@ -351,5 +351,10 @@ static inline long rwsem_atomic_update(l
return new;
}

+static inline int rwsem_is_locked(struct rw_semaphore *sem)
+{
+ return (sem->count != 0);
+}
+
#endif /* __KERNEL__ */
#endif /* _S390_RWSEM_H */
Index: linux-2.6.13/include/asm-sh/rwsem.h
===================================================================
--- linux-2.6.13.orig/include/asm-sh/rwsem.h
+++ linux-2.6.13/include/asm-sh/rwsem.h
@@ -166,5 +166,10 @@ static inline int rwsem_atomic_update(in
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: linux-2.6.13/include/asm-sparc64/rwsem.h
===================================================================
--- linux-2.6.13.orig/include/asm-sparc64/rwsem.h
+++ linux-2.6.13/include/asm-sparc64/rwsem.h
@@ -56,6 +56,11 @@ static inline void rwsem_atomic_add(int
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: linux-2.6.13/include/asm-x86_64/rwsem.h
===================================================================
--- linux-2.6.13.orig/include/asm-x86_64/rwsem.h
+++ linux-2.6.13/include/asm-x86_64/rwsem.h
@@ -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: linux-2.6.13/include/linux/rwsem-spinlock.h
===================================================================
--- linux-2.6.13.orig/include/linux/rwsem-spinlock.h
+++ linux-2.6.13/include/linux/rwsem-spinlock.h
@@ -61,5 +61,10 @@ extern void FASTCALL(__up_read(struct rw
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 */
\
 
 \ /
  Last update: 2005-09-03 17:48    [W:0.278 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site