eal: set name to threads
[dpdk.git] / lib / librte_eal / linuxapp / eal / eal_interrupts.c
index 078318c..a4b9506 100644 (file)
@@ -67,6 +67,7 @@
 
 #include "eal_private.h"
 #include "eal_vfio.h"
+#include "eal_thread.h"
 
 #define EAL_INTR_EPOLL_WAIT_FOREVER (-1)
 #define NB_OTHER_INTR               1
@@ -691,26 +692,30 @@ eal_intr_process_interrupts(struct epoll_event *events, int nfds)
                        bytes_read = sizeof(buf.vfio_intr_count);
                        break;
 #endif
+               case RTE_INTR_HANDLE_EXT:
                default:
                        bytes_read = 1;
                        break;
                }
 
-               /**
-                * read out to clear the ready-to-be-read flag
-                * for epoll_wait.
-                */
-               bytes_read = read(events[n].data.fd, &buf, bytes_read);
-               if (bytes_read < 0) {
-                       if (errno == EINTR || errno == EWOULDBLOCK)
-                               continue;
-
-                       RTE_LOG(ERR, EAL, "Error reading from file "
-                               "descriptor %d: %s\n", events[n].data.fd,
-                                                       strerror(errno));
-               } else if (bytes_read == 0)
-                       RTE_LOG(ERR, EAL, "Read nothing from file "
-                               "descriptor %d\n", events[n].data.fd);
+               if (src->intr_handle.type != RTE_INTR_HANDLE_EXT) {
+                       /**
+                        * read out to clear the ready-to-be-read flag
+                        * for epoll_wait.
+                        */
+                       bytes_read = read(events[n].data.fd, &buf, bytes_read);
+                       if (bytes_read < 0) {
+                               if (errno == EINTR || errno == EWOULDBLOCK)
+                                       continue;
+
+                               RTE_LOG(ERR, EAL, "Error reading from file "
+                                       "descriptor %d: %s\n",
+                                       events[n].data.fd,
+                                       strerror(errno));
+                       } else if (bytes_read == 0)
+                               RTE_LOG(ERR, EAL, "Read nothing from file "
+                                       "descriptor %d\n", events[n].data.fd);
+               }
 
                /* grab a lock, again to call callbacks and update status. */
                rte_spinlock_lock(&intr_lock);
@@ -856,7 +861,8 @@ eal_intr_thread_main(__rte_unused void *arg)
 int
 rte_eal_intr_init(void)
 {
-       int ret = 0;
+       int ret = 0, ret_1 = 0;
+       char thread_name[RTE_MAX_THREAD_NAME_LEN];
 
        /* init the global interrupt source head */
        TAILQ_INIT(&intr_sources);
@@ -871,9 +877,18 @@ rte_eal_intr_init(void)
        /* create the host thread to wait/handle the interrupt */
        ret = pthread_create(&intr_thread, NULL,
                        eal_intr_thread_main, NULL);
-       if (ret != 0)
+       if (ret != 0) {
                RTE_LOG(ERR, EAL,
                        "Failed to create thread for interrupt handling\n");
+       } else {
+               /* Set thread_name for aid in debugging. */
+               snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
+                       "eal-intr-thread");
+               ret_1 = pthread_setname_np(intr_thread, thread_name);
+               if (ret_1 != 0)
+                       RTE_LOG(ERR, EAL,
+                       "Failed to set thread name for interrupt handling\n");
+       }
 
        return -ret;
 }