aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2017-09-08 19:14:18 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-09-08 21:26:48 -0400
commit9b130ad5bb8255ee8534d92d67e12b2a4887eacb (patch)
tree125a5e867be6b0dbd4958ca41426e2c733768110 /arch/powerpc
parentac036f9570a2d318b7d8dbbdbf0e269d7cc68cef (diff)
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>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/kernel/paca.c2
-rw-r--r--arch/powerpc/kernel/setup-common.c2
-rw-r--r--arch/powerpc/sysdev/xive/native.c4
3 files changed, 4 insertions, 4 deletions
diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c
index 70f073d6c3b2..2ff2b8a19f71 100644
--- a/arch/powerpc/kernel/paca.c
+++ b/arch/powerpc/kernel/paca.c
@@ -224,7 +224,7 @@ void __init allocate_pacas(void)
224 paca = __va(memblock_alloc_base(paca_size, PAGE_SIZE, limit)); 224 paca = __va(memblock_alloc_base(paca_size, PAGE_SIZE, limit));
225 memset(paca, 0, paca_size); 225 memset(paca, 0, paca_size);
226 226
227 printk(KERN_DEBUG "Allocated %u bytes for %d pacas at %p\n", 227 printk(KERN_DEBUG "Allocated %u bytes for %u pacas at %p\n",
228 paca_size, nr_cpu_ids, paca); 228 paca_size, nr_cpu_ids, paca);
229 229
230 allocate_lppacas(nr_cpu_ids, limit); 230 allocate_lppacas(nr_cpu_ids, limit);
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 7de73589d8e2..0ac741fae90e 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -551,7 +551,7 @@ void __init smp_setup_cpu_maps(void)
551 if (maxcpus > nr_cpu_ids) { 551 if (maxcpus > nr_cpu_ids) {
552 printk(KERN_WARNING 552 printk(KERN_WARNING
553 "Partition configured for %d cpus, " 553 "Partition configured for %d cpus, "
554 "operating system maximum is %d.\n", 554 "operating system maximum is %u.\n",
555 maxcpus, nr_cpu_ids); 555 maxcpus, nr_cpu_ids);
556 maxcpus = nr_cpu_ids; 556 maxcpus = nr_cpu_ids;
557 } else 557 } else
diff --git a/arch/powerpc/sysdev/xive/native.c b/arch/powerpc/sysdev/xive/native.c
index 44f3a25ca630..ebc244b08d67 100644
--- a/arch/powerpc/sysdev/xive/native.c
+++ b/arch/powerpc/sysdev/xive/native.c
@@ -511,13 +511,13 @@ static bool xive_parse_provisioning(struct device_node *np)
511static void xive_native_setup_pools(void) 511static void xive_native_setup_pools(void)
512{ 512{
513 /* Allocate a pool big enough */ 513 /* Allocate a pool big enough */
514 pr_debug("XIVE: Allocating VP block for pool size %d\n", nr_cpu_ids); 514 pr_debug("XIVE: Allocating VP block for pool size %u\n", nr_cpu_ids);
515 515
516 xive_pool_vps = xive_native_alloc_vp_block(nr_cpu_ids); 516 xive_pool_vps = xive_native_alloc_vp_block(nr_cpu_ids);
517 if (WARN_ON(xive_pool_vps == XIVE_INVALID_VP)) 517 if (WARN_ON(xive_pool_vps == XIVE_INVALID_VP))
518 pr_err("XIVE: Failed to allocate pool VP, KVM might not function\n"); 518 pr_err("XIVE: Failed to allocate pool VP, KVM might not function\n");
519 519
520 pr_debug("XIVE: Pool VPs allocated at 0x%x for %d max CPUs\n", 520 pr_debug("XIVE: Pool VPs allocated at 0x%x for %u max CPUs\n",
521 xive_pool_vps, nr_cpu_ids); 521 xive_pool_vps, nr_cpu_ids);
522} 522}
523 523