Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpumask: convert struct cpuinfo_x86's llc_shared_map to cpumask_var_t

Impact: reduce kernel memory usage when CONFIG_CPUMASK_OFFSTACK=y

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

+27 -8
+1 -1
arch/x86/include/asm/processor.h
··· 94 94 unsigned long loops_per_jiffy; 95 95 #ifdef CONFIG_SMP 96 96 /* cpus sharing the last level cache: */ 97 - cpumask_t llc_shared_map; 97 + cpumask_var_t llc_shared_map; 98 98 #endif 99 99 /* cpuid returned max cores value: */ 100 100 u16 x86_max_cores;
+26 -7
arch/x86/kernel/smpboot.c
··· 329 329 cpu_idle(); 330 330 } 331 331 332 + #ifdef CONFIG_CPUMASK_OFFSTACK 333 + /* In this case, llc_shared_map is a pointer to a cpumask. */ 334 + static inline void copy_cpuinfo_x86(struct cpuinfo_x86 *dst, 335 + const struct cpuinfo_x86 *src) 336 + { 337 + struct cpumask *llc = dst->llc_shared_map; 338 + *dst = *src; 339 + dst->llc_shared_map = llc; 340 + } 341 + #else 342 + static inline void copy_cpuinfo_x86(struct cpuinfo_x86 *dst, 343 + const struct cpuinfo_x86 *src) 344 + { 345 + *dst = *src; 346 + } 347 + #endif /* CONFIG_CPUMASK_OFFSTACK */ 348 + 332 349 /* 333 350 * The bootstrap kernel entry code has set these up. Save them for 334 351 * a given CPU ··· 355 338 { 356 339 struct cpuinfo_x86 *c = &cpu_data(id); 357 340 358 - *c = boot_cpu_data; 341 + copy_cpuinfo_x86(c, &boot_cpu_data); 359 342 c->cpu_index = id; 360 343 if (id != 0) 361 344 identify_secondary_cpu(c); ··· 379 362 cpumask_set_cpu(cpu, cpu_sibling_mask(i)); 380 363 cpumask_set_cpu(i, cpu_core_mask(cpu)); 381 364 cpumask_set_cpu(cpu, cpu_core_mask(i)); 382 - cpumask_set_cpu(i, &c->llc_shared_map); 383 - cpumask_set_cpu(cpu, &o->llc_shared_map); 365 + cpumask_set_cpu(i, c->llc_shared_map); 366 + cpumask_set_cpu(cpu, o->llc_shared_map); 384 367 } 385 368 } 386 369 } else { 387 370 cpumask_set_cpu(cpu, cpu_sibling_mask(cpu)); 388 371 } 389 372 390 - cpumask_set_cpu(cpu, &c->llc_shared_map); 373 + cpumask_set_cpu(cpu, c->llc_shared_map); 391 374 392 375 if (current_cpu_data.x86_max_cores == 1) { 393 376 cpumask_copy(cpu_core_mask(cpu), cpu_sibling_mask(cpu)); ··· 398 381 for_each_cpu(i, cpu_sibling_setup_mask) { 399 382 if (per_cpu(cpu_llc_id, cpu) != BAD_APICID && 400 383 per_cpu(cpu_llc_id, cpu) == per_cpu(cpu_llc_id, i)) { 401 - cpumask_set_cpu(i, &c->llc_shared_map); 402 - cpumask_set_cpu(cpu, &cpu_data(i).llc_shared_map); 384 + cpumask_set_cpu(i, c->llc_shared_map); 385 + cpumask_set_cpu(cpu, cpu_data(i).llc_shared_map); 403 386 } 404 387 if (c->phys_proc_id == cpu_data(i).phys_proc_id) { 405 388 cpumask_set_cpu(i, cpu_core_mask(cpu)); ··· 437 420 if (sched_mc_power_savings || sched_smt_power_savings) 438 421 return cpu_core_mask(cpu); 439 422 else 440 - return &c->llc_shared_map; 423 + return c->llc_shared_map; 441 424 } 442 425 443 426 static void impress_friends(void) ··· 1056 1039 for_each_possible_cpu(i) { 1057 1040 alloc_cpumask_var(&per_cpu(cpu_sibling_map, i), GFP_KERNEL); 1058 1041 alloc_cpumask_var(&per_cpu(cpu_core_map, i), GFP_KERNEL); 1042 + alloc_cpumask_var(&cpu_data(i).llc_shared_map, GFP_KERNEL); 1059 1043 cpumask_clear(per_cpu(cpu_core_map, i)); 1060 1044 cpumask_clear(per_cpu(cpu_sibling_map, i)); 1045 + cpumask_clear(cpu_data(i).llc_shared_map); 1061 1046 } 1062 1047 set_cpu_sibling_map(0); 1063 1048