@@ -26,6 +26,7 @@
#include <rte_errno.h>
#include <rte_lcore.h>
#include <rte_log.h>
+#include <rte_thread.h>
#include "eal_memcfg.h"
#include "eal_private.h"
@@ -33,7 +34,7 @@
#include "eal_internal_cfg.h"
static int mp_fd = -1;
-static pthread_t mp_handle_tid;
+static rte_thread_t mp_handle_tid;
static char mp_filter[PATH_MAX]; /* Filter for secondary process sockets */
static char mp_dir_path[PATH_MAX]; /* The directory path for all mp sockets */
static pthread_mutex_t mp_mutex_action = PTHREAD_MUTEX_INITIALIZER;
@@ -396,7 +397,7 @@ process_msg(struct mp_msg_internal *m, struct sockaddr_un *s)
}
}
-static void *
+static uint32_t
mp_handle(void *arg __rte_unused)
{
struct mp_msg_internal msg;
@@ -413,7 +414,7 @@ mp_handle(void *arg __rte_unused)
process_msg(&msg, &sa);
}
- return NULL;
+ return 0;
}
static int
@@ -646,8 +647,8 @@ rte_mp_channel_init(void)
return -1;
}
- if (rte_ctrl_thread_create(&mp_handle_tid, "dpdk-mp-msg",
- NULL, mp_handle, NULL) < 0) {
+ if (rte_thread_create_internal_control(&mp_handle_tid, "mp-msg",
+ mp_handle, NULL) < 0) {
RTE_LOG(ERR, EAL, "failed to create mp thread: %s\n",
strerror(errno));
close(dir_fd);
@@ -671,8 +672,8 @@ rte_mp_channel_cleanup(void)
if (fd < 0)
return;
- pthread_cancel(mp_handle_tid);
- pthread_join(mp_handle_tid, NULL);
+ pthread_cancel((pthread_t)mp_handle_tid.opaque_id);
+ rte_thread_join(mp_handle_tid, NULL);
close_socket_fd(fd);
}
@@ -52,7 +52,7 @@ static rte_spinlock_t intr_lock = RTE_SPINLOCK_INITIALIZER;
static struct rte_intr_source_list intr_sources;
/* interrupt handling thread */
-static pthread_t intr_thread;
+static rte_thread_t intr_thread;
static volatile int kq = -1;
@@ -591,7 +591,7 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)
}
}
-static void *
+static uint32_t
eal_intr_thread_main(void *arg __rte_unused)
{
struct kevent events[MAX_INTR_EVENTS];
@@ -619,7 +619,7 @@ eal_intr_thread_main(void *arg __rte_unused)
}
close(kq);
kq = -1;
- return NULL;
+ return 0;
}
int
@@ -637,7 +637,7 @@ rte_eal_intr_init(void)
}
/* create the host thread to wait/handle the interrupt */
- ret = rte_ctrl_thread_create(&intr_thread, "dpdk-intr", NULL,
+ ret = rte_thread_create_internal_control(&intr_thread, "intr",
eal_intr_thread_main, NULL);
if (ret != 0) {
rte_errno = -ret;
@@ -746,5 +746,5 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle)
int rte_thread_is_intr(void)
{
- return pthread_equal(intr_thread, pthread_self());
+ return rte_thread_equal(intr_thread, rte_thread_self());
}
@@ -5,7 +5,6 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
-#include <pthread.h>
#include <sys/queue.h>
#include <unistd.h>
#include <string.h>
@@ -19,6 +18,7 @@
#include <eal_trace_internal.h>
#include <rte_common.h>
#include <rte_interrupts.h>
+#include <rte_thread.h>
#include <rte_per_lcore.h>
#include <rte_lcore.h>
#include <rte_branch_prediction.h>
@@ -89,7 +89,7 @@ static union intr_pipefds intr_pipe;
static struct rte_intr_source_list intr_sources;
/* interrupt handling thread */
-static pthread_t intr_thread;
+static rte_thread_t intr_thread;
/* VFIO interrupts */
#ifdef VFIO_PRESENT
@@ -1103,7 +1103,7 @@ eal_intr_handle_interrupts(int pfd, unsigned totalfds)
* @return
* never return;
*/
-static __rte_noreturn void *
+static __rte_noreturn uint32_t
eal_intr_thread_main(__rte_unused void *arg)
{
/* host thread, never break out */
@@ -1188,7 +1188,7 @@ rte_eal_intr_init(void)
}
/* create the host thread to wait/handle the interrupt */
- ret = rte_ctrl_thread_create(&intr_thread, "dpdk-intr", NULL,
+ ret = rte_thread_create_internal_control(&intr_thread, "intr",
eal_intr_thread_main, NULL);
if (ret != 0) {
rte_errno = -ret;
@@ -1601,5 +1601,5 @@ rte_intr_cap_multiple(struct rte_intr_handle *intr_handle)
int rte_thread_is_intr(void)
{
- return pthread_equal(intr_thread, pthread_self());
+ return rte_thread_equal(intr_thread, rte_thread_self());
}
@@ -14,6 +14,7 @@
#include <rte_common.h>
#include <rte_cycles.h>
+#include <rte_thread.h>
#include "eal_private.h"
@@ -71,14 +72,14 @@ static uint64_t eal_hpet_resolution_hz = 0;
/* Incremented 4 times during one 32bits hpet full count */
static uint32_t eal_hpet_msb;
-static pthread_t msb_inc_thread_id;
+static rte_thread_t msb_inc_thread_id;
/*
* This function runs on a specific thread to update a global variable
* containing used to process MSB of the HPET (unfortunately, we need
* this because hpet is 32 bits by default under linux).
*/
-static void *
+static uint32_t
hpet_msb_inc(__rte_unused void *arg)
{
uint32_t t;
@@ -89,7 +90,7 @@ hpet_msb_inc(__rte_unused void *arg)
eal_hpet_msb ++;
sleep(10);
}
- return NULL;
+ return 0;
}
uint64_t
@@ -176,8 +177,8 @@ rte_eal_hpet_init(int make_default)
/* create a thread that will increment a global variable for
* msb (hpet is 32 bits by default under linux) */
- ret = rte_ctrl_thread_create(&msb_inc_thread_id, "dpdk-hpet-msb", NULL,
- hpet_msb_inc, NULL);
+ ret = rte_thread_create_internal_control(&msb_inc_thread_id, "hpet-msb",
+ hpet_msb_inc, NULL);
if (ret != 0) {
RTE_LOG(ERR, EAL, "ERROR: Cannot create HPET timer thread!\n");
internal_conf->no_hpet = 1;
@@ -190,7 +190,7 @@ rte_thread_create(rte_thread_t *thread_id,
pthread_mutex_unlock(&ctx.wrapper_mutex);
if (ret != 0)
- pthread_join((pthread_t)thread_id->opaque_id, NULL);
+ rte_thread_join(*thread_id, NULL);
cleanup:
if (attrp != NULL)
@@ -98,7 +98,7 @@ rte_eal_intr_init(void)
return -1;
}
- ret = rte_thread_create_control(&intr_thread, "dpdk-intr",
+ ret = rte_thread_create_internal_control(&intr_thread, "intr",
eal_intr_thread_main, NULL);
if (ret != 0) {
rte_errno = -ret;
@@ -10,6 +10,7 @@
#include <unistd.h>
#include <rte_cycles.h>
+#include <rte_thread.h>
#include <rte_common.h>
#include <dev_driver.h>
#include <rte_errno.h>
@@ -165,7 +166,7 @@ struct event_eth_rx_adapter {
/* Count of interrupt vectors in use */
uint32_t num_intr_vec;
/* Thread blocked on Rx interrupts */
- pthread_t rx_intr_thread;
+ rte_thread_t rx_intr_thread;
/* Configuration callback for rte_service configuration */
rte_event_eth_rx_adapter_conf_cb conf_cb;
/* Configuration callback argument */
@@ -1154,13 +1155,13 @@ rxa_intr_ring_del_entries(struct event_eth_rx_adapter *rx_adapter,
rte_spinlock_unlock(&rx_adapter->intr_ring_lock);
}
-/* pthread callback handling interrupt mode receive queues
+/* thread callback handling interrupt mode receive queues
* After receiving an Rx interrupt, it enqueues the port id and queue id of the
* interrupting queue to the adapter's ring buffer for interrupt events.
* These events are picked up by rxa_intr_ring_dequeue() which is invoked from
* the adapter service function.
*/
-static void *
+static uint32_t
rxa_intr_thread(void *arg)
{
struct event_eth_rx_adapter *rx_adapter = arg;
@@ -1179,7 +1180,7 @@ rxa_intr_thread(void *arg)
}
}
- return NULL;
+ return 0;
}
/* Dequeue <port, q> from interrupt ring and enqueue received
@@ -1595,7 +1596,7 @@ static int
rxa_create_intr_thread(struct event_eth_rx_adapter *rx_adapter)
{
int err;
- char thread_name[RTE_MAX_THREAD_NAME_LEN];
+ char thread_name[RTE_THREAD_INTERNAL_NAME_SIZE];
if (rx_adapter->intr_ring)
return 0;
@@ -1618,11 +1619,11 @@ rxa_create_intr_thread(struct event_eth_rx_adapter *rx_adapter)
rte_spinlock_init(&rx_adapter->intr_ring_lock);
- snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
- "dpdk-evt-rx%d", rx_adapter->id);
+ snprintf(thread_name, sizeof(thread_name),
+ "evt-rx%d", rx_adapter->id);
- err = rte_ctrl_thread_create(&rx_adapter->rx_intr_thread, thread_name,
- NULL, rxa_intr_thread, rx_adapter);
+ err = rte_thread_create_internal_control(&rx_adapter->rx_intr_thread,
+ thread_name, rxa_intr_thread, rx_adapter);
if (!err)
return 0;
@@ -1640,12 +1641,12 @@ rxa_destroy_intr_thread(struct event_eth_rx_adapter *rx_adapter)
{
int err;
- err = pthread_cancel(rx_adapter->rx_intr_thread);
+ err = pthread_cancel((pthread_t)rx_adapter->rx_intr_thread.opaque_id);
if (err)
RTE_EDEV_LOG_ERR("Can't cancel interrupt thread err = %d\n",
err);
- err = pthread_join(rx_adapter->rx_intr_thread, NULL);
+ err = rte_thread_join(rx_adapter->rx_intr_thread, NULL);
if (err)
RTE_EDEV_LOG_ERR("Can't join interrupt thread err = %d\n", err);
@@ -212,7 +212,7 @@ fdset_try_del(struct fdset *pfdset, int fd)
* will wait until the flag is reset to zero(which indicates the callback is
* finished), then it could free the context after fdset_del.
*/
-void *
+uint32_t
fdset_event_dispatch(void *arg)
{
int i;
@@ -227,7 +227,7 @@ fdset_event_dispatch(void *arg)
int val;
if (pfdset == NULL)
- return NULL;
+ return 0;
while (1) {
@@ -303,7 +303,7 @@ fdset_event_dispatch(void *arg)
fdset_shrink(pfdset);
}
- return NULL;
+ return 0;
}
static void
@@ -46,7 +46,7 @@ int fdset_add(struct fdset *pfdset, int fd,
void *fdset_del(struct fdset *pfdset, int fd);
int fdset_try_del(struct fdset *pfdset, int fd);
-void *fdset_event_dispatch(void *arg);
+uint32_t fdset_event_dispatch(void *arg);
int fdset_pipe_init(struct fdset *fdset);
@@ -13,8 +13,8 @@
#include <sys/queue.h>
#include <errno.h>
#include <fcntl.h>
-#include <pthread.h>
+#include <rte_thread.h>
#include <rte_log.h>
#include "fd_man.h"
@@ -431,7 +431,7 @@ struct vhost_user_reconnect_list {
};
static struct vhost_user_reconnect_list reconn_list;
-static pthread_t reconn_tid;
+static rte_thread_t reconn_tid;
static int
vhost_user_connect_nonblock(char *path, int fd, struct sockaddr *un, size_t sz)
@@ -455,7 +455,7 @@ vhost_user_connect_nonblock(char *path, int fd, struct sockaddr *un, size_t sz)
return 0;
}
-static void *
+static uint32_t
vhost_user_client_reconnect(void *arg __rte_unused)
{
int ret;
@@ -496,7 +496,7 @@ vhost_user_client_reconnect(void *arg __rte_unused)
sleep(1);
}
- return NULL;
+ return 0;
}
static int
@@ -511,8 +511,8 @@ vhost_user_reconnect_init(void)
}
TAILQ_INIT(&reconn_list.head);
- ret = rte_ctrl_thread_create(&reconn_tid, "dpdk-vhost-reco", NULL,
- vhost_user_client_reconnect, NULL);
+ ret = rte_thread_create_internal_control(&reconn_tid, "vhost-reco",
+ vhost_user_client_reconnect, NULL);
if (ret != 0) {
VHOST_LOG_CONFIG("thread", ERR, "failed to create reconnect thread\n");
if (pthread_mutex_destroy(&reconn_list.mutex))
@@ -1004,7 +1004,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
if (!vsocket->is_vduse) {
if ((flags & RTE_VHOST_USER_CLIENT) != 0) {
vsocket->reconnect = !(flags & RTE_VHOST_USER_NO_RECONNECT);
- if (vsocket->reconnect && reconn_tid == 0) {
+ if (vsocket->reconnect && reconn_tid.opaque_id == 0) {
if (vhost_user_reconnect_init() != 0)
goto out_mutex;
}
@@ -1174,7 +1174,7 @@ int
rte_vhost_driver_start(const char *path)
{
struct vhost_user_socket *vsocket;
- static pthread_t fdset_tid;
+ static rte_thread_t fdset_tid;
pthread_mutex_lock(&vhost_user.mutex);
vsocket = find_vhost_user_socket(path);
@@ -1186,7 +1186,7 @@ rte_vhost_driver_start(const char *path)
if (vsocket->is_vduse)
return vduse_device_create(path, vsocket->net_compliant_ol_flags);
- if (fdset_tid == 0) {
+ if (fdset_tid.opaque_id == 0) {
/**
* create a pipe which will be waited by poll and notified to
* rebuild the wait list of poll.
@@ -1196,9 +1196,8 @@ rte_vhost_driver_start(const char *path)
return -1;
}
- int ret = rte_ctrl_thread_create(&fdset_tid,
- "dpdk-vhost-evt", NULL, fdset_event_dispatch,
- &vhost_user.fdset);
+ int ret = rte_thread_create_internal_control(&fdset_tid,
+ "vhost-evt", fdset_event_dispatch, &vhost_user.fdset);
if (ret != 0) {
VHOST_LOG_CONFIG(path, ERR, "failed to create fdset handling thread\n");
fdset_pipe_uninit(&vhost_user.fdset);
@@ -16,6 +16,7 @@
#include <sys/stat.h>
#include <rte_common.h>
+#include <rte_thread.h>
#include "fd_man.h"
#include "iotlb.h"
@@ -415,7 +416,7 @@ int
vduse_device_create(const char *path, bool compliant_ol_flags)
{
int control_fd, dev_fd, vid, ret;
- pthread_t fdset_tid;
+ rte_thread_t fdset_tid;
uint32_t i, max_queue_pairs, total_queues;
struct virtio_net *dev;
struct virtio_net_config vnet_config = {{ 0 }};
@@ -435,7 +436,7 @@ vduse_device_create(const char *path, bool compliant_ol_flags)
return -1;
}
- ret = rte_ctrl_thread_create(&fdset_tid, "dpdk-vduse-evt", NULL,
+ ret = rte_thread_create_internal_control(&fdset_tid, "vduse-evt",
fdset_event_dispatch, &vduse.fdset);
if (ret != 0) {
VHOST_LOG_CONFIG(path, ERR, "failed to create vduse fdset handling thread\n");