Add a cpu notifier to virtio-net, so that we can reset the
virtqueue affinity if the cpu hotplug happens. It improve
the performance through enabling or disabling the virtqueue
affinity after doing cpu hotplug.
Cc: Rusty Russell <redacted>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <redacted>
Cc: virtualization@lists.linux-foundation.org
Cc: netdev@vger.kernel.org
Signed-off-by: Wanlong Gao <redacted>
---
drivers/net/virtio_net.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
From: Jason Wang <hidden> Date: 2012-12-26 10:06:46
On 12/26/2012 03:06 PM, Wanlong Gao wrote:
Add a cpu notifier to virtio-net, so that we can reset the
virtqueue affinity if the cpu hotplug happens. It improve
the performance through enabling or disabling the virtqueue
affinity after doing cpu hotplug.
Hi Wanlong:
Thanks for looking at this.
quoted hunk
Cc: Rusty Russell <redacted>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <redacted>
Cc: virtualization@lists.linux-foundation.org
Cc: netdev@vger.kernel.org
Signed-off-by: Wanlong Gao <redacted>
---
drivers/net/virtio_net.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
Add a cpu notifier to virtio-net, so that we can reset the
virtqueue affinity if the cpu hotplug happens. It improve
the performance through enabling or disabling the virtqueue
affinity after doing cpu hotplug.
Hi Wanlong:
Thanks for looking at this.
quoted
Cc: Rusty Russell <redacted>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <redacted>
Cc: virtualization@lists.linux-foundation.org
Cc: netdev@vger.kernel.org
Signed-off-by: Wanlong Gao <redacted>
---
drivers/net/virtio_net.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
From: "Michael S. Tsirkin" <mst@redhat.com> Date: 2012-12-26 10:43:35
On Wed, Dec 26, 2012 at 03:06:54PM +0800, Wanlong Gao wrote:
Add a cpu notifier to virtio-net, so that we can reset the
virtqueue affinity if the cpu hotplug happens. It improve
the performance through enabling or disabling the virtqueue
affinity after doing cpu hotplug.
Cc: Rusty Russell <redacted>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <redacted>
Cc: virtualization@lists.linux-foundation.org
Cc: netdev@vger.kernel.org
Signed-off-by: Wanlong Gao <redacted>
Thanks for looking into this.
Some comments:
1. Looks like the logic in
virtnet_set_affinity (and in virtnet_select_queue)
will not work very well when CPU IDs are not
consequitive. This can happen with hot unplug.
Maybe we should add a VQ allocator, and defining
a per-cpu variable specifying the VQ instead
of using CPU ID.
2. The below code seems racy e.g. when CPU is added
during device init.
3. using a global cpu_hotplug seems inelegant.
In any case we should document what is the
meaning of this variable.
From: Eric Dumazet <hidden> Date: 2012-12-26 15:51:20
On Wed, 2012-12-26 at 15:06 +0800, Wanlong Gao wrote:
quoted hunk
Add a cpu notifier to virtio-net, so that we can reset the
virtqueue affinity if the cpu hotplug happens. It improve
the performance through enabling or disabling the virtqueue
affinity after doing cpu hotplug.
Cc: Rusty Russell <redacted>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <redacted>
Cc: virtualization@lists.linux-foundation.org
Cc: netdev@vger.kernel.org
Signed-off-by: Wanlong Gao <redacted>
---
drivers/net/virtio_net.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
@@ -1372,6 +1404,11 @@ static int init_vqs(struct virtnet_info *vi)gotoerr_free;virtnet_set_affinity(vi,true);++ret=register_hotcpu_notifier(&virtnet_cpu_notifier);+if(ret)+gotoerr_free;+return0;err_free:
It looks like this patch assumes virtio_net supports a single instance.
Try your patch with two instances, I am pretty sure it wont do very
well.
It seems to me you need something else than a single boolean.
A sequence number for example should be better...
From: Jason Wang <hidden> Date: 2012-12-27 03:29:15
On 12/26/2012 06:19 PM, Wanlong Gao wrote:
On 12/26/2012 06:06 PM, Jason Wang wrote:
quoted
On 12/26/2012 03:06 PM, Wanlong Gao wrote:
quoted
Add a cpu notifier to virtio-net, so that we can reset the
virtqueue affinity if the cpu hotplug happens. It improve
the performance through enabling or disabling the virtqueue
affinity after doing cpu hotplug.
Hi Wanlong:
Thanks for looking at this.
quoted
Cc: Rusty Russell <redacted>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <redacted>
Cc: virtualization@lists.linux-foundation.org
Cc: netdev@vger.kernel.org
Signed-off-by: Wanlong Gao <redacted>
---
drivers/net/virtio_net.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
@@ -1131,7 +1154,14 @@ static int virtnet_change_mtu(struct net_device *dev, int new_mtu)*/staticu16virtnet_select_queue(structnet_device*dev,structsk_buff*skb){-inttxq=skb_rx_queue_recorded(skb)?skb_get_rx_queue(skb):+inttxq;++if(unlikely(cpu_hotplug==true)){+virtnet_set_affinity(netdev_priv(dev),true);+cpu_hotplug=false;+}+
Why don't you just do this in callback?
Callback can just give us a "hcpu", can't get the virtnet_info from callback. Am I missing something?
Well, I think you can just embed the notifier block into virtnet_info,
then use something like container_of in the callback to make the
notifier per device. This also solve the concern of Eric.
From: Jason Wang <hidden> Date: 2012-12-27 03:34:28
On 12/26/2012 06:46 PM, Michael S. Tsirkin wrote:
On Wed, Dec 26, 2012 at 03:06:54PM +0800, Wanlong Gao wrote:
quoted
Add a cpu notifier to virtio-net, so that we can reset the
virtqueue affinity if the cpu hotplug happens. It improve
the performance through enabling or disabling the virtqueue
affinity after doing cpu hotplug.
Cc: Rusty Russell <redacted>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <redacted>
Cc: virtualization@lists.linux-foundation.org
Cc: netdev@vger.kernel.org
Signed-off-by: Wanlong Gao <redacted>
Thanks for looking into this.
Some comments:
1. Looks like the logic in
virtnet_set_affinity (and in virtnet_select_queue)
will not work very well when CPU IDs are not
consequitive. This can happen with hot unplug.
Maybe we should add a VQ allocator, and defining
a per-cpu variable specifying the VQ instead
of using CPU ID.
Yes, and generate the affinity hint based on the mapping. Btw, what does
VQ allocator means here?
2. The below code seems racy e.g. when CPU is added
during device init.
3. using a global cpu_hotplug seems inelegant.
In any case we should document what is the
meaning of this variable.
Add a cpu notifier to virtio-net, so that we can reset the
virtqueue affinity if the cpu hotplug happens. It improve
the performance through enabling or disabling the virtqueue
affinity after doing cpu hotplug.
Hi Wanlong:
Thanks for looking at this.
quoted
Cc: Rusty Russell <redacted>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <redacted>
Cc: virtualization@lists.linux-foundation.org
Cc: netdev@vger.kernel.org
Signed-off-by: Wanlong Gao <redacted>
---
drivers/net/virtio_net.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
@@ -1131,7 +1154,14 @@ static int virtnet_change_mtu(struct net_device *dev, int new_mtu)*/staticu16virtnet_select_queue(structnet_device*dev,structsk_buff*skb){-inttxq=skb_rx_queue_recorded(skb)?skb_get_rx_queue(skb):+inttxq;++if(unlikely(cpu_hotplug==true)){+virtnet_set_affinity(netdev_priv(dev),true);+cpu_hotplug=false;+}+
Why don't you just do this in callback?
Callback can just give us a "hcpu", can't get the virtnet_info from callback. Am I missing something?
Well, I think you can just embed the notifier block into virtnet_info,
then use something like container_of in the callback to make the
notifier per device. This also solve the concern of Eric.
Yeah, thank you very much for your suggestion. I'll try it.
Not sure, I just try latest qemu, it even does not have a cpu_set command.
Adding Igor to CC,
As I know, hotplug support is cleaned from qemu, and Igor want to rework it but not been completed?
I'm not sure about that, Igor, could you send out your tech-preview-patches?
Thanks,
Wanlong Gao
From: "Michael S. Tsirkin" <mst@redhat.com> Date: 2012-12-27 11:49:08
On Thu, Dec 27, 2012 at 11:34:16AM +0800, Jason Wang wrote:
On 12/26/2012 06:46 PM, Michael S. Tsirkin wrote:
quoted
On Wed, Dec 26, 2012 at 03:06:54PM +0800, Wanlong Gao wrote:
quoted
Add a cpu notifier to virtio-net, so that we can reset the
virtqueue affinity if the cpu hotplug happens. It improve
the performance through enabling or disabling the virtqueue
affinity after doing cpu hotplug.
Cc: Rusty Russell <redacted>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <redacted>
Cc: virtualization@lists.linux-foundation.org
Cc: netdev@vger.kernel.org
Signed-off-by: Wanlong Gao <redacted>
Thanks for looking into this.
Some comments:
1. Looks like the logic in
virtnet_set_affinity (and in virtnet_select_queue)
will not work very well when CPU IDs are not
consequitive. This can happen with hot unplug.
Maybe we should add a VQ allocator, and defining
a per-cpu variable specifying the VQ instead
of using CPU ID.
Yes, and generate the affinity hint based on the mapping. Btw, what does
VQ allocator means here?
Some logic to generate CPU to VQ mapping.
quoted
2. The below code seems racy e.g. when CPU is added
during device init.
3. using a global cpu_hotplug seems inelegant.
In any case we should document what is the
meaning of this variable.
From: Igor Mammedov <hidden> Date: 2014-04-07 06:06:55
On Thu, 27 Dec 2012 11:43:30 +0800
Wanlong Gao [off-list ref] wrote:
On 12/27/2012 11:28 AM, Jason Wang wrote:
quoted
On 12/26/2012 06:19 PM, Wanlong Gao wrote:
quoted
On 12/26/2012 06:06 PM, Jason Wang wrote:
quoted
On 12/26/2012 03:06 PM, Wanlong Gao wrote:
quoted
Add a cpu notifier to virtio-net, so that we can reset the
virtqueue affinity if the cpu hotplug happens. It improve
the performance through enabling or disabling the virtqueue
affinity after doing cpu hotplug.
Hi Wanlong:
Thanks for looking at this.
quoted
Cc: Rusty Russell <redacted>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <redacted>
Cc: virtualization@lists.linux-foundation.org
Cc: netdev@vger.kernel.org
Signed-off-by: Wanlong Gao <redacted>
---
drivers/net/virtio_net.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
@@ -1131,7 +1154,14 @@ static int virtnet_change_mtu(struct net_device *dev, int new_mtu)*/staticu16virtnet_select_queue(structnet_device*dev,structsk_buff*skb){-inttxq=skb_rx_queue_recorded(skb)?skb_get_rx_queue(skb):+inttxq;++if(unlikely(cpu_hotplug==true)){+virtnet_set_affinity(netdev_priv(dev),true);+cpu_hotplug=false;+}+
Why don't you just do this in callback?
Callback can just give us a "hcpu", can't get the virtnet_info from callback. Am I missing something?
Well, I think you can just embed the notifier block into virtnet_info,
then use something like container_of in the callback to make the
notifier per device. This also solve the concern of Eric.
Yeah, thank you very much for your suggestion. I'll try it.
Not sure, I just try latest qemu, it even does not have a cpu_set command.
Adding Igor to CC,
As I know, hotplug support is cleaned from qemu, and Igor want to rework it but not been completed?
I'm not sure about that, Igor, could you send out your tech-preview-patches?
CPU hot-add is supported by upstream now, hot-remove is not supported yet,
besides of qemu work it would require quite a work on kvm side as well.