How to set thread name in dpdk 18.11

226 views Asked by At

in dpdk 17.05 struct lcore_config is public and pthread_t can get by lcore_config[lcore_id].thread_id in 18.11 struct lcore_config is private, how can I get pthread_t for lcore_id?

Problem - I can't set thread name with pthread_setname_np(<pthread_here>, "my_thread_name");

rte_gettid() returns int but I need pthread_t

1

There are 1 answers

0
Vipin Varghese On BEST ANSWER

in DPDK rte_lcore.h the API rte_thread_setname is responsible for setting alternate name rather than DPDK assigned name. In Linux DPDK internally invokes pthread_setname_np.

DPDK version: dpdk-stable-18.11.10 [edit-1] as per the DPDK code base setname if you have glbc > 2.12 glibc version: Ubuntu GLIBC 2.30-0ubuntu2.2

Code modified in C file:

        printf("hello from core %u\n", lcore_id);
        snprintf(name, 100, "hello-%d", lcore_id);
                if (rte_thread_setname( pthread_self(), name) == 0)
                                printf(" thread name %s\n", name);

CFLAGS added to Makefile:

CFLAGS += -DALLOW_EXPERIMENTAL_API

or build using EXTRA_CFLAGS=-DALLOW_EXPERIMENTAL_API make

36986 root      20   0  227916   6996   6024 R 93.8  0.0   0:40.60 helloworld
37004 root      20   0  227916   6996   6024 R 93.8  0.0   0:40.61 lcore-slave-1
37005 root      20   0  227916   6996   6024 R 93.8  0.0   0:40.61 lcore-slave-2
37006 root      20   0  227916   6996   6024 R 93.8  0.0   0:40.61 lcore-slave-3

After invoking

15326 root      20   0  153312   7728   5976 T   0.0   0.2   0:03.32 hello-0
15327 root      20   0  153312   7728   5976 T   0.0   0.2   0:00.00 eal-intr-thread
15328 root      20   0  153312   7728   5976 T   0.0   0.2   0:00.00 rte_mp_handle
15329 root      20   0  153312   7728   5976 T   0.0   0.2   0:03.32 hello-1
15330 root      20   0  153312   7728   5976 T   0.0   0.2   0:03.32 hello-2
15331 root      20   0  153312   7728   5976 T   0.0   0.2   0:03.32 hello-3