Skip to content

Commit

Permalink
tipc: replace reference table rwlock with spinlock
Browse files Browse the repository at this point in the history
The lock for protecting the reference table is declared as an
RWLOCK, although it is only used in write mode, never in read
mode.

We redefine it to become a spinlock.

Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jon Paul Maloy authored and David S. Miller committed Mar 12, 2014
1 parent 4a93f50 commit 978813e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions net/tipc/ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ struct ref_table {

static struct ref_table tipc_ref_table;

static DEFINE_RWLOCK(ref_table_lock);
static DEFINE_SPINLOCK(ref_table_lock);

/**
* tipc_ref_table_init - create reference table for objects
Expand Down Expand Up @@ -159,7 +159,7 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock)
}

/* take a free entry, if available; otherwise initialize a new entry */
write_lock_bh(&ref_table_lock);
spin_lock_bh(&ref_table_lock);
if (tipc_ref_table.first_free) {
index = tipc_ref_table.first_free;
entry = &(tipc_ref_table.entries[index]);
Expand All @@ -175,7 +175,7 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock)
} else {
ref = 0;
}
write_unlock_bh(&ref_table_lock);
spin_unlock_bh(&ref_table_lock);

/*
* Grab the lock so no one else can modify this entry
Expand Down Expand Up @@ -216,7 +216,7 @@ void tipc_ref_discard(u32 ref)
index = ref & index_mask;
entry = &(tipc_ref_table.entries[index]);

write_lock_bh(&ref_table_lock);
spin_lock_bh(&ref_table_lock);

if (!entry->object) {
pr_err("Attempt to discard ref. to non-existent obj\n");
Expand All @@ -242,7 +242,7 @@ void tipc_ref_discard(u32 ref)
tipc_ref_table.last_free = index;

exit:
write_unlock_bh(&ref_table_lock);
spin_unlock_bh(&ref_table_lock);
}

/**
Expand Down

0 comments on commit 978813e

Please sign in to comment.