Skip to content

Make tasks always have non-zero pids

Pavel Emelyanov lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 7 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3Introduce the dummy_pidinclude/linux/sched.h kernel/pid.c+16 -32 replies
2/3Prepare pid_nr() etc functions to work with not-NULL pidsinclude/linux/pid.h kernel/pid.c+23 -44 replies
3/3Use the __pid_nr() calls where appropriatefs/proc/base.c include/linux/sched.h kernel/fork.c +3 more+14 -140 replies

Reviews trailers per patch

None of the 3 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchSukadev Bhattiprolu
SeriesA-b
1/3
2/3
3/3

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/3] Make tasks always have non-zero pids

Some time ago Sukadev noticed that the vmlinux size has grown 5Kb due to merged pid namespaces. One of the big problems with it was fat inline functions. The other thing was noticed by Matt - the checks for task's pid to be not NULL take place and make the kernel grow due to inlining, but these checks are not always needed.

In this series I introduce a static pid (dummy), according to Matt's proposal, which is assigned to tasks during the detach_pid and transfer_pid instead of NULL. This pid lives in the init pid namespace and has the id = 0, so all the task_xid_xnr() calls will still return 0 on a dead task.

Places that get the struct pid from task either get it from the current (in this case they will never get this dummy), or use it to compare with some other value (so they will work the same for both NULL and dummy pids).

This saves up to 340 bytes for i386 kernel with minimal config and probably more with more users of pids.

Tested on i386 and x86_64 boxes. Tasks still live and die, namespaces and proc still work.