Skip to contentSkip to conversation

pid: remove pidhash

PATCH New [email protected] 1 participant 1 message Nov 17, 2017

Subsystems (4)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 74/94 pid: remove pidhash

From: Gargi Sharma <[email protected]>
Subject: pid: remove pidhash

pidhash is no longer required as all the information can be looked up from idr tree. nr_hashed represented the number of pids that had been hashed. Since, nr_hashed and PIDNS_HASH_ADDING are no longer relevant, it has been renamed to pid_allocated and PIDNS_ADDING respectively.

---

 arch/ia64/kernel/asm-offsets.c |    4 +-
 include/linux/init_task.h      |    1 
 include/linux/pid.h            |    2 -
 include/linux/pid_namespace.h  |    4 +-
 init/main.c                    |    1 
 kernel/fork.c                  |    2 -
 kernel/pid.c                   |   48 ++++++-------------------------
 kernel/pid_namespace.c         |    6 +--
 8 files changed, 18 insertions(+), 50 deletions(-)
arch/ia64/kernel/asm-offsets.c renamed from arch/ia64/kernel/asm-offsets.c~pid-remove-pidhash +2 -2
diff -puN arch/ia64/kernel/asm-offsets.c~pid-remove-pidhash arch/ia64/kernel/asm-offsets.c
@@ -31,8 +31,8 @@ void foo(void)
 	DEFINE(SIGFRAME_SIZE, sizeof (struct sigframe));
 	DEFINE(UNW_FRAME_INFO_SIZE, sizeof (struct unw_frame_info));
 
-	BUILD_BUG_ON(sizeof(struct upid) != 32);
-	DEFINE(IA64_UPID_SHIFT, 5);
+	BUILD_BUG_ON(sizeof(struct upid) != 16);
+	DEFINE(IA64_UPID_SHIFT, 4);
 
 	BLANK();
 
include/linux/init_task.h renamed from include/linux/init_task.h~pid-remove-pidhash +0 -1
diff -puN include/linux/init_task.h~pid-remove-pidhash include/linux/init_task.h
@@ -105,7 +105,6 @@ extern struct group_info init_groups;
 	.numbers	= { {						\
 		.nr		= 0,					\
 		.ns		= &init_pid_ns,				\
-		.pid_chain	= { .next = NULL, .pprev = NULL },	\
 	}, }								\
 }
 
include/linux/pid.h renamed from include/linux/pid.h~pid-remove-pidhash +0 -2
diff -puN include/linux/pid.h~pid-remove-pidhash include/linux/pid.h
@@ -51,10 +51,8 @@ enum pid_type
  */
 
 struct upid {
-	/* Try to keep pid_chain in the same cacheline as nr for find_vpid */
 	int nr;
 	struct pid_namespace *ns;
-	struct hlist_node pid_chain;
 };
 
 struct pid
include/linux/pid_namespace.h renamed from include/linux/pid_namespace.h~pid-remove-pidhash +2 -2
diff -puN include/linux/pid_namespace.h~pid-remove-pidhash include/linux/pid_namespace.h
@@ -25,7 +25,7 @@ struct pid_namespace {
 	struct kref kref;
 	struct idr idr;
 	struct rcu_head rcu;
-	unsigned int nr_hashed;
+	unsigned int pid_allocated;
 	struct task_struct *child_reaper;
 	struct kmem_cache *pid_cachep;
 	unsigned int level;
@@ -49,7 +49,7 @@ struct pid_namespace {
 
 extern struct pid_namespace init_pid_ns;
 
-#define PIDNS_HASH_ADDING (1U << 31)
+#define PIDNS_ADDING (1U << 31)
 
 #ifdef CONFIG_PID_NS
 static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
init/main.c renamed from init/main.c~pid-remove-pidhash +0 -1
diff -puN init/main.c~pid-remove-pidhash init/main.c
@@ -562,7 +562,6 @@ asmlinkage __visible void __init start_k
 	 * kmem_cache_init()
 	 */
 	setup_log_buf(0);
-	pidhash_init();
 	vfs_caches_init_early();
 	sort_main_extable();
 	trap_init();
kernel/fork.c renamed from kernel/fork.c~pid-remove-pidhash +1 -1
diff -puN kernel/fork.c~pid-remove-pidhash kernel/fork.c
@@ -1871,7 +1871,7 @@ static __latent_entropy struct task_stru
 		retval = -ERESTARTNOINTR;
 		goto bad_fork_cancel_cgroup;
 	}
-	if (unlikely(!(ns_of_pid(pid)->nr_hashed & PIDNS_HASH_ADDING))) {
+	if (unlikely(!(ns_of_pid(pid)->pid_allocated & PIDNS_ADDING))) {
 		retval = -ENOMEM;
 		goto bad_fork_cancel_cgroup;
 	}
kernel/pid.c renamed from kernel/pid.c~pid-remove-pidhash +10 -38

116 lines not on this page · raw message

kernel/pid_namespace.c renamed from kernel/pid_namespace.c~pid-remove-pidhash +3 -3
diff -puN kernel/pid_namespace.c~pid-remove-pidhash kernel/pid_namespace.c
@@ -133,7 +133,7 @@ static struct pid_namespace *create_pid_
 	ns->parent = get_pid_ns(parent_pid_ns);
 	ns->user_ns = get_user_ns(user_ns);
 	ns->ucounts = ucounts;
-	ns->nr_hashed = PIDNS_HASH_ADDING;
+	ns->pid_allocated = PIDNS_ADDING;
 	INIT_WORK(&ns->proc_work, proc_cleanup_work);
 
 	return ns;
@@ -254,7 +254,7 @@ void zap_pid_ns_processes(struct pid_nam
 	 * sys_wait4() above can't reap the EXIT_DEAD children but we do not
 	 * really care, we could reparent them to the global init. We could
 	 * exit and reap ->child_reaper even if it is not the last thread in
-	 * this pid_ns, free_pid(nr_hashed == 0) calls proc_cleanup_work(),
+	 * this pid_ns, free_pid(pid_allocated == 0) calls proc_cleanup_work(),
 	 * pid_ns can not go away until proc_kill_sb() drops the reference.
 	 *
 	 * But this ns can also have other tasks injected by setns()+fork().
@@ -268,7 +268,7 @@ void zap_pid_ns_processes(struct pid_nam
 	 */
 	for (;;) {
 		set_current_state(TASK_INTERRUPTIBLE);
-		if (pid_ns->nr_hashed == init_pids)
+		if (pid_ns->pid_allocated == init_pids)
 			break;
 		schedule();
 	}

_