You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
[PATCH] pidhash: don't count idle threads
fork_idle() does unhash_process() just after copy_process(). Contrary, boot_cpu's idle thread explicitely registers itself for each pid_type with nr = 0. copy_process() already checks p->pid != 0 before process_counts++, I think we can just skip attach_pid() calls and job control inits for idle threads and kill unhash_process(). We don't need to cleanup ->proc_dentry in fork_idle() because with this patch idle threads are never hashed in kernel/pid.c:pid_hash[]. We don't need to hash pid == 0 in pidmap_init(). free_pidmap() is never called with pid == 0 arg, so it will never be reused. So it is still possible to use pid == 0 in any PIDTYPE_xxx namespace from kernel/pid.c's POV. However with this patch we don't hash pid == 0 for PIDTYPE_PID case. We still have have PIDTYPE_PGID/PIDTYPE_SID entries with pid == 0: /sbin/init and kernel threads which don't call daemonize(). Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
committed by
Linus Torvalds
parent
c97d98931a
commit
73b9ebfe12
+1
-9
@@ -247,16 +247,8 @@ void __init pidhash_init(void)
|
||||
|
||||
void __init pidmap_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
pidmap_array->page = (void *)get_zeroed_page(GFP_KERNEL);
|
||||
/* Reserve PID 0. We never call free_pidmap(0) */
|
||||
set_bit(0, pidmap_array->page);
|
||||
atomic_dec(&pidmap_array->nr_free);
|
||||
|
||||
/*
|
||||
* Allocate PID 0, and hash it via all PID types:
|
||||
*/
|
||||
|
||||
for (i = 0; i < PIDTYPE_MAX; i++)
|
||||
attach_pid(current, i, 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user