Skip to content

Commit

Permalink
Merge tag 'for-linus' of git://github.com/rustyrussell/linux
Browse files Browse the repository at this point in the history
Pull cpumask cleanups from Rusty Russell:
 "(Somehow forgot to send this out; it's been sitting in linux-next, and
  if you don't want it, it can sit there another cycle)"

I'm a sucker for things that actually delete lines of code.

Fix up trivial conflict in arch/arm/kernel/kprobes.c, where Rusty fixed
a user of &cpu_online_map to be cpu_online_mask, but that code got
deleted by commit b21d55e ("ARM: 7332/1: extract out code patch
function from kprobes").

* tag 'for-linus' of git://github.com/rustyrussell/linux:
  cpumask: remove old cpu_*_map.
  documentation: remove references to cpu_*_map.
  drivers/cpufreq/db8500-cpufreq: remove references to cpu_*_map.
  remove references to cpu_*_map in arch/
  • Loading branch information
torvalds committed Apr 2, 2012
2 parents dd775ae + 615399c commit deb74f5
Show file tree
Hide file tree
Showing 28 changed files with 79 additions and 90 deletions.
2 changes: 1 addition & 1 deletion Documentation/cgroups/cpusets.txt
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ and name space for cpusets, with a minimum of additional kernel code.

The cpus and mems files in the root (top_cpuset) cpuset are
read-only. The cpus file automatically tracks the value of
cpu_online_map using a CPU hotplug notifier, and the mems file
cpu_online_mask using a CPU hotplug notifier, and the mems file
automatically tracks the value of node_states[N_HIGH_MEMORY]--i.e.,
nodes with memory--using the cpuset_track_online_nodes() hook.

Expand Down
22 changes: 11 additions & 11 deletions Documentation/cpu-hotplug.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ maxcpus=n Restrict boot time cpus to n. Say if you have 4 cpus, using
other cpus later online, read FAQ's for more info.

additional_cpus=n (*) Use this to limit hotpluggable cpus. This option sets
cpu_possible_map = cpu_present_map + additional_cpus
cpu_possible_mask = cpu_present_mask + additional_cpus

cede_offline={"off","on"} Use this option to disable/enable putting offlined
processors to an extended H_CEDE state on
Expand All @@ -64,33 +64,33 @@ should only rely on this to count the # of cpus, but *MUST* not rely
on the apicid values in those tables for disabled apics. In the event
BIOS doesn't mark such hot-pluggable cpus as disabled entries, one could
use this parameter "additional_cpus=x" to represent those cpus in the
cpu_possible_map.
cpu_possible_mask.

possible_cpus=n [s390,x86_64] use this to set hotpluggable cpus.
This option sets possible_cpus bits in
cpu_possible_map. Thus keeping the numbers of bits set
cpu_possible_mask. Thus keeping the numbers of bits set
constant even if the machine gets rebooted.

CPU maps and such
-----------------
[More on cpumaps and primitive to manipulate, please check
include/linux/cpumask.h that has more descriptive text.]

cpu_possible_map: Bitmap of possible CPUs that can ever be available in the
cpu_possible_mask: Bitmap of possible CPUs that can ever be available in the
system. This is used to allocate some boot time memory for per_cpu variables
that aren't designed to grow/shrink as CPUs are made available or removed.
Once set during boot time discovery phase, the map is static, i.e no bits
are added or removed anytime. Trimming it accurately for your system needs
upfront can save some boot time memory. See below for how we use heuristics
in x86_64 case to keep this under check.

cpu_online_map: Bitmap of all CPUs currently online. Its set in __cpu_up()
cpu_online_mask: Bitmap of all CPUs currently online. Its set in __cpu_up()
after a cpu is available for kernel scheduling and ready to receive
interrupts from devices. Its cleared when a cpu is brought down using
__cpu_disable(), before which all OS services including interrupts are
migrated to another target CPU.

cpu_present_map: Bitmap of CPUs currently present in the system. Not all
cpu_present_mask: Bitmap of CPUs currently present in the system. Not all
of them may be online. When physical hotplug is processed by the relevant
subsystem (e.g ACPI) can change and new bit either be added or removed
from the map depending on the event is hot-add/hot-remove. There are currently
Expand All @@ -99,22 +99,22 @@ at which time hotplug is disabled.

You really dont need to manipulate any of the system cpu maps. They should
be read-only for most use. When setting up per-cpu resources almost always use
cpu_possible_map/for_each_possible_cpu() to iterate.
cpu_possible_mask/for_each_possible_cpu() to iterate.

Never use anything other than cpumask_t to represent bitmap of CPUs.

#include <linux/cpumask.h>

for_each_possible_cpu - Iterate over cpu_possible_map
for_each_online_cpu - Iterate over cpu_online_map
for_each_present_cpu - Iterate over cpu_present_map
for_each_possible_cpu - Iterate over cpu_possible_mask
for_each_online_cpu - Iterate over cpu_online_mask
for_each_present_cpu - Iterate over cpu_present_mask
for_each_cpu_mask(x,mask) - Iterate over some random collection of cpu mask.

#include <linux/cpu.h>
get_online_cpus() and put_online_cpus():

The above calls are used to inhibit cpu hotplug operations. While the
cpu_hotplug.refcount is non zero, the cpu_online_map will not change.
cpu_hotplug.refcount is non zero, the cpu_online_mask will not change.
If you merely need to avoid cpus going away, you could also use
preempt_disable() and preempt_enable() for those sections.
Just remember the critical section cannot call any
Expand Down
2 changes: 1 addition & 1 deletion arch/alpha/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ setup_smp(void)
smp_num_probed = 1;
}

