Skip to contentSkip to conversation

Cleancache: shim to Xen Transcendent Memory

PATCH In review Dan Magenheimer 2 participants 2 messages Jul 8, 2010 – Jul 12, 2010

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Cleancache: shim to Xen Transcendent Memory

[PATCH] Cleancache: shim to Xen Transcendent Memory

This companion patch to the cleancache V3 patchset (see
http://lkml.org/lkml/2010/6/21/411) provides one consumer for the proposed cleancache internal kernel API. This user is Xen Transcendent Memory ("tmem"), supported in Xen 4.0+. (A second user, zcache, will be posted by Nitin Gupta soon.)

This patch affects Xen directories only; while broader review is welcome, the patch is provided primarily to answer concerns expressed about the apparent non-existence of consumers for the proposed cleancache patch.

Xen tmem provides "hypervisor RAM" as an ephemeral page-oriented pseudo-RAM store for cleancache pages, shared cleancache pages, and frontswap pages. Tmem provides enterprise-quality concurrency, full save/restore and live migration support, compression and deduplication.

A presentation showing up to 8% faster performance and up to 52% reduction in sectors read on a kernel compile workload, despite aggressive in-kernel page reclamation ("self-ballooning") can be found at:

http://oss.oracle.com/projects/tmem/dist/documentation/presentations/TranscendentMemoryXenSummit2010.pdf

Diffstat:

 arch/x86/include/asm/xen/hypercall.h     |    7 
 drivers/xen/Makefile                     |    2 
 drivers/xen/tmem.c                       |  238 +++++++++++++++++++++
 include/xen/interface/xen.h              |   20 +
 4 files changed, 266 insertions(+), 1 deletion(-)
arch/x86/include/asm/xen/hypercall.h +7 -0
diff -Napur linux-2.6.35-rc4/arch/x86/include/asm/xen/hypercall.h linux-2.6.35-rc4-cleancache_tmem/arch/x86/include/asm/xen/hypercall.h
@@ -417,6 +417,13 @@ HYPERVISOR_nmi_op(unsigned long op, unsi
 	return _hypercall2(int, nmi_op, op, arg);
 }
 
+static inline int
+HYPERVISOR_tmem_op(
+	struct tmem_op *op)
+{
+	return _hypercall1(int, tmem_op, op);
+}
+
 static inline void
 MULTI_fpu_taskswitch(struct multicall_entry *mcl, int set)
 {
drivers/xen/Makefile +2 -1
diff -Napur linux-2.6.35-rc4/drivers/xen/Makefile linux-2.6.35-rc4-cleancache_tmem/drivers/xen/Makefile
@@ -1,5 +1,6 @@
 obj-y	+= grant-table.o features.o events.o manage.o
 obj-y	+= xenbus/
+obj-y	+= tmem.o
 
 nostackp := $(call cc-option, -fno-stack-protector)
 CFLAGS_features.o			:= $(nostackp)
@@ -9,4 +10,4 @@ obj-$(CONFIG_XEN_XENCOMM)	+= xencomm.o
 obj-$(CONFIG_XEN_BALLOON)	+= balloon.o
 obj-$(CONFIG_XEN_DEV_EVTCHN)	+= evtchn.o
 obj-$(CONFIG_XENFS)		+= xenfs/
-obj-$(CONFIG_XEN_SYS_HYPERVISOR)	+= sys-hypervisor.o
\ No newline at end of file
+obj-$(CONFIG_XEN_SYS_HYPERVISOR)	+= sys-hypervisor.o
drivers/xen/tmem.c +238 -0

238 lines not on this page · raw message

include/xen/interface/xen.h +20 -0
diff -Napur linux-2.6.35-rc4/include/xen/interface/xen.h linux-2.6.35-rc4-cleancache_tmem/include/xen/interface/xen.h
@@ -58,6 +58,7 @@
 #define __HYPERVISOR_event_channel_op     32
 #define __HYPERVISOR_physdev_op           33
 #define __HYPERVISOR_hvm_op               34
+#define __HYPERVISOR_tmem_op              38
 
 /* Architecture-specific hypercall definitions. */
 #define __HYPERVISOR_arch_0               48
@@ -461,6 +462,25 @@ typedef uint8_t xen_domain_handle_t[16];
 #define __mk_unsigned_long(x) x ## UL
 #define mk_unsigned_long(x) __mk_unsigned_long(x)
 
+struct tmem_op {
+	uint32_t cmd;
+	int32_t pool_id;
+	union {
+		struct {  /* for cmd == TMEM_NEW_POOL */
+			uint64_t uuid[2];
+			uint32_t flags;
+		} new;
+		struct {
+			uint64_t object;
+			uint32_t index;
+			uint32_t tmem_offset;
+			uint32_t pfn_offset;
+			uint32_t len;
+			GUEST_HANDLE(void) gmfn; /* guest machine page frame */
+		} gen;
+	} u;
+};
+
 #else /* __ASSEMBLY__ */
 
 /* In assembly code we cannot use C numeric constant suffixes. */
#1 lore raw
Quoted 1 line · Dan Magenheimer

One nitpick:
..

drivers/xen/tmem.c line 130

Quoted 10 lines
drivers/xen/tmem.c +10 -0
+
+int tmem_enabled;
+
+static int __init enable_tmem(char *s)
+{
+	tmem_enabled = 1;
+	return 1;
+}
+
+__setup("tmem", enable_tmem);

Perhaps 'tmem_setup' is more appropiate as it might be that this function in the future would be only used to disable tmem, not actually enable it?

Otherwise, it has been reviewed by me.