xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: xen-devel@lists.xenproject.org, konrad@kernel.org
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH v1 06/12] tmem: Move client weight, frozen, live_migrating, and compress
Date: Wed, 28 Sep 2016 05:42:20 -0400	[thread overview]
Message-ID: <1475055746-22401-7-git-send-email-konrad.wilk@oracle.com> (raw)
In-Reply-To: <1475055746-22401-1-git-send-email-konrad.wilk@oracle.com>

in its own structure. This paves the way to make only
one hypercall to retrieve/set this information instead of multiple
ones.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
v1: First submission.
---
 xen/common/tmem.c           | 40 +++++++++++++++++++++-------------------
 xen/common/tmem_control.c   | 18 +++++++++---------
 xen/include/public/sysctl.h | 14 ++++++++++++++
 xen/include/xen/tmem_xen.h  |  6 +-----
 4 files changed, 45 insertions(+), 33 deletions(-)

diff --git a/xen/common/tmem.c b/xen/common/tmem.c
index cf5271c..27164ce 100644
--- a/xen/common/tmem.c
+++ b/xen/common/tmem.c
@@ -333,7 +333,7 @@ static void pgp_free(struct tmem_page_descriptor *pgp)
     atomic_dec(&pool->pgp_count);
     ASSERT(_atomic_read(pool->pgp_count) >= 0);
     pgp->size = -1;
