linux/kernel
Eric W. Biederman 92476d7fc0 [PATCH] pidhash: Refactor the pid hash table
Simplifies the code, reduces the need for 4 pid hash tables, and makes the
code more capable.

In the discussions I had with Oleg it was felt that to a large extent the
cleanup itself justified the work.  With struct pid being dynamically
allocated meant we could create the hash table entry when the pid was
allocated and free the hash table entry when the pid was freed.  Instead of
playing with the hash lists when ever a process would attach or detach to a
process.

For myself the fact that it gave what my previous task_ref patch gave for free
with simpler code was a big win.  The problem is that if you hold a reference
to struct task_struct you lock in 10K of low memory.  If you do that in a user
controllable way like /proc does, with an unprivileged but hostile user space
application with typical resource limits of 1000 fds and 100 processes I can
trigger the OOM killer by consuming all of low memory with task structs, on a
machine wight 1GB of low memory.

If I instead hold a reference to struct pid which holds a pointer to my
task_struct, I don't suffer from that problem because struct pid is 2 orders
of magnitude smaller.  In fact struct pid is small enough that most other
kernel data structures dwarf it, so simply limiting the number of referring
data structures is enough to prevent exhaustion of low memory.

This splits the current struct pid into two structures, struct pid and struct
pid_link, and reduces our number of hash tables from PIDTYPE_MAX to just one.
struct pid_link is the per process linkage into the hash tables and lives in
struct task_struct.  struct pid is given an indepedent lifetime, and holds
pointers to each of the pid types.

The independent life of struct pid simplifies attach_pid, and detach_pid,
because we are always manipulating the list of pids and not the hash table.
In addition in giving struct pid an indpendent life it makes the concept much
more powerful.

