Re: [PATCH 11/11] perf/x86/intel: Perform rotation on Intel CQM RMIDs
From: Peter Zijlstra
Date: Wed Oct 08 2014 - 14:08:24 EST
On Wed, Sep 24, 2014 at 03:04:15PM +0100, Matt Fleming wrote:
> + preempt_disable();
> + list_for_each_entry(entry, &cqm_rmid_limbo_lru, list) {
> + for_each_cpu(cpu, &cqm_cpumask) {
> + unsigned long *map;
> +
> + map = &limbo_bitmap[cpu * BITS_TO_LONGS(nr_bits)];
> + set_bit(entry->rmid, map);
> + }
> + }
> +
> + /*
> + * Test whether an RMID is free for each package.
> + */
> + smp_call_function_many(&cqm_cpumask, intel_cqm_stable, &info, true);
> +
> + /*
> + * Convert all cpu bitmaps into a single bitmap by ANDing all of
> + * them together. If we've still got any bits set that indicates
> + * an RMID is now unused on all cpus.
> + */
> + bitmap_fill(free_bitmap, nr_bits);
> + for_each_cpu(cpu, &cqm_cpumask) {
> + unsigned long *map;
> +
> + map = &limbo_bitmap[cpu * BITS_TO_LONGS(nr_bits)];
> + bitmap_and(free_bitmap, free_bitmap, map, nr_bits);
> + }
> +
> + if (!bitmap_empty(free_bitmap, nr_bits)) {
> + int i = -1;
> +
> + for (; i = find_next_bit(free_bitmap, nr_bits, i+1),
> + i < nr_bits;) {
> + entry = __rmid_entry(i);
> +
> + list_del(&entry->list); /* remove from limbo */
> +
> + /*
> + * The rotation RMID gets priority if it's
> + * currently invalid. In which case, skip adding
> + * the RMID to the the free lru.
> + */
> + if (!__rmid_valid(intel_cqm_rotation_rmid)) {
> + intel_cqm_rotation_rmid = i;
> + continue;
> + }
> +
> + /*
> + * If we have groups waiting for RMIDs, hand
> + * them one now.
> + */
> + raw_spin_lock_irq(&cache_lock);
> + list_for_each_entry(event, &cache_groups,
> + hw.cqm_groups_entry) {
> + if (__rmid_valid(event->hw.cqm_rmid))
> + continue;
> +
> + intel_cqm_xchg_rmid(event, i);
> + entry = NULL;
> + break;
> + }
> + raw_spin_unlock_irq(&cache_lock);
> +
> + if (!entry)
> + continue;
> +
> + /*
> + * Otherwise place it onto the free list.
> + */
> + list_add_tail(&entry->list, &cqm_rmid_free_lru);
> + }
> + }
> +
> + preempt_enable();
Why is all that under preempt_disable()?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/