[ovs-dev] [PATCH] netdev-dpdk: Fix crash when there is no pci numa info.

2014-09-25 Thread Alex Wang
When kernel cannot obtain the pci numa info, the numa_node file
in corresponding pci directory in sysfs will show -1.  Then the
rte_eth_dev_socket_id() function will return it to ovs.  On
current master, ovs assumes rte_eth_dev_socket_id() always
returns non-negative value.  So using this -1 in pmd thread
creation will cause ovs crash.

To fix the above issue, this commit makes ovs always check the
return value of rte_eth_dev_socket_id() and use numa node 0 if
the return value is negative.

Reported-by: Daniel Badea daniel.ba...@windriver.com
Signed-off-by: Alex Wang al...@nicira.com
---
 lib/netdev-dpdk.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 50ea965..9c93768 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -485,13 +485,18 @@ netdev_dpdk_init(struct netdev *netdev_, unsigned int 
port_no)
 OVS_REQUIRES(dpdk_mutex)
 {
 struct netdev_dpdk *netdev = netdev_dpdk_cast(netdev_);
+int sid;
 int err = 0;
 
 ovs_mutex_init(netdev-mutex);
 
 ovs_mutex_lock(netdev-mutex);
 
-netdev-socket_id = rte_eth_dev_socket_id(port_no);
+/* If the 'sid' is negative, it means that the kernel fails
+ * to obtain the pci numa info.  In that situation, always
+ * use 'SOCKET0'. */
+sid = rte_eth_dev_socket_id(port_no);
+netdev-socket_id = sid  0 ? SOCKET0 : sid;
 netdev_dpdk_alloc_txq(netdev, NR_QUEUE);
 netdev-port_id = port_no;
 netdev-flags = 0;
-- 
1.7.9.5

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] netdev-dpdk: Fix crash when there is no pci numa info.

2014-09-25 Thread Daniele Di Proietto
Thanks for the fix!

Acked-by: Daniele Di Proietto ddiproie...@vmware.com

On 9/25/14, 1:28 PM, Alex Wang al...@nicira.com wrote:

When kernel cannot obtain the pci numa info, the numa_node file
in corresponding pci directory in sysfs will show -1.  Then the
rte_eth_dev_socket_id() function will return it to ovs.  On
current master, ovs assumes rte_eth_dev_socket_id() always
returns non-negative value.  So using this -1 in pmd thread
creation will cause ovs crash.

To fix the above issue, this commit makes ovs always check the
return value of rte_eth_dev_socket_id() and use numa node 0 if
the return value is negative.

Reported-by: Daniel Badea daniel.ba...@windriver.com
Signed-off-by: Alex Wang al...@nicira.com
---
 lib/netdev-dpdk.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 50ea965..9c93768 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -485,13 +485,18 @@ netdev_dpdk_init(struct netdev *netdev_, unsigned
int port_no)
 OVS_REQUIRES(dpdk_mutex)
 {
 struct netdev_dpdk *netdev = netdev_dpdk_cast(netdev_);
+int sid;
 int err = 0;
 
 ovs_mutex_init(netdev-mutex);
 
 ovs_mutex_lock(netdev-mutex);
 
-netdev-socket_id = rte_eth_dev_socket_id(port_no);
+/* If the 'sid' is negative, it means that the kernel fails
+ * to obtain the pci numa info.  In that situation, always
+ * use 'SOCKET0'. */
+sid = rte_eth_dev_socket_id(port_no);
+netdev-socket_id = sid  0 ? SOCKET0 : sid;
 netdev_dpdk_alloc_txq(netdev, NR_QUEUE);
 netdev-port_id = port_no;
 netdev-flags = 0;
-- 
1.7.9.5

___
dev mailing list
dev@openvswitch.org
https://urldefense.proofpoint.com/v1/url?u=http://openvswitch.org/mailman/
listinfo/devk=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0Ar=MV9BdLjtFIdhBDBaw5z%2BU
6SSA2gAfY4L%2F1HCy3VjlKU%3D%0Am=X596LDIOn3vB8hKejLfNln2Hv%2FE45SfcQeQbYSI
zMtM%3D%0As=0c07569815c01a727f199675214802aa8c941cbffb74b700ea79174397c7c
ab3

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] netdev-dpdk: Fix crash when there is no pci numa info.

2014-09-25 Thread Justin Pettit
Don't forget to add Daniel to AUTHORS.

--Justin


