Skip to contentSkip to conversation

Checkpoint/restart code reshuffle

RFC PATCH New Matt Helsley 3 participants 19 messages Feb 26, 2010 14 messages not in the archive

Subsystems (8)
Memory management VFS Kbuild MM core +4 more subsystems
lore
Share & tools
lore
#0 lore raw

cover Checkpoint/restart code reshuffle

This patch series moves checkpoint/restart code alongside the kernel code that manages the checkpointed data under less exotic circumstances. This is an attempt to improve the maintenance of the code. For example, all of checkpoint/signal.c gets moved into kernel/signal.c.

Unfortunately this requires a giant #ifdef CONFIG_CHECKPOINT block inside kernel/signal.c. Normaly this is frowned upon however there is no alternative that I can see because most of the checkpoint functions clearly don't belong as static inlines in in headers.

By distributing their contents this way I was able to get rid of:

checkpoint/signal.c
checkpoint/memory.c
checkpoint/namespace.c

and I was able to move some of the contents from checkpoint/objhash.c into the relevant files. The rest seemed appropriately collected in checkpoint/ but they were core kernel pieces so I simply moved them to kernel/checkpoint/.

This is a taste of what's possible. Assuming this series is preferrable to maintainers, or if someone can identify a better way than some large #ifdefs in .c files, it shold be possible to further distribute

fs/checkpoint.c (to fs/file_table.c for example) checkpoint/objhash.c (to the various namespace and other files) include/linux/checkpoint.h (e.g. one for the objhash functions)

and maybe:
checkpoint/process.c (I need to consider this one some more..)

The series survives crude compile testing. There should be no functional changes to c/r except for the case where userns is not configured -- in that case, this version fails to restart checkpoint images with user namespaces. This can be fixed at the cost of restoring checkpoint/namespace.c or perhaps by adding the userns portion to a new file called kernel/no_user_namespace.c (or similar).

I'd like to know if folks think this will make the checkpoint/restart code more maintainable. I would also be glad to get rid of the #ifdefs if anyone has some better recommendations.

Cheers,
-Matt Helsley

#2 lore raw

PATCH 1/12 Prepare to move ckpt_obj_ops definitions

In reply to a message not in the archive

We are going to distribute the contents of this array to their respective kernel source files. For example, the signal and sighand ckpt_obj_ops will go into kernel/signal.c.

Then each portion of the kernel will register its checkpoint objects and their operations in their respective __init functions. This also eventually gets rid of a bunch of function declarations in include/linux/checkpoint.h.

---
 checkpoint/objhash.c |  420 ++++++++++++++++++++++++++------------------------
 1 files changed, 219 insertions(+), 201 deletions(-)
checkpoint/objhash.c +219 -201
index 693ad56..1ca7f47 100644
@@ -25,9 +25,6 @@
 #include <linux/checkpoint_hdr.h>
 #include <net/sock.h>
 
-struct ckpt_obj;
-struct ckpt_obj_ops;
-
 /* object operations */
 struct ckpt_obj_ops {
 	char *obj_name;
@@ -44,7 +41,7 @@ struct ckpt_obj {
 	int objref;
 	int flags;
 	void *ptr;
-	struct ckpt_obj_ops *ops;
+	const struct ckpt_obj_ops *ops;
 	struct hlist_node hash;
 	struct hlist_node next;
 };
@@ -356,200 +353,222 @@ static void *restore_lsm_string_wrap(struct ckpt_ctx *ctx)
 	return (void *)restore_lsm_string(ctx);
 }
 
+/* ignored object */
+static const struct ckpt_obj_ops ckpt_obj_ignored_ops = {
+	.obj_name = "IGNORED",
+	.obj_type = CKPT_OBJ_IGNORE,
+	.ref_drop = obj_no_drop,
+	.ref_grab = obj_no_grab,
+};
 