Kernel data structures can now embed a struct pid * instead of a pid_t and
not suffer from pid wrap around problems or from keeping unnecessarily
large amounts of memory allocated.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-03-31 12:19:00 -08:00
..
irq [PATCH] warn if free_irq() is called from IRQ context 2006-03-26 08:56:53 -08:00
power [PATCH] Fix suspend with traced tasks 2006-03-31 12:18:50 -08:00
.gitignore gitignore: ignore more generated files 2006-01-03 11:35:26 +01:00
Kconfig.hz [PATCH] i386: Selectable Frequency of the Timer Interrupt 2005-06-23 09:45:10 -07:00
Kconfig.preempt [PATCH] sched: voluntary kernel preemption 2005-06-25 16:24:45 -07:00
Makefile [PATCH] lightweight robust futexes: compat 2006-03-27 08:44:49 -08:00
acct.c [PATCH] Fix pacct bug in multithreading case. 2006-03-31 12:18:54 -08:00
audit.c [PATCH] Don't pass boot parameters to argv_init[] 2006-03-31 12:18:53 -08:00
audit.h [PATCH] sem2mutex: audit_netlink_sem 2006-03-20 14:08:55 -05:00
auditfilter.c [PATCH] sem2mutex: audit_netlink_sem 2006-03-20 14:08:55 -05:00
auditsc.c Merge branch 'audit.b3' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/audit-current 2006-03-25 09:24:53 -08:00
capability.c [PATCH] refactor capable() to one implementation, add __capable() helper 2006-03-25 08:22:56 -08:00
compat.c [PATCH] lightweight robust futexes: compat 2006-03-27 08:44:49 -08:00
configs.c update the email address of Randy Dunlap 2006-01-03 13:37:51 +01:00
cpu.c [PATCH] Notifier chain update: API changes 2006-03-27 08:44:50 -08:00
cpuset.c [PATCH] cpuset: memory migration interaction fix 2006-03-31 12:18:55 -08:00
dma.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
exec_domain.c [PATCH] Fix module refcount leak in __set_personality() 2006-03-24 07:33:30 -08:00
exit.c [PATCH] task: RCU protect task->usage 2006-03-31 12:18:59 -08:00
extable.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
fork.c [PATCH] pidhash: Refactor the pid hash table 2006-03-31 12:19:00 -08:00
futex.c [PATCH] futex: check and validate timevals 2006-03-31 12:18:59 -08:00
futex_compat.c [PATCH] futex: check and validate timevals 2006-03-31 12:18:59 -08:00
hrtimer.c [PATCH] hrtimer: call get_softirq_time() only when necessary in run_hrtimer_queue() 2006-03-31 12:18:58 -08:00
intermodule.c [PATCH] missing license tag in intermodule 2006-02-05 11:06:52 -08:00
itimer.c [PATCH] hrtimers: remove data field 2006-03-26 08:57:03 -08:00
kallsyms.c [PATCH] fix missing includes 2005-10-30 17:37:32 -08:00
kexec.c [PATCH] move capable() to capability.h 2006-01-11 18:42:13 -08:00
kfifo.c [PATCH] gfp flags annotations - part 1 2005-10-08 15:00:57 -07:00
kmod.c [PATCH] wait_for_helper: trivial style cleanup 2006-03-28 18:36:41 -08:00
kprobes.c [PATCH] kretprobe instance recycled by parent process 2006-03-26 08:57:04 -08:00
ksysfs.c [PATCH] fix build error if CONFIG_SYSFS=n 2006-03-24 07:33:31 -08:00
kthread.c [PATCH] find_task_by_pid() needs tasklist_lock 2006-03-25 08:22:57 -08:00
module.c [PATCH] modules: permit Dual-MIT/GPL licenses 2006-03-31 12:18:56 -08:00
mutex-debug.c [PATCH] fix/simplify mutex debugging code 2006-01-11 08:14:16 -08:00
mutex-debug.h [PATCH] mutex subsystem, debugging code 2006-01-09 15:59:20 -08:00
mutex.c [PATCH] mutex: trivial whitespace cleanups 2006-01-10 14:27:59 -08:00
mutex.h [PATCH] mutex subsystem, core 2006-01-09 15:59:19 -08:00
panic.c [PATCH] Notifier chain update: API changes 2006-03-27 08:44:50 -08:00
params.c [PATCH] Change dash2underscore() return value to char 2006-03-28 09:16:03 -08:00
pid.c [PATCH] pidhash: Refactor the pid hash table 2006-03-31 12:19:00 -08:00
posix-cpu-timers.c [PATCH] hrtimer: switch clock_nanosleep to hrtimer nanosleep API 2006-01-10 08:01:38 -08:00
posix-timers.c [PATCH] hrtimers: remove data field 2006-03-26 08:57:03 -08:00
printk.c [PATCH] console_setup() depends (wrongly?) on CONFIG_PRINTK 2006-03-24 07:33:27 -08:00
profile.c [PATCH] Notifier chain update: API changes 2006-03-27 08:44:50 -08:00
ptrace.c [PATCH] don't use REMOVE_LINKS/SET_LINKS for reparenting 2006-03-28 18:36:41 -08:00
rcupdate.c [PATCH] rcu_process_callbacks: don't cli() while testing ->nxtlist 2006-03-24 07:33:20 -08:00
rcutorture.c [PATCH] for_each_possible_cpu: fixes for generic part 2006-03-28 09:16:05 -08:00
relay.c [PATCH] relay: consolidate sendfile() and read() code 2006-03-23 19:58:45 +01:00
resource.c [PATCH] kernel/resource.c: __check_region(): remove pointless __deprecated 2006-01-10 08:02:02 -08:00
sched.c [PATCH] sched: activate SCHED BATCH expired 2006-03-31 12:18:59 -08:00
seccomp.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
signal.c [PATCH] Fix suspend with traced tasks 2006-03-31 12:18:50 -08:00
softirq.c [PATCH] on_each_cpu(): disable local interrupts 2006-03-22 07:53:59 -08:00
softlockup.c [PATCH] Notifier chain update: API changes 2006-03-27 08:44:50 -08:00
spinlock.c [PATCH] BUILD_LOCK_OPS: cleanup preempt_disable() usage 2006-03-23 07:38:16 -08:00
stop_machine.c [PATCH] Remove set_fs() in stop_machine() 2006-01-10 08:01:25 -08:00
sys.c [PATCH] Make setsid() more robust 2006-03-31 12:18:59 -08:00
sys_ni.c [PATCH] lightweight robust futexes: core 2006-03-27 08:44:49 -08:00
sysctl.c [PATCH] Range checking in do_proc_dointvec_(userhz_)jiffies_conv 2006-03-24 07:33:20 -08:00
time.c [PATCH] hrtimers: remove nsec_t typedef 2006-03-26 08:57:03 -08:00
timer.c [PATCH] sched: reduce overhead of calc_load 2006-03-31 12:18:58 -08:00
uid16.c [PATCH] move capable() to capability.h 2006-01-11 18:42:13 -08:00
user.c [PATCH] free_uid() locking improvement 2006-03-24 07:33:20 -08:00
wait.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
workqueue.c [SCSI] add execute_in_process_context() API 2006-02-27 23:34:40 -06:00