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 14:48:32 +0100
commit834c52595ad052b195c8c5b1346799c867858752 (patch)
tree2f766563e9ddc74ddca8901334397b2cf3eb4108
parentcb9f8e66c8258ddd815eda15127d39ec067d5c7e (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 c24d6da33..d298f3a74 100644
--- a/lib/netdev-dpdk.h
+++ b/lib/netdev-dpdk.h
@@ -51,11 +51,13 @@ free_dpdk_buf(struct dpif_packet *buf OVS_UNUSED)
/* Nothing */
}
+#ifndef ODP_NETDEV
static inline int
pmd_thread_setaffinity_cpu(int cpu OVS_UNUSED)
{
return 0;
}
+#endif /*#ifndef ODP_NETDEV */
static inline void
thread_set_nonpmd(void)
diff --git a/lib/netdev-odp.c b/lib/netdev-odp.c
index c78940484..c33788e5c 100644
--- a/lib/netdev-odp.c
+++ b/lib/netdev-odp.c
@@ -679,3 +679,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;
+}
+