Skip to content

Commit 417e315

Browse files
andre-rosatorvalds
authored andcommitted
pid: reduce code size by using a pointer to iterate over array
It decreases code size by 16 bytes on my gcc 4.4.1 on Core 2: text data bss dec hex filename 4314 2216 8 6538 198a kernel/pid.o-BEFORE 4298 2216 8 6522 197a kernel/pid.o-AFTER Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com> Cc: Pekka Enberg <penberg@cs.helsinki.fi> Cc: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 7be6d99 commit 417e315

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎kernel/pid.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,11 @@ struct pid *alloc_pid(struct pid_namespace *ns)
269269
for (type = 0; type < PIDTYPE_MAX; ++type)
270270
INIT_HLIST_HEAD(&pid->tasks[type]);
271271

272+
upid = pid->numbers + ns->level;
272273
spin_lock_irq(&pidmap_lock);
273-
for (i = ns->level; i >= 0; i--) {
274-
upid = &pid->numbers[i];
274+
for ( ; upid >= pid->numbers; --upid)
275275
hlist_add_head_rcu(&upid->pid_chain,
276276
&pid_hash[pid_hashfn(upid->nr, upid->ns)]);
277-
}
278277
spin_unlock_irq(&pidmap_lock);
279278

280279
out:

0 commit comments

Comments
 (0)