Skip to contentSkip to conversation

powerpc checkpoint/restart kernel support

PATCH In review Nathan Lynch 3 participants 17 messages Sep 16, 2009 7 messages not in the archive

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

cover powerpc checkpoint/restart kernel support

Patches 1-3 fix general issues and can be applied immediately.

Patches 4-8 implement the checkpoint and restart syscalls and architecture callbacks.

Patch 9 implements the clone_with_pids syscall, but I think the shape of that interface is yet to be finalized, so I guess it's FYI for now.

Simple single task checkpoint and restart work, as does clone_with_pids, apparently. Multiple task restart fails; the coordinator task appears to be receiving a signal during wait_all_tasks_finish() -> wait_for_completion_interruptible() for some reason I am still trying to tracking down.

Nathan Lynch (9):
checkpoint: fix integer-pointer conversion warnings fix trivial build breaks in compat code futex.h: fix compat builds
powerpc: reserve checkpoint arch identifiers
powerpc: provide APIs for validating and updating DABR
powerpc: checkpoint/restart implementation
powerpc: wire up checkpoint and restart syscalls
powerpc: enable checkpoint support in Kconfig
powerpc: clone_with_pids implementation

 arch/powerpc/Kconfig                      |    3 +
 arch/powerpc/include/asm/Kbuild           |    1 +
 arch/powerpc/include/asm/checkpoint_hdr.h |   22 ++
 arch/powerpc/include/asm/ptrace.h         |    7 +
 arch/powerpc/include/asm/syscalls.h       |    4 +
 arch/powerpc/include/asm/systbl.h         |    3 +
 arch/powerpc/include/asm/unistd.h         |    5 +-
 arch/powerpc/kernel/entry_32.S            |    8 +
 arch/powerpc/kernel/entry_64.S            |    5 +
 arch/powerpc/kernel/process.c             |   18 +
 arch/powerpc/kernel/ptrace.c              |   88 ++++--
 arch/powerpc/mm/Makefile                  |    1 +
 arch/powerpc/mm/checkpoint.c              |  531 +++++++++++++++++++++++++++++
 checkpoint/process.c                      |   14 +-
 include/linux/checkpoint_hdr.h            |    2 +
 include/linux/futex.h                     |    4 +
 16 files changed, 679 insertions(+), 37 deletions(-)
 create mode 100644 arch/powerpc/include/asm/checkpoint_hdr.h
 create mode 100644 arch/powerpc/mm/checkpoint.c

A message that is not in the archive (sent off-list or not yet received): 1253091418-14807-1-git-send-email-ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH 1/9 checkpoint: fix integer-pointer conversion warnings

CC checkpoint/process.o
checkpoint/process.c: In function ‘checkpoint_task_struct’:
checkpoint/process.c:97: warning: assignment makes integer from pointer without a cast checkpoint/process.c:98: warning: assignment makes integer from pointer without a cast checkpoint/process.c: In function ‘restore_task_struct’:
checkpoint/process.c:475: warning: assignment makes pointer from integer without a cast checkpoint/process.c:476: warning: assignment makes pointer from integer without a cast

---
 checkpoint/process.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
checkpoint/process.c +4 -4
index 41566db..b7f4a43 100644
@@ -94,8 +94,8 @@ static int checkpoint_task_struct(struct ckpt_ctx *ctx, struct task_struct *t)
 		h->exit_signal = t->exit_signal;
 		h->pdeath_signal = t->pdeath_signal;
 
-		h->set_child_tid = t->set_child_tid;
-		h->clear_child_tid = t->clear_child_tid;
+		h->set_child_tid = (unsigned long)t->set_child_tid;
+		h->clear_child_tid = (unsigned long)t->clear_child_tid;
 		save_task_robust_futex_list(h, t);
 	}
 
@@ -472,8 +472,8 @@ static int restore_task_struct(struct ckpt_ctx *ctx)
 		t->exit_signal = h->exit_signal;
 		t->pdeath_signal = h->pdeath_signal;
 
