History

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

Alexey Dobriyan committed 7 years ago

Commit b9726c21 parent d342a0b12 files · +14 −16Browse files

Unified · Split

12 files
  1. arch/arm64/mm/numa.c +1 −1
  2. arch/powerpc/mm/numa.c +1 −1
  3. arch/x86/kernel/setup_percpu.c +1 −1
  4. arch/x86/mm/numa.c +2 −2
  5. include/linux/nodemask.h +2 −2
  6. mm/list_lru.c +1 −2
  7. mm/memcontrol.c +1 −1
  8. mm/page_alloc.c +1 −1
  9. mm/slab.c +1 −2
  10. mm/slub.c +1 −1
  11. mm/swapfile.c +1 −1
  12. mm/vmscan.c +1 −1
arch/arm64/mm/numa.c+1−1
@@ -120,7 +120,7 @@ static void __init setup_node_to_cpumask_map(void) · 119 unmodified lines
120120 }
121121
122122 /* cpumask_of_node() will now work */
123− pr_debug("Node to cpumask map for %d nodes\n", nr_node_ids);
123+ pr_debug("Node to cpumask map for %u nodes\n", nr_node_ids);
124124 }
125125
126126 /*
arch/powerpc/mm/numa.c+1−1
@@ -84,7 +84,7 @@ static void __init setup_node_to_cpumask_map(void) · 83 unmodified lines
8484 alloc_bootmem_cpumask_var(&node_to_cpumask_map[node]);
8585
8686 /* cpumask_of_node() will now work */
87− dbg("Node to cpumask map for %d nodes\n", nr_node_ids);
87+ dbg("Node to cpumask map for %u nodes\n", nr_node_ids);
8888 }
8989
9090 static int __init fake_numa_create_new_node(unsigned long end_pfn,
arch/x86/kernel/setup_percpu.c+1−1
@@ -171,7 +171,7 @@ void __init setup_per_cpu_areas(void) · 170 unmodified lines
171171 unsigned long delta;
172172 int rc;
173173
174− pr_info("NR_CPUS:%d nr_cpumask_bits:%d nr_cpu_ids:%u nr_node_ids:%d\n",
174+ pr_info("NR_CPUS:%d nr_cpumask_bits:%d nr_cpu_ids:%u nr_node_ids:%u\n",
175175 NR_CPUS, nr_cpumask_bits, nr_cpu_ids, nr_node_ids);
176176
177177 /*
arch/x86/mm/numa.c+2−2
@@ -123,7 +123,7 @@ void __init setup_node_to_cpumask_map(void) · 122 unmodified lines
123123 alloc_bootmem_cpumask_var(&node_to_cpumask_map[node]);
124124
125125 /* cpumask_of_node() will now work */
126− pr_debug("Node to cpumask map for %d nodes\n", nr_node_ids);
126+ pr_debug("Node to cpumask map for %u nodes\n", nr_node_ids);
127127 }
128128
129129 static int __init numa_add_memblk_to(int nid, u64 start, u64 end,
@@ -866,7 +866,7 @@ const struct cpumask *cpumask_of_node(int node) · 736 unmodified lines
866866 {
867867 if (node >= nr_node_ids) {
868868 printk(KERN_WARNING
869− "cpumask_of_node(%d): node > nr_node_ids(%d)\n",
869+ "cpumask_of_node(%d): node > nr_node_ids(%u)\n",
870870 node, nr_node_ids);
871871 dump_stack();
872872 return cpu_none_mask;
include/linux/nodemask.h+2−2
@@ -444,7 +444,7 @@ static inline int next_memory_node(int nid) · 443 unmodified lines
444444 return next_node(nid, node_states[N_MEMORY]);
445445 }
446446
447−extern int nr_node_ids;
447+extern unsigned int nr_node_ids;
448448 extern int nr_online_nodes;
449449
450450 static inline void node_set_online(int nid)
@@ -485,7 +485,7 @@ static inline int num_node_state(enum node_states state) · 34 unmodified lines
485485 #define first_online_node 0
486486 #define first_memory_node 0
487487 #define next_online_node(nid) (MAX_NUMNODES)
488−#define nr_node_ids 1
488+#define nr_node_ids 1U
489489 #define nr_online_nodes 1
490490
491491 #define node_set_online(node) node_set_state((node), N_ONLINE)
mm/list_lru.c+1−2
@@ -601,7 +601,6 @@ int __list_lru_init(struct list_lru *lru, bool memcg_aware, · 600 unmodified lines
601601 struct lock_class_key *key, struct shrinker *shrinker)
602602 {
603603 int i;
604− size_t size = sizeof(*lru->node) * nr_node_ids;
605604 int err = -ENOMEM;
606605
607606 #ifdef CONFIG_MEMCG_KMEM
@@ -612,7 +611,7 @@ int __list_lru_init(struct list_lru *lru, bool memcg_aware, · 4 unmodified lines
612611 #endif
613612 memcg_get_cache_ids();
614613
615− lru->node = kzalloc(size, GFP_KERNEL);
614+ lru->node = kcalloc(nr_node_ids, sizeof(*lru->node), GFP_KERNEL);
616615 if (!lru->node)
617616 goto out;
618617
mm/memcontrol.c+1−1
@@ -4429,7 +4429,7 @@ static void mem_cgroup_free(struct mem_cgroup *memcg) · 4428 unmodified lines
44294429 static struct mem_cgroup *mem_cgroup_alloc(void)
44304430 {
44314431 struct mem_cgroup *memcg;
4432− size_t size;
4432+ unsigned int size;
44334433 int node;
44344434
44354435 size = sizeof(struct mem_cgroup);
mm/page_alloc.c+1−1
@@ -289,7 +289,7 @@ EXPORT_SYMBOL(movable_zone); · 288 unmodified lines
289289 #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
290290
291291 #if MAX_NUMNODES > 1
292−int nr_node_ids __read_mostly = MAX_NUMNODES;
292+unsigned int nr_node_ids __read_mostly = MAX_NUMNODES;
293293 int nr_online_nodes __read_mostly = 1;
294294 EXPORT_SYMBOL(nr_node_ids);
295295 EXPORT_SYMBOL(nr_online_nodes);
mm/slab.c+1−2
@@ -677,12 +677,11 @@ static struct alien_cache *__alloc_alien_cache(int node, int entries, · 676 unmodified lines
677677 static struct alien_cache **alloc_alien_cache(int node, int limit, gfp_t gfp)
678678 {
679679 struct alien_cache **alc_ptr;
680− size_t memsize = sizeof(void *) * nr_node_ids;
681680 int i;
682681
683682 if (limit > 1)
684683 limit = 12;
685− alc_ptr = kzalloc_node(memsize, gfp, node);
684+ alc_ptr = kcalloc_node(nr_node_ids, sizeof(void *), gfp, node);
686685 if (!alc_ptr)
687686 return NULL;
688687
mm/slub.c+1−1
@@ -4262,7 +4262,7 @@ void __init kmem_cache_init(void) · 4261 unmodified lines
42624262 cpuhp_setup_state_nocalls(CPUHP_SLUB_DEAD, "slub:dead", NULL,
42634263 slub_cpu_dead);
42644264
4265− pr_info("SLUB: HWalign=%d, Order=%u-%u, MinObjects=%u, CPUs=%u, Nodes=%d\n",
4265+ pr_info("SLUB: HWalign=%d, Order=%u-%u, MinObjects=%u, CPUs=%u, Nodes=%u\n",
42664266 cache_line_size(),
42674267 slub_min_order, slub_max_order, slub_min_objects,
42684268 nr_cpu_ids, nr_node_ids);
mm/swapfile.c+1−1
@@ -2713,7 +2713,7 @@ static struct swap_info_struct *alloc_swap_info(void) · 2712 unmodified lines
27132713 struct swap_info_struct *p;
27142714 unsigned int type;
27152715 int i;
2716− int size = sizeof(*p) + nr_node_ids * sizeof(struct plist_node);
2716+ unsigned int size = sizeof(*p) + nr_node_ids * sizeof(struct plist_node);
27172717
27182718 p = kvzalloc(size, GFP_KERNEL);
27192719 if (!p)
mm/vmscan.c+1−1
@@ -374,7 +374,7 @@ unsigned long lruvec_lru_size(struct lruvec *lruvec, enum lru_list lru, int zone · 373 unmodified lines
374374 */
375375 int prealloc_shrinker(struct shrinker *shrinker)
376376 {
377− size_t size = sizeof(*shrinker->nr_deferred);
377+ unsigned int size = sizeof(*shrinker->nr_deferred);
378378
379379 if (shrinker->flags & SHRINKER_NUMA_AWARE)
380380 size *= nr_node_ids;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t