/* Stores the pmd thread's 'pmd' to 'per_pmd_key'. */
ovsthread_setspecific(pmd->dp->per_pmd_key, pmd);
- pmd_thread_setaffinity_cpu(pmd->core_id);
+ ovs_numa_thread_setaffinity_core(pmd->core_id);
+ dpdk_set_lcore_id(pmd->core_id);
poll_cnt = pmd_load_queues_and_ports(pmd, &poll_list);
reload:
emc_cache_init(&pmd->flow_cache);
#endif
}
-int
-pmd_thread_setaffinity_cpu(unsigned cpu)
+void
+dpdk_set_lcore_id(unsigned 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;
- }
/* NON_PMD_CORE_ID is reserved for use by non pmd threads. */
ovs_assert(cpu != NON_PMD_CORE_ID);
RTE_PER_LCORE(_lcore_id) = cpu;
-
- return 0;
}
static bool
void netdev_dpdk_register(void);
void free_dpdk_buf(struct dp_packet *);
-int pmd_thread_setaffinity_cpu(unsigned cpu);
+void dpdk_set_lcore_id(unsigned cpu);
#else
/* Nothing */
}
-static inline int
-pmd_thread_setaffinity_cpu(unsigned cpu OVS_UNUSED)
+static inline void
+dpdk_set_lcore_id(unsigned cpu OVS_UNUSED)
{
- return 0;
+ /* Nothing */
}
#endif /* DPDK_NETDEV */
core->available = false;
}
}
+
+int ovs_numa_thread_setaffinity_core(unsigned core_id)
+{
+#ifdef __linux__
+ cpu_set_t cpuset;
+ int err;
+
+ CPU_ZERO(&cpuset);
+ CPU_SET(core_id, &cpuset);
+ err = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
+ if (err) {
+ VLOG_ERR("Thread affinity error %d",err);
+ return err;
+ }
+
+ return 0;
+#else /* !__linux__ */
+ return EOPNOTSUPP;
+#endif /* __linux__ */
+}
void ovs_numa_unpin_core(unsigned core_id);
struct ovs_numa_dump *ovs_numa_dump_cores_on_numa(int numa_id);
void ovs_numa_dump_destroy(struct ovs_numa_dump *);
+int ovs_numa_thread_setaffinity_core(unsigned core_id);
#define FOR_EACH_CORE_ON_NUMA(ITER, DUMP) \
LIST_FOR_EACH((ITER), list_node, &(DUMP)->dump)