The patch titled rwsem: implement rwsem_is_contended() has been added to the -mm tree. Its filename is rwsem-implement-rwsem_is_contended.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: rwsem: implement rwsem_is_contended() From: Michel Lespinasse <walken@xxxxxxxxxx> Trivial implementations for rwsem_is_contended() Signed-off-by: Michel Lespinasse <walken@xxxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Cc: Rik van Riel <riel@xxxxxxxxxx> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx> Cc: Nick Piggin <npiggin@xxxxxxxxx> Cc: KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxx> Cc: "H. Peter Anvin" <hpa@xxxxxxxxx> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Cc: David Howells <dhowells@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- arch/alpha/include/asm/rwsem.h | 5 +++++ arch/ia64/include/asm/rwsem.h | 5 +++++ arch/powerpc/include/asm/rwsem.h | 5 +++++ arch/s390/include/asm/rwsem.h | 5 +++++ arch/sh/include/asm/rwsem.h | 5 +++++ arch/sparc/include/asm/rwsem.h | 5 +++++ arch/x86/include/asm/rwsem.h | 5 +++++ arch/xtensa/include/asm/rwsem.h | 5 +++++ include/linux/rwsem-spinlock.h | 1 + lib/rwsem-spinlock.c | 12 ++++++++++++ 10 files changed, 53 insertions(+) diff -puN arch/alpha/include/asm/rwsem.h~rwsem-implement-rwsem_is_contended arch/alpha/include/asm/rwsem.h --- a/arch/alpha/include/asm/rwsem.h~rwsem-implement-rwsem_is_contended +++ a/arch/alpha/include/asm/rwsem.h @@ -255,5 +255,10 @@ static inline int rwsem_is_locked(struct return (sem->count != 0); } +static inline int rwsem_is_contended(struct rw_semaphore *sem) +{ + return (sem->count < 0); +} + #endif /* __KERNEL__ */ #endif /* _ALPHA_RWSEM_H */ diff -puN arch/ia64/include/asm/rwsem.h~rwsem-implement-rwsem_is_contended arch/ia64/include/asm/rwsem.h --- a/arch/ia64/include/asm/rwsem.h~rwsem-implement-rwsem_is_contended +++ a/arch/ia64/include/asm/rwsem.h @@ -179,4 +179,9 @@ static inline int rwsem_is_locked(struct return (sem->count != 0); } +static inline int rwsem_is_contended(struct rw_semaphore *sem) +{ + return (sem->count < 0); +} + #endif /* _ASM_IA64_RWSEM_H */ diff -puN arch/powerpc/include/asm/rwsem.h~rwsem-implement-rwsem_is_contended arch/powerpc/include/asm/rwsem.h --- a/arch/powerpc/include/asm/rwsem.h~rwsem-implement-rwsem_is_contended +++ a/arch/powerpc/include/asm/rwsem.h @@ -179,5 +179,10 @@ static inline int rwsem_is_locked(struct return sem->count != 0; } +static inline int rwsem_is_contended(struct rw_semaphore *sem) +{ + return sem->count < 0; +} + #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_RWSEM_H */ diff -puN arch/s390/include/asm/rwsem.h~rwsem-implement-rwsem_is_contended arch/s390/include/asm/rwsem.h --- a/arch/s390/include/asm/rwsem.h~rwsem-implement-rwsem_is_contended +++ a/arch/s390/include/asm/rwsem.h @@ -382,5 +382,10 @@ static inline int rwsem_is_locked(struct return (sem->count != 0); } +static inline int rwsem_is_contended(struct rw_semaphore *sem) +{ + return (sem->count < 0); +} + #endif /* __KERNEL__ */ #endif /* _S390_RWSEM_H */ diff -puN arch/sh/include/asm/rwsem.h~rwsem-implement-rwsem_is_contended arch/sh/include/asm/rwsem.h --- a/arch/sh/include/asm/rwsem.h~rwsem-implement-rwsem_is_contended +++ a/arch/sh/include/asm/rwsem.h @@ -184,5 +184,10 @@ static inline int rwsem_is_locked(struct return (sem->count != 0); } +static inline int rwsem_is_contended(struct rw_semaphore *sem) +{ + return (sem->count < 0); +} + #endif /* __KERNEL__ */ #endif /* _ASM_SH_RWSEM_H */ diff -puN arch/sparc/include/asm/rwsem.h~rwsem-implement-rwsem_is_contended arch/sparc/include/asm/rwsem.h --- a/arch/sparc/include/asm/rwsem.h~rwsem-implement-rwsem_is_contended +++ a/arch/sparc/include/asm/rwsem.h @@ -165,6 +165,11 @@ static inline int rwsem_is_locked(struct return (sem->count != 0); } +static inline int rwsem_is_contended(struct rw_semaphore *sem) +{ + return (sem->count < 0); +} + #endif /* __KERNEL__ */ #endif /* _SPARC64_RWSEM_H */ diff -puN arch/x86/include/asm/rwsem.h~rwsem-implement-rwsem_is_contended arch/x86/include/asm/rwsem.h --- a/arch/x86/include/asm/rwsem.h~rwsem-implement-rwsem_is_contended +++ a/arch/x86/include/asm/rwsem.h @@ -275,5 +275,10 @@ static inline int rwsem_is_locked(struct return (sem->count != 0); } +static inline int rwsem_is_contended(struct rw_semaphore *sem) +{ + return (sem->count < 0); +} + #endif /* __KERNEL__ */ #endif /* _ASM_X86_RWSEM_H */ diff -puN arch/xtensa/include/asm/rwsem.h~rwsem-implement-rwsem_is_contended arch/xtensa/include/asm/rwsem.h --- a/arch/xtensa/include/asm/rwsem.h~rwsem-implement-rwsem_is_contended +++ a/arch/xtensa/include/asm/rwsem.h @@ -165,4 +165,9 @@ static inline int rwsem_is_locked(struct return (sem->count != 0); } +static inline int rwsem_is_contended(struct rw_semaphore *sem) +{ + return (sem->count < 0); +} + #endif /* _XTENSA_RWSEM_H */ diff -puN include/linux/rwsem-spinlock.h~rwsem-implement-rwsem_is_contended include/linux/rwsem-spinlock.h --- a/include/linux/rwsem-spinlock.h~rwsem-implement-rwsem_is_contended +++ a/include/linux/rwsem-spinlock.h @@ -69,6 +69,7 @@ extern void __up_read(struct rw_semaphor extern void __up_write(struct rw_semaphore *sem); extern void __downgrade_write(struct rw_semaphore *sem); extern int rwsem_is_locked(struct rw_semaphore *sem); +extern int rwsem_is_contended(struct rw_semaphore *sem); #endif /* __KERNEL__ */ #endif /* _LINUX_RWSEM_SPINLOCK_H */ diff -puN lib/rwsem-spinlock.c~rwsem-implement-rwsem_is_contended lib/rwsem-spinlock.c --- a/lib/rwsem-spinlock.c~rwsem-implement-rwsem_is_contended +++ a/lib/rwsem-spinlock.c @@ -30,6 +30,18 @@ int rwsem_is_locked(struct rw_semaphore } EXPORT_SYMBOL(rwsem_is_locked); +int rwsem_is_contended(struct rw_semaphore *sem) +{ + int ret = 0; + unsigned long flags; + + if (spin_trylock_irqsave(&sem->wait_lock, flags)) { + ret = !list_empty(&sem->wait_list); + spin_unlock_irqrestore(&sem->wait_lock, flags); + } + return ret; +} + /* * initialise the semaphore */ _ Patches currently in -mm which might be from walken@xxxxxxxxxx are do_wp_page-remove-the-reuse-flag.patch do_wp_page-clarify-dirty_page-handling.patch mlock-avoid-dirtying-pages-and-triggering-writeback.patch mlock-only-hold-mmap_sem-in-shared-mode-when-faulting-in-pages.patch mm-add-foll_mlock-follow_page-flag.patch mm-move-vm_locked-check-to-__mlock_vma_pages_range.patch rwsem-implement-rwsem_is_contended.patch mlock-do-not-hold-mmap_sem-for-extended-periods-of-time.patch x86-rwsem-more-precise-rwsem_is_contended-implementation.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html