Skip to contentSkip to conversation

(Take 2): tmem: Core API between kernel and tmem

RFC PATCH In review Dan Magenheimer 2 participants 3 messages Jul 7, 2009

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

RFC PATCH 1/4 (Take 2): tmem: Core API between kernel and tmem

Tmem [PATCH 1/4] (Take 2): Core API between kernel and tmem

Declares tmem_ops accessors and initializes them to be no-ops (returning -ENOSYS). By itself, this API is useless; it requires a layer such as precache and/or preswap (or similar) on top to make use of the API and a layer below to declare non-no-op tmem accessors that interface to a tmem implementation (e.g. Xen hypercalls). (Many thanks to Jeremy Fitzhardinge for suggesting this approach.)

 Documentation/transcendent-memory.txt    |  175 +++++++++++++++++++++
 include/linux/tmem.h                     |   88 ++++++++++
 mm/Kconfig                               |   10 +
 mm/Makefile                              |    1 
 mm/tmem.c                                |   62 +++++++
 5 files changed, 336 insertions(+)
include/linux/tmem.h +88 -0
@@ -0,0 +1,88 @@
+/*
+ * linux/tmem.h
+ *
+ * Interface to transcendent memory
+ *
+ * Copyright (C) 2008,2009 Dan Magenheimer, Oracle Corp.
+ */
+
+#include <linux/errno.h>
+
+struct tmem_pool_uuid {
+	u64 uuid_lo;
+	u64 uuid_hi;
+};
+
+#define TMEM_POOL_PRIVATE_UUID	{ 0, 0 }
+
+struct tmem_ops {
+	int (*new_pool)(struct tmem_pool_uuid uuid, u32 flags);
+	int (*put_page)(u32 pool_id, u64 object, u32 index, unsigned long gmfn);
+	int (*get_page)(u32 pool_id, u64 object, u32 index, unsigned long gmfn);
+	int (*flush_page)(u32 pool_id, u64 object, u32 index);
+	int (*flush_object)(u32 pool_id, u64 object);
+	int (*destroy_pool)(u32 pool_id);
+};
+
+extern struct tmem_ops *tmem_ops;
+extern void tmem_set_ops(struct tmem_ops *ops);
+
+/* flags for tmem_ops.new_pool */
+#define TMEM_POOL_PERSIST          1
+#define TMEM_POOL_SHARED           2
+
+static inline int tmem_new_pool(struct tmem_pool_uuid uuid, u32 flags)
+{
+	int ret = -ENOSYS;
+#ifdef CONFIG_TMEM
+	ret = (*tmem_ops->new_pool)(uuid, flags);
+#endif
+	return ret;
+}
+
+static inline int tmem_put_page(u32 pool_id, u64 object, u32 index,
+	unsigned long gmfn)
+{
+	int ret = -ENOSYS;
+#ifdef CONFIG_TMEM
+	ret = (*tmem_ops->put_page)(pool_id, object, index, gmfn);
+#endif
+	return ret;
+}
+
+static inline int tmem_get_page(u32 pool_id, u64 object, u32 index,
+	unsigned long gmfn)
+{
+	int ret = -ENOSYS;
+#ifdef CONFIG_TMEM
+	ret = (*tmem_ops->get_page)(pool_id, object, index, gmfn);
+#endif
+	return ret;
+}
+
+static inline int tmem_flush_page(u32 pool_id, u64 object, u32 index)
+{
+	int ret = -ENOSYS;
+#ifdef CONFIG_TMEM
+	ret = (*tmem_ops->flush_page)(pool_id, object, index);
+#endif
+	return ret;
+}
+
+static inline int tmem_flush_object(u32 pool_id, u64 object)
+{
+	int ret = -ENOSYS;
+#ifdef CONFIG_TMEM
+	ret = (*tmem_ops->flush_object)(pool_id, object);
+#endif
+	return ret;
+}
+
+static inline int tmem_destroy_pool(u32 pool_id)
+{
+	int ret = -ENOSYS;
+#ifdef CONFIG_TMEM
+	ret = (*tmem_ops->destroy_pool)(pool_id);
+#endif
+	return ret;
+}
mm/tmem.c +62 -0

62 lines not on this page · raw message

mm/Kconfig +10 -0
@@ -253,3 +253,13 @@ config NOMMU_INITIAL_TRIM_EXCESS
 	  of 1 says that all excess pages should be trimmed.
 
 	  See Documentation/nommu-mmap.txt for more information.
+
+#
+# support for transcendent memory
+#
+config TMEM
+	bool "Transcendent memory support"
+	help
+	  In a virtualized environment, allows unused and underutilized
+	  system physical memory to be made accessible through a narrow
+	  well-defined page-copy-based API.
mm/Makefile +1 -0
@@ -16,6 +16,7 @@ obj-y			:= bootmem.o filemap.o mempool.o
 obj-$(CONFIG_PROC_PAGE_MONITOR) += pagewalk.o
 obj-$(CONFIG_BOUNCE)	+= bounce.o
 obj-$(CONFIG_SWAP)	+= page_io.o swap_state.o swapfile.o thrash.o
+obj-$(CONFIG_TMEM)	+= tmem.o
 obj-$(CONFIG_HAS_DMA)	+= dmapool.o
 obj-$(CONFIG_HUGETLBFS)	+= hugetlb.o
 obj-$(CONFIG_NUMA) 	+= mempolicy.o
Documentation/transcendent-memory.txt +175 -0

175 lines not on this page · raw message

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw
Quoted 1 line · Dan Magenheimer

Tmem [PATCH 1/4] (Take 2): Core API between kernel and tmem

I like the cleanup of your patch series.

However, what remains is a fair bit of code.

It would be good to have performance numbers before deciding whether or not to merge all this code.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#2 lore raw
Quoted 7 lines

From: Rik van Riel [mailto:[email protected]]
Subject: Re: [RFC PATCH 1/4] (Take 2): tmem: Core API between

Quoted 1 line · Dan Magenheimer

Tmem [PATCH 1/4] (Take 2): Core API between kernel and tmem

I like the cleanup of your patch series.

Thanks much, but credit goes to Jeremy for suggesting this very clean tmem_ops interface.

Quoted 1 line

However, what remains is a fair bit of code.

Yes, though much of the LOC is for clean layering and readability. (Nearly half of the patch is now comments.)

Quoted 2 lines

It would be good to have performance numbers before deciding whether or not to merge all this code.

On one benchmark that I will be presenting at Linux Symposium (8 dual-VCPU guests with 384MB of initial memory and doing self-ballooning to constrain memory, each guest compiling Linux continually; quad-core-dual-thread Nehalem processor with 4GB physical RAM) I am seeing savings of ~300 IO/sec at an approximate cost of 0.1%-0.2% of one CPU. But I admit much more benchmarking needs to be done.

Thanks,
Dan

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>