[SSI] openssi/kernel/cluster/ssi/cfs svrcfs.c,1.27,1.28
Roger Tsang <[email protected]> Fri, 05 Mar 2010 06:07:03 +0000
| Newsgroups | gmane.linux.cluster.ssic.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/cfs
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv3991/cluster/ssi/cfs
Modified Files:
Tag: OPENSSI-FC
svrcfs.c
Log Message:
CFS (#ifdef RCU_CFSTOK_TABLE):
- Remove sct_statelock spinlock in struct svrcfstok reference counting
code. Use atomic_test_and_add().
- sct_magic is no longer used except for debugging. (#ifdef DEBUG)
- sct_prlist is no longer used in svrcfstok_nodedown since the final
HASH_RELE() releases svrcfstok structure.
cluster/ssi/cfs/svrcfs.c | 98 ++++++++-----------------------
include/cluster/ssi/cfs/cfstok.h | 14 +++-
2 files changed, 38 insertions(+), 74 deletions(-)
Index: svrcfs.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/cfs/svrcfs.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- svrcfs.c 17 Dec 2009 06:43:50 -0000 1.27
+++ svrcfs.c 5 Mar 2010 06:07:00 -0000 1.28
@@ -243,34 +243,10 @@
static inline struct svrcfstok *
__hash_hold_and_check(svrcfstok_t *hp)
{
- LOCK_COND_LOCK(&hp->sct_statelock);
- if (hp->sct_magic != CFSTOK_MAGIC) {
- UNLOCK_COND_LOCK(&hp->sct_statelock);
+ if (!atomic_test_and_add(1, &hp->sct_refcnt))
return NULL;
- }
- HASH_HOLD(hp);
- UNLOCK_COND_LOCK(&hp->sct_statelock);
return hp;
}
-
-#ifdef DEBUG
-static int
-hash_hold_and_check(svrcfstok_t *hp)
-{
- struct svrcfstok *h;
-
- rcu_read_lock();
- if (hp->sct_magic != CFSTOK_MAGIC) {
- rcu_read_unlock();
- return 0;
- }
-
- h = __hash_hold_and_check(hp);
- rcu_read_unlock();
-
- return (h != NULL);
-}
-#endif /* DEBUG */
#endif
/*
@@ -455,7 +431,9 @@
INIT_RCU_HEAD(&hp->sct_rcu);
#endif
atomic_set(&hp->sct_refcnt, 1);
+#ifdef DEBUG
hp->sct_magic = CFSTOK_MAGIC;
+#endif
#else
hp->sct_refcnt = 1;
#endif /* !RCU_CFSTOK_TABLE */
@@ -470,7 +448,7 @@
INIT_CONDITION(&hp->sct_cond);
INIT_RW_LOCK(&hp->sct_objlock);
#endif /* !SVRCFS_TOKEN_KMEM_CACHE */
-#if !defined(CFSTOK_TABLE_LOCK_LOCK) || defined(RCU_CFSTOK_TABLE)
+#if !defined(CFSTOK_TABLE_LOCK_LOCK) && !defined(RCU_CFSTOK_TABLE)
INIT_LIST_HEAD(&(hp->sct_prlist));
#endif
@@ -664,17 +642,14 @@
#ifdef RCU_CFSTOK_TABLE
might_sleep_if(atomic_read(&hp->sct_refcnt) == 1);
if (!atomic_dec_and_lock(&hp->sct_refcnt, &svrcfstok_table_lock)) {
- /* WARN_ON(atomic_read(&hp->sct_refcnt) < 0); */
- return;
- }
- LOCK_COND_LOCK(&hp->sct_statelock);
- if (atomic_read(&hp->sct_refcnt)) {
- UNLOCK_COND_LOCK(&hp->sct_statelock);
- spin_unlock(&svrcfstok_table_lock);
+#ifdef DEBUG
+ WARN_ON(atomic_read(&hp->sct_refcnt) < 0);
+#endif
return;
}
+#ifdef DEBUG
hp->sct_magic = 0;
- UNLOCK_COND_LOCK(&hp->sct_statelock);
+#endif
hlist_del_rcu(&hp->sct_hlist);
spin_unlock(&svrcfstok_table_lock);
@@ -1053,14 +1028,9 @@
svrcfstok_hold_obj(object_t *objp)
{
#ifdef DEBUG
-#ifdef RCU_CFSTOK_TABLE
- BUG_ON(!hash_hold_and_check((struct svrcfstok *) objp->word1));
-#else
-#error not supported
+ BUG_ON(((struct svrcfstok *)objp->word1)->sct_magic != CFSTOK_MAGIC);
#endif
-#else
HASH_HOLD((struct svrcfstok *) objp->word1);
-#endif /* !DEBUG */
}
/*
@@ -2773,25 +2743,26 @@
u_long hash;
#endif
struct svrcfstok *hp; /* Pointer to server token structure. */
- struct svrcfstok *hp_next; /* Saved pointer to next structure. */
#ifdef RCU_CFSTOK_TABLE
struct hlist_node *pos;
+#ifdef DEBUG
+ struct svrcfstok *hp_next; /* Saved pointer to next structure. */
u_long count = 0;
#endif
- int doagain;
- int retry_count = 0;
-#if !defined(CFSTOK_TABLE_LOCK_LOCK) || defined(RCU_CFSTOK_TABLE)
+#else
+ struct svrcfstok *hp_next; /* Saved pointer to next structure. */
+#endif /* !RCU_CFSTOK_TABLE */
+ int doagain, retry_count = 0;
+#if !defined(CFSTOK_TABLE_LOCK_LOCK) && !defined(RCU_CFSTOK_TABLE)
LIST_HEAD(tofree_head);
#endif
#ifndef CFSTOK_TABLE_LOCK_LOCK
struct list_head *act_head;
#endif
- SSI_ASSERT(sb != NULL);
- SSI_ASSERT(cfs_sb_is_cfs(sb));
+ SSI_ASSERT(sb && cfs_sb_is_cfs(sb));
retry:
doagain = FALSE;
- /* Release all token structures belonging to this SB. */
#ifdef RCU_CFSTOK_TABLE
for (hash = 0; hash < HASHSIZ; hash++) {
rcu_read_lock();
@@ -2799,34 +2770,16 @@
if (hp->sct_sb == sb) {
if (atomic_read(&hp->sct_refcnt)) {
doagain = TRUE;
- continue;
- }
- LOCK_COND_LOCK(&hp->sct_statelock);
- if (atomic_read(&hp->sct_refcnt)) {
- UNLOCK_COND_LOCK(&hp->sct_statelock);
- BUG_ON(atomic_read(&hp->sct_refcnt) < 0);
- doagain = TRUE;
- continue;
+ break;
}
- hp->sct_magic = 0;
- UNLOCK_COND_LOCK(&hp->sct_statelock);
- spin_lock(&svrcfstok_table_lock);
- hlist_del_rcu(&hp->sct_hlist);
- spin_unlock(&svrcfstok_table_lock);
- list_add(&hp->sct_prlist, &tofree_head);
+ /* SSI: There is no need to release struct
+ * because the only way sct_refcnt gets to zero
+ * is HASH_RELE() which calls svrtok_dorelse().
+ * -Roger
+ */
}
}
rcu_read_unlock();
- list_for_each_entry_safe(hp, hp_next, &tofree_head, sct_prlist) {
- list_del(&hp->sct_prlist);
- svrtok_dorelse(hp, TRUE);
- count++;
- }
- if (unlikely(count)) {
- printk(KERN_WARNING "%s: found %lu stale token"
- " structures\n", __FUNCTION__, count);
- count = 0;
- }
}
if (doagain) {
if (++retry_count == 5) {
@@ -2837,7 +2790,8 @@
nidelay(HZ/10);
goto retry;
}
-#else /* !RCU_CFSTOK_TABLE */
+#else /* RCU_CFSTOK_TABLE */
+ /* Release all token structures belonging to this SB. */
LOCK_LOCK(&svrcfstok_table_lock);
for (hash = 0; hash < HASHSIZ; hash++) {
hp_next = svrcfs_hash_table[hash];
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev