Re: [PATCH V7 1/3] virtio-net: fix the set affinity bug when CPUIDs are not consecutive

From: Wanlong Gao
Date: Fri Jan 25 2013 - 04:16:14 EST



>>>>
>>>> - for (i = 0; i < vi->max_queue_pairs; i++) {
>>>> - int cpu = set ? i : -1;
>>>> - virtqueue_set_affinity(vi->rq[i].vq, cpu);
>>>> - virtqueue_set_affinity(vi->sq[i].vq, cpu);
>>>> - }
>>>> + if (set) {
>>>> + i = 0;
>>>> + for_each_online_cpu(cpu) {
>>>> + virtqueue_set_affinity(vi->rq[i].vq, cpu);
>>>> + virtqueue_set_affinity(vi->sq[i].vq, cpu);
>>>> + *per_cpu_ptr(vi->vq_index, cpu) = i;
>>>> + i++;
>>>> + }
>>>>
>>>> - if (set)
>>>> vi->affinity_hint_set = true;
>>>> - else
>>>> + } else {
>>>> + for(i = 0; i < vi->max_queue_pairs; i++) {
>>>> + virtqueue_set_affinity(vi->rq[i].vq, -1);
>>>> + virtqueue_set_affinity(vi->sq[i].vq, -1);
>>>> + }
>>>> +
>>>> + i = 0;
>>>> + for_each_online_cpu(cpu)
>>>> + *per_cpu_ptr(vi->vq_index, cpu) =
>>>> + ++i % vi->curr_queue_pairs;
>>>> +
>>>> vi->affinity_hint_set = false;
>>>> + }
>>>> }
>>> Sorry, looks like the issue of v6 still exists, we need set per-cpu
>>> index unconditionally here (and also in 2/3), the cpus != queues check
>>> may bypass this setting.
>> This fixed in 2/3, when cpus != queues, it will go into virtnet_clean_affinity(in 2/3),
>> then vq index is set in virtnet_clean_affinity. Am I missing something?
>
> Ah, so 2/3 looks fine. I suggest to fix this in 1/3 since it's not good
> to introduce a bug in patch 1 and fix it in patch 2, and this can also
> confuse the bisect.
>

Make sense, will move the fix from 2/3 to 1/3.

Thanks,
Wanlong Gao

--
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/