Skip to content

Pid namespaces

Pavel Emelianov containers lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest16 patches 49 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/16Round up the APIarch/mips/kernel/irixelf.c arch/mips/kernel/irixsig.c arch/mips/kernel/sysirix.c +16 more+48 -533 replies
2/16Miscelaneous preparations for namespacesinclude/linux/pid_namespace.h kernel/exit.c kernel/pid.c+8 -42 replies
3/16Introduce MS_KERNMOUNT flagfs/namespace.c fs/super.c include/linux/fs.h+8 -50 replies
4/16Change data structures for pid namespacesinclude/linux/init_task.h include/linux/pid.h include/linux/pid_namespace.h +1 more+20 -14 replies
5/16Make proc be mountable from different pid namespacesfs/proc/inode.c fs/proc/internal.h fs/proc/root.c +2 more+147 -90 replies
6/16Helpers to obtain pid numbersinclude/linux/pid.h include/linux/sched.h kernel/pid.c+132 -112 replies
7/16Helpers to find the task by its numerical idsfs/proc/base.c include/linux/pid.h include/linux/sched.h +1 more+58 -202 replies
8/16Masquerade the siginfo when sending a pid to a foreign namespaceinclude/linux/pid.h kernel/signal.c+38 -62 replies
9/16Make proc_flust_task to flush entries from multiple proc treesfs/proc/base.c include/linux/proc_fs.h kernel/exit.c+43 -60 replies
10/16Changes in copy_process() to work with pid namespacesinclude/linux/pid.h kernel/fork.c kernel/pid.c+19 -141 reply
11/16Add support for multiple kmem caches for pidskernel/pid.c+56 -50 replies
12/16Reference counting of pid naspaces by pidskernel/pid.c+15 -40 replies
13/16Switch to operating with pid_numbers instead of pidskernel/pid.c+33 -144 replies
14/16Make pid namespaces clonnableinclude/linux/pid_namespace.h include/linux/sched.h kernel/fork.c +2 more+118 -120 replies
15/16Changes to show virtual ids to userarch/ia64/kernel/signal.c arch/parisc/kernel/signal.c drivers/char/tty_io.c +21 more+173 -1160 replies
16/16Remove already unneeded memners from struct pidinclude/linux/init_task.h include/linux/pid.h+0 -60 replies

Reviews trailers per patch

1 of 16 patches has a Reviewed-by or Acked-by.

PatchSerge E. Hallyn
1/16A-b
2/16
3/16
4/16
5/16
6/16
7/16
8/16
9/16
10/16
11/16
12/16
13/16
14/16
15/16
16/16

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/16] Pid namespaces

This is "submition for inclusion" of hierarchical, not kconfig configurable, zero overheaded ;) pid namespaces.

The overall idea is the following:

The namespace are organized as a tree - once a task is cloned with CLONE_NEWPIDS (yes, I've also switched to it :) the new namespace becomes the parent's child and tasks living in the parent namespace see the tasks from the new one. The numerical ids are used on the kernel-user boundary, i.e. when we export pid to user we show the id, that should be used to address the task in question from the namespace we're exporting this id to.

The main difference from Suka's patches are the following:

0. Suka's patches change the kernel/pid.c code too heavy. This set keeps the kernel code look like it was without the patches. However, this is a minor issue. The major is:

1. Suka's approach is to remove the notion of the task's numerical pid from the kernel at all. The numbers are used on the kernel-user boundary or within the kernel but with the namespace this nr belongs to. This results in massive changes of struct's members fro int pid to struct pid *pid, task->pid becomes the virtual id and so on and so forth.
My approach is to keep the good old logic in the kernel. The task->pid is a global and unique pid, find_pid() finds the pid by its global id and so on. The virtual ids appear on the user-kernel boundary only. Thus drivers and other kernel code may still be unaware of pids unless they do not communicate with the userspace and get/put numerical pids.

And some more minor differences:

2. Suka's patches have the limit of pid namespace nesting. My patches do not.

3. Suka assumes that pid namespace can live without proc mount and tries to make the code work with pid_ns->proc_mnt change from NULL to not-NULL from times to times.
My code calls the kern_mount() at the namespace creation and thus the pid_namespace always works with proc.

There are some small issues that I can describe if someone is interested.

The tests like nptl perf, unixbench spawn, getpid and others didn't reveal any performance degradation in init_namespace with the RHEL5 kernel .config file. I admit, that different .config-s may show that patches hurt the performance, but the intention was *not* to make the kernel work worse with popular distributions.

This set has some ways to move forward, but this is some kind of a core, that do not change the init_pid_namespace behavior (checked with LTP tests) and may require some hacking to do with the namespaces only.

Patches apply to 2.6.22-rc6-mm1.