xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Bob Liu <lliubbo@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: james.harper@bendigoit.com.au, keir@xen.org,
	ian.campbell@citrix.com, andrew.cooper3@citrix.com,
	JBeulich@suse.com
Subject: [PATCH 09/14] tmem: remove unneeded parameters for obj destroy
Date: Wed, 18 Dec 2013 14:52:36 +0800	[thread overview]
Message-ID: <1387349561-27923-10-git-send-email-bob.liu@oracle.com> (raw)
In-Reply-To: <1387349561-27923-1-git-send-email-bob.liu@oracle.com>

Parameters selective and no_rebalance are unneeded during obj destory, this
patch remove them.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
---
 xen/common/tmem.c |   35 +++++++++++++++--------------------
 1 file changed, 15 insertions(+), 20 deletions(-)

diff --git a/xen/common/tmem.c b/xen/common/tmem.c
index 70c80ab..0febae1 100644
--- a/xen/common/tmem.c
+++ b/xen/common/tmem.c
@@ -885,7 +885,7 @@ restart_find:
 }
 
 /* free an object that has no more pgps in it */
-static void obj_free(struct tmem_object_root *obj, int no_rebalance)
+static void obj_free(struct tmem_object_root *obj)
 {
     struct tmem_pool *pool;
     struct oid old_oid;
@@ -908,9 +908,7 @@ static void obj_free(struct tmem_object_root *obj, int no_rebalance)
     oid_set_invalid(&obj->oid);
     obj->last_client = TMEM_CLI_ID_NULL;
     atomic_dec_and_assert(global_obj_count);
-    /* use no_rebalance only if all objects are being destroyed anyway */
-    if ( !no_rebalance )
-        rb_erase(&obj->rb_tree_node,&pool->obj_rb_root[oid_hash(&old_oid)]);
+    rb_erase(&obj->rb_tree_node, &pool->obj_rb_root[oid_hash(&old_oid)]);
     spin_unlock(&obj->obj_spinlock);
     tmem_free(obj, pool);
 }
@@ -969,15 +967,15 @@ static struct tmem_object_root * obj_alloc(struct tmem_pool *pool, struct oid *o
 }
 
 /* free an object after destroying any pgps in it */
-static void obj_destroy(struct tmem_object_root *obj, int no_rebalance)
+static void obj_destroy(struct tmem_object_root *obj)
 {
     ASSERT_WRITELOCK(&obj->pool->pool_rwlock);
     radix_tree_destroy(&obj->tree_root, pgp_destroy);
-    obj_free(obj,no_rebalance);
+    obj_free(obj);
 }
 
 /* destroys all objs in a pool, or only if obj->last_client matches cli_id */
-static void pool_destroy_objs(struct tmem_pool *pool, bool_t selective, domid_t cli_id)
+static void pool_destroy_objs(struct tmem_pool *pool, domid_t cli_id)
 {
     struct rb_node *node;
     struct tmem_object_root *obj;
@@ -993,11 +991,8 @@ static void pool_destroy_objs(struct tmem_pool *pool, bool_t selective, domid_t
             obj = container_of(node, struct tmem_object_root, rb_tree_node);
             spin_lock(&obj->obj_spinlock);
             node = rb_next(node);
-            if ( !selective )
-                /* FIXME: should be obj,1 but walking/erasing rbtree is racy */
-                obj_destroy(obj,0);
-            else if ( obj->last_client == cli_id )
-                obj_destroy(obj,0);
+            if ( obj->last_client == cli_id )
+                obj_destroy(obj);
             else
                 spin_unlock(&obj->obj_spinlock);
         }
@@ -1088,7 +1083,7 @@ static int shared_pool_quit(struct tmem_pool *pool, domid_t cli_id)
     ASSERT(pool->client != NULL);
     
     ASSERT_WRITELOCK(&tmem_rwlock);
-    pool_destroy_objs(pool,1,cli_id);
+    pool_destroy_objs(pool, cli_id);
     list_for_each_entry(sl,&pool->share_list, share_list)
     {
         if (sl->client->cli_id != cli_id)
@@ -1134,7 +1129,7 @@ static void pool_flush(struct tmem_pool *pool, domid_t cli_id, bool_t destroy)
                destroy?"destroy":"flush", tmem_client_str);
         return;
     }