-		t->set_child_tid = h->set_child_tid;
-		t->clear_child_tid = h->clear_child_tid;
+		t->set_child_tid = (void __user *)h->set_child_tid;
+		t->clear_child_tid = (void __user *)h->clear_child_tid;
 		restore_task_robust_futex_list(h);
 	}
 
Signature · 6 lines
1.6.0.6

_______________________________________________
Containers mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/containers

A message that is not in the archive (sent off-list or not yet received): 1253091418-14807-2-git-send-email-ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org

#4 lore raw

Re: [PATCH 1/9] checkpoint: fix integer-pointer conversion warnings

Quoted 18 lines · Nathan Lynch

CC checkpoint/process.o
checkpoint/process.c: In function ‘checkpoint_task_struct’:
checkpoint/process.c:97: warning: assignment makes integer from pointer without a cast checkpoint/process.c:98: warning: assignment makes integer from pointer without a cast checkpoint/process.c: In function ‘restore_task_struct’:
checkpoint/process.c:475: warning: assignment makes pointer from integer without a cast checkpoint/process.c:476: warning: assignment makes pointer from integer without a cast

---
 checkpoint/process.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
checkpoint/process.c +0 -0
index 41566db..b7f4a43 100644

checkpoint/process.c static int checkpoint_task_struct(struct ckpt_ctx *ctx, struct task_struct *t) · line 98

Quoted 7 lines
checkpoint/process.c +2 -2
@@ -94,8 +94,8 @@ static int checkpoint_task_struct(struct ckpt_ctx *ctx, struct task_struct *t)
 		h->exit_signal = t->exit_signal;
 		h->pdeath_signal = t->pdeath_signal;
 
-		h->set_child_tid = t->set_child_tid;
-		h->clear_child_tid = t->clear_child_tid;
+		h->set_child_tid = (unsigned long)t->set_child_tid;
+		h->clear_child_tid = (unsigned long)t->clear_child_tid;

But it's defined as __u64 in checkpoint_hdr.h. So on 32-bit this cast won't be right, right?

But a major ack to shutting this thing up.

thanks,
-serge

Quoted 21 lines
checkpoint/process.c +2 -2
 		save_task_robust_futex_list(h, t);
 	}
 
@@ -472,8 +472,8 @@ static int restore_task_struct(struct ckpt_ctx *ctx)
 		t->exit_signal = h->exit_signal;
 		t->pdeath_signal = h->pdeath_signal;
 
-		t->set_child_tid = h->set_child_tid;
-		t->clear_child_tid = h->clear_child_tid;
+		t->set_child_tid = (void __user *)h->set_child_tid;
+		t->clear_child_tid = (void __user *)h->clear_child_tid;
 		restore_task_robust_futex_list(h);
 	}
 
Signature · 6 lines
1.6.0.6

_______________________________________________
Containers mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/containers

_______________________________________________
Containers mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/containers

A message that is not in the archive (sent off-list or not yet received): 20090916142137.GA13476-r/[email protected]

#6 lore raw

Re: [PATCH 1/9] checkpoint: fix integer-pointer conversion warnings

Quoted 22 lines · Serge E. Hallyn
Quoted 21 lines · Nathan Lynch

CC checkpoint/process.o
checkpoint/process.c: In function ‘checkpoint_task_struct’:
checkpoint/process.c:97: warning: assignment makes integer from pointer without a cast checkpoint/process.c:98: warning: assignment makes integer from pointer without a cast checkpoint/process.c: In function ‘restore_task_struct’:
checkpoint/process.c:475: warning: assignment makes pointer from integer without a cast checkpoint/process.c:476: warning: assignment makes pointer from integer without a cast

---
 checkpoint/process.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
checkpoint/process.c +0 -0
index 41566db..b7f4a43 100644
@@ -94,8 +94,8 @@ static int checkpoint_task_struct(struct ckpt_ctx *ctx, struct task_struct *t)
 		h->exit_signal = t->exit_signal;
 		h->pdeath_signal = t->pdeath_signal;
 
