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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux