The patch titled Subject: numa: make "nr_node_ids" unsigned int has been added to the -mm tree. Its filename is numa-make-nr_node_ids-unsigned-int.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/numa-make-nr_node_ids-unsigned-int.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/numa-make-nr_node_ids-unsigned-int.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Alexey Dobriyan <adobriyan@xxxxxxxxx> Subject: numa: make "nr_node_ids" unsigned int Number of NUMA nodes can't be negative. This saves a few bytes on x86_64: add/remove: 0/0 grow/shrink: 4/21 up/down: 27/-265 (-238) Function old new delta hv_synic_alloc.cold 88 110 +22 prealloc_shrinker 260 262 +2 bootstrap 249 251 +2 sched_init_numa 1566 1567 +1 show_slab_objects 778 777 -1 s_show 1201 1200 -1 kmem_cache_init 346 345 -1 __alloc_workqueue_key 1146 1145 -1 mem_cgroup_css_alloc 1614 1612 -2 __do_sys_swapon 4702 4699 -3 __list_lru_init 655 651 -4 nic_probe 2379 2374 -5 store_user_store 118 111 -7 red_zone_store 106 99 -7 poison_store 106 99 -7 wq_numa_init 348 338 -10 __kmem_cache_empty 75 65 -10 task_numa_free 186 173 -13 merge_across_nodes_store 351 336 -15 irq_create_affinity_masks 1261 1246 -15 do_numa_crng_init 343 321 -22 task_numa_fault 4760 4737 -23 swapfile_init 179 156 -23 hv_synic_alloc 536 492 -44 apply_wqattrs_prepare 746 695 -51 Link: http://lkml.kernel.org/r/20190201223029.GA15820@avx2 Signed-off-by: Alexey Dobriyan <adobriyan@xxxxxxxxx> Reviewed-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- --- a/arch/arm64/mm/numa.c~numa-make-nr_node_ids-unsigned-int +++ a/arch/arm64/mm/numa.c @@ -120,7 +120,7 @@ static void __init setup_node_to_cpumask } /* cpumask_of_node() will now work */ - pr_debug("Node to cpumask map for %d nodes\n", nr_node_ids); + pr_debug("Node to cpumask map for %u nodes\n", nr_node_ids); } /* --- a/arch/powerpc/mm/numa.c~numa-make-nr_node_ids-unsigned-int +++ a/arch/powerpc/mm/numa.c @@ -84,7 +84,7 @@ static void __init setup_node_to_cpumask alloc_bootmem_cpumask_var(&node_to_cpumask_map[node]); /* cpumask_of_node() will now work */ - dbg("Node to cpumask map for %d nodes\n", nr_node_ids); + dbg("Node to cpumask map for %u nodes\n", nr_node_ids); } static int __init fake_numa_create_new_node(unsigned long end_pfn, --- a/arch/x86/kernel/setup_percpu.c~numa-make-nr_node_ids-unsigned-int +++ a/arch/x86/kernel/setup_percpu.c @@ -171,7 +171,7 @@ void __init setup_per_cpu_areas(void) unsigned long delta; int rc; - pr_info("NR_CPUS:%d nr_cpumask_bits:%d nr_cpu_ids:%u nr_node_ids:%d\n", + pr_info("NR_CPUS:%d nr_cpumask_bits:%d nr_cpu_ids:%u nr_node_ids:%u\n", NR_CPUS, nr_cpumask_bits, nr_cpu_ids, nr_node_ids); /* --- a/arch/x86/mm/numa.c~numa-make-nr_node_ids-unsigned-int +++ a/arch/x86/mm/numa.c @@ -123,7 +123,7 @@ void __init setup_node_to_cpumask_map(vo alloc_bootmem_cpumask_var(&node_to_cpumask_map[node]); /* cpumask_of_node() will now work */ - pr_debug("Node to cpumask map for %d nodes\n", nr_node_ids); + pr_debug("Node to cpumask map for %u nodes\n", nr_node_ids); } static int __init numa_add_memblk_to(int nid, u64 start, u64 end, @@ -866,7 +866,7 @@ const struct cpumask *cpumask_of_node(in { if (node >= nr_node_ids) { printk(KERN_WARNING - "cpumask_of_node(%d): node > nr_node_ids(%d)\n", + "cpumask_of_node(%d): node > nr_node_ids(%u)\n", node, nr_node_ids); dump_stack(); return cpu_none_mask; --- a/include/linux/nodemask.h~numa-make-nr_node_ids-unsigned-int +++ a/include/linux/nodemask.h @@ -99,10 +99,10 @@ typedef struct { DECLARE_BITMAP(bits, MA extern nodemask_t _unused_nodemask_arg_; #if MAX_NUMNODES > 1 -extern int nr_node_ids; +extern unsigned int nr_node_ids; extern int nr_online_nodes; #else -#define nr_node_ids 1 +#define nr_node_ids 1U #define nr_online_nodes 1 #endif --- a/mm/list_lru.c~numa-make-nr_node_ids-unsigned-int +++ a/mm/list_lru.c @@ -601,7 +601,6 @@ int __list_lru_init(struct list_lru *lru struct lock_class_key *key, struct shrinker *shrinker) { int i; - size_t size = sizeof(*lru->node) * nr_node_ids; int err = -ENOMEM; #ifdef CONFIG_MEMCG_KMEM @@ -612,7 +611,7 @@ int __list_lru_init(struct list_lru *lru #endif memcg_get_cache_ids(); - lru->node = kzalloc(size, GFP_KERNEL); + lru->node = kcalloc(nr_node_ids, sizeof(*lru->node), GFP_KERNEL); if (!lru->node) goto out; --- a/mm/memcontrol.c~numa-make-nr_node_ids-unsigned-int +++ a/mm/memcontrol.c @@ -4444,7 +4444,7 @@ static void mem_cgroup_free(struct mem_c static struct mem_cgroup *mem_cgroup_alloc(void) { struct mem_cgroup *memcg; - size_t size; + unsigned int size; int node; size = sizeof(struct mem_cgroup); --- a/mm/page_alloc.c~numa-make-nr_node_ids-unsigned-int +++ a/mm/page_alloc.c @@ -289,7 +289,7 @@ EXPORT_SYMBOL(movable_zone); #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ #if MAX_NUMNODES > 1 -int nr_node_ids __read_mostly = MAX_NUMNODES; +unsigned int nr_node_ids __read_mostly = MAX_NUMNODES; int nr_online_nodes __read_mostly = 1; EXPORT_SYMBOL(nr_node_ids); EXPORT_SYMBOL(nr_online_nodes); --- a/mm/slab.c~numa-make-nr_node_ids-unsigned-int +++ a/mm/slab.c @@ -677,12 +677,11 @@ static struct alien_cache *__alloc_alien static struct alien_cache **alloc_alien_cache(int node, int limit, gfp_t gfp) { struct alien_cache **alc_ptr; - size_t memsize = sizeof(void *) * nr_node_ids; int i; if (limit > 1) limit = 12; - alc_ptr = kzalloc_node(memsize, gfp, node); + alc_ptr = kcalloc_node(nr_node_ids, sizeof(void *), gfp, node); if (!alc_ptr) return NULL; --- a/mm/slub.c~numa-make-nr_node_ids-unsigned-int +++ a/mm/slub.c @@ -4254,7 +4254,7 @@ void __init kmem_cache_init(void) cpuhp_setup_state_nocalls(CPUHP_SLUB_DEAD, "slub:dead", NULL, slub_cpu_dead); - pr_info("SLUB: HWalign=%d, Order=%u-%u, MinObjects=%u, CPUs=%u, Nodes=%d\n", + pr_info("SLUB: HWalign=%d, Order=%u-%u, MinObjects=%u, CPUs=%u, Nodes=%u\n", cache_line_size(), slub_min_order, slub_max_order, slub_min_objects, nr_cpu_ids, nr_node_ids); --- a/mm/swapfile.c~numa-make-nr_node_ids-unsigned-int +++ a/mm/swapfile.c @@ -2713,7 +2713,7 @@ static struct swap_info_struct *alloc_sw struct swap_info_struct *p; unsigned int type; int i; - int size = sizeof(*p) + nr_node_ids * sizeof(struct plist_node); + unsigned int size = sizeof(*p) + nr_node_ids * sizeof(struct plist_node); p = kvzalloc(size, GFP_KERNEL); if (!p) --- a/mm/vmscan.c~numa-make-nr_node_ids-unsigned-int +++ a/mm/vmscan.c @@ -374,7 +374,7 @@ unsigned long lruvec_lru_size(struct lru */ int prealloc_shrinker(struct shrinker *shrinker) { - size_t size = sizeof(*shrinker->nr_deferred); + unsigned int size = sizeof(*shrinker->nr_deferred); if (shrinker->flags & SHRINKER_NUMA_AWARE) size *= nr_node_ids; _ Patches currently in -mm which might be from adobriyan@xxxxxxxxx are mm-shuffle-gfp_-flags.patch numa-make-nr_node_ids-unsigned-int.patch numa-make-nr_online_nodes-unsigned-int.patch proc-return-exit-code-4-for-skipped-tests.patch proc-read-kernel-cpu-stat-pointer-once.patch proc-use-seq_puts-everywhere.patch proc-test-proc-maps-smaps-smaps_rollup-statm.patch elf-dont-be-afraid-of-overflow.patch elf-use-list_for_each_entry.patch elf-spread-const-a-little.patch proc-calculate-end-pointer-for-proc-lookup-at-compile-time.patch