From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: xen-devel@lists.xenproject.org, jbeulich@suse.com
Cc: Bob Liu <lliubbo@gmail.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH v2.1 07/15] tmem: cleanup the pgp free path
Date: Wed, 9 Apr 2014 09:26:11 -0400 [thread overview]
Message-ID: <1397049979-3479-8-git-send-email-konrad.wilk@oracle.com> (raw)
In-Reply-To: <1397049979-3479-1-git-send-email-konrad.wilk@oracle.com>
From: Bob Liu <lliubbo@gmail.com>
There are several functions related with pgp free, but their relationships are
not clear enough for understanding. This patch made some cleanup by remove
pgp_delist() and pgp_free_from_inv_list().
The call trace is simple now:
pgp_delist_free()
> pgp_free()
> __pgp_free()
Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
xen/common/tmem.c | 66 +++++++++++++++++++++++--------------------------------
1 file changed, 28 insertions(+), 38 deletions(-)
diff --git a/xen/common/tmem.c b/xen/common/tmem.c
index 96d616d..58e11ec 100644
--- a/xen/common/tmem.c
+++ b/xen/common/tmem.c
@@ -654,6 +654,13 @@ static void pgp_free_data(struct tmem_page_descriptor *pgp, struct tmem_pool *po
pgp->size = -1;
}
+static void __pgp_free(struct tmem_page_descriptor *pgp, struct tmem_pool *pool)
+{
+ pgp->us.obj = NULL;
+ pgp->index = -1;
+ tmem_free(pgp, pool);
+}
+
static void pgp_free(struct tmem_page_descriptor *pgp)
{
struct tmem_pool *pool = NULL;
@@ -678,30 +685,22 @@ static void pgp_free(struct tmem_page_descriptor *pgp)
pgp->pool_id = pool->pool_id;
return;
}
- pgp->us.obj = NULL;
- pgp->index = -1;
- tmem_free(pgp, pool);
-}
-
-static void pgp_free_from_inv_list(struct client *client, struct tmem_page_descriptor *pgp)
-{
- struct tmem_pool *pool = client->pools[pgp->pool_id];
-
- pgp->us.obj = NULL;
- pgp->index = -1;
- tmem_free(pgp, pool);
+ __pgp_free(pgp, pool);
}
-/* remove the page from appropriate lists but not from parent object */
-static void pgp_delist(struct tmem_page_descriptor *pgp)
+/* remove pgp from global/pool/client lists and free it */
+static void pgp_delist_free(struct tmem_page_descriptor *pgp)
{
struct client *client;
+ uint64_t life;
ASSERT(pgp != NULL);
ASSERT(pgp->us.obj != NULL);
ASSERT(pgp->us.obj->pool != NULL);
client = pgp->us.obj->pool->client;
ASSERT(client != NULL);
+
+ /* Delist pgp */
if ( !is_persistent(pgp->us.obj->pool) )
{
spin_lock(&eph_lists_spinlock);
@@ -714,7 +713,9 @@ static void pgp_delist(struct tmem_page_descriptor *pgp)
ASSERT(global_eph_count >= 0);
list_del_init(&pgp->global_eph_pages);
spin_unlock(&eph_lists_spinlock);
- } else {
+ }
+ else
+ {
if ( client->live_migrating )
{
spin_lock(&pers_lists_spinlock);
@@ -723,26 +724,18 @@ static void pgp_delist(struct tmem_page_descriptor *pgp)
if ( pgp != pgp->us.obj->pool->cur_pgp )
list_del_init(&pgp->us.pool_pers_pages);
spin_unlock(&pers_lists_spinlock);
- } else {
+ }
+ else
+ {
spin_lock(&pers_lists_spinlock);
list_del_init(&pgp->us.pool_pers_pages);
spin_unlock(&pers_lists_spinlock);
}
}
-}
-
-/* remove page from lists (but not from parent object) and free it */
-static void pgp_delete(struct tmem_page_descriptor *pgp)
-{
- uint64_t life;
-
- ASSERT(pgp != NULL);
- ASSERT(pgp->us.obj != NULL);
- ASSERT(pgp->us.obj->pool != NULL);
life = get_cycles() - pgp->timestamp;
pgp->us.obj->pool->sum_life_cycles += life;
- pgp_delist(pgp);
- ASSERT(pgp_lookup_in_obj(pgp->us.obj,pgp->index) == NULL);
+
+ /* free pgp */
pgp_free(pgp);
}
@@ -751,12 +744,8 @@ static void pgp_destroy(void *v)
{
struct tmem_page_descriptor *pgp = (struct tmem_page_descriptor *)v;
- ASSERT_SPINLOCK(&pgp->us.obj->obj_spinlock);
- pgp_delist(pgp);
- ASSERT(pgp->us.obj != NULL);
pgp->us.obj->pgp_count--;
- ASSERT(pgp->us.obj->pgp_count >= 0);
- pgp_free(pgp);
+ pgp_delist_free(pgp);
}
static int pgp_add_to_obj(struct tmem_object_root *obj, uint32_t index, struct tmem_page_descriptor *pgp)
@@ -1330,6 +1319,7 @@ static int tmem_evict(void)
goto out;
found:
+ /* Delist */
list_del_init(&pgp->us.client_eph_pages);
client->eph_count--;
list_del_init(&pgp->global_eph_pages);
@@ -1533,7 +1523,7 @@ failed_dup:
cleanup:
pgpfound = pgp_delete_from_obj(obj, pgp->index);
ASSERT(pgpfound == pgp);
- pgp_delete(pgpfound);
+ pgp_delist_free(pgpfound);
if ( obj->pgp_count == 0 )
{
write_lock(&pool->pool_rwlock);
@@ -1696,7 +1686,7 @@ del_pgp_from_obj:
pgp_delete_from_obj(obj, pgp->index);
free_pgp:
- pgp_delete(pgp);
+ pgp_free(pgp);
unlock_obj:
if ( newobj )
{
@@ -1755,7 +1745,7 @@ static int do_tmem_get(struct tmem_pool *pool, struct oid *oidp, uint32_t index,
{
if ( !is_shared(pool) )
{
- pgp_delete(pgp);
+ pgp_delist_free(pgp);
if ( obj->pgp_count == 0 )
{
write_lock(&pool->pool_rwlock);
@@ -1805,7 +1795,7 @@ static int do_tmem_flush_page(struct tmem_pool *pool, struct oid *oidp, uint32_t
spin_unlock(&obj->obj_spinlock);
goto out;
}
- pgp_delete(pgp);
+ pgp_delist_free(pgp);
if ( obj->pgp_count == 0 )
{
write_lock(&pool->pool_rwlock);
@@ -2378,7 +2368,7 @@ static int tmemc_save_subop(int cli_id, uint32_t pool_id,
if ( !list_empty(&client->persistent_invalidated_list) )
list_for_each_entry_safe(pgp,pgp2,
&client->persistent_invalidated_list, client_inv_pages)
- pgp_free_from_inv_list(client,pgp);
+ __pgp_free(pgp, client->pools[pgp->pool_id]);
client->frozen = client->was_frozen;
rc = 0;
break;
--
1.8.5.3
next prev parent reply other threads:[~2014-04-09 13:26 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-09 13:26 [PATCH/GIT PULL] Cleanups and bug-fix in tmem for v4.5 (v2.1) Konrad Rzeszutek Wilk
2014-04-09 13:26 ` [PATCH v2.1 01/15] tmem: refactor function do_tmem_op() Konrad Rzeszutek Wilk
2014-04-09 13:26 ` [PATCH v2.1 02/15] tmem: remove pageshift from struct tmem_pool Konrad Rzeszutek Wilk
2014-04-09 13:26 ` [PATCH v2.1 03/15] tmem: cleanup: drop unneeded client/pool initialization Konrad Rzeszutek Wilk
2014-04-09 13:26 ` [PATCH v2.1 04/15] tmem: bugfix in obj allocate path Konrad Rzeszutek Wilk
2014-04-09 13:26 ` [PATCH v2.1 05/15] tmem: cleanup: remove unneed parameter from pgp_delist() Konrad Rzeszutek Wilk
2014-04-09 13:26 ` [PATCH v2.1 06/15] tmem: cleanup: remove unneed parameter from pgp_free() Konrad Rzeszutek Wilk
2014-04-09 13:26 ` Konrad Rzeszutek Wilk [this message]
2014-04-09 13:26 ` [PATCH v2.1 08/15] tmem: drop oneline function client_freeze() Konrad Rzeszutek Wilk
2014-04-09 13:26 ` [PATCH v2.1 09/15] tmem: cleanup: drop global_pool_list Konrad Rzeszutek Wilk
2014-04-09 13:26 ` [PATCH v2.1 10/15] tmem: fix the return value of tmemc_set_var() Konrad Rzeszutek Wilk
2014-04-09 13:26 ` [PATCH v2.1 11/15] tmem: remove unneeded parameters from obj destroy path Konrad Rzeszutek Wilk
2014-04-09 13:26 ` [PATCH v2.1 12/15] tmem: cleanup: refactor function tmemc_shared_pool_auth() Konrad Rzeszutek Wilk
2014-04-09 13:26 ` [PATCH v2.1 13/15] tmem: reorg the shared pool allocate path Konrad Rzeszutek Wilk
2014-04-09 13:26 ` [PATCH v2.1 14/15] tmem: remove useless parameter from client and pool flush Konrad Rzeszutek Wilk
2014-04-09 13:26 ` [PATCH v2.1 15/15] xen: tmem: tmem_try_to_evict_pgp: fix a lock issue Konrad Rzeszutek Wilk
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=1397049979-3479-8-git-send-email-konrad.wilk@oracle.com \
--to=konrad.wilk@oracle.com \
--cc=jbeulich@suse.com \
--cc=lliubbo@gmail.com \
--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).