Quoted 7 lines

checkpoint/process.c static int checkpoint_task_struct(struct ckpt_ctx *ctx, struct task_struct *t) · line 98

Quoted 4 lines
checkpoint/process.c +2 -2
-		h->set_child_tid = t->set_child_tid;
-		h->clear_child_tid = t->clear_child_tid;
+		h->set_child_tid = (unsigned long)t->set_child_tid;
+		h->clear_child_tid = (unsigned long)t->clear_child_tid;

But it's defined as __u64 in checkpoint_hdr.h. So on 32-bit this cast won't be right, right?

Should be harmless.

Quoted 2 lines

But a major ack to shutting this thing up.

Definitely. In fact, it's addressed already in the PGID patch :)

Oren.

_______________________________________________
Containers mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/containers

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw

Re: [PATCH 1/9] checkpoint: fix integer-pointer conversion warnings

Quoted 33 lines · Oren Laadan
Quoted 22 lines · Serge E. Hallyn
Quoted 21 lines · Nathan Lynch

CC checkpoint/process.o
checkpoint/process.c: In function ‘checkpoint_task_struct’:
checkpoint/process.c:97: warning: assignment makes integer from pointer without a cast checkpoint/process.c:98: warning: assignment makes integer from pointer without a cast checkpoint/process.c: In function ‘restore_task_struct’:
checkpoint/process.c:475: warning: assignment makes pointer from integer without a cast checkpoint/process.c:476: warning: assignment makes pointer from integer without a cast

---
 checkpoint/process.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
checkpoint/process.c +0 -0
index 41566db..b7f4a43 100644
@@ -94,8 +94,8 @@ static int checkpoint_task_struct(struct ckpt_ctx *ctx, struct task_struct *t)
 		h->exit_signal = t->exit_signal;
 		h->pdeath_signal = t->pdeath_signal;
 
Quoted 7 lines

checkpoint/process.c static int checkpoint_task_struct(struct ckpt_ctx *ctx, struct task_struct *t) · line 98

Quoted 4 lines
checkpoint/process.c +2 -2
-		h->set_child_tid = t->set_child_tid;
-		h->clear_child_tid = t->clear_child_tid;
+		h->set_child_tid = (unsigned long)t->set_child_tid;
+		h->clear_child_tid = (unsigned long)t->clear_child_tid;

But it's defined as __u64 in checkpoint_hdr.h. So on 32-bit this cast won't be right, right?

Quoted 6 lines

Should be harmless.

Quoted 2 lines

But a major ack to shutting this thing up.

Definitely. In fact, it's addressed already in the PGID patch :)

Right, I thought it looked familiar :)
_______________________________________________
Containers mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/containers

#9 lore raw

PATCH 2/9 fix trivial build breaks in compat code

In reply to a message not in the archive
---
 checkpoint/process.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
checkpoint/process.c +3 -3
index b7f4a43..41c1c85 100644
@@ -308,7 +308,7 @@ int checkpoint_restart_block(struct ckpt_ctx *ctx, struct task_struct *t)
 #ifdef CONFIG_COMPAT
 	} else if (fn == compat_nanosleep_restart) {
 
-		h->function_type = CKPT_RESTART_BLOCK_NANOSLEEP;
+		h->function_type = CKPT_RESTART_BLOCK_COMPAT_NANOSLEEP;
 		h->arg_0 = restart_block->nanosleep.index;
 		h->arg_1 = (unsigned long)restart_block->nanosleep.rmtp;
 		h->arg_2 = (unsigned long)restart_block->nanosleep.compat_rmtp;
@@ -670,7 +670,7 @@ int restore_restart_block(struct ckpt_ctx *ctx)
 		restart_block.nanosleep.compat_rmtp =
 			(struct compat_timespec __user *)
 				(unsigned long) h->arg_2;
-		resatrt_block.nanosleep.expires = expire;
+		restart_block.nanosleep.expires = expire;
 		break;
 	case CKPT_RESTART_BLOCK_COMPAT_CLOCK_NANOSLEEP:
 		clockid = h->arg_0;
@@ -683,7 +683,7 @@ int restore_restart_block(struct ckpt_ctx *ctx)
 		restart_block.nanosleep.compat_rmtp =
 			(struct compat_timespec __user *)
 				(unsigned long) h->arg_2;
-		resatrt_block.nanosleep.expires = expire;
+		restart_block.nanosleep.expires = expire;
 		break;
 #endif
 	case CKPT_RESTART_BLOCK_FUTEX:
Signature · 1 line
1.6.0.6
#10 lore raw

PATCH 3/9 futex.h: fix compat builds

In reply to a message not in the archive

With any build where CONFIG_COMPAT=y:

checkpoint/process.c: In function 'save_task_robust_futex_list':
checkpoint/process.c:37: error: implicit declaration of function 'ptr_to_compat' checkpoint/process.c:38: error: dereferencing pointer to incomplete type checkpoint/process.c: In function 'restore_task_robust_futex_list':
checkpoint/process.c:54: error: implicit declaration of function 'compat_ptr' checkpoint/process.c:54: warning: assignment makes pointer from integer without a cast checkpoint/process.c:55: error: implicit declaration of function 'do_compat_set_robust_list'

ptr_to_compat et al need compat.h; however, futex.h is exported while compat.h is not. So the include is guarded by #ifdef __KERNEL__.

---
 include/linux/futex.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
include/linux/futex.h +4 -0
index 2e126a9..3fb9f33 100644
@@ -4,6 +4,10 @@
 #include <linux/compiler.h>
 #include <linux/types.h>
 
+#ifdef __KERNEL__
+#include <linux/compat.h>
+#endif
+
 struct inode;
 struct mm_struct;
 struct task_struct;
Signature · 1 line
1.6.0.6

A message that is not in the archive (sent off-list or not yet received): 1253091418-14807-4-git-send-email-ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org

#12 lore raw

Re: [PATCH 3/9] futex.h: fix compat builds

Quoted 10 lines · Nathan Lynch

With any build where CONFIG_COMPAT=y:

checkpoint/process.c: In function 'save_task_robust_futex_list':
checkpoint/process.c:37: error: implicit declaration of function 'ptr_to_compat' checkpoint/process.c:38: error: dereferencing pointer to incomplete type checkpoint/process.c: In function 'restore_task_robust_futex_list':
checkpoint/process.c:54: error: implicit declaration of function 'compat_ptr' checkpoint/process.c:54: warning: assignment makes pointer from integer without a cast checkpoint/process.c:55: error: implicit declaration of function 'do_compat_set_robust_list'

Quoted 4 lines

ptr_to_compat et al need compat.h; however, futex.h is exported while compat.h is not. So the include is guarded by #ifdef __KERNEL__.

Including futex.h does not require compat.h. Rather, it's the code in checkpoint/process.c that uses ptr_to_compat() et al. Is there a reason not to include compat.h from checkpoint/process.c instead ?

Oren.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#14 lore raw

Re: [PATCH 3/9] futex.h: fix compat builds

Quoted 12 lines · Oren Laadan
Quoted 10 lines · Nathan Lynch

With any build where CONFIG_COMPAT=y:

checkpoint/process.c: In function 'save_task_robust_futex_list':
checkpoint/process.c:37: error: implicit declaration of function 'ptr_to_compat' checkpoint/process.c:38: error: dereferencing pointer to incomplete type checkpoint/process.c: In function 'restore_task_robust_futex_list':
checkpoint/process.c:54: error: implicit declaration of function 'compat_ptr' checkpoint/process.c:54: warning: assignment makes pointer from integer without a cast checkpoint/process.c:55: error: implicit declaration of function 'do_compat_set_robust_list'

Quoted 8 lines
Quoted 4 lines

ptr_to_compat et al need compat.h; however, futex.h is exported while compat.h is not. So the include is guarded by #ifdef __KERNEL__.

Including futex.h does not require compat.h. Rather, it's the code in checkpoint/process.c that uses ptr_to_compat() et al. Is there a reason not to include compat.h from checkpoint/process.c instead ?

Oh my, you're right. I had this hanging around from an older tree where futex.h did need it, but it's obviously not the right fix now. The include should go in checkpoint/process.c.

#15 lore raw

PATCH 4/9 powerpc: reserve checkpoint arch identifiers

In reply to a message not in the archive
---
 include/linux/checkpoint_hdr.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/linux/checkpoint_hdr.h +2 -0
index 06bc6e2..851cdf2 100644
@@ -110,6 +110,8 @@ enum {
 	/* do not change order (will break ABI) */
 	CKPT_ARCH_X86_32 = 1,
 	CKPT_ARCH_S390X,
+	CKPT_ARCH_PPC32,
+	CKPT_ARCH_PPC64,
 };
 
 /* shared objrects (objref) */
Signature · 1 line
1.6.0.6
#16 lore raw

PATCH 5/9 powerpc: provide APIs for validating and updating DABR

In reply to a message not in the archive

A checkpointed task image may specify a value for the DABR (Data Access Breakpoint Register). The restart code needs to validate this value before making any changes to the current task.

ptrace_set_debugreg encapsulates the bounds checking and platform dependencies of programming the DABR. Split this into "validate" (debugreg_valid) and "update" (debugreg_update) functions, and make them available for use outside of the ptrace code.

Also ptrace_set_debugreg has extern linkage, but no users outside of ptrace.c. Make it static.

---
 arch/powerpc/include/asm/ptrace.h |    7 +++
 arch/powerpc/kernel/ptrace.c      |   88 +++++++++++++++++++++++++------------
 2 files changed, 66 insertions(+), 29 deletions(-)
arch/powerpc/include/asm/ptrace.h +7 -0
index 8c34149..c6cb2c6 100644
@@ -81,6 +81,8 @@ struct pt_regs {
 
 #ifndef __ASSEMBLY__
 
+#include <linux/types.h>
+
 #define instruction_pointer(regs) ((regs)->nip)
 #define user_stack_pointer(regs) ((regs)->gpr[1])
 #define regs_return_value(regs) ((regs)->gpr[3])
@@ -140,6 +142,11 @@ extern void user_enable_single_step(struct task_struct *);
 extern void user_enable_block_step(struct task_struct *);
 extern void user_disable_single_step(struct task_struct *);
 
+/* for reprogramming DABR/DAC during restart of a checkpointed task */
+extern bool debugreg_valid(unsigned long val, unsigned int index);
+extern void debugreg_update(struct task_struct *task, unsigned long val,
+			    unsigned int index);
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
arch/powerpc/kernel/ptrace.c +59 -29

128 lines not on this page · raw message

Signature · 1 line
1.6.0.6
#17 lore raw

PATCH 6/9 powerpc: checkpoint/restart implementation

In reply to a message not in the archive

Support for checkpointing and restarting GPRs, FPU state, DABR, and Altivec state.

The portion of the checkpoint image manipulated by this code begins with a bitmask of features indicating the various contexts saved. Fields in image that can vary depending on kernel configuration (e.g. FP regs due to VSX) have their sizes explicitly recorded, except for GPRS, so migrating between ppc32 and ppc64 won't work yet.

The restart code ensures that the task is not modified until the checkpoint image is validated against the current kernel configuration and hardware features (e.g. can't restart a task using Altivec on non-Altivec systems).

What works:
* self and external checkpoint of simple (single thread, one open file) 32- and 64-bit processes on a ppc64 kernel

What doesn't work:
* restarting a 32-bit task from a 64-bit task and vice versa

Untested:
* ppc32 (but it builds)

---
 arch/powerpc/include/asm/Kbuild           |    1 +
 arch/powerpc/include/asm/checkpoint_hdr.h |   22 ++
 arch/powerpc/mm/Makefile                  |    1 +
 arch/powerpc/mm/checkpoint.c              |  531 +++++++++++++++++++++++++++++
 4 files changed, 555 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/include/asm/checkpoint_hdr.h
 create mode 100644 arch/powerpc/mm/checkpoint.c
arch/powerpc/include/asm/Kbuild +1 -0
index 5ab7d7f..20379f1 100644
@@ -12,6 +12,7 @@ header-y += shmbuf.h
 header-y += socket.h
 header-y += termbits.h
 header-y += fcntl.h
+header-y += checkpoint_hdr.h
 header-y += poll.h
 header-y += sockios.h
 header-y += ucontext.h
arch/powerpc/include/asm/checkpoint_hdr.h new file +22 -0
new file mode 100644
index 0000000..db109b2
@@ -0,0 +1,22 @@
+#ifndef __ASM_POWERPC_CKPT_HDR_H
+#define __ASM_POWERPC_CKPT_HDR_H
+
+#include <linux/types.h>
+
+/* This must match _NSIG in <asm/signal.h> */
+#define CKPT_ARCH_NSIG 64
+
+#ifdef __KERNEL__
+#ifdef CONFIG_PPC64
+#define CKPT_ARCH_ID CKPT_ARCH_PPC64
+#else
+#define CKPT_ARCH_ID CKPT_ARCH_PPC32
+#endif
+#endif
+
+struct ckpt_hdr_header_arch {
+	struct ckpt_hdr h;
+	__u32 what;
+} __attribute__((aligned(8)));
+
+#endif /* __ASM_POWERPC_CKPT_HDR_H */
arch/powerpc/mm/Makefile +1 -0
index 3e68363..aa8733c 100644
@@ -31,3 +31,4 @@ obj-$(CONFIG_HUGETLB_PAGE)	+= hugetlbpage.o
 obj-$(CONFIG_PPC_SUBPAGE_PROT)	+= subpage-prot.o
 obj-$(CONFIG_NOT_COHERENT_CACHE) += dma-noncoherent.o
 obj-$(CONFIG_HIGHMEM)		+= highmem.o
+obj-$(CONFIG_CHECKPOINT)	+= checkpoint.o
arch/powerpc/mm/checkpoint.c new file +531 -0

531 lines not on this page · raw message

Signature · 1 line
1.6.0.6
#18 lore raw

PATCH 7/9 powerpc: wire up checkpoint and restart syscalls

In reply to a message not in the archive
---
 arch/powerpc/include/asm/systbl.h |    2 ++
 arch/powerpc/include/asm/unistd.h |    4 +++-
 2 files changed, 5 insertions(+), 1 deletions(-)
arch/powerpc/include/asm/systbl.h +2 -0
index 370600c..3d44cf3 100644
@@ -326,3 +326,5 @@ SYSCALL_SPU(perf_counter_open)
 COMPAT_SYS_SPU(preadv)
 COMPAT_SYS_SPU(pwritev)
 COMPAT_SYS(rt_tgsigqueueinfo)
+SYSCALL(checkpoint)
+SYSCALL(restart)
arch/powerpc/include/asm/unistd.h +3 -1
index cef080b..ef41ebb 100644
@@ -345,10 +345,12 @@
 #define __NR_preadv		320
 #define __NR_pwritev		321
 #define __NR_rt_tgsigqueueinfo	322
+#define __NR_checkpoint		323
+#define __NR_restart		324
 
 #ifdef __KERNEL__
 
-#define __NR_syscalls		323
+#define __NR_syscalls		325
 
 #define __NR__exit __NR_exit
 #define NR_syscalls	__NR_syscalls
Signature · 1 line
1.6.0.6
#19 lore raw

PATCH 8/9 powerpc: enable checkpoint support in Kconfig

In reply to a message not in the archive
---
 arch/powerpc/Kconfig |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
arch/powerpc/Kconfig +3 -0
index d00131c..2ca160e 100644
@@ -26,6 +26,9 @@ config MMU
 	bool
 	default y
 
+config CHECKPOINT_SUPPORT
+	def_bool y
+
 config GENERIC_CMOS_UPDATE
 	def_bool y
 
Signature · 1 line
1.6.0.6
#20 lore raw

PATCH 9/9 powerpc: clone_with_pids implementation

In reply to a message not in the archive

Mostly copy-paste from existing clone code.

(may want to hold off applying this until the ongoing clone_with_pids discussion is resolved.)

---
 arch/powerpc/include/asm/syscalls.h |    4 ++++
 arch/powerpc/include/asm/systbl.h   |    1 +
 arch/powerpc/include/asm/unistd.h   |    3 ++-
 arch/powerpc/kernel/entry_32.S      |    8 ++++++++
 arch/powerpc/kernel/entry_64.S      |    5 +++++
 arch/powerpc/kernel/process.c       |   18 ++++++++++++++++++
 6 files changed, 38 insertions(+), 1 deletions(-)
arch/powerpc/include/asm/syscalls.h +4 -0
index eb8eb40..25dfe8b 100644
@@ -24,6 +24,10 @@ asmlinkage int sys_execve(unsigned long a0, unsigned long a1,
 asmlinkage int sys_clone(unsigned long clone_flags, unsigned long usp,
 		int __user *parent_tidp, void __user *child_threadptr,
 		int __user *child_tidp, int p6, struct pt_regs *regs);
+asmlinkage int sys_clone_with_pids(unsigned long clone_flags,
+		unsigned long usp, int __user *parent_tidp,
+		void __user *child_threadptr, int __user *child_tidp,
+		void __user *upid_setp, struct pt_regs *regs);
 asmlinkage int sys_fork(unsigned long p1, unsigned long p2,
 		unsigned long p3, unsigned long p4, unsigned long p5,
 		unsigned long p6, struct pt_regs *regs);
arch/powerpc/include/asm/systbl.h +1 -0
index 3d44cf3..e3c0b96 100644
@@ -328,3 +328,4 @@ COMPAT_SYS_SPU(pwritev)
 COMPAT_SYS(rt_tgsigqueueinfo)
 SYSCALL(checkpoint)
 SYSCALL(restart)
+PPC_SYS(clone_with_pids)
arch/powerpc/include/asm/unistd.h +2 -1
index ef41ebb..c54db8b 100644
@@ -347,10 +347,11 @@
 #define __NR_rt_tgsigqueueinfo	322
 #define __NR_checkpoint		323
 #define __NR_restart		324
+#define __NR_clone_with_pids	325
 
 #ifdef __KERNEL__
 
-#define __NR_syscalls		325
+#define __NR_syscalls		326
 
 #define __NR__exit __NR_exit
 #define NR_syscalls	__NR_syscalls
arch/powerpc/kernel/entry_32.S +8 -0
index 3cadba6..081dd36 100644
@@ -586,6 +586,14 @@ ppc_clone:
 	stw	r0,_TRAP(r1)		/* register set saved */
 	b	sys_clone
 
+	.globl	ppc_clone_with_pids
+ppc_clone_with_pids:
+	SAVE_NVGPRS(r1)
+	lwz	r0,_TRAP(r1)
+	rlwinm	r0,r0,0,0,30		/* clear LSB to indicate full */
+	stw	r0,_TRAP(r1)		/* register set saved */
+	b	sys_clone_with_pids
+
 	.globl	ppc_swapcontext
 ppc_swapcontext:
 	SAVE_NVGPRS(r1)
arch/powerpc/kernel/entry_64.S +5 -0
index 43e0734..39fa316 100644
@@ -320,6 +320,11 @@ _GLOBAL(ppc_clone)
 	bl	.sys_clone
 	b	syscall_exit
 
+_GLOBAL(ppc_clone_with_pids)
+	bl	.save_nvgprs
+	bl	.sys_clone_with_pids
+	b	syscall_exit
+
 _GLOBAL(ppc32_swapcontext)
 	bl	.save_nvgprs
 	bl	.compat_sys_swapcontext
arch/powerpc/kernel/process.c +18 -0
index 892a9f2..5ac4470 100644
@@ -898,6 +898,24 @@ int sys_clone(unsigned long clone_flags, unsigned long usp,
  	return do_fork(clone_flags, usp, regs, 0, parent_tidp, child_tidp);
 }
 
+int sys_clone_with_pids(unsigned long clone_flags, unsigned long usp,
+	      int __user *parent_tidp, void __user *child_threadptr,
+	      int __user *child_tidp, void __user *upid_setp,
+	      struct pt_regs *regs)
+{
+	CHECK_FULL_REGS(regs);
+	if (usp == 0)
+		usp = regs->gpr[1];
+#ifdef CONFIG_PPC64
+	if (test_thread_flag(TIF_32BIT)) {
+		parent_tidp = TRUNC_PTR(parent_tidp);
+		child_tidp = TRUNC_PTR(child_tidp);
+	}
+#endif
+ 	return do_fork_with_pids(clone_flags, usp, regs, 0,
+				 parent_tidp, child_tidp, upid_setp);
+}
+
 int sys_fork(unsigned long p1, unsigned long p2, unsigned long p3,
 	     unsigned long p4, unsigned long p5, unsigned long p6,
 	     struct pt_regs *regs)
Signature · 1 line
1.6.0.6
#21 lore raw
In reply to a message not in the archive

Thanks Nathan,

I'll apply the general fixes right away.

I'm about to push ckpt-v18-rc1 today. Would you like that to include the remaining patches as well ?

Oren.

Quoted 45 lines · Nathan Lynch

Patches 1-3 fix general issues and can be applied immediately.

Patches 4-8 implement the checkpoint and restart syscalls and architecture callbacks.

Patch 9 implements the clone_with_pids syscall, but I think the shape of that interface is yet to be finalized, so I guess it's FYI for now.

Simple single task checkpoint and restart work, as does clone_with_pids, apparently. Multiple task restart fails; the coordinator task appears to be receiving a signal during wait_all_tasks_finish() -> wait_for_completion_interruptible() for some reason I am still trying to tracking down.

Nathan Lynch (9):
checkpoint: fix integer-pointer conversion warnings fix trivial build breaks in compat code futex.h: fix compat builds
powerpc: reserve checkpoint arch identifiers
powerpc: provide APIs for validating and updating DABR
powerpc: checkpoint/restart implementation
powerpc: wire up checkpoint and restart syscalls
powerpc: enable checkpoint support in Kconfig
powerpc: clone_with_pids implementation

 arch/powerpc/Kconfig                      |    3 +
 arch/powerpc/include/asm/Kbuild           |    1 +
 arch/powerpc/include/asm/checkpoint_hdr.h |   22 ++
 arch/powerpc/include/asm/ptrace.h         |    7 +
 arch/powerpc/include/asm/syscalls.h       |    4 +
 arch/powerpc/include/asm/systbl.h         |    3 +
 arch/powerpc/include/asm/unistd.h         |    5 +-
 arch/powerpc/kernel/entry_32.S            |    8 +
 arch/powerpc/kernel/entry_64.S            |    5 +
 arch/powerpc/kernel/process.c             |   18 +
 arch/powerpc/kernel/ptrace.c              |   88 ++++--
 arch/powerpc/mm/Makefile                  |    1 +
 arch/powerpc/mm/checkpoint.c              |  531 +++++++++++++++++++++++++++++
 checkpoint/process.c                      |   14 +-
 include/linux/checkpoint_hdr.h            |    2 +
 include/linux/futex.h                     |    4 +
 16 files changed, 679 insertions(+), 37 deletions(-)
 create mode 100644 arch/powerpc/include/asm/checkpoint_hdr.h
 create mode 100644 arch/powerpc/mm/checkpoint.c

A message that is not in the archive (sent off-list or not yet received): [email protected]

#23 lore raw
Quoted 6 lines · Oren Laadan

Thanks Nathan,

I'll apply the general fixes right away.

I'm about to push ckpt-v18-rc1 today. Would you like that to include the remaining patches as well ?

Yes, please. Thank you.