printk(KERN_INFO "SMP: %d CPUs probed -- cpu_present_map = %lx\n",
printk(KERN_INFO "SMP: %d CPUs probed -- cpu_present_mask = %lx\n",
smp_num_probed, cpumask_bits(cpu_present_mask)[0]);
}

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ int __kprobes __arch_disarm_kprobe(void *p)

void __kprobes arch_disarm_kprobe(struct kprobe *p)
{
stop_machine(__arch_disarm_kprobe, p, &cpu_online_map);
stop_machine(__arch_disarm_kprobe, p, cpu_online_mask);
}

void __kprobes arch_remove_kprobe(struct kprobe *p)
Expand Down
7 changes: 4 additions & 3 deletions arch/arm/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
* re-initialize the map in platform_smp_prepare_cpus() if
* present != possible (e.g. physical hotplug).
*/
init_cpu_present(&cpu_possible_map);
init_cpu_present(cpu_possible_mask);

/*
* Initialise the SCU if there are more than one CPU
Expand Down Expand Up @@ -581,8 +581,9 @@ void smp_send_stop(void)
unsigned long timeout;

if (num_online_cpus() > 1) {
cpumask_t mask = cpu_online_map;
cpu_clear(smp_processor_id(), mask);
struct cpumask mask;
cpumask_copy(&mask, cpu_online_mask);
cpumask_clear_cpu(smp_processor_id(), &mask);

smp_cross_call(&mask, IPI_CPU_STOP);
}
Expand Down
8 changes: 4 additions & 4 deletions arch/hexagon/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define BASE_IPI_IRQ 26

/*
* cpu_possible_map needs to be filled out prior to setup_per_cpu_areas
* cpu_possible_mask needs to be filled out prior to setup_per_cpu_areas
* (which is prior to any of our smp_prepare_cpu crap), in order to set
* up the... per_cpu areas.
*/
Expand Down Expand Up @@ -208,7 +208,7 @@ int __cpuinit __cpu_up(unsigned int cpu)
stack_start = ((void *) thread) + THREAD_SIZE;
__vmstart(start_secondary, stack_start);

while (!cpu_isset(cpu, cpu_online_map))
while (!cpu_online(cpu))
barrier();

return 0;
Expand All @@ -229,7 +229,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)

/* Right now, let's just fake it. */
for (i = 0; i < max_cpus; i++)
cpu_set(i, cpu_present_map);
set_cpu_present(i, true);

/* Also need to register the interrupts for IPI */
if (max_cpus > 1)
Expand Down Expand Up @@ -269,5 +269,5 @@ void smp_start_cpus(void)
int i;

for (i = 0; i < NR_CPUS; i++)
cpu_set(i, cpu_possible_map);
set_cpu_possible(i, true);
}
2 changes: 1 addition & 1 deletion arch/ia64/kernel/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ static __init int setup_additional_cpus(char *s)
early_param("additional_cpus", setup_additional_cpus);