On September 25, 2014 at 1:27:30 PM, Alex Wang (al...@nicira.com) wrote:
 When kernel cannot obtain the pci numa info, the numa_node file
 in corresponding pci directory in sysfs will show -1. Then the
 rte_eth_dev_socket_id() function will return it to ovs. On
 current master, ovs assumes rte_eth_dev_socket_id() always
 returns non-negative value. So using this -1 in pmd thread
 creation will cause ovs crash.
 
 To fix the above issue, this commit makes ovs always check the
 return value of rte_eth_dev_socket_id() and use numa node 0 if
 the return value is negative.
 
 Reported-by: Daniel Badea 
 Signed-off-by: Alex Wang 
 ---
 lib/netdev-dpdk.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)
 
 diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
 index 50ea965..9c93768 100644
 --- a/lib/netdev-dpdk.c
 +++ b/lib/netdev-dpdk.c
 @@ -485,13 +485,18 @@ netdev_dpdk_init(struct netdev *netdev_, unsigned int 
 port_no) 
 OVS_REQUIRES(dpdk_mutex)
 {
 struct netdev_dpdk *netdev = netdev_dpdk_cast(netdev_);
 + int sid;
 int err = 0;
 
 ovs_mutex_init(netdev-mutex);
 
 ovs_mutex_lock(netdev-mutex);
 
 - netdev-socket_id = rte_eth_dev_socket_id(port_no);
 + /* If the 'sid' is negative, it means that the kernel fails
 + * to obtain the pci numa info. In that situation, always
 + * use 'SOCKET0'. */
 + sid = rte_eth_dev_socket_id(port_no);
 + netdev-socket_id = sid  0 ? SOCKET0 : sid;
 netdev_dpdk_alloc_txq(netdev, NR_QUEUE);
 netdev-port_id = port_no;
 netdev-flags = 0;
 --
 1.7.9.5
 
 ___
 dev mailing list
 dev@openvswitch.org
 http://openvswitch.org/mailman/listinfo/dev
 

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] netdev-dpdk: Fix crash when there is no pci numa info.

2014-09-25 Thread Alex Wang
Thx, Daniele also reminded me of that, will fold that in with the patch.

On Thu, Sep 25, 2014 at 2:07 PM, Justin Pettit jpet...@nicira.com wrote:

 Don't forget to add Daniel to AUTHORS.

 --Justin


 On September 25, 2014 at 1:27:30 PM, Alex Wang (al...@nicira.com) wrote:
  When kernel cannot obtain the pci numa info, the numa_node file
  in corresponding pci directory in sysfs will show -1. Then the
  rte_eth_dev_socket_id() function will return it to ovs. On
  current master, ovs assumes rte_eth_dev_socket_id() always
  returns non-negative value. So using this -1 in pmd thread
  creation will cause ovs crash.
 
  To fix the above issue, this commit makes ovs always check the
  return value of rte_eth_dev_socket_id() and use numa node 0 if
  the return value is negative.
 
  Reported-by: Daniel Badea
  Signed-off-by: Alex Wang
  ---
  lib/netdev-dpdk.c | 7 ++-
  1 file changed, 6 insertions(+), 1 deletion(-)
 
  diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
  index 50ea965..9c93768 100644
  --- a/lib/netdev-dpdk.c
  +++ b/lib/netdev-dpdk.c
  @@ -485,13 +485,18 @@ netdev_dpdk_init(struct netdev *netdev_, unsigned
 int port_no)
  OVS_REQUIRES(dpdk_mutex)
  {
  struct netdev_dpdk *netdev = netdev_dpdk_cast(netdev_);
  + int sid;
  int err = 0;
 
  ovs_mutex_init(netdev-mutex);
 
  ovs_mutex_lock(netdev-mutex);
 
  - netdev-socket_id = rte_eth_dev_socket_id(port_no);
  + /* If the 'sid' is negative, it means that the kernel fails
  + * to obtain the pci numa info. In that situation, always
  + * use 'SOCKET0'. */
  + sid = rte_eth_dev_socket_id(port_no);
  + netdev-socket_id = sid  0 ? SOCKET0 : sid;
  netdev_dpdk_alloc_txq(netdev, NR_QUEUE);
  netdev-port_id = port_no;
  netdev-flags = 0;
  --
  1.7.9.5
 
  ___
  dev mailing list
  dev@openvswitch.org
  http://openvswitch.org/mailman/listinfo/dev
 


___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev