From patchwork Wed Sep 28 09:42:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Rzeszutek Wilk X-Patchwork-Id: 9353661 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5DCBB6077A for ; Wed, 28 Sep 2016 09:44:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C83329478 for ; Wed, 28 Sep 2016 09:44:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4126B29480; Wed, 28 Sep 2016 09:44:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 60FE62947C for ; Wed, 28 Sep 2016 09:44:53 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpBO2-000067-GE; Wed, 28 Sep 2016 09:42:46 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpBO1-0008W4-GD for xen-devel@lists.xenproject.org; Wed, 28 Sep 2016 09:42:45 +0000 Received: from [85.158.137.68] by server-2.bemta-3.messagelabs.com id 89/DF-01945-2909BE75; Wed, 28 Sep 2016 09:42:42 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJLMWRWlGSWpSXmKPExsUyZ7p8oO6kCa/ DDSbs4rH4vmUykwOjx+EPV1gCGKNYM/OS8isSWDN+3vnPWHAhqOL7vF9MDYx3bLsYuTiEBCYy SbyfPY0VwvnNKHFi/3N2CGcjo0TrpAnMEM4ERoklS+4xdTFycLAJmEi8WeXYxcjJISJgKrF94 kkWEJtZwE3i8PmP7CC2sECYxPc9f1hBbBYBVYm7LRuYQWxeoJqTd3Yyg4yREJCXeHa7HsTkFH CXuH/YF6RCCKjie8NjsIkSAoYSnzcuZZ7AyLeAkWEVo3pxalFZapGuqV5SUWZ6RkluYmaOrqG BsV5uanFxYnpqTmJSsV5yfu4mRmCQ1DMwMO5gvPzV6RCjJAeTkijv5vDX4UJ8SfkplRmJxRnx RaU5qcWHGGU4OJQkeBX6gXKCRanpqRVpmTnAcIVJS3DwKInwRoKkeYsLEnOLM9MhUqcYFaXEe Y/3ASUEQBIZpXlwbbAYucQoKyXMy8jAwCDEU5BalJtZgir/ilGcg1FJmDcTZDxPZl4J3PRXQI uZgBYvPfECZHFJIkJKChh1t02e8qacmaVldVRX1G4NW+rrZz+0J1kt3COSXFI6NfqMy8bfc41 ui36RnrhB8Oq/7l0lu3fc1JNvvbrTfrrn2h/sn72DLWe+e3Z1BquZl+rD9zxbVP1Vr0j/91H/ atT6lSvv993wTU1sZzdv1Fm57Py0WpuGRN/rdWGxVZ+TJk++aqYoIfJbiaU4I9FQi7moOBEAJ awDA4wCAAA= X-Env-Sender: konrad.wilk@oracle.com X-Msg-Ref: server-9.tower-31.messagelabs.com!1475055760!15693194!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 7517 invoked from network); 28 Sep 2016 09:42:41 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-9.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 28 Sep 2016 09:42:41 -0000 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u8S9gcMM020904 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Sep 2016 09:42:38 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.13.8) with ESMTP id u8S9gbeY009190 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Sep 2016 09:42:38 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u8S9gbSt031895; Wed, 28 Sep 2016 09:42:37 GMT Received: from localhost.localdomain.com (/209.6.196.81) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 28 Sep 2016 02:42:37 -0700 From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, konrad@kernel.org Date: Wed, 28 Sep 2016 05:42:20 -0400 Message-Id: <1475055746-22401-7-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1475055746-22401-1-git-send-email-konrad.wilk@oracle.com> References: <1475055746-22401-1-git-send-email-konrad.wilk@oracle.com> X-Source-IP: userv0022.oracle.com [156.151.31.74] Cc: Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH v1 06/12] tmem: Move client weight, frozen, live_migrating, and compress X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;