aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Kallio <marko.kallio@tieto.com>2015-06-02 18:31:16 +0100
committerZoltan Kiss <zoltan.kiss@linaro.org>2015-07-09 18:41:16 +0100
commit5fc406713fdf9cdc52b80a0683f9d6cbcc380e1a (patch)
tree177054c7eeede9abd61a1caace85e3c2a8702a3a
parent2f9bf8942e7a330ac15fd3a39b021fe6734867c0 (diff)
netdev: affinity fix for ovs-odp
This patch will fix the core affinity setting in ovs, when using ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=1e In case of 2 NUMA nodes there is needed to do more work to netdev-odp.c Reviewed-by: Santosh Shukla <santosh.shukla@linaro.org> Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org> Signed-off-by: Marko Kallio <marko.kallio@tieto.com>
-rw-r--r--lib/netdev-dpdk.h2
-rw-r--r--lib/netdev-odp.c20
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/netdev-dpdk.h b/lib/netdev-dpdk.h
index 646d3e21f..e7777fe49 100644
--- a/lib/netdev-dpdk.h
+++ b/lib/netdev-dpdk.h
@@ -54,11 +54,13 @@ free_dpdk_buf(struct dp_packet *buf OVS_UNUSED)
/* Nothing */
}
+#ifndef ODP_NETDEV
static inline int
pmd_thread_setaffinity_cpu(unsigned cpu OVS_UNUSED)
{
return 0;
}
+#endif /*#ifndef ODP_NETDEV */
#endif /* DPDK_NETDEV */
#endif
diff --git a/lib/netdev-odp.c b/lib/netdev-odp.c
index b3803f275..c04299b4d 100644
--- a/lib/netdev-odp.c
+++ b/lib/netdev-odp.c
@@ -677,3 +677,23 @@ netdev_odp_register(void)
ovsthread_once_done(&once);
}
}
+
+int
+pmd_thread_setaffinity_cpu(int cpu)
+{
+ cpu_set_t cpuset;
+ int err;
+
+ CPU_ZERO(&cpuset);
+ CPU_SET(cpu, &cpuset);
+ err = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
+ if (err) {
+ VLOG_ERR("Thread affinity error %d",err);
+ return err;
+ }
+ /* lcore_id 0 is reseved for use by non pmd threads. */
+ ovs_assert(cpu);
+
+ return 0;
+}
+