Skip to contentSkip to conversation

pidns: make pid->level and pid_ns->level unsigned

PATCH New Pavel Emelyanov 1 participant 1 message Feb 26, 2008 Namespaces:

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pidns: make pid->level and pid_ns->level unsigned

These values represent the nesting level of a namespace and pids living in it, and it's always non-negative.

Turning this from int to unsigned int saves some space in pid.c (11 bytes on x86 and 64 on ia64) by letting the compiler optimize the pid_nr_ns a bit. E.g. on ia64 this removes the sign extension calls, which compiler adds to optimize access to pid->nubers[ns->level].

---

include/linux/pid.h +1 -1
index c798081..03573e3 100644
@@ -60,7 +60,7 @@ struct pid
 	/* lists of tasks that use this pid */
 	struct hlist_head tasks[PIDTYPE_MAX];
 	struct rcu_head rcu;
-	int level;
+	unsigned int level;
 	struct upid numbers[1];
 };
 
include/linux/pid_namespace.h +1 -1
index fcd61fa..caff528 100644
@@ -20,7 +20,7 @@ struct pid_namespace {
 	int last_pid;
 	struct task_struct *child_reaper;
 	struct kmem_cache *pid_cachep;
-	int level;
+	unsigned int level;
 	struct pid_namespace *parent;
 #ifdef CONFIG_PROC_FS
 	struct vfsmount *proc_mnt;
kernel/pid_namespace.c +1 -1
index 6d792b6..cb17497 100644
@@ -66,7 +66,7 @@ err_alloc:
 	return NULL;
 }
 
-static struct pid_namespace *create_pid_namespace(int level)
+static struct pid_namespace *create_pid_namespace(unsigned int level)
 {
 	struct pid_namespace *ns;
 	int i;