From: Dan Magenheimer Subject: PING? RE: [PATCH] tmem (hypervisor-side): ABI v1 to handle long object-ids (XEN-4.0-TESTING and XEN-UNSTABLE) Date: Mon, 13 Sep 2010 08:54:24 -0700 (PDT) Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Jackson , Keir Fraser Cc: "Xen-Devel (xen-devel@lists.xensource.com)" List-Id: xen-devel@lists.xenproject.org Just returned from a week of vacation. I see these patches have not yet been applied to unstable for 4.0-testing, hypervisor or tools. Did I drop the ball on something? (sorry if I am suffering from post-vacation amnesia). Thanks, Dan > -----Original Message----- > From: Dan Magenheimer > Sent: Friday, September 03, 2010 9:48 AM > To: Xen-Devel (xen-devel@lists.xensource.com) > Cc: Ian Jackson; Keir Fraser > Subject: [PATCH] tmem (hypervisor-side): ABI v1 to handle long object- > ids (XEN-4.0-TESTING and XEN-UNSTABLE) >=20 > [PATCH] tmem (hypervisor-side): move to new ABI version to handle > long object-ids >=20 > Please apply patch to both xen-4.0-testing and xen-unstable > (same patch applies cleanly to both). >=20 > (Note to Keir/Ian: These patches should be applied > together, but I'm not clear on how to submit patches > that cross MAINTAINERS boundaries as this one does.) >=20 > After a great deal of discussion and review with linux > kernel developers, it appears there are "next-generation" > filesystems (such as btrfs, xfs, Lustre) that will not > be able to use tmem due to an ABI limitation... a field > that represents a unique file identifier is 64-bits in > the tmem ABI and may need to be as large as 192-bits. > So to support these guest filesystems, the tmem ABI must be > revised, from "v0" to "v1". >=20 > I *think* it is still the case that tmem is experimental > and is not used anywhere yet in production. >=20 > The tmem ABI is designed to support multiple revisions, > so the Xen tmem implementation could be updated to > handle both v0 and v1. However this is a bit > messy and would require data structures for both v0 > and v1 to appear in public Xen header files. >=20 > I am inclined to update the Xen tmem implementation > to only support v1 and gracefully fail v0. This would > result in only a performance loss (as if tmem were > disabled) for newly launched tmem-v0-enabled guests, > but live-migration between old tmem-v0 Xen and new > tmem-v1 Xen machines would fail, and saved tmem-v0 > guests will not be able to be restored on a tmem-v1 > Xen machine. I would plan to update both pre-4.0.2 > and unstable (future 4.1) to only support v1. >=20 > I believe these restrictions are reasonable at this > point in the tmem lifecycle, though they may not > be reasonable in the near future; should the tmem > ABI need to be revised from v1 to v2, I understand > backwards compatibility will be required. >=20 > Signed-off-by: Dan Magenheimer >=20 > diff -r 07ac5459b250 xen/common/tmem.c > --- a/xen/common/tmem.c=09Wed Aug 25 09:23:31 2010 +0100 > +++ b/xen/common/tmem.c=09Thu Sep 02 16:43:33 2010 -0600 > @@ -26,7 +26,7 @@ > #define EXPORT /* indicates code other modules are dependent upon */ > #define FORWARD >=20 > -#define TMEM_SPEC_VERSION 0 > +#define TMEM_SPEC_VERSION 1 >=20 > /************ INTERFACE TO TMEM HOST-DEPENDENT (tmh) CODE > ************/ >=20 > @@ -149,14 +149,13 @@ typedef struct share_list sharelist_t; >=20 > #define OBJ_HASH_BUCKETS 256 /* must be power of two */ > #define OBJ_HASH_BUCKETS_MASK (OBJ_HASH_BUCKETS-1) > -#define OBJ_HASH(_oid) (tmh_hash(_oid, BITS_PER_LONG) & > OBJ_HASH_BUCKETS_MASK) >=20 > struct tm_pool { > bool_t shared; > bool_t persistent; > bool_t is_dying; > int pageshift; /* 0 =3D=3D 2**12 */ > - struct list_head pool_list; /* FIXME do we need this anymore? */ > + struct list_head pool_list; > client_t *client; > uint64_t uuid[2]; /* 0 for private, non-zero for shared */ > uint32_t pool_id; > @@ -189,9 +188,14 @@ typedef struct tm_pool pool_t; > #define is_shared(_p) (_p->shared) > #define is_private(_p) (!(_p->shared)) >=20 > +struct oid { > + uint64_t oid[3]; > +}; > +typedef struct oid OID; > + > struct tmem_object_root { > DECL_SENTINEL > - uint64_t oid; > + OID oid; > struct rb_node rb_tree_node; /* protected by pool->pool_rwlock */ > unsigned long objnode_count; /* atomicity depends on obj_spinlock > */ > long pgp_count; /* atomicity depends on obj_spinlock */ > @@ -217,12 +221,14 @@ struct tmem_page_descriptor { > struct list_head client_inv_pages; > }; > union { > - struct list_head client_eph_pages; > - struct list_head pool_pers_pages; > - }; > - union { > - obj_t *obj; > - uint64_t inv_oid; /* used for invalid list only */ > + struct { > + union { > + struct list_head client_eph_pages; > + struct list_head pool_pers_pages; > + }; > + obj_t *obj; > + } us; > + OID inv_oid; /* used for invalid list only */ > }; > pagesize_t size; /* 0 =3D=3D PAGE_SIZE (pfp), -1 =3D=3D data invalid= , > else compressed data (cdata) */ > @@ -467,9 +473,9 @@ static NOINLINE int pcd_associate(pgp_t >=20 > if ( !tmh_dedup_enabled() ) > return 0; > - ASSERT(pgp->obj !=3D NULL); > - ASSERT(pgp->obj->pool !=3D NULL); > - ASSERT(!pgp->obj->pool->persistent); > + ASSERT(pgp->us.obj !=3D NULL); > + ASSERT(pgp->us.obj->pool !=3D NULL); > + ASSERT(!pgp->us.obj->pool->persistent); > if ( cdata =3D=3D NULL ) > { > ASSERT(pgp->pfp !=3D NULL); > @@ -528,7 +534,7 @@ static NOINLINE int pcd_associate(pgp_t > /* match! if not compressed, free the no-longer-needed > page */ > /* but if compressed, data is assumed static so don't > free! */ > if ( cdata =3D=3D NULL ) > - tmem_page_free(pgp->obj->pool,pgp->pfp); > + tmem_page_free(pgp->us.obj->pool,pgp->pfp); > deduped_puts++; > goto match; > } > @@ -540,7 +546,7 @@ static NOINLINE int pcd_associate(pgp_t > ret =3D -ENOMEM; > goto unlock; > } else if ( cdata !=3D NULL ) { > - if ( (pcd->cdata =3D tmem_malloc_bytes(csize,pgp->obj->pool)) = =3D=3D > NULL ) > + if ( (pcd->cdata =3D tmem_malloc_bytes(csize,pgp->us.obj->pool)) > =3D=3D NULL ) > { > tmem_free(pcd,sizeof(pcd_t),NULL); > ret =3D -ENOMEM; > @@ -561,11 +567,11 @@ static NOINLINE int pcd_associate(pgp_t > pcd->size =3D 0; > pcd->tze =3D NULL; > } else if ( pfp_size < PAGE_SIZE && > - ((pcd->tze =3D tmem_malloc_bytes(pfp_size,pgp->obj->pool)) !=3D > NULL) ) { > + ((pcd->tze =3D tmem_malloc_bytes(pfp_size,pgp->us.obj->pool)) > !=3D NULL) ) { > tmh_tze_copy_from_pfp(pcd->tze,pgp->pfp,pfp_size); > pcd->size =3D pfp_size; > pcd_tot_tze_size +=3D pfp_size; > - tmem_page_free(pgp->obj->pool,pgp->pfp); > + tmem_page_free(pgp->us.obj->pool,pgp->pfp); > } else { > pcd->pfp =3D pgp->pfp; > pcd->size =3D PAGE_SIZE; > @@ -602,9 +608,9 @@ static NOINLINE pgp_t *pgp_alloc(obj_t * > pool =3D obj->pool; > if ( (pgp =3D tmem_malloc(pgp_t, pool)) =3D=3D NULL ) > return NULL; > - pgp->obj =3D obj; > + pgp->us.obj =3D obj; > INIT_LIST_HEAD(&pgp->global_eph_pages); > - INIT_LIST_HEAD(&pgp->client_eph_pages); > + INIT_LIST_HEAD(&pgp->us.client_eph_pages); > pgp->pfp =3D NULL; > if ( tmh_dedup_enabled() ) > { > @@ -642,7 +648,7 @@ static NOINLINE void pgp_free_data(pgp_t > else if ( pgp_size ) > tmem_free(pgp->cdata,pgp_size,pool); > else > - tmem_page_free(pgp->obj->pool,pgp->pfp); > + tmem_page_free(pgp->us.obj->pool,pgp->pfp); > if ( pool !=3D NULL && pgp_size ) > { > pool->client->compressed_pages--; > @@ -657,18 +663,18 @@ static NOINLINE void pgp_free(pgp_t *pgp > pool_t *pool =3D NULL; >=20 > ASSERT_SENTINEL(pgp,PGD); > - ASSERT(pgp->obj !=3D NULL); > - ASSERT_SENTINEL(pgp->obj,OBJ); > - ASSERT_SENTINEL(pgp->obj->pool,POOL); > - ASSERT(pgp->obj->pool->client !=3D NULL); > + ASSERT(pgp->us.obj !=3D NULL); > + ASSERT_SENTINEL(pgp->us.obj,OBJ); > + ASSERT_SENTINEL(pgp->us.obj->pool,POOL); > + ASSERT(pgp->us.obj->pool->client !=3D NULL); > if ( from_delete ) > - ASSERT(pgp_lookup_in_obj(pgp->obj,pgp->index) =3D=3D NULL); > - ASSERT(pgp->obj->pool !=3D NULL); > - pool =3D pgp->obj->pool; > + ASSERT(pgp_lookup_in_obj(pgp->us.obj,pgp->index) =3D=3D NULL); > + ASSERT(pgp->us.obj->pool !=3D NULL); > + pool =3D pgp->us.obj->pool; > if ( is_ephemeral(pool) ) > { > ASSERT(list_empty(&pgp->global_eph_pages)); > - ASSERT(list_empty(&pgp->client_eph_pages)); > + ASSERT(list_empty(&pgp->us.client_eph_pages)); > } > pgp_free_data(pgp, pool); > atomic_dec_and_assert(global_pgp_count); > @@ -676,12 +682,12 @@ static NOINLINE void pgp_free(pgp_t *pgp > pgp->size =3D -1; > if ( is_persistent(pool) && pool->client->live_migrating ) > { > - pgp->inv_oid =3D pgp->obj->oid; > + pgp->inv_oid =3D pgp->us.obj->oid; > pgp->pool_id =3D pool->pool_id; > return; > } > INVERT_SENTINEL(pgp,PGD); > - pgp->obj =3D NULL; > + pgp->us.obj =3D NULL; > pgp->index =3D -1; > tmem_free(pgp,sizeof(pgp_t),pool); > } > @@ -693,7 +699,7 @@ static NOINLINE void pgp_free_from_inv_l > ASSERT_SENTINEL(pool,POOL); > ASSERT_SENTINEL(pgp,PGD); > INVERT_SENTINEL(pgp,PGD); > - pgp->obj =3D NULL; > + pgp->us.obj =3D NULL; > pgp->index =3D -1; > tmem_free(pgp,sizeof(pgp_t),pool); > } > @@ -704,18 +710,18 @@ static void pgp_delist(pgp_t *pgp, bool_ > client_t *client; >=20 > ASSERT(pgp !=3D NULL); > - ASSERT(pgp->obj !=3D NULL); > - ASSERT(pgp->obj->pool !=3D NULL); > - client =3D pgp->obj->pool->client; > + ASSERT(pgp->us.obj !=3D NULL); > + ASSERT(pgp->us.obj->pool !=3D NULL); > + client =3D pgp->us.obj->pool->client; > ASSERT(client !=3D NULL); > - if ( is_ephemeral(pgp->obj->pool) ) > + if ( is_ephemeral(pgp->us.obj->pool) ) > { > if ( !no_eph_lock ) > tmem_spin_lock(&eph_lists_spinlock); > - if ( !list_empty(&pgp->client_eph_pages) ) > + if ( !list_empty(&pgp->us.client_eph_pages) ) > client->eph_count--; > ASSERT(client->eph_count >=3D 0); > - list_del_init(&pgp->client_eph_pages); > + list_del_init(&pgp->us.client_eph_pages); > if ( !list_empty(&pgp->global_eph_pages) ) > global_eph_count--; > ASSERT(global_eph_count >=3D 0); > @@ -728,12 +734,12 @@ static void pgp_delist(pgp_t *pgp, bool_ > tmem_spin_lock(&pers_lists_spinlock); > list_add_tail(&pgp->client_inv_pages, > &client->persistent_invalidated_list); > - if ( pgp !=3D pgp->obj->pool->cur_pgp ) > - list_del_init(&pgp->pool_pers_pages); > + if ( pgp !=3D pgp->us.obj->pool->cur_pgp ) > + list_del_init(&pgp->us.pool_pers_pages); > tmem_spin_unlock(&pers_lists_spinlock); > } else { > tmem_spin_lock(&pers_lists_spinlock); > - list_del_init(&pgp->pool_pers_pages); > + list_del_init(&pgp->us.pool_pers_pages); > tmem_spin_unlock(&pers_lists_spinlock); > } > } > @@ -745,10 +751,10 @@ static NOINLINE void pgp_delete(pgp_t *p > uint64_t life; >=20 > ASSERT(pgp !=3D NULL); > - ASSERT(pgp->obj !=3D NULL); > - ASSERT(pgp->obj->pool !=3D NULL); > + ASSERT(pgp->us.obj !=3D NULL); > + ASSERT(pgp->us.obj->pool !=3D NULL); > life =3D get_cycles() - pgp->timestamp; > - pgp->obj->pool->sum_life_cycles +=3D life; > + pgp->us.obj->pool->sum_life_cycles +=3D life; > pgp_delist(pgp, no_eph_lock); > pgp_free(pgp,1); > } > @@ -758,11 +764,11 @@ static NOINLINE void pgp_destroy(void *v > { > pgp_t *pgp =3D (pgp_t *)v; >=20 > - ASSERT_SPINLOCK(&pgp->obj->obj_spinlock); > + ASSERT_SPINLOCK(&pgp->us.obj->obj_spinlock); > pgp_delist(pgp,0); > - ASSERT(pgp->obj !=3D NULL); > - pgp->obj->pgp_count--; > - ASSERT(pgp->obj->pgp_count >=3D 0); > + ASSERT(pgp->us.obj !=3D NULL); > + pgp->us.obj->pgp_count--; > + ASSERT(pgp->us.obj->pgp_count >=3D 0); > pgp_free(pgp,0); > } >=20 > @@ -849,37 +855,74 @@ static void rtn_free(rtn_t *rtn) >=20 > /************ POOL OBJECT COLLECTION MANIPULATION ROUTINES > *******************/ >=20 > +int oid_compare(OID *left, OID *right) > +{ > + if ( left->oid[2] =3D=3D right->oid[2] ) > + { > + if ( left->oid[1] =3D=3D right->oid[1] ) > + { > + if ( left->oid[0] =3D=3D right->oid[0] ) > + return 0; > + else if ( left->oid[0] < left->oid[0] ) > + return -1; > + else > + return 1; > + } > + else if ( left->oid[1] < left->oid[1] ) > + return -1; > + else > + return 1; > + } > + else if ( left->oid[2] < left->oid[2] ) > + return -1; > + else > + return 1; > +} > + > +void oid_set_invalid(OID *oidp) > +{ > + oidp->oid[0] =3D oidp->oid[1] =3D oidp->oid[2] =3D -1UL; > +} > + > +unsigned oid_hash(OID *oidp) > +{ > + return (tmh_hash(oidp->oid[0] ^ oidp->oid[1] ^ oidp->oid[2], > + BITS_PER_LONG) & OBJ_HASH_BUCKETS_MASK); > +} > + > /* searches for object=3D=3Doid in pool, returns locked object if found = */ > -static NOINLINE obj_t * obj_find(pool_t *pool, uint64_t oid) > +static NOINLINE obj_t * obj_find(pool_t *pool, OID *oidp) > { > struct rb_node *node; > obj_t *obj; >=20 > restart_find: > tmem_read_lock(&pool->pool_rwlock); > - node =3D pool->obj_rb_root[OBJ_HASH(oid)].rb_node; > + node =3D pool->obj_rb_root[oid_hash(oidp)].rb_node; > while ( node ) > { > obj =3D container_of(node, obj_t, rb_tree_node); > - if ( obj->oid =3D=3D oid ) > + switch ( oid_compare(&obj->oid, oidp) ) > { > - if ( tmh_lock_all ) > - obj->no_evict =3D 1; > - else > - { > - if ( !tmem_spin_trylock(&obj->obj_spinlock) ) > + case 0: /* equal */ > + if ( tmh_lock_all ) > + obj->no_evict =3D 1; > + else > { > + if ( !tmem_spin_trylock(&obj->obj_spinlock) ) > + { > + tmem_read_unlock(&pool->pool_rwlock); > + goto restart_find; > + } > tmem_read_unlock(&pool->pool_rwlock); > - goto restart_find; > } > - tmem_read_unlock(&pool->pool_rwlock); > - } > - return obj; > + return obj; > + case -1: > + node =3D node->rb_left; > + break; > + case 1: > + node =3D node->rb_right; > } > - else if ( oid < obj->oid ) > - node =3D node->rb_left; > - else > - node =3D node->rb_right; > } > tmem_read_unlock(&pool->pool_rwlock); > return NULL; > @@ -889,7 +932,7 @@ static NOINLINE void obj_free(obj_t *obj > static NOINLINE void obj_free(obj_t *obj, int no_rebalance) > { > pool_t *pool; > - uint64_t old_oid; > + OID old_oid; >=20 > ASSERT_SPINLOCK(&obj->obj_spinlock); > ASSERT(obj !=3D NULL); > @@ -908,12 +951,12 @@ static NOINLINE void obj_free(obj_t *obj > INVERT_SENTINEL(obj,OBJ); > obj->pool =3D NULL; > old_oid =3D obj->oid; > - obj->oid =3D -1; > + oid_set_invalid(&obj->oid); > obj->last_client =3D 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[OBJ_HASH(old_oid)]); > + rb_erase(&obj->rb_tree_node,&pool- > >obj_rb_root[oid_hash(&old_oid)]); > tmem_free(obj,sizeof(obj_t),pool); > } >=20 > @@ -927,12 +970,17 @@ static NOINLINE int obj_rb_insert(struct > { > this =3D container_of(*new, obj_t, rb_tree_node); > parent =3D *new; > - if ( obj->oid < this->oid ) > - new =3D &((*new)->rb_left); > - else if ( obj->oid > this->oid ) > - new =3D &((*new)->rb_right); > - else > - return 0; > + switch ( oid_compare(&obj->oid, &this->oid) ) > + { > + case 0: > + return 0; > + case -1: > + new =3D &((*new)->rb_left); > + break; > + case 1: > + new =3D &((*new)->rb_right); > + break; > + } > } > rb_link_node(&obj->rb_tree_node, parent, new); > rb_insert_color(&obj->rb_tree_node, root); > @@ -943,7 +991,7 @@ static NOINLINE int obj_rb_insert(struct > * allocate, initialize, and insert an tmem_object_root > * (should be called only if find failed) > */ > -static NOINLINE obj_t * obj_new(pool_t *pool, uint64_t oid) > +static NOINLINE obj_t * obj_new(pool_t *pool, OID *oidp) > { > obj_t *obj; >=20 > @@ -958,13 +1006,13 @@ static NOINLINE obj_t * obj_new(pool_t * > INIT_RADIX_TREE(&obj->tree_root,0); > spin_lock_init(&obj->obj_spinlock); > obj->pool =3D pool; > - obj->oid =3D oid; > + obj->oid =3D *oidp; > obj->objnode_count =3D 0; > obj->pgp_count =3D 0; > obj->last_client =3D CLI_ID_NULL; > SET_SENTINEL(obj,OBJ); > tmem_spin_lock(&obj->obj_spinlock); > - obj_rb_insert(&pool->obj_rb_root[OBJ_HASH(oid)], obj); > + obj_rb_insert(&pool->obj_rb_root[oid_hash(oidp)], obj); > obj->no_evict =3D 1; > ASSERT_SPINLOCK(&obj->obj_spinlock); > return obj; > @@ -1256,7 +1304,7 @@ static void client_freeze(client_t *clie >=20 > static bool_t tmem_try_to_evict_pgp(pgp_t *pgp, bool_t > *hold_pool_rwlock) > { > - obj_t *obj =3D pgp->obj; > + obj_t *obj =3D pgp->us.obj; > pool_t *pool =3D obj->pool; > client_t *client =3D pool->client; > uint16_t firstbyte =3D pgp->firstbyte; > @@ -1280,8 +1328,8 @@ static bool_t tmem_try_to_evict_pgp(pgp_ > pgp->eviction_attempted++; > list_del(&pgp->global_eph_pages); > list_add_tail(&pgp- > >global_eph_pages,&global_ephemeral_page_list); > - list_del(&pgp->client_eph_pages); > - list_add_tail(&pgp->client_eph_pages,&client- > >ephemeral_page_list); > + list_del(&pgp->us.client_eph_pages); > + list_add_tail(&pgp->us.client_eph_pages,&client- > >ephemeral_page_list); > goto pcd_unlock; > } > } > @@ -1314,7 +1362,7 @@ static int tmem_evict(void) > if ( (client !=3D NULL) && client_over_quota(client) && > !list_empty(&client->ephemeral_page_list) ) > { > - list_for_each_entry_safe(pgp,pgp2,&client- > >ephemeral_page_list,client_eph_pages) > + list_for_each_entry_safe(pgp,pgp2,&client- > >ephemeral_page_list,us.client_eph_pages) > if ( tmem_try_to_evict_pgp(pgp,&hold_pool_rwlock) ) > goto found; > } else if ( list_empty(&global_ephemeral_page_list) ) { > @@ -1331,7 +1379,7 @@ found: > found: > ASSERT(pgp !=3D NULL); > ASSERT_SENTINEL(pgp,PGD); > - obj =3D pgp->obj; > + obj =3D pgp->us.obj; > ASSERT(obj !=3D NULL); > ASSERT(obj->no_evict =3D=3D 0); > ASSERT(obj->pool !=3D NULL); > @@ -1407,16 +1455,16 @@ static NOINLINE int do_tmem_put_compress > DECL_LOCAL_CYC_COUNTER(compress); >=20 > ASSERT(pgp !=3D NULL); > - ASSERT(pgp->obj !=3D NULL); > - ASSERT_SPINLOCK(&pgp->obj->obj_spinlock); > - ASSERT(pgp->obj->pool !=3D NULL); > - ASSERT(pgp->obj->pool->client !=3D NULL); > + ASSERT(pgp->us.obj !=3D NULL); > + ASSERT_SPINLOCK(&pgp->us.obj->obj_spinlock); > + ASSERT(pgp->us.obj->pool !=3D NULL); > + ASSERT(pgp->us.obj->pool->client !=3D NULL); > #ifdef __i386__ > return -ENOMEM; > #endif >=20 > if ( pgp->pfp !=3D NULL ) > - pgp_free_data(pgp, pgp->obj->pool); > + pgp_free_data(pgp, pgp->us.obj->pool); > START_CYC_COUNTER(compress); > ret =3D tmh_compress_from_client(cmfn, &dst, &size, cva); > if ( (ret =3D=3D -EFAULT) || (ret =3D=3D 0) ) > @@ -1424,10 +1472,10 @@ static NOINLINE int do_tmem_put_compress > else if ( (size =3D=3D 0) || (size >=3D tmem_subpage_maxsize()) ) { > ret =3D 0; > goto out; > - } else if ( tmh_dedup_enabled() && !is_persistent(pgp->obj->pool) > ) { > + } else if ( tmh_dedup_enabled() && !is_persistent(pgp->us.obj- > >pool) ) { > if ( (ret =3D pcd_associate(pgp,dst,size)) =3D=3D -ENOMEM ) > goto out; > - } else if ( (p =3D tmem_malloc_bytes(size,pgp->obj->pool)) =3D=3D NU= LL ) > { > + } else if ( (p =3D tmem_malloc_bytes(size,pgp->us.obj->pool)) =3D=3D > NULL ) { > ret =3D -ENOMEM; > goto out; > } else { > @@ -1435,8 +1483,8 @@ static NOINLINE int do_tmem_put_compress > pgp->cdata =3D p; > } > pgp->size =3D size; > - pgp->obj->pool->client->compressed_pages++; > - pgp->obj->pool->client->compressed_sum_size +=3D size; > + pgp->us.obj->pool->client->compressed_pages++; > + pgp->us.obj->pool->client->compressed_sum_size +=3D size; > ret =3D 1; >=20 > out: > @@ -1456,7 +1504,7 @@ static NOINLINE int do_tmem_dup_put(pgp_ > ASSERT(pgp !=3D NULL); > ASSERT(pgp->pfp !=3D NULL); > ASSERT(pgp->size !=3D -1); > - obj =3D pgp->obj; > + obj =3D pgp->us.obj; > ASSERT_SPINLOCK(&obj->obj_spinlock); > ASSERT(obj !=3D NULL); > pool =3D obj->pool; > @@ -1535,7 +1583,7 @@ cleanup: >=20 >=20 > static NOINLINE int do_tmem_put(pool_t *pool, > - uint64_t oid, uint32_t index, > + OID *oidp, uint32_t index, > tmem_cli_mfn_t cmfn, pagesize_t tmem_offset, > pagesize_t pfn_offset, pagesize_t len, void *cva) > { > @@ -1547,7 +1595,7 @@ static NOINLINE int do_tmem_put(pool_t * > ASSERT(pool !=3D NULL); > pool->puts++; > /* does page already exist (dup)? if so, handle specially */ > - if ( (obj =3D objfound =3D obj_find(pool,oid)) !=3D NULL ) > + if ( (obj =3D objfound =3D obj_find(pool,oidp)) !=3D NULL ) > { > ASSERT_SPINLOCK(&objfound->obj_spinlock); > if ((pgp =3D pgp_lookup_in_obj(objfound, index)) !=3D NULL) > @@ -1561,7 +1609,7 @@ static NOINLINE int do_tmem_put(pool_t * > if ( (objfound =3D=3D NULL) ) > { > tmem_write_lock(&pool->pool_rwlock); > - if ( (obj =3D objnew =3D obj_new(pool,oid)) =3D=3D NULL ) > + if ( (obj =3D objnew =3D obj_new(pool,oidp)) =3D=3D NULL ) > { > tmem_write_unlock(&pool->pool_rwlock); > return -ENOMEM; > @@ -1627,14 +1675,14 @@ insert_page: > &global_ephemeral_page_list); > if (++global_eph_count > global_eph_count_max) > global_eph_count_max =3D global_eph_count; > - list_add_tail(&pgp->client_eph_pages, > + list_add_tail(&pgp->us.client_eph_pages, > &client->ephemeral_page_list); > if (++client->eph_count > client->eph_count_max) > client->eph_count_max =3D client->eph_count; > tmem_spin_unlock(&eph_lists_spinlock); > } else { /* is_persistent */ > tmem_spin_lock(&pers_lists_spinlock); > - list_add_tail(&pgp->pool_pers_pages, > + list_add_tail(&pgp->us.pool_pers_pages, > &pool->persistent_page_list); > tmem_spin_unlock(&pers_lists_spinlock); > } > @@ -1678,7 +1726,7 @@ free: > return ret; > } >=20 > -static NOINLINE int do_tmem_get(pool_t *pool, uint64_t oid, uint32_t > index, > +static NOINLINE int do_tmem_get(pool_t *pool, OID *oidp, uint32_t > index, > tmem_cli_mfn_t cmfn, pagesize_t tmem_offset, > pagesize_t pfn_offset, pagesize_t len, void *cva) > { > @@ -1691,7 +1739,7 @@ static NOINLINE int do_tmem_get(pool_t * > return -EEMPTY; >=20 > pool->gets++; > - obj =3D obj_find(pool,oid); > + obj =3D obj_find(pool,oidp); > if ( obj =3D=3D NULL ) > return 0; >=20 > @@ -1737,8 +1785,8 @@ static NOINLINE int do_tmem_get(pool_t * > tmem_spin_lock(&eph_lists_spinlock); > list_del(&pgp->global_eph_pages); > list_add_tail(&pgp- > >global_eph_pages,&global_ephemeral_page_list); > - list_del(&pgp->client_eph_pages); > - list_add_tail(&pgp->client_eph_pages,&client- > >ephemeral_page_list); > + list_del(&pgp->us.client_eph_pages); > + list_add_tail(&pgp->us.client_eph_pages,&client- > >ephemeral_page_list); > tmem_spin_unlock(&eph_lists_spinlock); > ASSERT(obj !=3D NULL); > obj->last_client =3D tmh_get_cli_id_from_current(); > @@ -1763,13 +1811,13 @@ bad_copy: >=20 > } >=20 > -static NOINLINE int do_tmem_flush_page(pool_t *pool, uint64_t oid, > uint32_t index) > +static NOINLINE int do_tmem_flush_page(pool_t *pool, OID *oidp, > uint32_t index) > { > obj_t *obj; > pgp_t *pgp; >=20 > pool->flushs++; > - obj =3D obj_find(pool,oid); > + obj =3D obj_find(pool,oidp); > if ( obj =3D=3D NULL ) > goto out; > pgp =3D pgp_delete_from_obj(obj, index); > @@ -1798,12 +1846,12 @@ out: > return 1; > } >=20 > -static NOINLINE int do_tmem_flush_object(pool_t *pool, uint64_t oid) > +static NOINLINE int do_tmem_flush_object(pool_t *pool, OID *oidp) > { > obj_t *obj; >=20 > pool->flush_objs++; > - obj =3D obj_find(pool,oid); > + obj =3D obj_find(pool,oidp); > if ( obj =3D=3D NULL ) > goto out; > tmem_write_lock(&pool->pool_rwlock); > @@ -1863,6 +1911,16 @@ static NOINLINE int do_tmem_new_pool(cli > if ( pagebits !=3D (PAGE_SHIFT - 12) ) > { > printk("failed... unsupported pagesize > %d\n",1<<(pagebits+12)); > + return -EPERM; > + } > + if ( flags & TMEM_POOL_PRECOMPRESSED ) > + { > + printk("failed... precompression flag set but unsupported\n"); > + return -EPERM; > + } > + if ( flags & TMEM_POOL_RESERVED_BITS ) > + { > + printk("failed... reserved bits must be zero\n"); > return -EPERM; > } > if ( (pool =3D pool_alloc()) =3D=3D NULL ) > @@ -2369,6 +2427,7 @@ static NOINLINE int tmemc_save_get_next_ > pool_t *pool =3D (client =3D=3D NULL || pool_id >=3D MAX_POOLS_PER_D= OMAIN) > ? NULL : client->pools[pool_id]; > pgp_t *pgp; > + OID oid; > int ret =3D 0; > struct tmem_handle *h; > unsigned int pagesize =3D 1 << (pool->pageshift+12); > @@ -2389,22 +2448,23 @@ static NOINLINE int tmemc_save_get_next_ > { > /* process the first one */ > pool->cur_pgp =3D pgp =3D list_entry((&pool- > >persistent_page_list)->next, > - pgp_t,pool_pers_pages); > - } else if ( list_is_last(&pool->cur_pgp->pool_pers_pages, > + pgp_t,us.pool_pers_pages); > + } else if ( list_is_last(&pool->cur_pgp->us.pool_pers_pages, > &pool->persistent_page_list) ) > { > /* already processed the last one in the list */ > ret =3D -1; > goto out; > } > - pgp =3D list_entry((&pool->cur_pgp->pool_pers_pages)->next, > - pgp_t,pool_pers_pages); > + pgp =3D list_entry((&pool->cur_pgp->us.pool_pers_pages)->next, > + pgp_t,us.pool_pers_pages); > pool->cur_pgp =3D pgp; > + oid =3D pgp->us.obj->oid; > h =3D (struct tmem_handle *)buf.p; > - h->oid =3D pgp->obj->oid; > + *(OID *)&h->oid[0] =3D oid; > h->index =3D pgp->index; > buf.p =3D (void *)(h+1); > - ret =3D do_tmem_get(pool, h->oid, h->index,0,0,0,pagesize,buf.p); > + ret =3D do_tmem_get(pool, &oid, h->index,0,0,0,pagesize,buf.p); >=20 > out: > tmem_spin_unlock(&pers_lists_spinlock); > @@ -2444,7 +2504,7 @@ static NOINLINE int tmemc_save_get_next_ > } > h =3D (struct tmem_handle *)buf.p; > h->pool_id =3D pgp->pool_id; > - h->oid =3D pgp->inv_oid; > + *(OID *)&h->oid =3D pgp->inv_oid; > h->index =3D pgp->index; > ret =3D 1; > out: > @@ -2452,7 +2512,7 @@ out: > return ret; > } >=20 > -static int tmemc_restore_put_page(int cli_id, int pool_id, uint64_t > oid, > +static int tmemc_restore_put_page(int cli_id, int pool_id, OID *oidp, > uint32_t index, tmem_cli_va_t buf, uint32_t > bufsize) > { > client_t *client =3D tmh_client_from_cli_id(cli_id); > @@ -2461,10 +2521,10 @@ static int tmemc_restore_put_page(int cl >=20 > if ( pool =3D=3D NULL ) > return -1; > - return do_tmem_put(pool,oid,index,0,0,0,bufsize,buf.p); > + return do_tmem_put(pool,oidp,index,0,0,0,bufsize,buf.p); > } >=20 > -static int tmemc_restore_flush_page(int cli_id, int pool_id, uint64_t > oid, > +static int tmemc_restore_flush_page(int cli_id, int pool_id, OID > *oidp, > uint32_t index) > { > client_t *client =3D tmh_client_from_cli_id(cli_id); > @@ -2473,7 +2533,7 @@ static int tmemc_restore_flush_page(int >=20 > if ( pool =3D=3D NULL ) > return -1; > - return do_tmem_flush_page(pool,oid,index); > + return do_tmem_flush_page(pool,oidp,index); > } >=20 > static NOINLINE int do_tmem_control(struct tmem_op *op) > @@ -2481,6 +2541,7 @@ static NOINLINE int do_tmem_control(stru > int ret; > uint32_t pool_id =3D op->pool_id; > uint32_t subop =3D op->u.ctrl.subop; > + OID *oidp =3D (OID *)(&op->u.ctrl.oid[0]); >=20 > if (!tmh_current_is_privileged()) > { > @@ -2533,12 +2594,12 @@ static NOINLINE int do_tmem_control(stru > break; > case TMEMC_RESTORE_PUT_PAGE: > ret =3D tmemc_restore_put_page(op->u.ctrl.cli_id,pool_id, > - op->u.ctrl.arg3, op->u.ctrl.arg2, > + oidp, op->u.ctrl.arg2, > op->u.ctrl.buf, op->u.ctrl.arg1); > break; > case TMEMC_RESTORE_FLUSH_PAGE: > ret =3D tmemc_restore_flush_page(op->u.ctrl.cli_id,pool_id, > - op->u.ctrl.arg3, op- > >u.ctrl.arg2); > + oidp, op->u.ctrl.arg2); > break; > default: > ret =3D -1; > @@ -2553,6 +2614,7 @@ EXPORT long do_tmem_op(tmem_cli_op_t uop > struct tmem_op op; > client_t *client =3D tmh_client_from_current(); > pool_t *pool =3D NULL; > + OID *oidp; > int rc =3D 0; > bool_t succ_get =3D 0, succ_put =3D 0; > bool_t non_succ_get =3D 0, non_succ_put =3D 0; > @@ -2656,6 +2718,7 @@ EXPORT long do_tmem_op(tmem_cli_op_t uop > ASSERT_SENTINEL(pool,POOL); > } >=20 > + oidp =3D (OID *)&op.u.gen.oid[0]; > switch ( op.cmd ) > { > case TMEM_NEW_POOL: > @@ -2664,28 +2727,28 @@ EXPORT long do_tmem_op(tmem_cli_op_t uop > break; > case TMEM_NEW_PAGE: > tmem_ensure_avail_pages(); > - rc =3D do_tmem_put(pool, op.u.gen.object, > + rc =3D do_tmem_put(pool, oidp, > op.u.gen.index, op.u.gen.cmfn, 0, 0, 0, > NULL); > break; > case TMEM_PUT_PAGE: > tmem_ensure_avail_pages(); > - rc =3D do_tmem_put(pool, op.u.gen.object, > + rc =3D do_tmem_put(pool, oidp, > op.u.gen.index, op.u.gen.cmfn, 0, 0, PAGE_SIZE, > NULL); > if (rc =3D=3D 1) succ_put =3D 1; > else non_succ_put =3D 1; > break; > case TMEM_GET_PAGE: > - rc =3D do_tmem_get(pool, op.u.gen.object, op.u.gen.index, > op.u.gen.cmfn, > + rc =3D do_tmem_get(pool, oidp, op.u.gen.index, op.u.gen.cmfn, > 0, 0, PAGE_SIZE, 0); > if (rc =3D=3D 1) succ_get =3D 1; > else non_succ_get =3D 1; > break; > case TMEM_FLUSH_PAGE: > flush =3D 1; > - rc =3D do_tmem_flush_page(pool, op.u.gen.object, > op.u.gen.index); > + rc =3D do_tmem_flush_page(pool, oidp, op.u.gen.index); > break; > case TMEM_FLUSH_OBJECT: > - rc =3D do_tmem_flush_object(pool, op.u.gen.object); > + rc =3D do_tmem_flush_object(pool, oidp); > flush_obj =3D 1; > break; > case TMEM_DESTROY_POOL: > @@ -2693,12 +2756,12 @@ EXPORT long do_tmem_op(tmem_cli_op_t uop > rc =3D do_tmem_destroy_pool(op.pool_id); > break; > case TMEM_READ: > - rc =3D do_tmem_get(pool, op.u.gen.object, op.u.gen.index, > op.u.gen.cmfn, > + rc =3D do_tmem_get(pool, oidp, op.u.gen.index, op.u.gen.cmfn, > op.u.gen.tmem_offset, op.u.gen.pfn_offset, > op.u.gen.len,0); > break; > case TMEM_WRITE: > - rc =3D do_tmem_put(pool, op.u.gen.object, > + rc =3D do_tmem_put(pool, oidp, > op.u.gen.index, op.u.gen.cmfn, > op.u.gen.tmem_offset, op.u.gen.pfn_offset, > op.u.gen.len, NULL); > diff -r 07ac5459b250 xen/include/public/tmem.h > --- a/xen/include/public/tmem.h=09Wed Aug 25 09:23:31 2010 +0100 > +++ b/xen/include/public/tmem.h=09Thu Sep 02 16:43:33 2010 -0600 > @@ -28,6 +28,9 @@ > #define __XEN_PUBLIC_TMEM_H__ >=20 > #include "xen.h" > + > +/* version of ABI */ > +#define TMEM_SPEC_VERSION 1 >=20 > /* Commands to HYPERVISOR_tmem_op() */ > #define TMEM_CONTROL 0 > @@ -75,10 +78,12 @@ > /* Bits for HYPERVISOR_tmem_op(TMEM_NEW_POOL) */ > #define TMEM_POOL_PERSIST 1 > #define TMEM_POOL_SHARED 2 > +#define TMEM_POOL_PRECOMPRESSED 4 > #define TMEM_POOL_PAGESIZE_SHIFT 4 > #define TMEM_POOL_PAGESIZE_MASK 0xf > #define TMEM_POOL_VERSION_SHIFT 24 > #define TMEM_POOL_VERSION_MASK 0xff > +#define TMEM_POOL_RESERVED_BITS 0x00ffff00 >=20 > /* Bits for client flags (save/restore) */ > #define TMEM_CLIENT_COMPRESS 1 > @@ -106,12 +111,12 @@ struct tmem_op { > uint32_t cli_id; > uint32_t arg1; > uint32_t arg2; > - uint64_t arg3; > + uint64_t oid[3]; > tmem_cli_va_t buf; > } ctrl; /* for cmd =3D=3D TMEM_CONTROL */ > struct { >=20 > - uint64_t object; > + uint64_t oid[3]; > uint32_t index; > uint32_t tmem_offset; > uint32_t pfn_offset; > @@ -126,9 +131,8 @@ struct tmem_handle { > struct tmem_handle { > uint32_t pool_id; > uint32_t index; > - uint64_t oid; > + uint64_t oid[3]; > }; > - > #endif >=20 > #endif /* __XEN_PUBLIC_TMEM_H__ */