-    if ( is_persistent(pool) && pool->client->live_migrating )
+    if ( is_persistent(pool) && pool->client->info.flags.u.migrating )
     {
         pgp->inv_oid = pgp->us.obj->oid;
         pgp->pool_id = pool->pool_id;
@@ -370,7 +370,7 @@ static void pgp_delist_free(struct tmem_page_descriptor *pgp)
     }
     else
     {
-        if ( client->live_migrating )
+        if ( client->info.flags.u.migrating )
         {
             spin_lock(&pers_lists_spinlock);
             list_add_tail(&pgp->client_inv_pages,
@@ -791,7 +791,7 @@ static void pool_flush(struct tmem_pool *pool, domid_t cli_id)
                     is_persistent(pool) ? "persistent" : "ephemeral" ,
                     is_shared(pool) ? "shared" : "private",
                     tmem_cli_id_str, pool->client->cli_id, pool->pool_id);
-    if ( pool->client->live_migrating )
+    if ( pool->client->info.flags.u.migrating )
     {
         tmem_client_warn("can't destroy pool while %s is live-migrating\n",
                     tmem_client_str);
@@ -843,7 +843,9 @@ static struct client *client_create(domid_t cli_id)
     rcu_unlock_domain(d);
 
     client->cli_id = cli_id;
-    client->compress = tmem_compression_enabled();
+    client->info.version = TMEM_SPEC_VERSION;
+    client->info.maxpools = MAX_POOLS_PER_DOMAIN;
+    client->info.flags.u.compress = tmem_compression_enabled();
     client->shared_auth_required = tmem_shared_auth();
     for ( i = 0; i < MAX_GLOBAL_SHARED_POOLS; i++)
         client->shared_auth_uuid[i][0] =
@@ -887,11 +889,11 @@ static bool_t client_over_quota(struct client *client)
     int total = _atomic_read(tmem_global.client_weight_total);
 
     ASSERT(client != NULL);
-    if ( (total == 0) || (client->weight == 0) ||
+    if ( (total == 0) || (client->info.weight == 0) ||
           (client->eph_count == 0) )
         return 0;
     return ( ((tmem_global.eph_count*100L) / client->eph_count ) >
-             ((total*100L) / client->weight) );
+             ((total*100L) / client->info.weight) );
 }
 
 /************ MEMORY REVOCATION ROUTINES *******************************/
@@ -1067,10 +1069,10 @@ static int do_tmem_dup_put(struct tmem_page_descriptor *pgp, xen_pfn_t cmfn,
     pool = obj->pool;
     ASSERT(pool != NULL);
     client = pool->client;
-    if ( client->live_migrating )
+    if ( client->info.flags.u.migrating )
         goto failed_dup; /* No dups allowed when migrating. */
     /* Can we successfully manipulate pgp to change out the data? */
-    if ( client->compress && pgp->size != 0 )
+    if ( client->info.flags.u.compress && pgp->size != 0 )
     {
         ret = do_tmem_put_compress(pgp, cmfn, clibuf);
         if ( ret == 1 )
@@ -1142,7 +1144,7 @@ static int do_tmem_put(struct tmem_pool *pool,
     ASSERT(pool != NULL);
     client = pool->client;
     ASSERT(client != NULL);
-    ret = client->frozen ? -EFROZEN : -ENOMEM;
+    ret = client->info.flags.u.frozen  ? -EFROZEN : -ENOMEM;
     pool->puts++;
 
 refind:
@@ -1156,14 +1158,14 @@ refind:
         else
         {
             /* No puts allowed into a frozen pool (except dup puts). */
-            if ( client->frozen )
+            if ( client->info.flags.u.frozen )
                 goto unlock_obj;
         }
     }
     else
     {
         /* No puts allowed into a frozen pool (except dup puts). */
-        if ( client->frozen )
+        if ( client->info.flags.u.frozen )
             return ret;
         if ( (obj = obj_alloc(pool, oidp)) == NULL )
             return -ENOMEM;
@@ -1198,7 +1200,7 @@ refind:
     pgp->index = index;
     pgp->size = 0;
 
-    if ( client->compress )
+    if ( client->info.flags.u.compress )
     {
         ASSERT(pgp->pfp == NULL);
         ret = do_tmem_put_compress(pgp, cmfn, clibuf);
@@ -1390,7 +1392,7 @@ static int do_tmem_flush_page(struct tmem_pool *pool,
     pool->flushs_found++;
 
 out:
-    if ( pool->client->frozen )
+    if ( pool->client->info.flags.u.frozen )
         return -EFROZEN;
     else
         return 1;
@@ -1411,7 +1413,7 @@ static int do_tmem_flush_object(struct tmem_pool *pool,
     write_unlock(&pool->pool_rwlock);
 
 out:
-    if ( pool->client->frozen )
+    if ( pool->client->info.flags.u.frozen )
         return -EFROZEN;
     else
         return 1;
@@ -1669,10 +1671,10 @@ static int tmemc_save_subop(int cli_id, uint32_t pool_id,
             rc = 0;
             break;
         }
-        client->was_frozen = client->frozen;
-        client->frozen = 1;
+        client->was_frozen = client->info.flags.u.frozen;
+        client->info.flags.u.frozen = 1;
         if ( arg1 != 0 )
-            client->live_migrating = 1;
+            client->info.flags.u.migrating = 1;
         rc = 1;
         break;
     case XEN_SYSCTL_TMEM_OP_RESTORE_BEGIN:
@@ -1682,12 +1684,12 @@ static int tmemc_save_subop(int cli_id, uint32_t pool_id,
     case XEN_SYSCTL_TMEM_OP_SAVE_END:
         if ( client == NULL )
             break;
-        client->live_migrating = 0;
+        client->info.flags.u.migrating = 0;
         if ( !list_empty(&client->persistent_invalidated_list) )
             list_for_each_entry_safe(pgp,pgp2,
               &client->persistent_invalidated_list, client_inv_pages)
                 __pgp_free(pgp, client->pools[pgp->pool_id]);
-        client->frozen = client->was_frozen;
+        client->info.flags.u.frozen = client->was_frozen;
         rc = 0;
         break;
     }
diff --git a/xen/common/tmem_control.c b/xen/common/tmem_control.c
index cda327b..ba003a8 100644
--- a/xen/common/tmem_control.c
+++ b/xen/common/tmem_control.c
@@ -27,14 +27,14 @@ static int tmemc_freeze_pools(domid_t cli_id, int arg)
     if ( cli_id == TMEM_CLI_ID_NULL )
     {
         list_for_each_entry(client,&tmem_global.client_list,client_list)
-            client->frozen = freeze;
+            client->info.flags.u.frozen = freeze;
         tmem_client_info("tmem: all pools %s for all %ss\n", s, tmem_client_str);
     }
     else
     {
         if ( (client = tmem_client_from_cli_id(cli_id)) == NULL)
             return -1;
-        client->frozen = freeze;
+        client->info.flags.u.frozen = freeze;
         tmem_client_info("tmem: all pools %s for %s=%d\n",
                          s, tmem_cli_id_str, cli_id);
     }
@@ -105,7 +105,7 @@ static int tmemc_list_client(struct client *c, tmem_cli_va_param_t buf,
 
     n = scnprintf(info,BSIZE,"C=CI:%d,ww:%d,co:%d,fr:%d,"
         "Tc:%"PRIu64",Ge:%ld,Pp:%ld,Gp:%ld%c",
-        c->cli_id, c->weight, c->compress, c->frozen,
+        c->cli_id, c->info.weight, c->info.flags.u.compress, c->info.flags.u.frozen,
         c->total_cycles, c->succ_eph_gets, c->succ_pers_puts, c->succ_pers_gets,
         use_long ? ',' : '\n');
     if (use_long)
@@ -266,15 +266,15 @@ static int __tmemc_set_var(struct client *client, uint32_t subop, uint32_t arg1)
     switch (subop)
     {
     case XEN_SYSCTL_TMEM_OP_SET_WEIGHT:
-        old_weight = client->weight;
-        client->weight = arg1;
+        old_weight = client->info.weight;
+        client->info.weight = arg1;
         tmem_client_info("tmem: weight set to %d for %s=%d\n",
                         arg1, tmem_cli_id_str, cli_id);
         atomic_sub(old_weight,&tmem_global.client_weight_total);
-        atomic_add(client->weight,&tmem_global.client_weight_total);
+        atomic_add(client->info.weight,&tmem_global.client_weight_total);
         break;
     case XEN_SYSCTL_TMEM_OP_SET_COMPRESS:
-        client->compress = arg1 ? 1 : 0;
+        client->info.flags.u.compress = arg1 ? 1 : 0;
         tmem_client_info("tmem: compression %s for %s=%d\n",
             arg1 ? "enabled" : "disabled",tmem_cli_id_str,cli_id);
         break;
@@ -327,12 +327,12 @@ static int tmemc_save_subop(int cli_id, uint32_t pool_id,
     case XEN_SYSCTL_TMEM_OP_SAVE_GET_CLIENT_WEIGHT:
         if ( client == NULL )
             break;
-        rc = client->weight == -1 ? -2 : client->weight;
+        rc = client->info.weight == -1 ? -2 : client->info.weight;
         break;
     case XEN_SYSCTL_TMEM_OP_SAVE_GET_CLIENT_FLAGS:
         if ( client == NULL )
             break;
-        rc = (client->compress ? TMEM_CLIENT_COMPRESS : 0 ) |
+        rc = (client->info.flags.u.compress ? TMEM_CLIENT_COMPRESS : 0 ) |
              (client->was_frozen ? TMEM_CLIENT_FROZEN : 0 );
         break;
     case XEN_SYSCTL_TMEM_OP_SAVE_GET_POOL_FLAGS:
diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h
index 847ec35..a29a8fa 100644
--- a/xen/include/public/sysctl.h
+++ b/xen/include/public/sysctl.h
@@ -785,6 +785,20 @@ struct tmem_handle {
     xen_tmem_oid_t oid;
 };
 
+struct tmem_client {
+    uint32_t version;
+    uint32_t maxpools;
+    union {             /* See TMEM_CLIENT_[COMPRESS,FROZEN] */
+        uint32_t raw;
+        struct {
+            uint8_t frozen:1,
+                    compress:1,
+                    migrating:1;
+        } u;
+    } flags;
+    uint32_t weight;
+};
+
 struct xen_sysctl_tmem_op {
     uint32_t cmd;       /* IN: XEN_SYSCTL_TMEM_OP_* . */
     int32_t pool_id;    /* IN: 0 by default unless _SAVE_*, RESTORE_* .*/
diff --git a/xen/include/xen/tmem_xen.h b/xen/include/xen/tmem_xen.h
index 7a1bb03..c0e776c 100644
--- a/xen/include/xen/tmem_xen.h
+++ b/xen/include/xen/tmem_xen.h
@@ -293,13 +293,9 @@ struct client {
     struct list_head ephemeral_page_list;
     long eph_count, eph_count_max;
     domid_t cli_id;
-    uint32_t weight;
-    uint32_t cap;
-    bool_t compress;
-    bool_t frozen;
+    struct tmem_client info;
     bool_t shared_auth_required;
     /* For save/restore/migration. */
-    bool_t live_migrating;
     bool_t was_frozen;
     struct list_head persistent_invalidated_list;
     struct tmem_page_descriptor *cur_pgp;
-- 
2.4.11


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2016-09-28  9:42 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-28  9:42 [PATCH v1] Tmem cleanups/improvements for v4.8 Konrad Rzeszutek Wilk
2016-09-28  9:42 ` [PATCH v1 01/12] libxc/tmem/restore: Remove call to XEN_SYSCTL_TMEM_OP_SAVE_GET_VERSION Konrad Rzeszutek Wilk
2016-09-28 11:00   ` Wei Liu
2016-09-28  9:42 ` [PATCH v1 02/12] tmem: Retire XEN_SYSCTL_TMEM_OP_[SET_CAP|SAVE_GET_CLIENT_CAP] Konrad Rzeszutek Wilk
2016-09-28 11:00   ` Wei Liu
2016-09-28 15:03     ` Konrad Rzeszutek Wilk
2016-09-28 12:10   ` Jan Beulich
2016-09-30 14:04     ` Konrad Rzeszutek Wilk
2016-09-28  9:42 ` [PATCH v1 03/12] tmem: Wrap tmem dedup code with CONFIG_TMEM_DEDUP Konrad Rzeszutek Wilk
2016-09-28 12:18   ` Jan Beulich
2016-09-28  9:42 ` [PATCH v1 04/12] tmem: Wrap tmem tze code with CONFIG_TMEM_TZE Konrad Rzeszutek Wilk
2016-09-28 12:19   ` Jan Beulich
2016-09-28  9:42 ` [PATCH v1 05/12] tmem: Delete deduplication (and tze) code Konrad Rzeszutek Wilk
2016-09-28 12:34   ` Jan Beulich
2016-09-28 15:05     ` Konrad Rzeszutek Wilk
2016-09-28  9:42 ` Konrad Rzeszutek Wilk [this message]
2016-09-28 12:39   ` [PATCH v1 06/12] tmem: Move client weight, frozen, live_migrating, and compress Jan Beulich
2016-09-28  9:42 ` [PATCH v1 07/12] tmem/libxc: Squash XEN_SYSCTL_TMEM_OP_[SET|SAVE] Konrad Rzeszutek Wilk
2016-09-28 11:06   ` Wei Liu
2016-09-28 12:50   ` Jan Beulich
2016-09-28  9:42 ` [PATCH v1 08/12] tmem: Handle 'struct tmem_info' as a seperate field in the Konrad Rzeszutek Wilk
2016-09-28 11:00   ` Wei Liu
2016-09-28 12:56   ` Jan Beulich
2016-09-30 14:36     ` Konrad Rzeszutek Wilk
2016-09-30 14:56       ` Jan Beulich
2016-09-30 16:51         ` Konrad Rzeszutek Wilk
2016-09-28  9:42 ` [PATCH v1 09/12] tmem: Check version and maxpools when XEN_SYSCTL_TMEM_SET_CLIENT_INFO Konrad Rzeszutek Wilk
2016-09-28 11:00   ` Wei Liu
2016-09-28 12:58   ` Jan Beulich
2016-09-28  9:42 ` [PATCH v1 10/12] tmem: Unify XEN_SYSCTL_TMEM_OP_[[SAVE_[BEGIN|END]|RESTORE_BEGIN] Konrad Rzeszutek Wilk
2016-09-28 11:06   ` Wei Liu
2016-09-28 13:00   ` Jan Beulich
2016-09-28  9:42 ` [PATCH v1 11/12] tmem/xc_tmem_control: Rename 'arg1' to 'len' and 'arg2' to arg Konrad Rzeszutek Wilk
2016-09-28 11:07   ` Wei Liu
2016-09-28  9:42 ` [PATCH v1 12/12] tmem: Batch and squash XEN_SYSCTL_TMEM_OP_SAVE_GET_POOL_[FLAGS, NPAGES, UUID] in one sub-call: XEN_SYSCTL_TMEM_OP_GET_POOLS Konrad Rzeszutek Wilk
2016-09-28 11:07   ` Wei Liu
2016-09-28 13:11   ` Jan Beulich

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=1475055746-22401-7-git-send-email-konrad.wilk@oracle.com \
    --to=konrad.wilk@oracle.com \
    --cc=konrad@kernel.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).