-    pool_destroy_objs(pool,0,TMEM_CLI_ID_NULL);
+    pool_destroy_objs(pool, TMEM_CLI_ID_NULL);
     if ( destroy )
     {
         pool->client->pools[pool->pool_id] = NULL;
@@ -1339,7 +1334,7 @@ found:
     if ( obj->pgp_count == 0 )
     {
         ASSERT_WRITELOCK(&pool->pool_rwlock);
-        obj_free(obj,0);
+        obj_free(obj);
     }
     else
         spin_unlock(&obj->obj_spinlock);
@@ -1518,7 +1513,7 @@ cleanup:
     if ( obj->pgp_count == 0 )
     {
         write_lock(&pool->pool_rwlock);
-        obj_free(obj,0);
+        obj_free(obj);
         write_unlock(&pool->pool_rwlock);
     } else {
         spin_unlock(&obj->obj_spinlock);
@@ -1679,7 +1674,7 @@ unlock_obj:
     if ( newobj )
     {
         write_lock(&pool->pool_rwlock);
-        obj_free(obj, 0);
+        obj_free(obj);
         write_unlock(&pool->pool_rwlock);
     }
     else
@@ -1737,7 +1732,7 @@ static int do_tmem_get(struct tmem_pool *pool, struct oid *oidp, uint32_t index,
             if ( obj->pgp_count == 0 )
             {
                 write_lock(&pool->pool_rwlock);
-                obj_free(obj,0);
+                obj_free(obj);
                 obj = NULL;
                 write_unlock(&pool->pool_rwlock);
             }
@@ -1787,7 +1782,7 @@ static int do_tmem_flush_page(struct tmem_pool *pool, struct oid *oidp, uint32_t
     if ( obj->pgp_count == 0 )
     {
         write_lock(&pool->pool_rwlock);
-        obj_free(obj,0);
+        obj_free(obj);
         write_unlock(&pool->pool_rwlock);
     } else {
         spin_unlock(&obj->obj_spinlock);
@@ -1810,7 +1805,7 @@ static int do_tmem_flush_object(struct tmem_pool *pool, struct oid *oidp)
     if ( obj == NULL )
         goto out;
     write_lock(&pool->pool_rwlock);
-    obj_destroy(obj,0);
+    obj_destroy(obj);
     pool->flush_objs_found++;
     write_unlock(&pool->pool_rwlock);
 
-- 
1.7.10.4

  parent reply	other threads:[~2013-12-18  6:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-18  6:52 [PATCH 00/14] xen: new patches for tmem cleanup Bob Liu
2013-12-18  6:52 ` [PATCH 01/14] tmem: cleanup: drop pageshift from struct tmem_pool Bob Liu
2013-12-18  6:52 ` [PATCH 02/14] tmem: refactor function do_tmem_op() Bob Liu
2013-12-18  6:52 ` [PATCH 03/14] tmem: cleanup: drop unneeded client/pool initialization Bob Liu
2013-12-18  6:52 ` [PATCH 04/14] tmem: bugfix in obj allocate path Bob Liu
2013-12-18  6:52 ` [PATCH 05/14] tmem: cleanup: remove unneed parameter for pgp_delist() Bob Liu
2013-12-18  6:52 ` [PATCH 06/14] tmem: cleanup: remove unneed parameter for pgp_free() Bob Liu
2013-12-18  6:52 ` [PATCH 07/14] tmem: cleanup the pgp free path Bob Liu
2013-12-18  6:52 ` [PATCH 08/14] tmem: drop oneline function client_freeze() Bob Liu
2013-12-18  6:52 ` Bob Liu [this message]
2013-12-18  6:52 ` [PATCH 10/14] tmem: cleanup: drop global_pool_list Bob Liu
2013-12-18  6:52 ` [PATCH 11/14] tmem: fix the return value of tmemc_set_var() Bob Liu
2013-12-18  6:52 ` [PATCH 12/14] tmem: cleanup: refactor function tmemc_shared_pool_auth() Bob Liu
2013-12-18  6:52 ` [PATCH 13/14] tmem: reorg the shared pool allocate path Bob Liu
2013-12-18  6:52 ` [PATCH 14/14] tmem: remove useless parameter from client and pool flush Bob Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1387349561-27923-10-git-send-email-bob.liu@oracle.com \
    --to=lliubbo@gmail.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=james.harper@bendigoit.com.au \
    --cc=keir@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).