/*
* cpu_possible_map should be static, it cannot change as CPUs
* cpu_possible_mask should be static, it cannot change as CPUs
* are onlined, or offlined. The reason is per-cpu data-structures
* are allocated by some modules at init time, and dont expect to
* do this dynamically on cpu arrival/departure.
Expand Down
4 changes: 2 additions & 2 deletions arch/mips/cavium-octeon/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static inline void octeon_send_ipi_mask(const struct cpumask *mask,
}

/**
* Detect available CPUs, populate cpu_possible_map
* Detect available CPUs, populate cpu_possible_mask
*/
static void octeon_smp_hotplug_setup(void)
{
Expand Down Expand Up @@ -268,7 +268,7 @@ static int octeon_cpu_disable(void)

spin_lock(&smp_reserve_lock);

cpu_clear(cpu, cpu_online_map);
set_cpu_online(cpu, false);
cpu_clear(cpu, cpu_callin_map);
local_irq_disable();
fixup_irqs();
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/kernel/mips-mt-fpaff.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ asmlinkage long mipsmt_sys_sched_getaffinity(pid_t pid, unsigned int len,
if (retval)
goto out_unlock;

cpus_and(mask, p->thread.user_cpus_allowed, cpu_possible_map);
cpumask_and(&mask, &p->thread.user_cpus_allowed, cpu_possible_mask);

out_unlock:
read_unlock(&tasklist_lock);
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/kernel/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
int i;

#ifdef CONFIG_SMP
if (!cpu_isset(n, cpu_online_map))
if (!cpu_online(n))
return 0;
#endif

Expand Down
2 changes: 1 addition & 1 deletion arch/mips/kernel/smp-bmips.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ static int bmips_cpu_disable(void)

pr_info("SMP: CPU%d is offline\n", cpu);

cpu_clear(cpu, cpu_online_map);
set_cpu_online(cpu, false);
cpu_clear(cpu, cpu_callin_map);

local_flush_tlb_all();
Expand Down
27 changes: 12 additions & 15 deletions arch/mips/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ static void stop_this_cpu(void *dummy)
/*
* Remove this CPU:
*/
cpu_clear(smp_processor_id(), cpu_online_map);
set_cpu_online(smp_processor_id(), false);
for (;;) {
if (cpu_wait)
(*cpu_wait)(); /* Wait if available. */
Expand All @@ -174,7 +174,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
mp_ops->prepare_cpus(max_cpus);
set_cpu_sibling_map(0);
#ifndef CONFIG_HOTPLUG_CPU
init_cpu_present(&cpu_possible_map);
init_cpu_present(cpu_possible_mask);
#endif
}

Expand Down Expand Up @@ -248,7 +248,7 @@ int __cpuinit __cpu_up(unsigned int cpu)
while (!cpu_isset(cpu, cpu_callin_map))
udelay(100);

cpu_set(cpu, cpu_online_map);
set_cpu_online(cpu, true);

return 0;
}
Expand Down Expand Up @@ -320,13 +320,12 @@ void flush_tlb_mm(struct mm_struct *mm)
if ((atomic_read(&mm->mm_users) != 1) || (current->mm != mm)) {
smp_on_other_tlbs(flush_tlb_mm_ipi, mm);
} else {
cpumask_t mask = cpu_online_map;
unsigned int cpu;

cpu_clear(smp_processor_id(), mask);
for_each_cpu_mask(cpu, mask)
if (cpu_context(cpu, mm))
for_each_online_cpu(cpu) {
if (cpu != smp_processor_id() && cpu_context(cpu, mm))
cpu_context(cpu, mm) = 0;
}
}
local_flush_tlb_mm(mm);

Expand Down Expand Up @@ -360,13 +359,12 @@ void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned l

smp_on_other_tlbs(flush_tlb_range_ipi, &fd);
} else {
cpumask_t mask = cpu_online_map;
unsigned int cpu;

cpu_clear(smp_processor_id(), mask);
for_each_cpu_mask(cpu, mask)
if (cpu_context(cpu, mm))
for_each_online_cpu(cpu) {
if (cpu != smp_processor_id() && cpu_context(cpu, mm))
cpu_context(cpu, mm) = 0;
}
}
local_flush_tlb_range(vma, start, end);
preempt_enable();
Expand Down Expand Up @@ -407,13 +405,12 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long page)

