*/
#include <unistd.h>
#include <stdint.h>
+#include <sched.h>
#include <fcntl.h>
#include <sys/eventfd.h>
usleep(priv->timer_delay_us);
else
/* Give-up CPU to improve polling threads scheduling. */
- pthread_yield();
+ sched_yield();
}
static void *
pthread_cond_init(&priv->timer_cond, NULL);
priv->timer_on = 0;
pthread_attr_init(&attr);
- CPU_ZERO(&cpuset);
- if (priv->event_core != -1)
- CPU_SET(priv->event_core, &cpuset);
- else
- cpuset = rte_lcore_cpuset(rte_get_main_lcore());
- ret = pthread_attr_setaffinity_np(&attr, sizeof(cpuset),
- &cpuset);
- if (ret) {
- DRV_LOG(ERR, "Failed to set thread affinity.");
- return -1;
- }
ret = pthread_attr_setschedpolicy(&attr, SCHED_RR);
if (ret) {
DRV_LOG(ERR, "Failed to set thread sched policy = RR.");
DRV_LOG(ERR, "Failed to create timer thread.");
return -1;
}
+ CPU_ZERO(&cpuset);
+ if (priv->event_core != -1)
+ CPU_SET(priv->event_core, &cpuset);
+ else
+ cpuset = rte_lcore_cpuset(rte_get_main_lcore());
+ ret = pthread_setaffinity_np(priv->timer_tid,
+ sizeof(cpuset), &cpuset);
+ if (ret) {
+ DRV_LOG(ERR, "Failed to set thread affinity.");
+ goto error;
+ }
snprintf(name, sizeof(name), "vDPA-mlx5-%d", priv->vid);
ret = pthread_setname_np(priv->timer_tid, name);
if (ret) {