Skip to contentSkip to conversation

virtio support for container

RFC Pavel Fedin 2 participants 12 messages Dec 30, 2015 – Jan 6, 2016

lore
Share & tools
lore
#0 lore raw

Hello everybody!

I am currently working on improved version of this patchset, and i am testing it with openvswitch. I run two openvswitch instances:
on host and in container. Both ovs instances forward packets between its LOCAL port and vhost/virtio port. This way i can comfortably run PING between my host and container.
The problem is that the patchset seems to be broken somehow. ovs-vswitchd fails to open dpdk0 device, and if i set --log-level=9
for DPDK, i see this in the console:
--- cut ---
Broadcast message from [email protected] (Wed 2015-12-30 11:13:00 MSK):

ovs-vswitchd[557]: EAL: TSC frequency is ~3400032 KHz

Broadcast message from [email protected] (Wed 2015-12-30 11:13:00 MSK):

ovs-vswitchd[560]: EAL: memzone_reserve_aligned_thread_unsafe(): memzone <RG_MP_ovs_mp_1500_0_262144> already exists

Broadcast message from [email protected] (Wed 2015-12-30 11:13:00 MSK):

ovs-vswitchd[560]: RING: Cannot reserve memory
--- cut ---

How can i debug this?

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia

#1 lore raw

Hi Fedin,

First of all, when you say openvswitch, are you referring to ovs-dpdk?

And can you detail your test case? Like, how do you want ovs_on_host and ovs_in_container to be connected? Through two-direct-connected physical NICs, or one vhost port in ovs_on_host and one virtio port in ovs_in_container?

Thanks,
Jianfeng

Quoted 44 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Pavel Fedin
Sent: Wednesday, December 30, 2015 5:47 PM
To: [email protected]
Subject: Re: [dpdk-dev] [RFC 0/5] virtio support for container

Hello everybody!

I am currently working on improved version of this patchset, and i am testing
it with openvswitch. I run two openvswitch instances:
on host and in container. Both ovs instances forward packets between its LOCAL port and vhost/virtio port. This way i can
comfortably run PING between my host and container.
The problem is that the patchset seems to be broken somehow. ovs-
vswitchd fails to open dpdk0 device, and if i set --log-level=9 for DPDK, i see this in the console:
--- cut ---
Broadcast message from [email protected] (Wed

2015-12-30 11:13:00 MSK):

ovs-vswitchd[557]: EAL: TSC frequency is ~3400032 KHz

Broadcast message from [email protected] (Wed

2015-12-30 11:13:00 MSK):

ovs-vswitchd[560]: EAL: memzone_reserve_aligned_thread_unsafe():
memzone <RG_MP_ovs_mp_1500_0_262144> already exists

Broadcast message from [email protected] (Wed

2015-12-30 11:13:00 MSK):

ovs-vswitchd[560]: RING: Cannot reserve memory
--- cut ---

How can i debug this?

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia

#2 lore raw

Hello!

Quoted 1 line

First of all, when you say openvswitch, are you referring to ovs-dpdk?

I am referring to mainline ovs, compiled with dpdk, and using userspace dataplane. AFAIK ovs-dpdk is early Intel fork, which is abandoned at the moment.

Quoted 4 lines

And can you detail your test case? Like, how do you want ovs_on_host and ovs_in_container to be connected?
Through two-direct-connected physical NICs, or one vhost port in ovs_on_host and one virtio port in ovs_in_container?

vhost port. i. e.

                             |
LOCAL------dpdkvhostuser<----+---->cvio----->LOCAL
      ovs                    |          ovs
                             |
                host         |        container

By this time i advanced in my research. ovs not only crashes by itself, but manages to crash host side. It does this by doing
reconfiguration sequence without sending VHOST_USER_SET_MEM_TABLE, therefore host-side ovs tries to refer old addresses and dies badly.
Those messages about memory pool already being present are perhaps OK.

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia

#3 lore raw
Quoted 31 lines

-----Original Message-----
From: Pavel Fedin [mailto:[email protected]]
Sent: Thursday, December 31, 2015 5:40 PM
To: Tan, Jianfeng; [email protected]
Subject: RE: [dpdk-dev] [RFC 0/5] virtio support for container

Hello!

Quoted 1 line

First of all, when you say openvswitch, are you referring to ovs-dpdk?

I am referring to mainline ovs, compiled with dpdk, and using userspace
dataplane.
AFAIK ovs-dpdk is early Intel fork, which is abandoned at the moment.

Quoted 1 line

