[Devel] Re: [RFC][PATCH 7/7][v2] Define clone_with_pids syscall

Matt Helsley matthltc at us.ibm.com
Thu May 28 05:02:13 PDT 2009

On Wed, May 27, 2009 at 09:39:45PM -0700, Sukadev Bhattiprolu wrote:
> From: Sukadev Bhattiprolu <sukadev at linux.vnet.ibm.com>
> Date: Mon, 4 May 2009 01:17:45 -0700
> Subject: [RFC][PATCH 7/7][v2] Define clone_with_pids syscall
> clone_with_pids() is same as clone(), except that it takes a 'target_pid_set'
> paramter which lets caller choose a specific pid number for the child process
> in each of the child process's pid namespace. This system call would be needed
> to implement Checkpoint/Restart (i.e after a checkpoint, restart a process with
> its original pids).
> Call clone_with_pids as follows:
> 	pid_t pids[] = { 0, 77, 99 };
> 	struct target_pid_set pid_set;
> 	pid_set.num_pids = sizeof(pids) / sizeof(int);
> 	pid_set.target_pids = &pids;
> 	syscall(__NR_clone_with_pids, flags, stack, NULL, NULL, NULL, &pid_set);
> If a target-pid is 0, the kernel continues to assign a pid for the process in
> that namespace. In the above example, pids[0] is 0, meaning the kernel will
> assign next available pid to the process in init_pid_ns. But kernel will assign
> pid 77 in the child pid namespace 1 and pid 99 in pid namespace 2. If either
> 77 or 99 are taken, the system call fails with -EBUSY.
> If 'pid_set.num_pids' exceeds the current nesting level of pid namespaces,
> the system call fails with -EINVAL.

The patch description shows the solution before alluding to the problem.
You could prepend a more elaborate problem description:

	Container restart requires that a task have the same pid it had
	when it was checkpointed. When containers are nested the tasks within
	the containers exist in multiple pid namespaces and hence have multiple
	pids to specify during restart.

	clone_with_pids(), intended for use during restart, is the same as clone(), 

I think that makes it clearer why you're introducing clone_with_pids()
and why clone() or clone_with_pid() would be insufficient.

Containers mailing list
Containers at lists.linux-foundation.org

More information about the Devel mailing list