Skip to contentSkip to conversation

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

PATCH Dan Magenheimer 1 participant 1 message Dec 18, 2009

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

Tmem [PATCH 1/5] (Take 3): 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 cleancache and/or frontswap (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    |  176 +++++++++++++++++++++
 include/linux/tmem.h                     |   88 ++++++++++
 mm/tmem.c                                |   93 +++++++++++
 3 files changed, 357 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 +93 -0

93 lines not on this page · raw message

Documentation/transcendent-memory.txt +176 -0

176 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>