aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/cpumask.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/cpumask.h')
-rw-r--r--include/linux/cpumask.h75
1 files changed, 29 insertions, 46 deletions
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index b5ad19a6f43f..db2341beca45 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -416,65 +416,54 @@ int __next_cpu_nr(int n, const cpumask_t *srcp);
416 416
417/* 417/*
418 * The following particular system cpumasks and operations manage 418 * The following particular system cpumasks and operations manage
419 * possible, present, active and online cpus. Each of them is a fixed size 419 * possible, present, active and online cpus.
420 * bitmap of size NR_CPUS.
421 * 420 *
422 * #ifdef CONFIG_HOTPLUG_CPU 421 * cpu_possible_mask- has bit 'cpu' set iff cpu is populatable
423 * cpu_possible_map - has bit 'cpu' set iff cpu is populatable 422 * cpu_present_mask - has bit 'cpu' set iff cpu is populated
424 * cpu_present_map - has bit 'cpu' set iff cpu is populated 423 * cpu_online_mask - has bit 'cpu' set iff cpu available to scheduler
425 * cpu_online_map - has bit 'cpu' set iff cpu available to scheduler 424 * cpu_active_mask - has bit 'cpu' set iff cpu available to migration
426 * cpu_active_map - has bit 'cpu' set iff cpu available to migration
427 * #else
428 * cpu_possible_map - has bit 'cpu' set iff cpu is populated
429 * cpu_present_map - copy of cpu_possible_map
430 * cpu_online_map - has bit 'cpu' set iff cpu available to scheduler
431 * #endif
432 * 425 *
433 * In either case, NR_CPUS is fixed at compile time, as the static 426 * If !CONFIG_HOTPLUG_CPU, present == possible, and active == online.
434 * size of these bitmaps. The cpu_possible_map is fixed at boot
435 * time, as the set of CPU id's that it is possible might ever
436 * be plugged in at anytime during the life of that system boot.
437 * The cpu_present_map is dynamic(*), representing which CPUs
438 * are currently plugged in. And cpu_online_map is the dynamic
439 * subset of cpu_present_map, indicating those CPUs available
440 * for scheduling.
441 * 427 *
442 * If HOTPLUG is enabled, then cpu_possible_map is forced to have 428 * The cpu_possible_mask is fixed at boot time, as the set of CPU id's
429 * that it is possible might ever be plugged in at anytime during the
430 * life of that system boot. The cpu_present_mask is dynamic(*),
431 * representing which CPUs are currently plugged in. And
432 * cpu_online_mask is the dynamic subset of cpu_present_mask,
433 * indicating those CPUs available for scheduling.
434 *
435 * If HOTPLUG is enabled, then cpu_possible_mask is forced to have
443 * all NR_CPUS bits set, otherwise it is just the set of CPUs that 436 * all NR_CPUS bits set, otherwise it is just the set of CPUs that
444 * ACPI reports present at boot. 437 * ACPI reports present at boot.
445 * 438 *
446 * If HOTPLUG is enabled, then cpu_present_map varies dynamically, 439 * If HOTPLUG is enabled, then cpu_present_mask varies dynamically,
447 * depending on what ACPI reports as currently plugged in, otherwise 440 * depending on what ACPI reports as currently plugged in, otherwise
448 * cpu_present_map is just a copy of cpu_possible_map. 441 * cpu_present_mask is just a copy of cpu_possible_mask.
449 * 442 *
450 * (*) Well, cpu_present_map is dynamic in the hotplug case. If not 443 * (*) Well, cpu_present_mask is dynamic in the hotplug case. If not
451 * hotplug, it's a copy of cpu_possible_map, hence fixed at boot. 444 * hotplug, it's a copy of cpu_possible_mask, hence fixed at boot.
452 * 445 *
453 * Subtleties: 446 * Subtleties:
454 * 1) UP arch's (NR_CPUS == 1, CONFIG_SMP not defined) hardcode 447 * 1) UP arch's (NR_CPUS == 1, CONFIG_SMP not defined) hardcode
455 * assumption that their single CPU is online. The UP 448 * assumption that their single CPU is online. The UP
456 * cpu_{online,possible,present}_maps are placebos. Changing them 449 * cpu_{online,possible,present}_masks are placebos. Changing them
457 * will have no useful affect on the following num_*_cpus() 450 * will have no useful affect on the following num_*_cpus()
458 * and cpu_*() macros in the UP case. This ugliness is a UP 451 * and cpu_*() macros in the UP case. This ugliness is a UP
459 * optimization - don't waste any instructions or memory references 452 * optimization - don't waste any instructions or memory references
460 * asking if you're online or how many CPUs there are if there is 453 * asking if you're online or how many CPUs there are if there is
461 * only one CPU. 454 * only one CPU.
462 * 2) Most SMP arch's #define some of these maps to be some
463 * other map specific to that arch. Therefore, the following
464 * must be #define macros, not inlines. To see why, examine
465 * the assembly code produced by the following. Note that
466 * set1() writes phys_x_map, but set2() writes x_map:
467 * int x_map, phys_x_map;
468 * #define set1(a) x_map = a
469 * inline void set2(int a) { x_map = a; }
470 * #define x_map phys_x_map
471 * main(){ set1(3); set2(5); }
472 */ 455 */
473 456
474extern cpumask_t cpu_possible_map; 457extern const struct cpumask *const cpu_possible_mask;
475extern cpumask_t cpu_online_map; 458extern const struct cpumask *const cpu_online_mask;
476extern cpumask_t cpu_present_map; 459extern const struct cpumask *const cpu_present_mask;
477extern cpumask_t cpu_active_map; 460extern const struct cpumask *const cpu_active_mask;
461
462/* These strip const, as traditionally they weren't const. */
463#define cpu_possible_map (*(cpumask_t *)cpu_possible_mask)
464#define cpu_online_map (*(cpumask_t *)cpu_online_mask)
465#define cpu_present_map (*(cpumask_t *)cpu_present_mask)
466#define cpu_active_map (*(cpumask_t *)cpu_active_mask)
478 467
479#if NR_CPUS > 1 468#if NR_CPUS > 1
480#define num_online_cpus() cpus_weight_nr(cpu_online_map) 469#define num_online_cpus() cpus_weight_nr(cpu_online_map)
@@ -1058,12 +1047,6 @@ static inline void free_bootmem_cpumask_var(cpumask_var_t mask)
1058} 1047}
1059#endif /* CONFIG_CPUMASK_OFFSTACK */ 1048#endif /* CONFIG_CPUMASK_OFFSTACK */
1060 1049
1061/* The pointer versions of the maps, these will become the primary versions. */
1062#define cpu_possible_mask ((const struct cpumask *)&cpu_possible_map)
1063#define cpu_online_mask ((const struct cpumask *)&cpu_online_map)
1064#define cpu_present_mask ((const struct cpumask *)&cpu_present_map)
1065#define cpu_active_mask ((const struct cpumask *)&cpu_active_map)
1066
1067/* It's common to want to use cpu_all_mask in struct member initializers, 1050/* It's common to want to use cpu_all_mask in struct member initializers,
1068 * so it has to refer to an address rather than a pointer. */ 1051 * so it has to refer to an address rather than a pointer. */
1069extern const DECLARE_BITMAP(cpu_all_bits, NR_CPUS); 1052extern const DECLARE_BITMAP(cpu_all_bits, NR_CPUS);