Thread (7 messages) 7 messages, 2 authors, 2013-01-25

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

From: Wanlong Gao <hidden>
Date: 2013-01-25 09:16:28
Also in: lkml

quoted
quoted
quoted
 
-	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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help