[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] tmem: Move client weight, frozen, live_migrating, and compress
commit dd24b046b94efe2f97b906123f2eefb3235116b1 Author: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> AuthorDate: Fri Sep 30 10:10:42 2016 -0400 Commit: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> CommitDate: Fri Sep 30 15:26:22 2016 -0400 tmem: Move client weight, frozen, live_migrating, and compress in its own structure. This paves the way to make only one hypercall to retrieve/set this information instead of multiple ones. Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx> Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> --- xen/common/tmem.c | 38 +++++++++++++++++++------------------- xen/common/tmem_control.c | 18 +++++++++--------- xen/include/public/sysctl.h | 12 ++++++++++++ xen/include/xen/tmem_xen.h | 5 +---- 4 files changed, 41 insertions(+), 32 deletions(-) diff --git a/xen/common/tmem.c b/xen/common/tmem.c index cf5271c..95b97b8 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,7 @@ 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.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 +887,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 +1067,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 +1142,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 +1156,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 +1198,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 +1390,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 +1411,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 +1669,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 +1682,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 c493f33..728b80c 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -796,6 +796,18 @@ struct tmem_handle { xen_tmem_oid_t oid; }; +struct xen_tmem_client { + 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 1d31de8..955f3df 100644 --- a/xen/include/xen/tmem_xen.h +++ b/xen/include/xen/tmem_xen.h @@ -293,12 +293,9 @@ struct client { struct list_head ephemeral_page_list; long eph_count, eph_count_max; domid_t cli_id; - uint32_t weight; - bool_t compress; - bool_t frozen; + struct xen_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; -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |