treewide: make "nr_cpu_ids" unsigned
authorAlexey Dobriyan <adobriyan@gmail.com>
Fri, 8 Sep 2017 23:14:18 +0000 (16:14 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 9 Sep 2017 01:26:48 +0000 (18:26 -0700)
commit9b130ad5bb8255ee8534d92d67e12b2a4887eacb
tree125a5e867be6b0dbd4958ca41426e2c733768110
parentac036f9570a2d318b7d8dbbdbf0e269d7cc68cef
treewide: make "nr_cpu_ids" unsigned

First, number of CPUs can't be negative number.

Second, different signnnedness leads to suboptimal code in the following
cases:

1)
kmalloc(nr_cpu_ids * sizeof(X));

"int" has to be sign extended to size_t.

2)
while (loff_t *pos < nr_cpu_ids)

MOVSXD is 1 byte longed than the same MOV.

Other cases exist as well. Basically compiler is told that nr_cpu_ids
can't be negative which can't be deduced if it is "int".

Code savings on allyesconfig kernel: -3KB

add/remove: 0/0 grow/shrink: 25/264 up/down: 261/-3631 (-3370)
function                                     old     new   delta
coretemp_cpu_online                          450     512     +62
rcu_init_one                                1234    1272     +38
pci_device_probe                             374     399     +25

...

pgdat_reclaimable_pages                      628     556     -72
select_fallback_rq                           446     369     -77
task_numa_find_cpu                          1923    1807    -116

Link: http://lkml.kernel.org/r/20170819114959.GA30580@avx2
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
17 files changed:
arch/arm64/kernel/smp.c
arch/powerpc/kernel/paca.c
arch/powerpc/kernel/setup-common.c
arch/powerpc/sysdev/xive/native.c
arch/tile/kernel/setup.c
arch/x86/kernel/apic/apic.c
arch/x86/kernel/setup_percpu.c
arch/x86/kernel/smpboot.c
drivers/base/cpu.c
drivers/scsi/scsi_debug.c
include/linux/cpumask.h
kernel/rcu/tree.c
kernel/rcu/tree_plugin.h
kernel/sched/topology.c
kernel/smp.c
kernel/trace/trace_functions_graph.c
mm/slub.c