view xen/include/xen/lzo.h @ 19646:f210a633571c

Transcendent memory ("tmem") for Xen.

Tmem, when called from a tmem-capable (paravirtualized) guest, makes
use of otherwise unutilized ("fallow") memory to create and manage
pools of pages that can be accessed from the guest either as
"ephemeral" pages or as "persistent" pages. In either case, the pages
are not directly addressible by the guest, only copied to and fro via
the tmem interface. Ephemeral pages are a nice place for a guest to
put recently evicted clean pages that it might need again; these pages
can be reclaimed synchronously by Xen for other guests or other uses.
Persistent pages are a nice place for a guest to put "swap" pages to
avoid sending them to disk. These pages retain data as long as the
guest lives, but count against the guest memory allocation.

Tmem pages may optionally be compressed and, in certain cases, can be
shared between guests. Tmem also handles concurrency nicely and
provides limited QoS settings to combat malicious DoS attempts.
Save/restore and live migration support is not yet provided.

Tmem is primarily targeted for an x86 64-bit hypervisor. On a 32-bit
x86 hypervisor, it has limited functionality and testing due to
limitations of the xen heap. Nearly all of tmem is
architecture-independent; three routines remain to be ported to ia64
and it should work on that architecture too. It is also structured to
be portable to non-Xen environments.

Tmem defaults off (for now) and must be enabled with a "tmem" xen boot
option (and does nothing unless a tmem-capable guest is running). The
"tmem_compress" boot option enables compression which takes about 10x
more CPU but approximately doubles the number of pages that can be

Tmem can be controlled via several "xm" commands and many interesting
tmem statistics can be obtained. A README and internal specification
will follow, but lots of useful prose about tmem, as well as Linux
patches, can be found at http://oss.oracle.com/projects/tmem .

Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue May 26 11:05:04 2009 +0100 (2009-05-26)
line source
1 #ifndef __LZO_H__
2 #define __LZO_H__
3 /*
4 * LZO Public Kernel Interface
5 * A mini subset of the LZO real-time data compression library
6 *
7 * Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com>
8 *
9 * The full LZO package can be found at:
10 * http://www.oberhumer.com/opensource/lzo/
11 *
12 * Changed for kernel use by:
13 * Nitin Gupta <nitingupta910@gmail.com>
14 * Richard Purdie <rpurdie@openedhand.com>
15 */
17 #define LZO1X_MEM_COMPRESS (16384 * sizeof(unsigned char *))
20 #define lzo1x_worst_compress(x) ((x) + ((x) / 16) + 64 + 3)
22 /* This requires 'workmem' of size LZO1X_1_MEM_COMPRESS */
23 int lzo1x_1_compress(const unsigned char *src, size_t src_len,
24 unsigned char *dst, size_t *dst_len, void *wrkmem);
26 /* safe decompression with overrun testing */
27 int lzo1x_decompress_safe(const unsigned char *src, size_t src_len,
28 unsigned char *dst, size_t *dst_len);
30 /*
31 * Return values (< 0 = Error)
32 */
33 #define LZO_E_OK 0
34 #define LZO_E_ERROR (-1)
35 #define LZO_E_OUT_OF_MEMORY (-2)
36 #define LZO_E_NOT_COMPRESSIBLE (-3)
37 #define LZO_E_INPUT_OVERRUN (-4)
38 #define LZO_E_OUTPUT_OVERRUN (-5)
40 #define LZO_E_EOF_NOT_FOUND (-7)
41 #define LZO_E_INPUT_NOT_CONSUMED (-8)
44 #endif