Skip to contentSkip to conversation

blk_mq_update_queue_map makes an (invalid?) assumption about cpu ordering

DISCUSSION Jeff Moyer 2 participants 3 messages Oct 15, 2013

lore
Share & tools
lore

Jeff Moyer

author
#0 lore raw

Hi, Jens,

blk_mq_update_queue_map does this:

        for_each_possible_cpu(i) {
                if (!cpu_online(i)) {
                        map[i] = 0;
                        continue;
                }

...

                first_sibling = get_first_sibling(i);
                if (first_sibling == i) {
                        map[i] = cpu_to_queue_index(nr_uniq_cpus, nr_queues,
                                                        queue);
                        queue++;
                } else
                        map[i] = map[first_sibling];

This assumes that the first_sibling is listed before any other siblings, which I don't believe is true. I don't think you get any guaranteed ordering in that cpu_possible_mask.

... or did I miss something?

Cheers,
Jeff

#1 lore raw
Quoted 19 lines · Jeff Moyer

Hi, Jens,

blk_mq_update_queue_map does this:

        for_each_possible_cpu(i) {
                if (!cpu_online(i)) {
                        map[i] = 0;
                        continue;
                }

...

                first_sibling = get_first_sibling(i);
                if (first_sibling == i) {
                        map[i] = cpu_to_queue_index(nr_uniq_cpus, nr_queues,
                                                        queue);
                        queue++;
                } else
                        map[i] = map[first_sibling];
Quoted 5 lines

This assumes that the first_sibling is listed before any other siblings, which I don't believe is true. I don't think you get any guaranteed ordering in that cpu_possible_mask.

... or did I miss something?

That's correct, it's assuming the first sibling is the lowest numbered one. Are there cases where that would not be correct? I was sort of assuming that was what "first" meant here.

Signature · 1 line
Jens Axboe
author
#2 lore raw
Quoted 9 lines · Jens Axboe
Quoted 5 lines

This assumes that the first_sibling is listed before any other siblings, which I don't believe is true. I don't think you get any guaranteed ordering in that cpu_possible_mask.

... or did I miss something?

That's correct, it's assuming the first sibling is the lowest numbered one. Are there cases where that would not be correct? I was sort of assuming that was what "first" meant here.

Yeah, you're right. I hadn't read down the call chain:

static int get_first_sibling(unsigned int cpu)

        ret = cpumask_first(topology_thread_cpumask(cpu));

Nothing to see here, move along...

-Jeff