Skip to content

Commit caafa43

Browse files
xemultorvalds
authored andcommitted
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]. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent ab883af commit caafa43

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎include/linux/pid.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct pid
6060
/* lists of tasks that use this pid */
6161
struct hlist_head tasks[PIDTYPE_MAX];
6262
struct rcu_head rcu;
63-
int level;
63+
unsigned int level;
6464
struct upid numbers[1];
6565
};
6666

‎include/linux/pid_namespace.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct pid_namespace {
2020
int last_pid;
2121
struct task_struct *child_reaper;
2222
struct kmem_cache *pid_cachep;
23-
int level;
23+
unsigned int level;
2424
struct pid_namespace *parent;
2525
#ifdef CONFIG_PROC_FS
2626
struct vfsmount *proc_mnt;

‎kernel/pid_namespace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static struct kmem_cache *create_pid_cachep(int nr_ids)
6666
return NULL;
6767
}
6868

69-
static struct pid_namespace *create_pid_namespace(int level)
69+
static struct pid_namespace *create_pid_namespace(unsigned int level)
7070
{
7171
struct pid_namespace *ns;
7272
int i;

0 commit comments

Comments
 (0)