And can you detail your test case? Like, how do you want ovs_on_host and

ovs_in_container to

Quoted 2 lines

be connected?
Through two-direct-connected physical NICs, or one vhost port in

ovs_on_host and one virtio

Quoted 1 line

port in ovs_in_container?

vhost port. i. e.

                             |
LOCAL------dpdkvhostuser<----+---->cvio----->LOCAL
      ovs                    |          ovs
                             |
                host         |        container
Quoted 5 lines

By this time i advanced in my research. ovs not only crashes by itself, but
manages to crash host side. It does this by doing reconfiguration sequence without sending VHOST_USER_SET_MEM_TABLE, therefore host-side ovs tries to refer old addresses and dies badly.

Yes, this case is exactly suited for this patchset.

Before you start another ovs_in_container, previous ones get killed? If so, vhost information in ovs_on_host will be wiped as the unix socket is broken.
And by the way, ovs just allows one virtio for one vhost port, much different from the exmpale, vhost-switch.

Thanks,
Jianfeng

Quoted 7 lines

Those messages about memory pool already being present are perhaps OK.

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia

#4 lore raw

Hello!

Quoted 1 line

Before you start another ovs_in_container, previous ones get killed?

Of course. It crashes.

Quoted 1 line

If so, vhost information in ovs_on_host will be wiped as the unix socket is broken.

Yes. And ovs_on_host crashes because:
a) ovs_in_container does not send VHOST_USER_SET_MEM_TABLE (i don't know why yet)
b) set_vring_addr() does not make sure that dev->mem is set.

I am preparing a patch to fix (b).

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia

#5 lore raw

Hi,

Quoted 1 line

a) ovs_in_container does not send VHOST_USER_SET_MEM_TABLE

Please check if rte_eth_dev_start() is called.
(rte_eth_dev_start -> virtio_dev_start -> vtpci_reinit_complete -> kick_all_vq)

Quoted 2 lines

b) set_vring_addr() does not make sure that dev->mem is set. I am preparing a patch to fix (b).

Yes, it seems like a bug, lack of necessary check.

Thanks,
Jianfeng

#6 lore raw

Hello!

Quoted 8 lines
Quoted 1 line

a) ovs_in_container does not send VHOST_USER_SET_MEM_TABLE

Please check if rte_eth_dev_start() is called.
(rte_eth_dev_start -> virtio_dev_start -> vtpci_reinit_complete -> kick_all_vq)

Quoted 2 lines

b) set_vring_addr() does not make sure that dev->mem is set. I am preparing a patch to fix (b).

Yes, it seems like a bug, lack of necessary check.

I've made some progress about (a). It's tricky. This caused by this fragment:

        if (vhost_user_read(vhost->sockfd, &msg, len, fds, fd_num) < 0)
                return 0;

Here you ignore errors. And this particular request for some reason ends up in EBADF. The most magic part is that sometimes it just
works...
Not sure if i can finish it today, and here in Russia we have New Year holidays until 11th.

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia

#7 lore raw

Hello!

Quoted 11 lines

I've made some progress about (a). It's tricky. This caused by this fragment:

        if (vhost_user_read(vhost->sockfd, &msg, len, fds, fd_num) < 0)
                return 0;

Here you ignore errors. And this particular request for some reason ends up
in EBADF. The most magic part is that sometimes it just
works...
Not sure if i can finish it today, and here in Russia we have New Year holidays
until 11th.

Oops, I made a mistake here. I got vhost_user_read() and vhost_user_write() backwards.

+ len = VHOST_USER_HDR_SIZE + msg.size;
+ if (vhost_user_read(hw->sockfd, &msg, len, fds, fd_num) < 0)
+ return 0;
+
+ if (need_reply) {
+ if (vhost_user_write(hw->sockfd, &msg) < 0)
+ return -1;
+
+ if (req != msg.request) {
+ PMD_DRV_LOG(ERR, "Received unexpected msg type."
+ " Expected %d received %d",
+ req, msg.request);
+ return -1;
+ }

Thanks,
Jianfeng

#8 lore raw

Hello!

Quoted 7 lines
Quoted 5 lines

Here you ignore errors. And this particular request for some reason ends up
in EBADF. The most magic part is that sometimes it just
works...
Not sure if i can finish it today, and here in Russia we have New Year holidays
until 11th.

Oops, I made a mistake here. I got vhost_user_read() and vhost_user_write() backwards.

But nevertheless they do the right thing. vhost_user_read() actually writes the message into socket, and vhost_user_write() reads
it. So they should work correctly.
I've just checked, fd number is not corrupted.

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia

#9 lore raw
In reply to Tan, Jianfeng

Hello!

Quoted 3 lines
Quoted 1 line

a) ovs_in_container does not send VHOST_USER_SET_MEM_TABLE

Please check if rte_eth_dev_start() is called.
(rte_eth_dev_start -> virtio_dev_start -> vtpci_reinit_complete -> kick_all_vq)

I've figured out what happened, and it's my fault only :( I have modified your patchset and added --shared-mem option. And forgot
to specify it to gdb :) Without it memory is not shared, and rte_memseg_info_get() returned fd = -1. And if you put it into control message for sendmsg(), you get your -EBADF.
So please ignore this.
But, nevertheless, ovs in container still dies with:
--- cut ---
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fff97fff700 (LWP 3866)]
virtio_recv_mergeable_pkts (rx_queue=0x7fffd46a9a80, rx_pkts=0x7fff97ffe850, nb_pkts=32) at /home/p.fedin/dpdk/drivers/net/virtio/virtio_rxtx.c:683
683 /home/p.fedin/dpdk/drivers/net/virtio/virtio_rxtx.c: No such file or directory.
Missing separate debuginfos, use: dnf debuginfo-install keyutils-libs-1.5.9-7.fc23.x86_64 krb5-libs-1.13.2-11.fc23.x86_64 libcap-ng-0.7.7-2.fc23.x86_64 libcom_err-1.42.13-3.fc23.x86_64 libselinux-2.4-4.fc23.x86_64 openssl-libs-1.0.2d-2.fc23.x86_64 pcre-8.37-4.fc23.x86_64 zlib-1.2.8-9.fc23.x86_64
(gdb) where
#0 virtio_recv_mergeable_pkts (rx_queue=0x7fffd46a9a80, rx_pkts=0x7fff97ffe850, nb_pkts=32) at /home/p.fedin/dpdk/drivers/net/virtio/virtio_rxtx.c:683
#1 0x0000000000669ee8 in rte_eth_rx_burst (nb_pkts=32, rx_pkts=0x7fff97ffe850, queue_id=0, port_id=0 '\000') at /home/p.fedin/dpdk/build/include/rte_ethdev.h:2510
#2 netdev_dpdk_rxq_recv (rxq_=<optimized out>, packets=0x7fff97ffe850, c=0x7fff97ffe84c) at lib/netdev-dpdk.c:1033 #3 0x00000000005e8ca1 in netdev_rxq_recv (rx=<optimized out>, buffers=buffers@entry=0x7fff97ffe850, cnt=cnt@entry=0x7fff97ffe84c) at lib/netdev.c:654
#4 0x00000000005cb338 in dp_netdev_process_rxq_port (pmd=pmd@entry=0x7fffac7f8010, rxq=<optimized out>, port=<optimized out>, port=<optimized out>) at lib/dpif-netdev.c:2510

#5  0x00000000005cc649 in pmd_thread_main (f_=0x7fffac7f8010) at lib/dpif-netdev.c:2671
#6  0x0000000000628424 in ovsthread_wrapper (aux_=<optimized out>) at lib/ovs-thread.c:340
#7  0x00007ffff70f660a in start_thread () from /lib64/libpthread.so.0
#8  0x00007ffff6926bbd in clone () from /lib64/libc.so.6

(gdb)
--- cut ---

and l2fwd does not reproduce this. So, let's wait until 11.01.2016. And happy New Year to everybody who reads it (and who doesn't)
:)

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia

#10 lore raw
In reply to Tan, Jianfeng

Hello!

Last minute note. I have found the problem but have no time to research and fix it.
It happens because ovs first creates the device, starts it, then stops it, and reconfigures queues. The second queue allocation
happens from within netdev_set_multiq(). Then ovs restarts the device and proceeds to actually using it.
But, queues are not initialized properly in DPDK after the second allocation. Because of this thing:

	/* On restart after stop do not touch queues */
	if (hw->started)
		return 0;

It keeps us away from calling virtio_dev_rxtx_start(), which should in turn call virtio_dev_vring_start(), which calls
vring_init(). So, VIRTQUEUE_NUSED() dies badly because vq->vq_ring all contains NULLs.
See you all after 10th. And happy New Year again!

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia

Quoted 53 lines

-----Original Message-----
From: Pavel Fedin [mailto:[email protected]]
Sent: Thursday, December 31, 2015 4:47 PM
To: 'Tan, Jianfeng'; '[email protected]'
Subject: RE: [dpdk-dev] [RFC 0/5] virtio support for container