smp_on_other_tlbs(flush_tlb_page_ipi, &fd);
} else {
cpumask_t mask = cpu_online_map;
unsigned int cpu;

cpu_clear(smp_processor_id(), mask);
for_each_cpu_mask(cpu, mask)
if (cpu_context(cpu, vma->vm_mm))
for_each_online_cpu(cpu) {
if (cpu != smp_processor_id() && cpu_context(cpu, vma->vm_mm))
cpu_context(cpu, vma->vm_mm) = 0;
}
}
local_flush_tlb_page(vma, page);
preempt_enable();
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/kernel/smtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ static void smtc_configure_tlb(void)
* possibly leave some TCs/VPEs as "slave" processors.
*
* Use c0_MVPConf0 to find out how many TCs are available, setting up
* cpu_possible_map and the logical/physical mappings.
* cpu_possible_mask and the logical/physical mappings.
*/

int __init smtc_build_cpu_map(int start_cpu_slot)
Expand Down
6 changes: 3 additions & 3 deletions arch/mips/mm/c-octeon.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ static void octeon_flush_icache_all_cores(struct vm_area_struct *vma)
if (vma)
mask = *mm_cpumask(vma->vm_mm);
else
mask = cpu_online_map;
cpu_clear(cpu, mask);
for_each_cpu_mask(cpu, mask)
mask = *cpu_online_mask;
cpumask_clear_cpu(cpu, &mask);
for_each_cpu(cpu, &mask)
octeon_send_ipi_single(cpu, SMP_ICACHE_FLUSH);

preempt_enable();
Expand Down
6 changes: 3 additions & 3 deletions arch/mips/netlogic/common/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void __init nlm_smp_setup(void)
cpu_set(boot_cpu, phys_cpu_present_map);
__cpu_number_map[boot_cpu] = 0;
__cpu_logical_map[0] = boot_cpu;
cpu_set(0, cpu_possible_map);
set_cpu_possible(0, true);

num_cpus = 1;
for (i = 0; i < NR_CPUS; i++) {
Expand All @@ -177,14 +177,14 @@ void __init nlm_smp_setup(void)
cpu_set(i, phys_cpu_present_map);
__cpu_number_map[i] = num_cpus;
__cpu_logical_map[num_cpus] = i;
cpu_set(num_cpus, cpu_possible_map);
set_cpu_possible(num_cpus, true);
++num_cpus;
}
}

pr_info("Phys CPU present map: %lx, possible map %lx\n",
(unsigned long)phys_cpu_present_map.bits[0],
(unsigned long)cpu_possible_map.bits[0]);
(unsigned long)cpumask_bits(cpu_possible_mask)[0]);

pr_info("Detected %i Slave CPU(s)\n", num_cpus);
nlm_set_nmi_handler(nlm_boot_secondary_cpus);
Expand Down
8 changes: 4 additions & 4 deletions arch/mips/pmc-sierra/yosemite/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static void __cpuinit yos_boot_secondary(int cpu, struct task_struct *idle)
}

/*
* Detect available CPUs, populate cpu_possible_map before smp_init
* Detect available CPUs, populate cpu_possible_mask before smp_init
*
* We don't want to start the secondary CPU yet nor do we have a nice probing
* feature in PMON so we just assume presence of the secondary core.
Expand All @@ -155,10 +155,10 @@ static void __init yos_smp_setup(void)
{
int i;

cpus_clear(cpu_possible_map);
init_cpu_possible(cpu_none_mask);

for (i = 0; i < 2; i++) {
cpu_set(i, cpu_possible_map);
set_cpu_possible(i, true);
__cpu_number_map[i] = i;
__cpu_logical_map[i] = i;
}
Expand All @@ -169,7 +169,7 @@ static void __init yos_prepare_cpus(unsigned int max_cpus)
/*
* Be paranoid. Enable the IPI only if we're really about to go SMP.
*/
if (cpus_weight(cpu_possible_map))
if (num_possible_cpus())
set_c0_status(STATUSF_IP5);
}

Expand Down
2 changes: 1 addition & 1 deletion arch/mips/sgi-ip27/ip27-smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static int do_cpumask(cnodeid_t cnode, nasid_t nasid, int highest)
/* Only let it join in if it's marked enabled */
if ((acpu->cpu_info.flags & KLINFO_ENABLE) &&
(tot_cpus_found != NR_CPUS)) {
cpu_set(cpuid, cpu_possible_map);
set_cpu_possible(cpuid, true);
alloc_cpupda(cpuid, tot_cpus_found);
cpus_found++;
tot_cpus_found++;
Expand Down
Loading

0 comments on commit deb74f5

Please sign in to comment.