diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2010-04-06 07:11:48 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2010-04-06 07:11:48 +0100 |
commit | 38c433d0c711406778aba1ae183a195da98656f0 (patch) | |
tree | eaad27720c4cf4a2b69df8149bbe0a8b3151f0e4 /xen/common/tmem_xen.c | |
parent | 6a9ee8cf218b621ebc3d88e621f32cc3f030e742 (diff) | |
download | xen-38c433d0c711406778aba1ae183a195da98656f0.tar.gz xen-38c433d0c711406778aba1ae183a195da98656f0.tar.bz2 xen-38c433d0c711406778aba1ae183a195da98656f0.zip |
tmem: add page deduplication with optional compression or trailing-zero-elimination
Add "page deduplication" capability (with optional compression
and trailing-zero elimination) to Xen's tmem.
(Transparent to tmem-enabled guests.) Ephemeral pages
that have the exact same content are "combined" so that only
one page frame is needed. Since ephemeral pages are essentially
read-only, no C-O-W (and thus no equivalent of swapping) is
necessary. Deduplication can be combined with compression
or "trailing zero elimination" for even more space savings.
Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
Diffstat (limited to 'xen/common/tmem_xen.c')
-rw-r--r-- | xen/common/tmem_xen.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/xen/common/tmem_xen.c b/xen/common/tmem_xen.c index b0d572a4ff..0da1b4754d 100644 --- a/xen/common/tmem_xen.c +++ b/xen/common/tmem_xen.c @@ -20,6 +20,12 @@ boolean_param("tmem", opt_tmem); EXPORT int opt_tmem_compress = 0; boolean_param("tmem_compress", opt_tmem_compress); +EXPORT int opt_tmem_dedup = 0; +boolean_param("tmem_dedup", opt_tmem_dedup); + +EXPORT int opt_tmem_tze = 0; +boolean_param("tmem_tze", opt_tmem_tze); + EXPORT int opt_tmem_shared_auth = 0; boolean_param("tmem_shared_auth", opt_tmem_shared_auth); @@ -103,8 +109,8 @@ static inline void *cli_mfn_to_va(tmem_cli_mfn_t cmfn, unsigned long *pcli_mfn) #endif EXPORT int tmh_copy_from_client(pfp_t *pfp, - tmem_cli_mfn_t cmfn, uint32_t tmem_offset, - uint32_t pfn_offset, uint32_t len, void *cli_va) + tmem_cli_mfn_t cmfn, pagesize_t tmem_offset, + pagesize_t pfn_offset, pagesize_t len, void *cli_va) { unsigned long tmem_mfn; void *tmem_va; @@ -148,7 +154,7 @@ EXPORT int tmh_compress_from_client(tmem_cli_mfn_t cmfn, } EXPORT int tmh_copy_to_client(tmem_cli_mfn_t cmfn, pfp_t *pfp, - uint32_t tmem_offset, uint32_t pfn_offset, uint32_t len, void *cli_va) + pagesize_t tmem_offset, pagesize_t pfn_offset, pagesize_t len, void *cli_va) { unsigned long tmem_mfn, cli_mfn = 0; int mark_dirty = 1; @@ -199,6 +205,27 @@ EXPORT int tmh_decompress_to_client(tmem_cli_mfn_t cmfn, void *tmem_va, return 1; } +EXPORT int tmh_copy_tze_to_client(tmem_cli_mfn_t cmfn, void *tmem_va, + pagesize_t len) +{ + void *cli_va; + unsigned long cli_mfn; + + ASSERT(!(len & (sizeof(uint64_t)-1))); + ASSERT(len <= PAGE_SIZE); + ASSERT(len > 0 || tmem_va == NULL); + if ( (cli_va = cli_mfn_to_va(cmfn,&cli_mfn)) == NULL) + return -EFAULT; + if ( len > 0 ) + memcpy((char *)cli_va,(char *)tmem_va,len); + if ( len < PAGE_SIZE ) + memset((char *)cli_va+len,0,PAGE_SIZE-len); + unmap_domain_page(cli_va); + paging_mark_dirty(current->domain,cli_mfn); + mb(); + return 1; +} + /****************** XEN-SPECIFIC MEMORY ALLOCATION ********************/ EXPORT struct xmem_pool *tmh_mempool = 0; |