Exemplo n.º 1
0
static int amd_pmu_cpu_prepare(int cpu)
{
    struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);

    WARN_ON_ONCE(cpuc->amd_nb);

    if (boot_cpu_data.x86_max_cores < 2)
        return NOTIFY_OK;

    cpuc->amd_nb = amd_alloc_nb(cpu, -1);
    if (!cpuc->amd_nb)
        return NOTIFY_BAD;

    return NOTIFY_OK;
}
Exemplo n.º 2
0
static void amd_pmu_cpu_online(int cpu)
{
	struct cpu_hw_events *cpu1, *cpu2;
	struct amd_nb *nb = NULL;
	int i, nb_id;

	if (boot_cpu_data.x86_max_cores < 2)
		return;

	/*
	 * function may be called too early in the
	 * boot process, in which case nb_id is bogus
	 */
	nb_id = amd_get_nb_id(cpu);
	if (nb_id == BAD_APICID)
		return;

	cpu1 = &per_cpu(cpu_hw_events, cpu);
	cpu1->amd_nb = NULL;

	raw_spin_lock(&amd_nb_lock);

	for_each_online_cpu(i) {
		cpu2 = &per_cpu(cpu_hw_events, i);
		nb = cpu2->amd_nb;
		if (!nb)
			continue;
		if (nb->nb_id == nb_id)
			goto found;
	}

	nb = amd_alloc_nb(cpu, nb_id);
	if (!nb) {
		pr_err("perf_events: failed NB allocation for CPU%d\n", cpu);
		raw_spin_unlock(&amd_nb_lock);
		return;
	}
found:
	nb->refcnt++;
	cpu1->amd_nb = nb;

	raw_spin_unlock(&amd_nb_lock);
}