Hello!

Quoted 3 lines
Quoted 1 line

a) ovs_in_container does not send VHOST_USER_SET_MEM_TABLE

Please check if rte_eth_dev_start() is called.
(rte_eth_dev_start -> virtio_dev_start -> vtpci_reinit_complete -> kick_all_vq)

I've figured out what happened, and it's my fault only :( I have modified your patchset and
added --shared-mem option. And forgot to specify it to gdb :) Without it memory is not shared, and rte_memseg_info_get() returned fd = -1. And if you put it into control message for sendmsg(), you get your -EBADF.
So please ignore this.
But, nevertheless, ovs in container still dies with:
--- cut ---
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fff97fff700 (LWP 3866)]
virtio_recv_mergeable_pkts (rx_queue=0x7fffd46a9a80, rx_pkts=0x7fff97ffe850, nb_pkts=32) at /home/p.fedin/dpdk/drivers/net/virtio/virtio_rxtx.c:683
683 /home/p.fedin/dpdk/drivers/net/virtio/virtio_rxtx.c: No such file or directory.
Missing separate debuginfos, use: dnf debuginfo-install keyutils-libs-1.5.9-7.fc23.x86_64 krb5-libs-1.13.2-11.fc23.x86_64 libcap-ng-0.7.7-2.fc23.x86_64 libcom_err-1.42.13- 3.fc23.x86_64 libselinux-2.4-4.fc23.x86_64 openssl-libs-1.0.2d-2.fc23.x86_64 pcre-8.37- 4.fc23.x86_64 zlib-1.2.8-9.fc23.x86_64
(gdb) where
#0 virtio_recv_mergeable_pkts (rx_queue=0x7fffd46a9a80, rx_pkts=0x7fff97ffe850, nb_pkts=32) at /home/p.fedin/dpdk/drivers/net/virtio/virtio_rxtx.c:683
#1 0x0000000000669ee8 in rte_eth_rx_burst (nb_pkts=32, rx_pkts=0x7fff97ffe850, queue_id=0, port_id=0 '\000') at /home/p.fedin/dpdk/build/include/rte_ethdev.h:2510
#2 netdev_dpdk_rxq_recv (rxq_=<optimized out>, packets=0x7fff97ffe850, c=0x7fff97ffe84c) at lib/netdev-dpdk.c:1033
#3 0x00000000005e8ca1 in netdev_rxq_recv (rx=<optimized out>, buffers=buffers@entry=0x7fff97ffe850, cnt=cnt@entry=0x7fff97ffe84c) at lib/netdev.c:654 #4 0x00000000005cb338 in dp_netdev_process_rxq_port (pmd=pmd@entry=0x7fffac7f8010, rxq=<optimized out>, port=<optimized out>, port=<optimized out>) at lib/dpif-netdev.c:2510

#5  0x00000000005cc649 in pmd_thread_main (f_=0x7fffac7f8010) at lib/dpif-netdev.c:2671
#6  0x0000000000628424 in ovsthread_wrapper (aux_=<optimized out>) at lib/ovs-thread.c:340
#7  0x00007ffff70f660a in start_thread () from /lib64/libpthread.so.0
#8  0x00007ffff6926bbd in clone () from /lib64/libc.so.6

(gdb)
--- cut ---

and l2fwd does not reproduce this. So, let's wait until 11.01.2016. And happy New Year to
everybody who reads it (and who doesn't) :)

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia

#11 lore raw
Quoted 10 lines · Pavel Fedin

Hello!

Last minute note. I have found the problem but have no time to research and fix it.
It happens because ovs first creates the device, starts it, then stops it, and reconfigures queues. The second queue allocation
happens from within netdev_set_multiq(). Then ovs restarts the device and proceeds to actually using it.
But, queues are not initialized properly in DPDK after the second allocation. Because of this thing:

	/* On restart after stop do not touch queues */
	if (hw->started)
		return 0;

Hi Fedin,

As you see, I also think it is a bug. A device should be ok to start/stop/start...

I already send a patch to fix this.
http://dpdk.org/ml/archives/dev/2016-January/031010.html

Thanks,
Jianfeng

Quoted 6 lines

It keeps us away from calling virtio_dev_rxtx_start(), which should in turn call virtio_dev_vring_start(), which calls
vring_init(). So, VIRTQUEUE_NUSED() dies badly because vq->vq_ring all contains NULLs.
See you all after 10th. And happy New Year again!