diff options
author | Andres Lagar-Cavilla <andres@lagarcavilla.org> | 2012-01-26 12:46:26 +0000 |
---|---|---|
committer | Andres Lagar-Cavilla <andres@lagarcavilla.org> | 2012-01-26 12:46:26 +0000 |
commit | 447e175bade9a36a638b8aa0a950aa0fb855623a (patch) | |
tree | e654b4277c514c7c2b831ae25a81172deeed2871 /tools/memshr/bidir-hash.h | |
parent | 5cadc6c3e09dfedba6b65ff728c60d13af7262f8 (diff) | |
download | xen-447e175bade9a36a638b8aa0a950aa0fb855623a.tar.gz xen-447e175bade9a36a638b8aa0a950aa0fb855623a.tar.bz2 xen-447e175bade9a36a638b8aa0a950aa0fb855623a.zip |
Update memshr API and tools
This patch is the folded version of API updates, along with the associated tool
changes to ensure that the build is always consistent.
API updates:
- The source domain in the sharing calls is no longer assumed to be dom0.
- Previously, the mem sharing code would return an opaque handle to index
shared pages (and nominees) in its global hash table. By removing the hash
table, the handle becomes a version, to avoid sharing a stale version of a
page. Thus, libxc wrappers and tools need to be updated to recall the share
functions with the information needed to fetch the page (which they readily
have).
Tool updates:
The only (in-tree, that we know of) consumer of the mem sharing API is the
memshr tool. This is updated to use the new API.
Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Signed-off-by: Adin Scannell <adin@scannell.ca>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Tim Deegan <tim@xen.org>
Diffstat (limited to 'tools/memshr/bidir-hash.h')
-rw-r--r-- | tools/memshr/bidir-hash.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/tools/memshr/bidir-hash.h b/tools/memshr/bidir-hash.h index 5c4acae3e0..cc9166fa47 100644 --- a/tools/memshr/bidir-hash.h +++ b/tools/memshr/bidir-hash.h @@ -20,6 +20,7 @@ #define __BIDIR_HASH_H__ #include <stdint.h> +#include <string.h> #include "memshr-priv.h" typedef struct vbdblk { @@ -81,15 +82,16 @@ static int fgprtshr_mfn_cmp(uint32_t m1, uint32_t m2) #undef BIDIR_VALUE #undef BIDIR_KEY_T #undef BIDIR_VALUE_T + /* TODO better hashes! */ static inline uint32_t blockshr_block_hash(vbdblk_t block) { return (uint32_t)(block.sec) ^ (uint32_t)(block.disk_id); } -static inline uint32_t blockshr_shrhnd_hash(uint64_t shrhnd) +static inline uint32_t blockshr_shrhnd_hash(share_tuple_t shrhnd) { - return (uint32_t)shrhnd; + return ((uint32_t) shrhnd.handle); } static inline int blockshr_block_cmp(vbdblk_t b1, vbdblk_t b2) @@ -97,15 +99,15 @@ static inline int blockshr_block_cmp(vbdblk_t b1, vbdblk_t b2) return (b1.sec == b2.sec) && (b1.disk_id == b2.disk_id); } -static inline int blockshr_shrhnd_cmp(uint64_t h1, uint64_t h2) +static inline int blockshr_shrhnd_cmp(share_tuple_t h1, share_tuple_t h2) { - return (h1 == h2); + return ( !memcmp(&h1, &h2, sizeof(share_tuple_t)) ); } #define BIDIR_NAME_PREFIX blockshr #define BIDIR_KEY block #define BIDIR_VALUE shrhnd #define BIDIR_KEY_T vbdblk_t -#define BIDIR_VALUE_T uint64_t +#define BIDIR_VALUE_T share_tuple_t #include "bidir-namedefs.h" #endif /* BLOCK_MAP */ |