-static struct ckpt_obj_ops ckpt_obj_ops[] = {
-	/* ignored object */
-	{
-		.obj_name = "IGNORED",
-		.obj_type = CKPT_OBJ_IGNORE,
-		.ref_drop = obj_no_drop,
-		.ref_grab = obj_no_grab,
-	},
-	/* inode object */
-	{
-		.obj_name = "INODE",
-		.obj_type = CKPT_OBJ_INODE,
-		.ref_drop = obj_inode_drop,
-		.ref_grab = obj_inode_grab,
-	},
-	/* files_struct object */
-	{
-		.obj_name = "FILE_TABLE",
-		.obj_type = CKPT_OBJ_FILE_TABLE,
-		.ref_drop = obj_file_table_drop,
-		.ref_grab = obj_file_table_grab,
-		.ref_users = obj_file_table_users,
-		.checkpoint = checkpoint_file_table,
-		.restore = restore_file_table,
-	},
-	/* file object */
-	{
-		.obj_name = "FILE",
-		.obj_type = CKPT_OBJ_FILE,
-		.ref_drop = obj_file_drop,
-		.ref_grab = obj_file_grab,
-		.ref_users = obj_file_users,
-		.checkpoint = checkpoint_file,
-		.restore = restore_file,
-	},
-	/* mm object */
-	{
-		.obj_name = "MM",
-		.obj_type = CKPT_OBJ_MM,
-		.ref_drop = obj_mm_drop,
-		.ref_grab = obj_mm_grab,
-		.ref_users = obj_mm_users,
-		.checkpoint = checkpoint_mm,
-		.restore = restore_mm,
-	},
-	/* fs object */
-	{
-		.obj_name = "FS",
-		.obj_type = CKPT_OBJ_FS,
-		.ref_drop = obj_fs_drop,
-		.ref_grab = obj_fs_grab,
-		.ref_users = obj_fs_users,
-		.checkpoint = checkpoint_fs,
-		.restore = restore_fs,
-	},
-	/* sighand object */
-	{
-		.obj_name = "SIGHAND",
-		.obj_type = CKPT_OBJ_SIGHAND,
-		.ref_drop = obj_sighand_drop,
-		.ref_grab = obj_sighand_grab,
-		.ref_users = obj_sighand_users,
-		.checkpoint = checkpoint_sighand,
-		.restore = restore_sighand,
-	},
-	/* signal object */
-	{
-		.obj_name = "SIGNAL",
-		.obj_type = CKPT_OBJ_SIGNAL,
-		.ref_drop = obj_no_drop,
-		.ref_grab = obj_no_grab,
-	},
-	/* ns object */
-	{
-		.obj_name = "NSPROXY",
-		.obj_type = CKPT_OBJ_NS,
-		.ref_drop = obj_ns_drop,
-		.ref_grab = obj_ns_grab,
-		.ref_users = obj_ns_users,
-		.checkpoint = checkpoint_ns,
-		.restore = restore_ns,
-	},
-	/* uts_ns object */
-	{
-		.obj_name = "UTS_NS",
-		.obj_type = CKPT_OBJ_UTS_NS,
-		.ref_drop = obj_uts_ns_drop,
-		.ref_grab = obj_uts_ns_grab,
-		.ref_users = obj_uts_ns_users,
-		.checkpoint = checkpoint_uts_ns,
-		.restore = restore_uts_ns,
-	},
-	/* ipc_ns object */
-	{
-		.obj_name = "IPC_NS",
-		.obj_type = CKPT_OBJ_IPC_NS,
-		.ref_drop = obj_ipc_ns_drop,
-		.ref_grab = obj_ipc_ns_grab,
-		.ref_users = obj_ipc_ns_users,
-		.checkpoint = checkpoint_ipc_ns,
-		.restore = restore_ipc_ns,
-	},
-	/* mnt_ns object */
-	{
-		.obj_name = "MOUNTS NS",
-		.obj_type = CKPT_OBJ_MNT_NS,
-		.ref_grab = obj_mnt_ns_grab,
-		.ref_drop = obj_mnt_ns_drop,
-		.ref_users = obj_mnt_ns_users,
-	},
-	/* user_ns object */
-	{
-		.obj_name = "USER_NS",
-		.obj_type = CKPT_OBJ_USER_NS,
-		.ref_drop = obj_userns_drop,
-		.ref_grab = obj_userns_grab,
-		.checkpoint = checkpoint_userns,
-		.restore = restore_userns,
-	},
-	/* struct cred */
-	{
-		.obj_name = "CRED",
-		.obj_type = CKPT_OBJ_CRED,
-		.ref_drop = obj_cred_drop,
-		.ref_grab = obj_cred_grab,
-		.checkpoint = checkpoint_cred,
-		.restore = restore_cred,
-	},
-	/* user object */
-	{
-		.obj_name = "USER",
-		.obj_type = CKPT_OBJ_USER,
-		.ref_drop = obj_user_drop,
-		.ref_grab = obj_user_grab,
-		.checkpoint = checkpoint_user,
-		.restore = restore_user,
-	},
-	/* struct groupinfo */
-	{
-		.obj_name = "GROUPINFO",
-		.obj_type = CKPT_OBJ_GROUPINFO,
-		.ref_drop = obj_groupinfo_drop,
-		.ref_grab = obj_groupinfo_grab,
-		.checkpoint = checkpoint_groupinfo,
-		.restore = restore_groupinfo,
-	},
-	/* sock object */
-	{
-		.obj_name = "SOCKET",
-		.obj_type = CKPT_OBJ_SOCK,
-		.ref_drop = obj_sock_drop,
-		.ref_grab = obj_sock_grab,
-		.ref_users = obj_sock_users,
-		.checkpoint = checkpoint_sock,
-		.restore = restore_sock,
-	},
-	/* struct tty_struct */
-	{
-		.obj_name = "TTY",
-		.obj_type = CKPT_OBJ_TTY,
-		.ref_drop = obj_tty_drop,
-		.ref_grab = obj_tty_grab,
-		.ref_users = obj_tty_users,
-		.checkpoint = checkpoint_tty,
-		.restore = restore_tty,
-	},
-	/*
-	 * LSM void *security on objhash - at checkpoint
-	 * We don't take a ref because we won't be doing
-	 * anything more with this void* - unless we happen
-	 * to run into it again through some other objects's
-	 * ->security (in which case that object has it pinned).
-	 */
-	{
-		.obj_name = "SECURITY PTR",
-		.obj_type = CKPT_OBJ_SECURITY_PTR,
-		.ref_drop = obj_no_drop,
-		.ref_grab = obj_no_grab,
-	},
-	/*
-	 * LSM security strings - at restart
-	 * This is a struct which we malloc during restart and
-	 * must be freed (by objhash cleanup) at the end of
-	 * restart
-	 */
-	{
-		.obj_name = "SECURITY STRING",
-		.obj_type = CKPT_OBJ_SECURITY,
-		.ref_grab = lsm_string_grab,
-		.ref_drop = lsm_string_drop,
-		.checkpoint = checkpoint_lsm_string,
-		.restore = restore_lsm_string_wrap,
-	},
+/* inode object */
+static const struct ckpt_obj_ops ckpt_obj_inode_ops = {
+	.obj_name = "INODE",
+	.obj_type = CKPT_OBJ_INODE,
+	.ref_drop = obj_inode_drop,
+	.ref_grab = obj_inode_grab,
+};
+
+/* files_struct object */
+static const struct ckpt_obj_ops ckpt_obj_files_struct_ops = {
+	.obj_name = "FILE_TABLE",
+	.obj_type = CKPT_OBJ_FILE_TABLE,
+	.ref_drop = obj_file_table_drop,
+	.ref_grab = obj_file_table_grab,
+	.ref_users = obj_file_table_users,
+	.checkpoint = checkpoint_file_table,
+	.restore = restore_file_table,
+};
+/* file object */
+static const struct ckpt_obj_ops ckpt_obj_file_ops = {
+	.obj_name = "FILE",
+	.obj_type = CKPT_OBJ_FILE,
+	.ref_drop = obj_file_drop,
+	.ref_grab = obj_file_grab,
+	.ref_users = obj_file_users,
+	.checkpoint = checkpoint_file,
+	.restore = restore_file,
+};
+/* mm object */
+static const struct ckpt_obj_ops ckpt_obj_mm_ops = {
+	.obj_name = "MM",
+	.obj_type = CKPT_OBJ_MM,
+	.ref_drop = obj_mm_drop,
+	.ref_grab = obj_mm_grab,
+	.ref_users = obj_mm_users,
+	.checkpoint = checkpoint_mm,
+	.restore = restore_mm,
+};
+/* fs object */
+static const struct ckpt_obj_ops ckpt_obj_fs_ops = {
+	.obj_name = "FS",
+	.obj_type = CKPT_OBJ_FS,
+	.ref_drop = obj_fs_drop,
+	.ref_grab = obj_fs_grab,
+	.ref_users = obj_fs_users,
+	.checkpoint = checkpoint_fs,
+	.restore = restore_fs,
+};
+/* sighand object */
+static const struct ckpt_obj_ops ckpt_obj_sighand_ops = {
+	.obj_name = "SIGHAND",
+	.obj_type = CKPT_OBJ_SIGHAND,
+	.ref_drop = obj_sighand_drop,
+	.ref_grab = obj_sighand_grab,
+	.ref_users = obj_sighand_users,
+	.checkpoint = checkpoint_sighand,
+	.restore = restore_sighand,
+};
+/* signal object */
+static const struct ckpt_obj_ops ckpt_obj_signal_ops = {
+	.obj_name = "SIGNAL",
+	.obj_type = CKPT_OBJ_SIGNAL,
+	.ref_drop = obj_no_drop,
+	.ref_grab = obj_no_grab,
+};
+/* ns object */
+static const struct ckpt_obj_ops ckpt_obj_nsproxy_ops = {
+	.obj_name = "NSPROXY",
+	.obj_type = CKPT_OBJ_NS,
+	.ref_drop = obj_ns_drop,
+	.ref_grab = obj_ns_grab,
+	.ref_users = obj_ns_users,
+	.checkpoint = checkpoint_ns,
+	.restore = restore_ns,
+};
+/* uts_ns object */
+static const struct ckpt_obj_ops ckpt_obj_uts_ns_ops = {
+	.obj_name = "UTS_NS",
+	.obj_type = CKPT_OBJ_UTS_NS,
+	.ref_drop = obj_uts_ns_drop,
+	.ref_grab = obj_uts_ns_grab,
+	.ref_users = obj_uts_ns_users,
+	.checkpoint = checkpoint_uts_ns,
+	.restore = restore_uts_ns,
+};
+/* ipc_ns object */
+static const struct ckpt_obj_ops ckpt_obj_ipc_ns_ops = {
+	.obj_name = "IPC_NS",
+	.obj_type = CKPT_OBJ_IPC_NS,
+	.ref_drop = obj_ipc_ns_drop,
+	.ref_grab = obj_ipc_ns_grab,
+	.ref_users = obj_ipc_ns_users,
+	.checkpoint = checkpoint_ipc_ns,
+	.restore = restore_ipc_ns,
+};
+/* mnt_ns object */
+static const struct ckpt_obj_ops ckpt_obj_mnt_ns_ops = {
+	.obj_name = "MOUNTS NS",
+	.obj_type = CKPT_OBJ_MNT_NS,
+	.ref_grab = obj_mnt_ns_grab,
+	.ref_drop = obj_mnt_ns_drop,
+	.ref_users = obj_mnt_ns_users,
+};
+/* user_ns object */
+static const struct ckpt_obj_ops ckpt_obj_user_ns_ops = {
+	.obj_name = "USER_NS",
+	.obj_type = CKPT_OBJ_USER_NS,
+	.ref_drop = obj_userns_drop,
+	.ref_grab = obj_userns_grab,
+	.checkpoint = checkpoint_userns,
+	.restore = restore_userns,
+};
+/* struct cred */
+static const struct ckpt_obj_ops ckpt_obj_cred_ops = {
+	.obj_name = "CRED",
+	.obj_type = CKPT_OBJ_CRED,
+	.ref_drop = obj_cred_drop,
+	.ref_grab = obj_cred_grab,
+	.checkpoint = checkpoint_cred,
+	.restore = restore_cred,
+};
+/* user object */
+static const struct ckpt_obj_ops ckpt_obj_user_ops = {
+	.obj_name = "USER",
+	.obj_type = CKPT_OBJ_USER,
+	.ref_drop = obj_user_drop,
+	.ref_grab = obj_user_grab,
+	.checkpoint = checkpoint_user,
+	.restore = restore_user,
+};
+/* struct groupinfo */
+static const struct ckpt_obj_ops ckpt_obj_groupinfo_ops = {
+	.obj_name = "GROUPINFO",
+	.obj_type = CKPT_OBJ_GROUPINFO,
+	.ref_drop = obj_groupinfo_drop,
+	.ref_grab = obj_groupinfo_grab,
+	.checkpoint = checkpoint_groupinfo,
+	.restore = restore_groupinfo,
+};
+/* sock object */
+static const struct ckpt_obj_ops ckpt_obj_sock_ops = {
+	.obj_name = "SOCKET",
+	.obj_type = CKPT_OBJ_SOCK,
+	.ref_drop = obj_sock_drop,
+	.ref_grab = obj_sock_grab,
+	.ref_users = obj_sock_users,
+	.checkpoint = checkpoint_sock,
+	.restore = restore_sock,
+};
+/* struct tty_struct */
+static const struct ckpt_obj_ops ckpt_obj_tty_ops = {
+	.obj_name = "TTY",
+	.obj_type = CKPT_OBJ_TTY,
+	.ref_drop = obj_tty_drop,
+	.ref_grab = obj_tty_grab,
+	.ref_users = obj_tty_users,
+	.checkpoint = checkpoint_tty,
+	.restore = restore_tty,
+};
+/*
+ * LSM void *security on objhash - at checkpoint
+ * We don't take a ref because we won't be doing
+ * anything more with this void* - unless we happen
+ * to run into it again through some other objects's
+ * ->security (in which case that object has it pinned).
+ */
+static const struct ckpt_obj_ops ckpt_obj_security_ptr_ops = {
+	.obj_name = "SECURITY PTR",
+	.obj_type = CKPT_OBJ_SECURITY_PTR,
+	.ref_drop = obj_no_drop,
+	.ref_grab = obj_no_grab,
+};
+/*
+ * LSM security strings - at restart
+ * This is a struct which we malloc during restart and
+ * must be freed (by objhash cleanup) at the end of
+ * restart
+ */
+static const struct ckpt_obj_ops ckpt_obj_security_strings_ops = {
+	.obj_name = "SECURITY STRING",
+	.obj_type = CKPT_OBJ_SECURITY,
+	.ref_grab = lsm_string_grab,
+	.ref_drop = lsm_string_drop,
+	.checkpoint = checkpoint_lsm_string,
+	.restore = restore_lsm_string_wrap,
+};
+
+static const struct ckpt_obj_ops *ckpt_obj_ops[] = {
+	[CKPT_OBJ_IGNORE] = &ckpt_obj_ignored_ops,
+	[CKPT_OBJ_INODE] = &ckpt_obj_inode_ops,
+	[CKPT_OBJ_FILE_TABLE] = &ckpt_obj_files_struct_ops,
+	[CKPT_OBJ_FILE] = &ckpt_obj_file_ops,
+	[CKPT_OBJ_MM] = &ckpt_obj_mm_ops,
+	[CKPT_OBJ_FS] = &ckpt_obj_fs_ops,
+	[CKPT_OBJ_SIGHAND] = &ckpt_obj_sighand_ops,
+	[CKPT_OBJ_SIGNAL] = &ckpt_obj_signal_ops,
+	[CKPT_OBJ_NS] = &ckpt_obj_nsproxy_ops,
+	[CKPT_OBJ_UTS_NS] = &ckpt_obj_uts_ns_ops,
+	[CKPT_OBJ_IPC_NS] = &ckpt_obj_ipc_ns_ops,
+	[CKPT_OBJ_MNT_NS] = &ckpt_obj_mnt_ns_ops,
+	[CKPT_OBJ_USER_NS] = &ckpt_obj_mnt_ns_ops,
+	[CKPT_OBJ_CRED] = &ckpt_obj_cred_ops,
+	[CKPT_OBJ_USER] = &ckpt_obj_user_ops,
+	[CKPT_OBJ_GROUPINFO] = &ckpt_obj_groupinfo_ops,
+	[CKPT_OBJ_SOCK] = &ckpt_obj_sock_ops,
+	[CKPT_OBJ_TTY] = &ckpt_obj_tty_ops,
+	[CKPT_OBJ_SECURITY_PTR] = &ckpt_obj_security_ptr_ops,
+	[CKPT_OBJ_SECURITY] = &ckpt_obj_security_strings_ops,
 };
 
 
@@ -652,7 +671,7 @@ static inline int obj_alloc_objref(struct ckpt_ctx *ctx)
 static struct ckpt_obj *obj_new(struct ckpt_ctx *ctx, void *ptr,
 				int objref, enum obj_type type)
 {
-	struct ckpt_obj_ops *ops = &ckpt_obj_ops[type];
+	const struct ckpt_obj_ops *ops = ckpt_obj_ops[type];
 	struct ckpt_obj *obj;
 	int i, ret;
 
@@ -1041,7 +1060,7 @@ int ckpt_obj_visited(struct ckpt_ctx *ctx)
  */
 int restore_obj(struct ckpt_ctx *ctx, struct ckpt_hdr_objref *h)
 {
-	struct ckpt_obj_ops *ops;
+	const struct ckpt_obj_ops *ops;
 	struct ckpt_obj *obj;
 	void *ptr = NULL;
 
@@ -1051,7 +1070,7 @@ int restore_obj(struct ckpt_ctx *ctx, struct ckpt_hdr_objref *h)
 	if (h->objref <= 0)
 		return -EINVAL;
 
-	ops = &ckpt_obj_ops[h->objtype];
+	ops = ckpt_obj_ops[h->objtype];
 	BUG_ON(ops->obj_type != h->objtype);
 
 	if (ops->restore)
@@ -1209,4 +1228,3 @@ out:
 	ckpt_hdr_put(ctx, h);
 	return l;
 }
-
Signature · 1 line
1.6.3.3
#4 lore raw

PATCH 2/12 Add ability to register checkpoint obj ops

In reply to a message not in the archive

The array indices are allocated staticly by the CKPT_OBJ_* enums in include/linux/checkpoint_hdr.h. There's no sanity checking here but if it's desirable we can do checks like:

	BUG_ON(ops->obj_type >= CKPT_OBJ_MAX);       /* bounds check */
	BUG_ON(ckpt_obj_ops[ops->obj_type] != NULL); /* Something has
				already registered or (also bad) re-registration				is occurring. */
---
 checkpoint/objhash.c             |   16 +++++-----------
 include/linux/checkpoint.h       |    6 ++++++
 include/linux/checkpoint_types.h |   11 +++++++++++
 3 files changed, 22 insertions(+), 11 deletions(-)
checkpoint/objhash.c +5 -11
index 1ca7f47..832520d 100644
@@ -25,17 +25,6 @@
 #include <linux/checkpoint_hdr.h>
 #include <net/sock.h>
 
-/* object operations */
-struct ckpt_obj_ops {
-	char *obj_name;
-	enum obj_type obj_type;
-	void (*ref_drop)(void *ptr, int lastref);
-	int (*ref_grab)(void *ptr);
-	int (*ref_users)(void *ptr);
-	int (*checkpoint)(struct ckpt_ctx *ctx, void *ptr);
-	void *(*restore)(struct ckpt_ctx *ctx);
-};
-
 struct ckpt_obj {
 	int users;
 	int objref;
@@ -571,6 +560,11 @@ static const struct ckpt_obj_ops *ckpt_obj_ops[] = {
 	[CKPT_OBJ_SECURITY] = &ckpt_obj_security_strings_ops,
 };
 
+void register_checkpoint_obj(const struct ckpt_obj_ops *ops)
+{
+	ckpt_obj_ops[ops->obj_type] = ops;
+}
+
 
 #define CKPT_OBJ_HASH_NBITS  10
 #define CKPT_OBJ_HASH_TOTAL  (1UL << CKPT_OBJ_HASH_NBITS)
include/linux/checkpoint.h +6 -0
index 7101d6f..e4d668a 100644
@@ -485,6 +485,12 @@ extern void _ckpt_msg_complete(struct ckpt_ctx *ctx);
 	_do_ckpt_msg(ctx, err, "[E @ %s:%d]" fmt, __func__, __LINE__, ##args); \
 } while (0)
 
+struct ckpt_obj_ops;
+extern void register_checkpoint_obj(const struct ckpt_obj_ops *ops);
+#else
+struct ckpt_obj_ops;
+static inline void register_checkpoint_obj(const struct ckpt_obj_ops *ops)
+{}
 #endif /* CONFIG_CHECKPOINT */
 #endif /* __KERNEL__ */
 
include/linux/checkpoint_types.h +11 -0
index 5d5e00d..94e6e37 100644
@@ -23,6 +23,17 @@
 #include <linux/wait.h>
 #include <linux/security.h>
 
+/* object operations */
+struct ckpt_obj_ops {
+	char *obj_name;
+	int obj_type;
+	void (*ref_drop)(void *ptr, int lastref);
+	int (*ref_grab)(void *ptr);
+	int (*ref_users)(void *ptr);
+	int (*checkpoint)(struct ckpt_ctx *ctx, void *ptr);
+	void *(*restore)(struct ckpt_ctx *ctx);
+};
+
 struct ckpt_stats {
 	int uts_ns;
 	int ipc_ns;
Signature · 1 line
1.6.3.3
#6 lore raw

PATCH 3/12 Replace obj_no_grab and obj_no_drop ckpt ops with NULL

In reply to a message not in the archive

Distributing the ckpt_obj_ops would require sharing these functions when we can get by with simple NULL pointers in the grab/drop operations.

---
 checkpoint/objhash.c |   36 ++++++++++++++++--------------------
 1 files changed, 16 insertions(+), 20 deletions(-)
checkpoint/objhash.c +16 -20
index 832520d..999d731 100644
@@ -47,16 +47,6 @@ struct ckpt_obj_hash {
 
 /* helper grab/drop/users functions */
 
-static void obj_no_drop(void *ptr, int lastref)
-{
-	return;
-}
-
-static int obj_no_grab(void *ptr)
-{
-	return 0;
-}
-
 static int obj_inode_grab(void *ptr)
 {
 	return igrab((struct inode *) ptr) ? 0 : -EBADF;
@@ -346,8 +336,8 @@ static void *restore_lsm_string_wrap(struct ckpt_ctx *ctx)
 static const struct ckpt_obj_ops ckpt_obj_ignored_ops = {
 	.obj_name = "IGNORED",
 	.obj_type = CKPT_OBJ_IGNORE,
-	.ref_drop = obj_no_drop,
-	.ref_grab = obj_no_grab,
+	.ref_drop = NULL,
+	.ref_grab = NULL,
 };
 
 /* inode object */
@@ -412,8 +402,8 @@ static const struct ckpt_obj_ops ckpt_obj_sighand_ops = {
 static const struct ckpt_obj_ops ckpt_obj_signal_ops = {
 	.obj_name = "SIGNAL",
 	.obj_type = CKPT_OBJ_SIGNAL,
-	.ref_drop = obj_no_drop,
-	.ref_grab = obj_no_grab,
+	.ref_drop = NULL,
+	.ref_grab = NULL,
 };
 /* ns object */
 static const struct ckpt_obj_ops ckpt_obj_nsproxy_ops = {
@@ -519,8 +509,8 @@ static const struct ckpt_obj_ops ckpt_obj_tty_ops = {
 static const struct ckpt_obj_ops ckpt_obj_security_ptr_ops = {
 	.obj_name = "SECURITY PTR",
 	.obj_type = CKPT_OBJ_SECURITY_PTR,
-	.ref_drop = obj_no_drop,
-	.ref_grab = obj_no_grab,
+	.ref_drop = NULL,
+	.ref_grab = NULL,
 };
 /*
  * LSM security strings - at restart
@@ -578,7 +568,8 @@ static void obj_hash_clear(struct ckpt_obj_hash *obj_hash)
 
 	for (i = 0; i < CKPT_OBJ_HASH_TOTAL; i++) {
 		hlist_for_each_entry_safe(obj, n, t, &h[i], hash) {
-			obj->ops->ref_drop(obj->ptr, 1);
+			if (obj->ops->ref_drop)
+				obj->ops->ref_drop(obj->ptr, 1);
 			kfree(obj);
 		}
 	}
@@ -692,7 +683,10 @@ static struct ckpt_obj *obj_new(struct ckpt_ctx *ctx, void *ptr,
 		i = hash_long((unsigned long) objref, CKPT_OBJ_HASH_NBITS);
 	}
 
-	ret = ops->ref_grab(obj->ptr);
+	if (ops->ref_grab)
+		ret = ops->ref_grab(obj->ptr);
+	else
+		ret = 0;
 	if (ret < 0) {
 		kfree(obj);
 		obj = ERR_PTR(ret);
@@ -1081,9 +1075,11 @@ int restore_obj(struct ckpt_ctx *ctx, struct ckpt_hdr_objref *h)
 	 * On success, this clears the extra reference taken by obj_new(),
 	 * and on failure, this cleans up the object itself.
 	 */
-	ops->ref_drop(ptr, 0);
+	if (ops->ref_drop)
+		ops->ref_drop(ptr, 0);
 	if (IS_ERR(obj)) {
-		ops->ref_drop(ptr, 1);
+		if (ops->ref_drop)
+			ops->ref_drop(ptr, 1);
 		return PTR_ERR(obj);
 	}
 	return obj->objref;
Signature · 1 line
1.6.3.3
#8 lore raw

PATCH 4/12 Move nsproxy checkpoint ops

In reply to a message not in the archive
---
 checkpoint/objhash.c       |   27 ---------------------------
 include/linux/checkpoint.h |    2 --
 kernel/nsproxy.c           |   40 ++++++++++++++++++++++++++++++++++++++--
 3 files changed, 38 insertions(+), 31 deletions(-)
checkpoint/objhash.c +0 -27
index 999d731..e2c2ce3 100644
@@ -144,22 +144,6 @@ static int obj_sighand_users(void *ptr)
 	return atomic_read(&((struct sighand_struct *) ptr)->count);
 }
 
-static int obj_ns_grab(void *ptr)
-{
-	get_nsproxy((struct nsproxy *) ptr);
-	return 0;
-}
-
-static void obj_ns_drop(void *ptr, int lastref)
-{
-	put_nsproxy((struct nsproxy *) ptr);
-}
-
-static int obj_ns_users(void *ptr)
-{
-	return atomic_read(&((struct nsproxy *) ptr)->count);
-}
-
 static int obj_uts_ns_grab(void *ptr)
 {
 	get_uts_ns((struct uts_namespace *) ptr);
@@ -405,16 +389,6 @@ static const struct ckpt_obj_ops ckpt_obj_signal_ops = {
 	.ref_drop = NULL,
 	.ref_grab = NULL,
 };
-/* ns object */
-static const struct ckpt_obj_ops ckpt_obj_nsproxy_ops = {
-	.obj_name = "NSPROXY",
-	.obj_type = CKPT_OBJ_NS,
-	.ref_drop = obj_ns_drop,
-	.ref_grab = obj_ns_grab,
-	.ref_users = obj_ns_users,
-	.checkpoint = checkpoint_ns,
-	.restore = restore_ns,
-};
 /* uts_ns object */
 static const struct ckpt_obj_ops ckpt_obj_uts_ns_ops = {
 	.obj_name = "UTS_NS",
@@ -536,7 +510,6 @@ static const struct ckpt_obj_ops *ckpt_obj_ops[] = {
 	[CKPT_OBJ_FS] = &ckpt_obj_fs_ops,
 	[CKPT_OBJ_SIGHAND] = &ckpt_obj_sighand_ops,
 	[CKPT_OBJ_SIGNAL] = &ckpt_obj_signal_ops,
-	[CKPT_OBJ_NS] = &ckpt_obj_nsproxy_ops,
 	[CKPT_OBJ_UTS_NS] = &ckpt_obj_uts_ns_ops,
 	[CKPT_OBJ_IPC_NS] = &ckpt_obj_ipc_ns_ops,
 	[CKPT_OBJ_MNT_NS] = &ckpt_obj_mnt_ns_ops,
include/linux/checkpoint.h +0 -2
index e4d668a..1f487a8 100644
@@ -202,8 +202,6 @@ extern int restore_restart_block(struct ckpt_ctx *ctx);
 
 /* namespaces */
 extern int ckpt_collect_ns(struct ckpt_ctx *ctx, struct task_struct *t);
-extern int checkpoint_ns(struct ckpt_ctx *ctx, void *ptr);
-extern void *restore_ns(struct ckpt_ctx *ctx);
 
 /* uts-ns */
 extern int checkpoint_uts_ns(struct ckpt_ctx *ctx, void *ptr);
kernel/nsproxy.c +38 -2
index 0da0d83..746edaf 100644
@@ -301,7 +301,7 @@ static int do_checkpoint_ns(struct ckpt_ctx *ctx, struct nsproxy *nsproxy)
 }
 
 
-int checkpoint_ns(struct ckpt_ctx *ctx, void *ptr)
+static int checkpoint_ns(struct ckpt_ctx *ctx, void *ptr)
 {
 	return do_checkpoint_ns(ctx, (struct nsproxy *) ptr);
 }
@@ -374,15 +374,51 @@ static struct nsproxy *do_restore_ns(struct ckpt_ctx *ctx)
 	return nsproxy;
 }
 
-void *restore_ns(struct ckpt_ctx *ctx)
+static void *restore_ns(struct ckpt_ctx *ctx)
 {
 	return (void *) do_restore_ns(ctx);
 }
+
+static int obj_ns_grab(void *ptr)
+{
+	get_nsproxy((struct nsproxy *) ptr);
+	return 0;
+}
+
+static void obj_ns_drop(void *ptr, int lastref)
+{
+	put_nsproxy((struct nsproxy *) ptr);
+}
+
+static int obj_ns_users(void *ptr)
+{
+	return atomic_read(&((struct nsproxy *) ptr)->count);
+}
+
+/* ns object */
+static const struct ckpt_obj_ops ckpt_obj_nsproxy_ops = {
+	.obj_name = "NSPROXY",
+	.obj_type = CKPT_OBJ_NS,
+	.ref_drop = obj_ns_drop,
+	.ref_grab = obj_ns_grab,
+	.ref_users = obj_ns_users,
+	.checkpoint = checkpoint_ns,
+	.restore = restore_ns,
+};
+
+static inline void register_nsproxy_checkpoint(void)
+{
+	register_checkpoint_obj(&ckpt_obj_nsproxy_ops);
+}
+#else
+static inline void register_nsproxy_checkpoint(void)
+{}
 #endif /* CONFIG_CHECKPOINT */
 
 static int __init nsproxy_cache_init(void)
 {
 	nsproxy_cachep = KMEM_CACHE(nsproxy, SLAB_PANIC);
+	register_nsproxy_checkpoint();
 	return 0;
 }
 
Signature · 1 line
1.6.3.3
#13 lore raw

PATCH 5/12 Move mm checkpoint ops to mm/mmap.c

In reply to a message not in the archive
---
 checkpoint/objhash.c |   27 ---------------------------
 mm/mmap.c            |   38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 27 deletions(-)
checkpoint/objhash.c +0 -27
index e2c2ce3..ce89066 100644
@@ -89,22 +89,6 @@ static int obj_file_users(void *ptr)
 	return atomic_long_read(&((struct file *) ptr)->f_count);
 }
 
-static int obj_mm_grab(void *ptr)
-{
-	atomic_inc(&((struct mm_struct *) ptr)->mm_users);
-	return 0;
-}
-
-static void obj_mm_drop(void *ptr, int lastref)
-{
-	mmput((struct mm_struct *) ptr);
-}
-
-static int obj_mm_users(void *ptr)
-{
-	return atomic_read(&((struct mm_struct *) ptr)->mm_users);
-}
-
 static int obj_fs_grab(void *ptr)
 {
 	get_fs_struct((struct fs_struct *) ptr);
@@ -352,16 +336,6 @@ static const struct ckpt_obj_ops ckpt_obj_file_ops = {
 	.checkpoint = checkpoint_file,
 	.restore = restore_file,
 };
-/* mm object */
-static const struct ckpt_obj_ops ckpt_obj_mm_ops = {
-	.obj_name = "MM",
-	.obj_type = CKPT_OBJ_MM,
-	.ref_drop = obj_mm_drop,
-	.ref_grab = obj_mm_grab,
-	.ref_users = obj_mm_users,
-	.checkpoint = checkpoint_mm,
-	.restore = restore_mm,
-};
 /* fs object */
 static const struct ckpt_obj_ops ckpt_obj_fs_ops = {
 	.obj_name = "FS",
@@ -506,7 +480,6 @@ static const struct ckpt_obj_ops *ckpt_obj_ops[] = {
 	[CKPT_OBJ_INODE] = &ckpt_obj_inode_ops,
 	[CKPT_OBJ_FILE_TABLE] = &ckpt_obj_files_struct_ops,
 	[CKPT_OBJ_FILE] = &ckpt_obj_file_ops,
-	[CKPT_OBJ_MM] = &ckpt_obj_mm_ops,
 	[CKPT_OBJ_FS] = &ckpt_obj_fs_ops,
 	[CKPT_OBJ_SIGHAND] = &ckpt_obj_sighand_ops,
 	[CKPT_OBJ_SIGNAL] = &ckpt_obj_signal_ops,
mm/mmap.c +38 -0
index 6aa606a..b19a754 100644
@@ -2623,6 +2623,43 @@ void mm_drop_all_locks(struct mm_struct *mm)
 	mutex_unlock(&mm_all_locks_mutex);
 }
 
+#ifdef CONFIG_CHECKPOINT
+static int obj_mm_grab(void *ptr)
+{
+	atomic_inc(&((struct mm_struct *) ptr)->mm_users);
+	return 0;
+}
+
+static void obj_mm_drop(void *ptr, int lastref)
+{
+	mmput((struct mm_struct *) ptr);
+}
+
+static int obj_mm_users(void *ptr)
+{
+	return atomic_read(&((struct mm_struct *) ptr)->mm_users);
+}
+
+/* mm object */
+static const struct ckpt_obj_ops ckpt_obj_mm_ops = {
+	.obj_name = "MM",
+	.obj_type = CKPT_OBJ_MM,
+	.ref_drop = obj_mm_drop,
+	.ref_grab = obj_mm_grab,
+	.ref_users = obj_mm_users,
+	.checkpoint = checkpoint_mm,
+	.restore = restore_mm,
+};
+
+static inline void register_mmap_checkpoint(void)
+{
+	register_checkpoint_obj(&ckpt_obj_mm_ops);
+}
+#else
+static inline void register_mmap_checkpoint(void)
+{}
+#endif
+
 /*
  * initialise the VMA slab
  */
@@ -2630,6 +2667,7 @@ void __init mmap_init(void)
 {
 	int ret;
 
+	register_mmap_checkpoint();
 	ret = percpu_counter_init(&vm_committed_as, 0);
 	VM_BUG_ON(ret);
 }
Signature · 1 line
1.6.3.3
#15 lore raw

PATCH 6/12 Move checkpoint/files.c into fs/

In reply to a message not in the archive

Subsequent patches break up fs/checkpoint.c into the file table checkpoint, the fs_struct checkpoint, etc.

---
 checkpoint/Makefile |    1 -
 checkpoint/files.c  | 1041 ---------------------------------------------------
 fs/Makefile         |    1 +
 fs/checkpoint.c     | 1041 +++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 1042 insertions(+), 1042 deletions(-)
 delete mode 100644 checkpoint/files.c
 create mode 100644 fs/checkpoint.c
checkpoint/Makefile +0 -1
index f8a55df..02e66b6 100644
@@ -9,6 +9,5 @@ obj-$(CONFIG_CHECKPOINT) += \
 	restart.o \
 	process.o \
 	namespace.o \
-	files.o \
 	memory.o \
 	signal.o
checkpoint/files.c deleted +0 -1041

1,041 lines not on this page · raw message

fs/Makefile +1 -0
index af6d047..93c4775 100644
@@ -29,6 +29,7 @@ obj-$(CONFIG_EVENTFD)		+= eventfd.o
 obj-$(CONFIG_AIO)               += aio.o
 obj-$(CONFIG_FILE_LOCKING)      += locks.o
 obj-$(CONFIG_COMPAT)		+= compat.o compat_ioctl.o
+obj-$(CONFIG_CHECKPOINT)	+= checkpoint.o
 
 nfsd-$(CONFIG_NFSD)		:= nfsctl.o
 obj-y				+= $(nfsd-y) $(nfsd-m)
fs/checkpoint.c new file +1041 -0

1,041 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#17 lore raw

PATCH 7/12 Move checkpoint/restart of signals into kernel/signal.c

In reply to a message not in the archive
---
 checkpoint/Makefile    |    1 -
 checkpoint/signal.c    |  732 ------------------------------------------------
 include/linux/signal.h |   17 +-
 kernel/signal.c        |  723 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 738 insertions(+), 735 deletions(-)
 delete mode 100644 checkpoint/signal.c
checkpoint/Makefile +0 -1
index 02e66b6..5bc8468 100644
@@ -10,4 +10,3 @@ obj-$(CONFIG_CHECKPOINT) += \
 	process.o \
 	namespace.o \
 	memory.o \
-	signal.o
checkpoint/signal.c deleted +0 -732

732 lines not on this page · raw message

include/linux/signal.h +15 -2
index af6cac3..4a19f62 100644
@@ -374,11 +374,24 @@ int unhandled_signal(struct task_struct *tsk, int sig);
 	(!siginmask(signr, SIG_KERNEL_IGNORE_MASK|SIG_KERNEL_STOP_MASK) && \
 	 (t)->sighand->action[(signr)-1].sa.sa_handler == SIG_DFL)
 
-void signals_init(void);
-
+#ifdef CONFIG_CHECKPOINT
 /* [arch] checkpoint: should saved_sigmask be used in place of blocked */
 int task_has_saved_sigmask(struct task_struct *task);
 
+struct ckpt_ctx;
+int ckpt_collect_sighand(struct ckpt_ctx *ctx, struct task_struct *t);
+int checkpoint_sighand(struct ckpt_ctx *ctx, void *ptr);
+int checkpoint_obj_sighand(struct ckpt_ctx *ctx, struct task_struct *t);
+int checkpoint_obj_signal(struct ckpt_ctx *ctx, struct task_struct *t);
+int checkpoint_task_signal(struct ckpt_ctx *ctx, struct task_struct *t);
+void *restore_sighand(struct ckpt_ctx *ctx);
+int restore_obj_sighand(struct ckpt_ctx *ctx, int sighand_objref);
+int restore_obj_signal(struct ckpt_ctx *ctx, int signal_objref);
+int restore_task_signal(struct ckpt_ctx *ctx);
+#endif /* CONFIG_CHECKPOINT */
+
+void signals_init(void);
+
 #endif /* __KERNEL__ */
 
 #endif /* _LINUX_SIGNAL_H */
kernel/signal.c +723 -0

735 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#22 lore raw

PATCH 8/12 Move signal ckpt_obj_ops into kernel/signal.c

In reply to a message not in the archive
---
 checkpoint/objhash.c       |   36 ---------------------------------
 include/linux/checkpoint.h |    2 -
 include/linux/signal.h     |    2 -
 kernel/signal.c            |   48 ++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 46 insertions(+), 42 deletions(-)
checkpoint/objhash.c +0 -36
index ce89066..cdbb1f1 100644
@@ -112,22 +112,6 @@ static int obj_fs_users(void *ptr)
 	return ((struct fs_struct *) ptr)->users;
 }
 
-static int obj_sighand_grab(void *ptr)
-{
-	atomic_inc(&((struct sighand_struct *) ptr)->count);
-	return 0;
-}
-
-static void obj_sighand_drop(void *ptr, int lastref)
-{
-	__cleanup_sighand((struct sighand_struct *) ptr);
-}
-
-static int obj_sighand_users(void *ptr)
-{
-	return atomic_read(&((struct sighand_struct *) ptr)->count);
-}
-
 static int obj_uts_ns_grab(void *ptr)
 {
 	get_uts_ns((struct uts_namespace *) ptr);
@@ -346,23 +330,6 @@ static const struct ckpt_obj_ops ckpt_obj_fs_ops = {
 	.checkpoint = checkpoint_fs,
 	.restore = restore_fs,
 };
-/* sighand object */
-static const struct ckpt_obj_ops ckpt_obj_sighand_ops = {
-	.obj_name = "SIGHAND",
-	.obj_type = CKPT_OBJ_SIGHAND,
-	.ref_drop = obj_sighand_drop,
-	.ref_grab = obj_sighand_grab,
-	.ref_users = obj_sighand_users,
-	.checkpoint = checkpoint_sighand,
-	.restore = restore_sighand,
-};
-/* signal object */
-static const struct ckpt_obj_ops ckpt_obj_signal_ops = {
-	.obj_name = "SIGNAL",
-	.obj_type = CKPT_OBJ_SIGNAL,
-	.ref_drop = NULL,
-	.ref_grab = NULL,
-};
 /* uts_ns object */
 static const struct ckpt_obj_ops ckpt_obj_uts_ns_ops = {
 	.obj_name = "UTS_NS",
@@ -481,8 +448,6 @@ static const struct ckpt_obj_ops *ckpt_obj_ops[] = {
 	[CKPT_OBJ_FILE_TABLE] = &ckpt_obj_files_struct_ops,
 	[CKPT_OBJ_FILE] = &ckpt_obj_file_ops,
 	[CKPT_OBJ_FS] = &ckpt_obj_fs_ops,
-	[CKPT_OBJ_SIGHAND] = &ckpt_obj_sighand_ops,
-	[CKPT_OBJ_SIGNAL] = &ckpt_obj_signal_ops,
 	[CKPT_OBJ_UTS_NS] = &ckpt_obj_uts_ns_ops,
 	[CKPT_OBJ_IPC_NS] = &ckpt_obj_ipc_ns_ops,
 	[CKPT_OBJ_MNT_NS] = &ckpt_obj_mnt_ns_ops,
@@ -501,7 +466,6 @@ void register_checkpoint_obj(const struct ckpt_obj_ops *ops)
 	ckpt_obj_ops[ops->obj_type] = ops;
 }
 
-
 #define CKPT_OBJ_HASH_NBITS  10
 #define CKPT_OBJ_HASH_TOTAL  (1UL << CKPT_OBJ_HASH_NBITS)
 
include/linux/checkpoint.h +0 -2
index 1f487a8..7a06272 100644
@@ -308,8 +308,6 @@ extern int checkpoint_obj_sighand(struct ckpt_ctx *ctx, struct task_struct *t);
 extern int restore_obj_sighand(struct ckpt_ctx *ctx, int sighand_objref);
 
 extern int ckpt_collect_sighand(struct ckpt_ctx *ctx, struct task_struct *t);
-extern int checkpoint_sighand(struct ckpt_ctx *ctx, void *ptr);
-extern void *restore_sighand(struct ckpt_ctx *ctx);
 
 extern int checkpoint_obj_signal(struct ckpt_ctx *ctx, struct task_struct *t);
 extern int restore_obj_signal(struct ckpt_ctx *ctx, int signal_objref);
include/linux/signal.h +0 -2
index 4a19f62..6d3b0e1 100644
@@ -380,11 +380,9 @@ int task_has_saved_sigmask(struct task_struct *task);
 
 struct ckpt_ctx;
 int ckpt_collect_sighand(struct ckpt_ctx *ctx, struct task_struct *t);
-int checkpoint_sighand(struct ckpt_ctx *ctx, void *ptr);
 int checkpoint_obj_sighand(struct ckpt_ctx *ctx, struct task_struct *t);
 int checkpoint_obj_signal(struct ckpt_ctx *ctx, struct task_struct *t);
 int checkpoint_task_signal(struct ckpt_ctx *ctx, struct task_struct *t);
-void *restore_sighand(struct ckpt_ctx *ctx);
 int restore_obj_sighand(struct ckpt_ctx *ctx, int sighand_objref);
 int restore_obj_signal(struct ckpt_ctx *ctx, int signal_objref);
 int restore_task_signal(struct ckpt_ctx *ctx);
kernel/signal.c +46 -2

75 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#24 lore raw

PATCH 9/12 Move mmap checkpoint/restart into mm/mmap.c

In reply to a message not in the archive

Moving the memory pieces is more complicated because portions of it are shared with ipc. Split the mm header bits into another header file: include/linux/mm_checkpoint.h file so it's clear that these are the only pieces we need in ipc/

---
 checkpoint/Makefile           |    3 +-
 checkpoint/memory.c           | 1364 -----------------------------------------
 checkpoint/process.c          |    1 +
 checkpoint/sys.c              |    1 +
 include/linux/checkpoint.h    |   50 +--
 include/linux/mm.h            |   18 +
 include/linux/mm_checkpoint.h |   45 ++
 include/linux/proc_fs.h       |   19 -
 ipc/checkpoint.c              |    3 +-
 ipc/checkpoint_msg.c          |    3 +-
 ipc/checkpoint_sem.c          |    3 +-
 ipc/checkpoint_shm.c          |    3 +-
 ipc/shm.c                     |    2 +-
 mm/filemap.c                  |    2 +-
 mm/mmap.c                     | 1348 ++++++++++++++++++++++++++++++++++++++++
 mm/shmem.c                    |    2 +-
 16 files changed, 1424 insertions(+), 1443 deletions(-)
 delete mode 100644 checkpoint/memory.c
 create mode 100644 include/linux/mm_checkpoint.h
checkpoint/Makefile +1 -2
index 5bc8468..9571af3 100644
@@ -8,5 +8,4 @@ obj-$(CONFIG_CHECKPOINT) += \
 	checkpoint.o \
 	restart.o \
 	process.o \
-	namespace.o \
-	memory.o \
+	namespace.o
checkpoint/memory.c deleted +0 -1364

1,364 lines not on this page · raw message

checkpoint/process.c +1 -0
index f917112..6e3e382 100644
@@ -21,6 +21,7 @@
 #include <linux/user_namespace.h>
 #include <linux/checkpoint.h>
 #include <linux/checkpoint_hdr.h>
+#include <linux/mm_checkpoint.h>
 #include <linux/syscalls.h>
 
 
checkpoint/sys.c +1 -0
index d34ff98..a420c02 100644
@@ -21,6 +21,7 @@
 #include <linux/uaccess.h>
 #include <linux/capability.h>
 #include <linux/checkpoint.h>
+#include <linux/mm_checkpoint.h> /* for ckpt_pgarr_free() */
 #include <linux/deferqueue.h>
 
 /*
include/linux/checkpoint.h +3 -47

78 lines not on this page · raw message

include/linux/mm.h +18 -0
index 210d8e3..2459d1d 100644
@@ -1303,8 +1303,26 @@ extern int apply_to_page_range(struct mm_struct *mm, unsigned long address,
 			       unsigned long size, pte_fn_t fn, void *data);
 
 #ifdef CONFIG_PROC_FS
+/* Set/Get/Dup a reference to the file /proc/<pid>/exe symlinks to. */
+extern void set_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file);
+extern struct file *get_mm_exe_file(struct mm_struct *mm);
+extern void dup_mm_exe_file(struct mm_struct *oldmm, struct mm_struct *newmm);
+
 void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
 #else
+static inline void set_mm_exe_file(struct mm_struct *mm,
+				   struct file *new_exe_file)
+{}
+
+static inline struct file *get_mm_exe_file(struct mm_struct *mm)
+{
+	return NULL;
+}
+
+static inline void dup_mm_exe_file(struct mm_struct *oldmm,
+				   struct mm_struct *newmm)
+{}
+
 static inline void vm_stat_account(struct mm_struct *mm,
 			unsigned long flags, struct file *file, long pages)
 {
include/linux/mm_checkpoint.h new file +45 -0

45 lines not on this page · raw message

include/linux/proc_fs.h +0 -19
index 379eaed..e187078 100644
@@ -173,12 +173,6 @@ extern void proc_net_remove(struct net *net, const char *name);
 extern struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name,
 	struct proc_dir_entry *parent);
 
-/* While the {get|set|dup}_mm_exe_file functions are for mm_structs, they are
- * only needed to implement /proc/<pid>|self/exe so we define them here. */
-extern void set_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file);
-extern struct file *get_mm_exe_file(struct mm_struct *mm);
-extern void dup_mm_exe_file(struct mm_struct *oldmm, struct mm_struct *newmm);
-
 #else
 
 #define proc_net_fops_create(net, name, mode, fops)  ({ (void)(mode), NULL; })
@@ -226,19 +220,6 @@ static inline void pid_ns_release_proc(struct pid_namespace *ns)
 {
 }
 
-static inline void set_mm_exe_file(struct mm_struct *mm,
-				   struct file *new_exe_file)
-{}
-
-static inline struct file *get_mm_exe_file(struct mm_struct *mm)
-{
-	return NULL;
-}
-
-static inline void dup_mm_exe_file(struct mm_struct *oldmm,
-	       			   struct mm_struct *newmm)
-{}
-
 #endif /* CONFIG_PROC_FS */
 
 #if !defined(CONFIG_PROC_KCORE)
ipc/checkpoint.c +1 -2
index 4322dea..2b05067 100644
@@ -15,8 +15,7 @@
 #include <linux/msg.h>
 #include <linux/sched.h>
 #include <linux/ipc_namespace.h>
-#include <linux/checkpoint.h>
-#include <linux/checkpoint_hdr.h>
+#include <linux/mm_checkpoint.h>
 
 #include "util.h"
 
ipc/checkpoint_msg.c +1 -2
index 61b3d78..51fb712 100644
@@ -22,8 +22,7 @@
 
 #include "util.h"
 
-#include <linux/checkpoint.h>
-#include <linux/checkpoint_hdr.h>
+#include <linux/mm_checkpoint.h>
 
 /************************************************************************
  * ipc checkpoint
ipc/checkpoint_sem.c +1 -2
index 395c84d..d1a9ba1 100644
@@ -22,8 +22,7 @@
 struct msg_msg;
 #include "util.h"
 
-#include <linux/checkpoint.h>
-#include <linux/checkpoint_hdr.h>
+#include <linux/mm_checkpoint.h>
 
 /************************************************************************
  * ipc checkpoint
ipc/checkpoint_shm.c +1 -2
index 01091d9..f06cfda 100644
@@ -26,8 +26,7 @@
 #include <linux/msg.h>	/* needed for util.h that uses 'struct msg_msg' */
 #include "util.h"
 
-#include <linux/checkpoint.h>
-#include <linux/checkpoint_hdr.h>
+#include <linux/mm_checkpoint.h>
 
 /************************************************************************
  * ipc checkpoint
ipc/shm.c +1 -1
index 18ae1b8..f4c3cea 100644
@@ -39,7 +39,7 @@
 #include <linux/nsproxy.h>
 #include <linux/mount.h>
 #include <linux/ipc_namespace.h>
-#include <linux/checkpoint.h>
+#include <linux/mm_checkpoint.h>
 
 #include <asm/uaccess.h>
 
mm/filemap.c +1 -1
index 4ea28e6..1495ec0 100644
@@ -34,7 +34,7 @@
 #include <linux/hardirq.h> /* for BUG_ON(!in_atomic()) only */
 #include <linux/memcontrol.h>
 #include <linux/mm_inline.h> /* for page_is_file_cache() */
-#include <linux/checkpoint.h>
+#include <linux/mm_checkpoint.h>
 #include "internal.h"
 
 /*
mm/mmap.c +1348 -0

1,360 lines not on this page · raw message

mm/shmem.c +1 -1
index e103155..3696342 100644
@@ -29,7 +29,7 @@
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/swap.h>
-#include <linux/checkpoint.h>
+#include <linux/mm_checkpoint.h>
 
 static struct vfsmount *shm_mnt;
 
Signature · 1 line
1.6.3.3
#26 lore raw

PATCH 10/12 Move uts ns into kernel/utsname*.c

In reply to a message not in the archive

Unlike other checkpoint object ops we're moving out of checkpoint/objhash.c, the one for uts namespaces needs to be defined even if CONFIG_UTS_NS is not. Because the definitions used in kernel/utsname_sysctl.c can come from kernel/utsname.c, we declare them in include/linux/utsname.h. If the definitions are missing then utsname_sysctl.c defines its own.

---
 checkpoint/namespace.c     |   82 --------------------------------------
 checkpoint/objhash.c       |   27 -------------
 include/linux/checkpoint.h |    4 --
 include/linux/utsname.h    |   11 +++++
 kernel/utsname.c           |   85 ++++++++++++++++++++++++++++++++++++++++
 kernel/utsname_sysctl.c    |   93 ++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 189 insertions(+), 113 deletions(-)
checkpoint/namespace.c +0 -82
index 4b3ac5a..538bd4a 100644
@@ -18,88 +18,6 @@
 #include <linux/checkpoint_hdr.h>
 
 /*
- * uts_ns  -  this needs to compile even for !CONFIG_UTS_NS, so
- *   the code may not reside in kernel/utsname.c (which wouldn't
- *   compile then).
- */
-static int do_checkpoint_uts_ns(struct ckpt_ctx *ctx,
-				struct uts_namespace *uts_ns)
-{
-	struct ckpt_hdr_utsns *h;
-	struct new_utsname *name;
-	int ret;
-
-	h = ckpt_hdr_get_type(ctx, sizeof(*h), CKPT_HDR_UTS_NS);
-	if (!h)
-		return -ENOMEM;
-
-	down_read(&uts_sem);
-	name = &uts_ns->name;
-	memcpy(h->sysname, name->sysname, sizeof(name->sysname));
-	memcpy(h->nodename, name->nodename, sizeof(name->nodename));
-	memcpy(h->release, name->release, sizeof(name->release));
-	memcpy(h->version, name->version, sizeof(name->version));
-	memcpy(h->machine, name->machine, sizeof(name->machine));
-	memcpy(h->domainname, name->domainname, sizeof(name->domainname));
-	up_read(&uts_sem);
-
-	ret = ckpt_write_obj(ctx, &h->h);
-	ckpt_hdr_put(ctx, h);
-	return ret;
-}
-
-int checkpoint_uts_ns(struct ckpt_ctx *ctx, void *ptr)
-{
-	return do_checkpoint_uts_ns(ctx, (struct uts_namespace *) ptr);
-}
-
-static struct uts_namespace *do_restore_uts_ns(struct ckpt_ctx *ctx)
-{
-	struct ckpt_hdr_utsns *h;
-	struct uts_namespace *uts_ns = NULL;
-	struct new_utsname *name;
-
-	h = ckpt_read_obj_type(ctx, sizeof(*h), CKPT_HDR_UTS_NS);
-	if (IS_ERR(h))
-		return (struct uts_namespace *) h;
-
-#ifdef CONFIG_UTS_NS
-	uts_ns = create_uts_ns();
-	if (!uts_ns) {
-		uts_ns = ERR_PTR(-ENOMEM);
-		goto out;
-	}
-	down_read(&uts_sem);
-	name = &uts_ns->name;
-	memcpy(name->sysname, h->sysname, sizeof(name->sysname));
-	memcpy(name->nodename, h->nodename, sizeof(name->nodename));
-	memcpy(name->release, h->release, sizeof(name->release));
-	memcpy(name->version, h->version, sizeof(name->version));
-	memcpy(name->machine, h->machine, sizeof(name->machine));
-	memcpy(name->domainname, h->domainname, sizeof(name->domainname));
-	up_read(&uts_sem);
-#else
-	/* complain if image contains multiple namespaces */
-	if (ctx->stats.uts_ns) {
-		uts_ns = ERR_PTR(-EEXIST);
-		goto out;
-	}
-	uts_ns = current->nsproxy->uts_ns;
-	get_uts_ns(uts_ns);
-#endif
-
-	ctx->stats.uts_ns++;
- out:
-	ckpt_hdr_put(ctx, h);
-	return uts_ns;
-}
-
-void *restore_uts_ns(struct ckpt_ctx *ctx)
-{
-	return (void *) do_restore_uts_ns(ctx);
-}
-
-/*
  * user_ns  -  trivial checkpoint/restore for !CONFIG_USER_NS case
  */
 #ifndef CONFIG_USER_NS
checkpoint/objhash.c +0 -27
index cdbb1f1..5678943 100644
@@ -112,22 +112,6 @@ static int obj_fs_users(void *ptr)
 	return ((struct fs_struct *) ptr)->users;
 }
 
-static int obj_uts_ns_grab(void *ptr)
-{
-	get_uts_ns((struct uts_namespace *) ptr);
-	return 0;
-}
-
-static void obj_uts_ns_drop(void *ptr, int lastref)
-{
-	put_uts_ns((struct uts_namespace *) ptr);
-}
-
-static int obj_uts_ns_users(void *ptr)
-{
-	return atomic_read(&((struct uts_namespace *) ptr)->kref.refcount);
-}
-
 static int obj_ipc_ns_grab(void *ptr)
 {
 	get_ipc_ns((struct ipc_namespace *) ptr);
@@ -330,16 +314,6 @@ static const struct ckpt_obj_ops ckpt_obj_fs_ops = {
 	.checkpoint = checkpoint_fs,
 	.restore = restore_fs,
 };
-/* uts_ns object */
-static const struct ckpt_obj_ops ckpt_obj_uts_ns_ops = {
-	.obj_name = "UTS_NS",
-	.obj_type = CKPT_OBJ_UTS_NS,
-	.ref_drop = obj_uts_ns_drop,
-	.ref_grab = obj_uts_ns_grab,
-	.ref_users = obj_uts_ns_users,
-	.checkpoint = checkpoint_uts_ns,
-	.restore = restore_uts_ns,
-};
 /* ipc_ns object */
 static const struct ckpt_obj_ops ckpt_obj_ipc_ns_ops = {
 	.obj_name = "IPC_NS",
@@ -448,7 +422,6 @@ static const struct ckpt_obj_ops *ckpt_obj_ops[] = {
 	[CKPT_OBJ_FILE_TABLE] = &ckpt_obj_files_struct_ops,
 	[CKPT_OBJ_FILE] = &ckpt_obj_file_ops,
 	[CKPT_OBJ_FS] = &ckpt_obj_fs_ops,
-	[CKPT_OBJ_UTS_NS] = &ckpt_obj_uts_ns_ops,
 	[CKPT_OBJ_IPC_NS] = &ckpt_obj_ipc_ns_ops,
 	[CKPT_OBJ_MNT_NS] = &ckpt_obj_mnt_ns_ops,
 	[CKPT_OBJ_USER_NS] = &ckpt_obj_mnt_ns_ops,
include/linux/checkpoint.h +0 -4
index 0fc3f70..4a2b24b 100644
@@ -201,10 +201,6 @@ extern int restore_restart_block(struct ckpt_ctx *ctx);
 /* namespaces */
 extern int ckpt_collect_ns(struct ckpt_ctx *ctx, struct task_struct *t);
 
-/* uts-ns */
-extern int checkpoint_uts_ns(struct ckpt_ctx *ctx, void *ptr);
-extern void *restore_uts_ns(struct ckpt_ctx *ctx);
-
 /* ipc-ns */
 #ifdef CONFIG_SYSVIPC
 extern int checkpoint_ipc_ns(struct ckpt_ctx *ctx, void *ptr);
include/linux/utsname.h +11 -0
index 774001d..ce6fede 100644
@@ -58,6 +58,17 @@ static inline void put_uts_ns(struct uts_namespace *ns)
 {
 	kref_put(&ns->kref, free_uts_ns);
 }
+
+#ifdef CONFIG_CHECKPOINT
+struct ckpt_ctx;
+extern int do_checkpoint_uts_ns(struct ckpt_ctx *ctx,
+				struct uts_namespace *uts_ns);
+
+extern struct uts_namespace *do_restore_uts_ns(struct ckpt_ctx *ctx);
+extern int obj_uts_ns_grab(void *ptr);
+extern void obj_uts_ns_drop(void *ptr, int lastref);
+extern int obj_uts_ns_users(void *ptr);
+#endif /* CONFIG_CHECKPOINT */
 #else
 static inline void get_uts_ns(struct uts_namespace *ns)
 {
kernel/utsname.c +85 -0

88 lines not on this page · raw message

kernel/utsname_sysctl.c +93 -0

111 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#29 lore raw

PATCH 11/12 Move user namespace ckpt_obj_ops

In reply to a message not in the archive

IMPORTANT: Removes the ability to checkpoint/restore an initial user namespace when CONFIG_USER_NS is not selected.

---
 checkpoint/Makefile            |    3 +-
 checkpoint/namespace.c         |   59 ----------------------------------------
 checkpoint/objhash.c           |   20 -------------
 include/linux/user_namespace.h |    1 -
 kernel/user_namespace.c        |   26 +++++++++++++++++
 5 files changed, 27 insertions(+), 82 deletions(-)
 delete mode 100644 checkpoint/namespace.c
checkpoint/Makefile +1 -2
index 9571af3..5aa6a75 100644
@@ -7,5 +7,4 @@ obj-$(CONFIG_CHECKPOINT) += \
 	objhash.o \
 	checkpoint.o \
 	restart.o \
-	process.o \
-	namespace.o
+	process.o
checkpoint/namespace.c deleted +0 -59

59 lines not on this page · raw message

checkpoint/objhash.c +0 -20
index 5678943..70c54f5 100644
@@ -167,17 +167,6 @@ static void obj_user_drop(void *ptr, int lastref)
 	free_uid((struct user_struct *) ptr);
 }
 
-static int obj_userns_grab(void *ptr)
-{
-	get_user_ns((struct user_namespace *) ptr);
-	return 0;
-}
-
-static void obj_userns_drop(void *ptr, int lastref)
-{
-	put_user_ns((struct user_namespace *) ptr);
-}
-
 static int obj_groupinfo_grab(void *ptr)
 {
 	get_group_info((struct group_info *) ptr);
@@ -332,15 +321,6 @@ static const struct ckpt_obj_ops ckpt_obj_mnt_ns_ops = {
 	.ref_drop = obj_mnt_ns_drop,
 	.ref_users = obj_mnt_ns_users,
 };
-/* user_ns object */
-static const struct ckpt_obj_ops ckpt_obj_user_ns_ops = {
-	.obj_name = "USER_NS",
-	.obj_type = CKPT_OBJ_USER_NS,
-	.ref_drop = obj_userns_drop,
-	.ref_grab = obj_userns_grab,
-	.checkpoint = checkpoint_userns,
-	.restore = restore_userns,
-};
 /* struct cred */
 static const struct ckpt_obj_ops ckpt_obj_cred_ops = {
 	.obj_name = "CRED",
include/linux/user_namespace.h +0 -1
index f6ea75d..96a74bc 100644
@@ -59,7 +59,6 @@ static inline int create_user_ns(struct cred *new)
 static inline void put_user_ns(struct user_namespace *ns)
 {
 }
-
 #endif
 
 #endif /* _LINUX_USER_H */
kernel/user_namespace.c +26 -0
index 3a35b50..f279942 100644
@@ -191,4 +191,30 @@ void *restore_userns(struct ckpt_ctx *ctx)
 {
 	return (void *) do_restore_userns(ctx);
 }
+
+static int obj_userns_grab(void *ptr)
+{
+	get_user_ns((struct user_namespace *) ptr);
+	return 0;
+}
+
+static void obj_userns_drop(void *ptr, int lastref)
+{
+	put_user_ns((struct user_namespace *) ptr);
+}
+
+static const struct ckpt_obj_ops ckpt_obj_user_ns_ops = {
+	.obj_name = "USER_NS",
+	.obj_type = CKPT_OBJ_USER_NS,
+	.ref_drop = obj_userns_drop,
+	.ref_grab = obj_userns_grab,
+	.checkpoint = checkpoint_userns,
+	.restore = restore_userns,
+};
+
+int __init userns_init(void)
+{
+	register_checkpoint_obj(&ckpt_obj_user_ns_ops);
+	return 0;
+}
 #endif
Signature · 1 line
1.6.3.3
#32 lore raw

PATCH 12/12 Move remaining checkpoint/* files into kernel/

In reply to a message not in the archive
---
 Makefile                       |    2 +-
 checkpoint/Kconfig             |   20 -
 checkpoint/Makefile            |   10 -
 checkpoint/checkpoint.c        |  660 -------------------
 checkpoint/objhash.c           | 1083 ------------------------------
 checkpoint/process.c           |  929 --------------------------
 checkpoint/restart.c           | 1423 ----------------------------------------
 checkpoint/sys.c               |  719 --------------------
 init/Kconfig                   |    2 +-
 kernel/Makefile                |    1 +
 kernel/checkpoint/Kconfig      |   20 +
 kernel/checkpoint/Makefile     |   10 +
 kernel/checkpoint/checkpoint.c |  660 +++++++++++++++++++
 kernel/checkpoint/objhash.c    | 1083 ++++++++++++++++++++++++++++++
 kernel/checkpoint/process.c    |  929 ++++++++++++++++++++++++++
 kernel/checkpoint/restart.c    | 1423 ++++++++++++++++++++++++++++++++++++++++
 kernel/checkpoint/sys.c        |  719 ++++++++++++++++++++
 17 files changed, 4847 insertions(+), 4846 deletions(-)
 delete mode 100644 checkpoint/Kconfig
 delete mode 100644 checkpoint/Makefile
 delete mode 100644 checkpoint/checkpoint.c
 delete mode 100644 checkpoint/objhash.c
 delete mode 100644 checkpoint/process.c
 delete mode 100644 checkpoint/restart.c
 delete mode 100644 checkpoint/sys.c
 create mode 100644 kernel/checkpoint/Kconfig
 create mode 100644 kernel/checkpoint/Makefile
 create mode 100644 kernel/checkpoint/checkpoint.c
 create mode 100644 kernel/checkpoint/objhash.c
 create mode 100644 kernel/checkpoint/process.c
 create mode 100644 kernel/checkpoint/restart.c
 create mode 100644 kernel/checkpoint/sys.c
Makefile +1 -1
index 58dd95e..c84fd64 100644
@@ -650,7 +650,7 @@ export mod_strip_cmd
 
 
 ifeq ($(KBUILD_EXTMOD),)
-core-y		+= kernel/ mm/ fs/ ipc/ security/ crypto/ block/ checkpoint/
+core-y		+= kernel/ mm/ fs/ ipc/ security/ crypto/ block/
 
 vmlinux-dirs	:= $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
 		     $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
checkpoint/Kconfig deleted +0 -20
deleted file mode 100644
index 4a2c845..0000000
@@ -1,20 +0,0 @@
-# Architectures should define CHECKPOINT_SUPPORT when they have
-# implemented the hooks for processor state etc. needed by the
-# core checkpoint/restart code.
-
-config DEFERQUEUE
-	bool
-	default n
-
-config CHECKPOINT
-	bool "Checkpoint/restart (EXPERIMENTAL)"
-	depends on CHECKPOINT_SUPPORT && EXPERIMENTAL
-	depends on CGROUP_FREEZER
-	select DEFERQUEUE
-	help
-	  Application checkpoint/restart is the ability to save the
-	  state of a running application so that it can later resume
-	  its execution from the time at which it was checkpointed.
-
-	  Turning this option on will enable checkpoint and restart
-	  functionality in the kernel.
checkpoint/Makefile deleted +0 -10
deleted file mode 100644
index 5aa6a75..0000000
@@ -1,10 +0,0 @@
-#
-# Makefile for linux checkpoint/restart.
-#
-
-obj-$(CONFIG_CHECKPOINT) += \
-	sys.o \
-	objhash.o \
-	checkpoint.o \
-	restart.o \
-	process.o
checkpoint/checkpoint.c deleted +0 -660

660 lines not on this page · raw message

checkpoint/objhash.c deleted +0 -1083

1,083 lines not on this page · raw message

checkpoint/process.c deleted +0 -929

929 lines not on this page · raw message

checkpoint/restart.c deleted +0 -1423

290 lines not on this page · raw message

checkpoint/sys.c deleted +0 -719

719 lines not on this page · raw message

init/Kconfig +1 -1
index fb43090..5184f65 100644

Lines of this file are not shown. View the raw message.

kernel/Makefile +1 -0
index 3c2c303..eea17e1 100644

Lines of this file are not shown. View the raw message.

kernel/checkpoint/Kconfig new file +20 -0
new file mode 100644
index 0000000..4a2c845

Lines of this file are not shown. View the raw message.

kernel/checkpoint/Makefile new file +10 -0
new file mode 100644
index 0000000..5aa6a75

Lines of this file are not shown. View the raw message.

kernel/checkpoint/checkpoint.c new file +660 -0

660 lines not on this page · raw message

kernel/checkpoint/objhash.c new file +1083 -0

1,083 lines not on this page · raw message

kernel/checkpoint/process.c new file +929 -0

929 lines not on this page · raw message

kernel/checkpoint/restart.c new file +1423 -0

1,423 lines not on this page · raw message

kernel/checkpoint/sys.c new file +719 -0

719 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.6.3.3

Part of the diff is not shown here. View the raw message.

#18 lore raw

Re: [PATCH 06/12] Move checkpoint/files.c into fs/

In reply to a message not in the archive
Quoted 4 lines · Matt Helsley

Subsequent patches break up fs/checkpoint.c into the file table checkpoint, the fs_struct checkpoint, etc.

The set looks good so far - it would have been nice though to do

git mv checkpoint/files.c fs/checkpoint.c

as one separate commit, and then 'git format-patch -M'. Then any changes you had to make in a separate patch. As you have it here, I'd have to review 1050 lines of the original file line by line against the 1050 lines in the new file... :(

-serge

#20 lore raw

Re: [PATCH 06/12] Move checkpoint/files.c into fs/

In reply to a message not in the archive
Quoted 11 lines · Serge E. Hallyn
Quoted 4 lines · Matt Helsley

Subsequent patches break up fs/checkpoint.c into the file table checkpoint, the fs_struct checkpoint, etc.

The set looks good so far - it would have been nice though to do

git mv checkpoint/files.c fs/checkpoint.c

as one separate commit, and then 'git format-patch -M'. Then any

I did a git mv but I didn't have it detect renames when sending the patches, sorry. I'll supply that next time since that'll be useful for more than just this patch.

Incidentally, the patch description isn't correct -- subsequent patches don't break it up. Those are part of my plans for future series. I just wanted to get this set out for review first. This is also why the intro says [00/13] when there are only 12 patches :P.

Thanks for reviewing these.

Cheers,
-Matt Helsley

#9 lore raw

Re: [PATCH 03/12] Replace obj_no_grab and obj_no_drop ckpt ops with NULL

In reply to a message not in the archive
Quoted 52 lines · Matt Helsley

Distributing the ckpt_obj_ops would require sharing these functions when we can get by with simple NULL pointers in the grab/drop operations.

---
 checkpoint/objhash.c |   36 ++++++++++++++++--------------------
 1 files changed, 16 insertions(+), 20 deletions(-)
checkpoint/objhash.c +4 -14
index 832520d..999d731 100644
@@ -47,16 +47,6 @@ struct ckpt_obj_hash {
 
 /* helper grab/drop/users functions */
 
-static void obj_no_drop(void *ptr, int lastref)
-{
-	return;
-}
-
-static int obj_no_grab(void *ptr)
-{
-	return 0;
-}
-
 static int obj_inode_grab(void *ptr)
 {
 	return igrab((struct inode *) ptr) ? 0 : -EBADF;
@@ -346,8 +336,8 @@ static void *restore_lsm_string_wrap(struct ckpt_ctx *ctx)
 static const struct ckpt_obj_ops ckpt_obj_ignored_ops = {
 	.obj_name = "IGNORED",
 	.obj_type = CKPT_OBJ_IGNORE,
-	.ref_drop = obj_no_drop,
-	.ref_grab = obj_no_grab,
+	.ref_drop = NULL,
+	.ref_grab = NULL,
 };
 
 /* inode object */
@@ -412,8 +402,8 @@ static const struct ckpt_obj_ops ckpt_obj_sighand_ops = {
 static const struct ckpt_obj_ops ckpt_obj_signal_ops = {
 	.obj_name = "SIGNAL",
 	.obj_type = CKPT_OBJ_SIGNAL,
-	.ref_drop = obj_no_drop,
-	.ref_grab = obj_no_grab,
+	.ref_drop = NULL,
+	.ref_grab = NULL,
 };
 /* ns object */
 static const struct ckpt_obj_ops ckpt_obj_nsproxy_ops = {

checkpoint/objhash.c static const struct ckpt_obj_ops ckpt_obj_tty_ops = { · line 514

Quoted 8 lines
checkpoint/objhash.c +2 -2
@@ -519,8 +509,8 @@ static const struct ckpt_obj_ops ckpt_obj_tty_ops = {
 static const struct ckpt_obj_ops ckpt_obj_security_ptr_ops = {
 	.obj_name = "SECURITY PTR",
 	.obj_type = CKPT_OBJ_SECURITY_PTR,
-	.ref_drop = obj_no_drop,
-	.ref_grab = obj_no_grab,
+	.ref_drop = NULL,
+	.ref_grab = NULL,
 };

ref_drop/grab will be NULL if you just remove the initializers -- do you think it is preferable to be explicit?

Regardless, this is looking good to me.

#27 lore raw

Re: [PATCH 09/12] Move mmap checkpoint/restart into mm/mmap.c

In reply to a message not in the archive
Quoted 11 lines · Matt Helsley

Moving the memory pieces is more complicated because portions of it are shared with ipc. Split the mm header bits into another header file: include/linux/mm_checkpoint.h file so it's clear that these are the only pieces we need in ipc/

include/linux/mm_checkpoint.h new file +0 -0
new file mode 100644
index 0000000..0092321

include/linux/mm_checkpoint.h line 4

Quoted 4 lines
include/linux/mm_checkpoint.h new file +4 -0
@@ -0,0 +1,45 @@
+#ifndef _LINUX_MM_CHECKPOINT_H
+#define _LINUX_MM_CHECKPOINT_H
+
+#include <linux/checkpoint.h> /* for ckpt_obj_fetch, restore_read_page */

But ckpt_obj_fetch and restore_read_page aren't referred to in this file? I understand that users of mm_checkpoint.h may need those APIs but it's more conventional for those users to include the appropriate headers directly.

include/linux/mm_checkpoint.h line 6

Quoted 2 lines
include/linux/mm_checkpoint.h new file +2 -0
+#include <linux/checkpoint_hdr.h> /* for struct ckpt_hdr_vma */
+#include <linux/checkpoint_types.h> /* for struct ckpt_ctx */

You can just declare these like so:

struct ckpt_hdr_vma;
struct ckpt_ctx;

Need similar for inode, vm_area_struct, etc. -- I think so far you're just getting lucky because checkpoint headers are included late and the headers for the objects they refer to have already been included.

Quoted 83 lines
include/linux/mm_checkpoint.h new file +39 -0
+
+extern void ckpt_pgarr_free(struct ckpt_ctx *ctx);
+
+extern int checkpoint_obj_mm(struct ckpt_ctx *ctx, struct task_struct *t);
+extern int restore_obj_mm(struct ckpt_ctx *ctx, int mm_objref);
+
+extern int ckpt_collect_mm(struct ckpt_ctx *ctx, struct task_struct *t);
+
+extern int checkpoint_memory_contents(struct ckpt_ctx *ctx,
+				      struct vm_area_struct *vma,
+				      struct inode *inode);
+extern int restore_memory_contents(struct ckpt_ctx *ctx, struct inode *inode);
+
+/* common vma checkpoint/restore operations */
+extern int generic_vma_checkpoint(struct ckpt_ctx *ctx,
+				  struct vm_area_struct *vma,
+				  enum vma_type type,
+				  int vma_objref, int ino_objref);
+extern unsigned long generic_vma_restore(struct mm_struct *mm,
+					 struct file *file,
+					 struct ckpt_hdr_vma *h);
+extern int private_vma_checkpoint(struct ckpt_ctx *ctx,
+				  struct vm_area_struct *vma,
+				  enum vma_type type,
+				  int vma_objref);
+extern int private_vma_restore(struct ckpt_ctx *ctx, struct mm_struct *mm,
+			       struct file *file, struct ckpt_hdr_vma *h);
+extern int shmem_vma_checkpoint(struct ckpt_ctx *ctx,
+				struct vm_area_struct *vma,
+				enum vma_type type,
+				int ino_objref);
+
+
+#define CKPT_VMA_NOT_SUPPORTED						\
+	(VM_IO | VM_HUGETLB | VM_NONLINEAR | VM_PFNMAP |		\
+	 VM_RESERVED | VM_NORESERVE | VM_HUGETLB | VM_NONLINEAR |	\
+	 VM_MAPPED_COPY | VM_INSERTPAGE | VM_MIXEDMAP | VM_SAO)
+
+#endif /* _LINUX_MM_CHECKPOINT_H */
include/linux/proc_fs.h +0 -19
index 379eaed..e187078 100644
@@ -173,12 +173,6 @@ extern void proc_net_remove(struct net *net, const char *name);
 extern struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name,
 	struct proc_dir_entry *parent);
 
-/* While the {get|set|dup}_mm_exe_file functions are for mm_structs, they are
- * only needed to implement /proc/<pid>|self/exe so we define them here. */
-extern void set_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file);
-extern struct file *get_mm_exe_file(struct mm_struct *mm);
-extern void dup_mm_exe_file(struct mm_struct *oldmm, struct mm_struct *newmm);
-
 #else
 
 #define proc_net_fops_create(net, name, mode, fops)  ({ (void)(mode), NULL; })
@@ -226,19 +220,6 @@ static inline void pid_ns_release_proc(struct pid_namespace *ns)
 {
 }
 
-static inline void set_mm_exe_file(struct mm_struct *mm,
-				   struct file *new_exe_file)
-{}
-
-static inline struct file *get_mm_exe_file(struct mm_struct *mm)
-{
-	return NULL;
-}
-
-static inline void dup_mm_exe_file(struct mm_struct *oldmm,
-	       			   struct mm_struct *newmm)
-{}
-
 #endif /* CONFIG_PROC_FS */
 
 #if !defined(CONFIG_PROC_KCORE)
ipc/checkpoint.c +0 -0
index 4322dea..2b05067 100644

ipc/checkpoint.c line 18

Quoted 6 lines
ipc/checkpoint.c +1 -2
@@ -15,8 +15,7 @@
 #include <linux/msg.h>
 #include <linux/sched.h>
 #include <linux/ipc_namespace.h>
-#include <linux/checkpoint.h>
-#include <linux/checkpoint_hdr.h>
+#include <linux/mm_checkpoint.h>

I'm not sure I understand the reason for this kind of change in this patch. ipc/checkpoint.c surely uses the APIs in checkpoint.h and checkpoint_hdr.h so it should include them directly -- that's the usual Linux practice AFAIK. By all means, if there's a foo.c that needs only the APIs in mm_checkpoint.h, then it should include only that.

#30 lore raw

Re: [PATCH 10/12] Move uts ns into kernel/utsname*.c

In reply to a message not in the archive
Quoted 6 lines · Matt Helsley

Unlike other checkpoint object ops we're moving out of checkpoint/objhash.c, the one for uts namespaces needs to be defined even if CONFIG_UTS_NS is not. Because the definitions used in kernel/utsname_sysctl.c can come from kernel/utsname.c, we declare them in include/linux/utsname.h. If the definitions are missing then utsname_sysctl.c defines its own.

...

Quoted 5 lines
kernel/utsname.c +0 -0
index c82ed83..865a6f4 100644

kernel/utsname.c void free_uts_ns(struct kref *kref) · line 83

Quoted 10 lines
kernel/utsname.c +7 -0
@@ -74,3 +74,88 @@ void free_uts_ns(struct kref *kref)
 	ns = container_of(kref, struct uts_namespace, kref);
 	kfree(ns);
 }
+
+#ifdef CONFIG_CHECKPOINT
+/* default debug level for output */
+#undef CKPT_DFLAG
+#define CKPT_DFLAG  CKPT_DSYS
+#include <linux/checkpoint.h>
+#include <linux/checkpoint_hdr.h>

I don't have any problem with #ifdef CONFIG_CHECKPOINT around blocks of functions -- it's pretty much unavoidable and it's common practice. But #undef and #include in such an #ifdef block are somewhat unusual, and in this case they seem to be additions, not code movement. Can you explain what's going on here?

#11 lore raw

Re: [PATCH 03/12] Replace obj_no_grab and obj_no_drop ckpt ops with NULL

In reply to a message not in the archive
Quoted 56 lines · Nathan Lynch
Quoted 55 lines · Matt Helsley

Distributing the ckpt_obj_ops would require sharing these functions when we can get by with simple NULL pointers in the grab/drop operations.

---
 checkpoint/objhash.c |   36 ++++++++++++++++--------------------
 1 files changed, 16 insertions(+), 20 deletions(-)
checkpoint/objhash.c +4 -14
index 832520d..999d731 100644
@@ -47,16 +47,6 @@ struct ckpt_obj_hash {
 
 /* helper grab/drop/users functions */
 
-static void obj_no_drop(void *ptr, int lastref)
-{
-	return;
-}
-
-static int obj_no_grab(void *ptr)
-{
-	return 0;
-}
-
 static int obj_inode_grab(void *ptr)
 {
 	return igrab((struct inode *) ptr) ? 0 : -EBADF;
@@ -346,8 +336,8 @@ static void *restore_lsm_string_wrap(struct ckpt_ctx *ctx)
 static const struct ckpt_obj_ops ckpt_obj_ignored_ops = {
 	.obj_name = "IGNORED",
 	.obj_type = CKPT_OBJ_IGNORE,
-	.ref_drop = obj_no_drop,
-	.ref_grab = obj_no_grab,
+	.ref_drop = NULL,
+	.ref_grab = NULL,
 };
 
 /* inode object */
@@ -412,8 +402,8 @@ static const struct ckpt_obj_ops ckpt_obj_sighand_ops = {
 static const struct ckpt_obj_ops ckpt_obj_signal_ops = {
 	.obj_name = "SIGNAL",
 	.obj_type = CKPT_OBJ_SIGNAL,
-	.ref_drop = obj_no_drop,
-	.ref_grab = obj_no_grab,
+	.ref_drop = NULL,
+	.ref_grab = NULL,
 };
 /* ns object */
 static const struct ckpt_obj_ops ckpt_obj_nsproxy_ops = {
@@ -519,8 +509,8 @@ static const struct ckpt_obj_ops ckpt_obj_tty_ops = {
 static const struct ckpt_obj_ops ckpt_obj_security_ptr_ops = {
 	.obj_name = "SECURITY PTR",
 	.obj_type = CKPT_OBJ_SECURITY_PTR,
Quoted 8 lines

checkpoint/objhash.c static const struct ckpt_obj_ops ckpt_obj_tty_ops = { · line 514

Quoted 5 lines
checkpoint/objhash.c +2 -2
-	.ref_drop = obj_no_drop,
-	.ref_grab = obj_no_grab,
+	.ref_drop = NULL,
+	.ref_grab = NULL,
 };

ref_drop/grab will be NULL if you just remove the initializers -- do you think it is preferable to be explicit?

Doh! Yes, I should fix that. Thanks!

Cheers,
-Matt Helsley