lkml.org 
[lkml]   [2009]   [Oct]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [Patch v4] rwsem: fix rwsem_is_locked() bugs
On Thu, 8 Oct 2009 05:23:53 -0400
Amerigo Wang <amwang@redhat.com> wrote:

> --- a/include/linux/rwsem-spinlock.h
> +++ b/include/linux/rwsem-spinlock.h
> @@ -71,7 +71,13 @@ extern void __downgrade_write(struct rw_semaphore *sem);
>
> static inline int rwsem_is_locked(struct rw_semaphore *sem)
> {
> - return (sem->activity != 0);
> + int ret = 1;
> +
> + if (spin_trylock_irq(&sem->wait_lock)) {
> + ret = (sem->activity != 0);
> + spin_unlock_irq(&sem->wait_lock);
> + }
> + return ret;
> }

a) probably to large to be inlined

b) the function will now cause bugs if called under
local_irq_disable(). That wasn't the case before. Fixable via
spin_lock_irqsave().

In the present kernel there don't appear to be any irqs-off callers.
There may of course be some out-of-tree ones which will get bitten by
this semantic change.

If we decide to leave this new rule in place then we should add a
WARN_ON(irqs_disabled()) to prevent hitting people with a nasty, subtle
bug.

Methinks that _irqsave() is better.


\
 
 \ /
  Last update: 2009-10-13 22:51    [W:0.305 / U:0.720 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site