[root@localhost ring_test]# ps -Leo pid,tid,args:30,psr,comm | grep dpdk_test 47138 47138 ./build/app/dpdk_test -c 0x3f 0 dpdk_test 47138 47139 ./build/app/dpdk_test -c 0x3f 11 eal-intr-thread 47138 47140 ./build/app/dpdk_test -c 0x3f 42 rte_mp_handle 47138 47141 ./build/app/dpdk_test -c 0x3f 1 lcore-slave-1 47138 47142 ./build/app/dpdk_test -c 0x3f 2 lcore-slave-2 47138 47143 ./build/app/dpdk_test -c 0x3f 3 lcore-slave-3 47138 47144 ./build/app/dpdk_test -c 0x3f 4 lcore-slave-4 47138 47145 ./build/app/dpdk_test -c 0x3f 5 lcore-slave-5 47729 47729 grep --color=auto dpdk_test 3 grep
[root@localhost ring_test]# ps -Leo pid,tid,args:30,psr,comm | grep dpdk_test 47138 47138 ./build/app/dpdk_test -c 0x3f 0 dpdk_test 47138 47139 ./build/app/dpdk_test -c 0x3f 11 eal-intr-thread 47138 47140 ./build/app/dpdk_test -c 0x3f 42 rte_mp_handle 47138 47141 ./build/app/dpdk_test -c 0x3f 1 lcore-slave-1 47138 47142 ./build/app/dpdk_test -c 0x3f 2 lcore-slave-2 47138 47143 ./build/app/dpdk_test -c 0x3f 3 lcore-slave-3 47138 47144 ./build/app/dpdk_test -c 0x3f 4 lcore-slave-4 47138 47145 ./build/app/dpdk_test -c 0x3f 5 lcore-slave-5 47729 47729 grep --color=auto dpdk_test 3 grep [root@localhost ring_test]# pstack 47145 Thread 1 (process 47145): #0 0x0000ffffab63a9c4 in nanosleep () at ../sysdeps/unix/syscall-template.S:83 #1 0x0000ffffab66703c in usleep (useconds=<optimized out>) at ../sysdeps/unix/sysv/linux/usleep.c:32 #2 0x00000000004651a0 in lcore_recv () #3 0x00000000005917d8 in eal_thread_loop (arg=0x0) at /data1/dpdk-19.11/lib/librte_eal/linux/eal/eal_thread.c:153 #4 0x0000ffffab727d38 in start_thread (arg=0xffffa84dd910) at pthread_create.c:309 #5 0x0000ffffab66f5f0 in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:91 [root@localhost ring_test]# pstack 47141 Thread 1 (process 47141): #0 0x0000ffffab72f3a8 in read () at ../sysdeps/unix/syscall-template.S:83 #1 0x0000000000591650 in eal_thread_loop (arg=0x0) at /data1/dpdk-19.11/lib/librte_eal/linux/eal/eal_thread.c:133 #2 0x0000ffffab727d38 in start_thread (arg=0xffffaa51d910) at pthread_create.c:309 #3 0x0000ffffab66f5f0 in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:91 [root@localhost ring_test]# pstack 47142 Thread 1 (process 47142): #0 0x0000ffffab72f3a8 in read () at ../sysdeps/unix/syscall-template.S:83 #1 0x0000000000591650 in eal_thread_loop (arg=0x0) at /data1/dpdk-19.11/lib/librte_eal/linux/eal/eal_thread.c:133 #2 0x0000ffffab727d38 in start_thread (arg=0xffffa9d0d910) at pthread_create.c:309 #3 0x0000ffffab66f5f0 in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:91 [root@localhost ring_test]# pstack 47143 Thread 1 (process 47143): #0 0x0000ffffab72f3a8 in read () at ../sysdeps/unix/syscall-template.S:83 #1 0x0000000000591650 in eal_thread_loop (arg=0x0) at /data1/dpdk-19.11/lib/librte_eal/linux/eal/eal_thread.c:133 #2 0x0000ffffab727d38 in start_thread (arg=0xffffa94fd910) at pthread_create.c:309 #3 0x0000ffffab66f5f0 in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:91 [root@localhost ring_test]# pstack 47144 Thread 1 (process 47144): #0 0x0000ffffab72f3a8 in read () at ../sysdeps/unix/syscall-template.S:83 #1 0x0000000000591650 in eal_thread_loop (arg=0x0) at /data1/dpdk-19.11/lib/librte_eal/linux/eal/eal_thread.c:133 #2 0x0000ffffab727d38 in start_thread (arg=0xffffa8ced910) at pthread_create.c:309 #3 0x0000ffffab66f5f0 in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:91 [root@localhost ring_test]# pstack 47145 Thread 1 (process 47145): #0 0x0000ffffab63a9c4 in nanosleep () at ../sysdeps/unix/syscall-template.S:83 #1 0x0000ffffab66703c in usleep (useconds=<optimized out>) at ../sysdeps/unix/sysv/linux/usleep.c:32 #2 0x00000000004651a0 in lcore_recv () #3 0x00000000005917d8 in eal_thread_loop (arg=0x0) at /data1/dpdk-19.11/lib/librte_eal/linux/eal/eal_thread.c:153 #4 0x0000ffffab727d38 in start_thread (arg=0xffffa84dd910) at pthread_create.c:309 #5 0x0000ffffab66f5f0 in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:91 [root@localhost ring_test]#
#include <stdio.h> #include <unistd.h> #include <rte_memory.h> #include <rte_ring.h> #define RING_SIZE 64 struct lcore_params { struct rte_ring *send_ring, *recv_ring; }; struct data { uint32_t value; }; static int lcore_recv(struct lcore_params *p) { unsigned lcore_id = rte_lcore_id(); printf("Starting core %u ", lcore_id); void * vp; while (rte_ring_dequeue(p->send_ring, &vp) != 0){ usleep(5); } struct data * d = (struct data *) vp; printf("core %u: Received %d ", lcore_id, d->value); d->value ++; rte_ring_enqueue(p->recv_ring, (void *)d); return 0; } static void enqueue_sample_data(struct rte_ring * ring) { int i; uint32_t values[4] = {1, 3, 5, 8}; for (i = 0; i < 4; ++i) { struct data * d = malloc(sizeof(struct data)); d->value = values[i]; rte_ring_enqueue(ring, (void*)d); } } static void print_ring(struct rte_ring * ring) { struct data * d; while (rte_ring_dequeue(ring, (void *)&d) == 0) { printf("DEQ-DATA:%d ", d->value); free(d); } } int main(int argc, char **argv) { int ret; unsigned lcore_id; ret = rte_eal_init(argc, argv); if (ret < 0) rte_exit(EXIT_FAILURE, "Cannot init EAL "); struct lcore_params params; params.send_ring = rte_ring_create("R1", RING_SIZE, SOCKET_ID_ANY, 0/*RING_F_SP_ENQ*/); if (!params.send_ring) { rte_exit(EXIT_FAILURE, "Problem getting sending ring "); } params.recv_ring = rte_ring_create("R2", RING_SIZE, SOCKET_ID_ANY, 0/*RING_F_SC_DEQ*/); if (!params.recv_ring) { rte_exit(EXIT_FAILURE, "Problem getting receiving ring "); } enqueue_sample_data(params.send_ring); printf("Starting lcores. "); RTE_LCORE_FOREACH_SLAVE(lcore_id) { rte_eal_remote_launch((lcore_function_t*)lcore_recv, ¶ms, lcore_id); } printf("Waiting for lcores to finish. "); rte_eal_mp_wait_lcore(); print_ring(params.recv_ring); return 0; }
1、开了6个线程,
./build/app/dpdk_test -c 0x3f EAL: Detected 128 lcore(s) EAL: Detected 4 NUMA nodes EAL: Multi-process socket /var/run/dpdk/rte/mp_socket EAL: Selected IOVA mode 'PA' EAL: No available hugepages reported in hugepages-2048kB EAL: Probing VFIO support... EAL: VFIO support initialized EAL: PCI device 0000:05:00.0 on NUMA socket 0 EAL: probe driver: 19e5:200 net_hinic net_hinic: Initializing pf hinic-0000:05:00.0 in primary process net_hinic: Device 0000:05:00.0 hwif attribute: net_hinic: func_idx:0, p2p_idx:0, pciintf_idx:0, vf_in_pf:0, ppf_idx:0, global_vf_id:15, func_type:2 net_hinic: num_aeqs:4, num_ceqs:4, num_irqs:32, dma_attr:2 net_hinic: API CMD poll status timeout net_hinic: chain type: 0x7 net_hinic: chain hw cpld error: 0x1 net_hinic: chain hw check error: 0x0 net_hinic: chain hw current fsm: 0x0 net_hinic: chain hw current ci: 0x0 net_hinic: Chain hw current pi: 0x1 net_hinic: Send msg to mgmt failed net_hinic: Failed to get board info, err: -110, status: 0x0, out size: 0x0 net_hinic: Check card workmode failed, dev_name: 0000:05:00.0 net_hinic: Create nic device failed, dev_name: 0000:05:00.0 net_hinic: Initialize 0000:05:00.0 in primary failed EAL: Requested device 0000:05:00.0 cannot be used EAL: PCI device 0000:06:00.0 on NUMA socket 0 EAL: probe driver: 19e5:200 net_hinic EAL: using IOMMU type 1 (Type 1) net_hinic: Initializing pf hinic-0000:06:00.0 in primary process net_hinic: Device 0000:06:00.0 hwif attribute: net_hinic: func_idx:1, p2p_idx:1, pciintf_idx:0, vf_in_pf:0, ppf_idx:0, global_vf_id:135, func_type:0 net_hinic: num_aeqs:4, num_ceqs:4, num_irqs:32, dma_attr:2 net_hinic: Get public resource capability: net_hinic: host_id: 0x0, ep_id: 0x1, intr_type: 0x0, max_cos_id: 0x7, er_id: 0x1, port_id: 0x1 net_hinic: host_total_function: 0xf2, host_oq_id_mask_val: 0x8, max_vf: 0x78 net_hinic: pf_num: 0x2, pf_id_start: 0x0, vf_num: 0xf0, vf_id_start: 0x10 net_hinic: Get l2nic resource capability: net_hinic: max_sqs: 0x10, max_rqs: 0x10, vf_max_sqs: 0x4, vf_max_rqs: 0x4 net_hinic: Initialize 0000:06:00.0 in primary successfully EAL: PCI device 0000:7d:00.0 on NUMA socket 0 EAL: probe driver: 19e5:a222 net_hns3 EAL: PCI device 0000:7d:00.1 on NUMA socket 0 EAL: probe driver: 19e5:a221 net_hns3 EAL: PCI device 0000:7d:00.2 on NUMA socket 0 EAL: probe driver: 19e5:a222 net_hns3 EAL: PCI device 0000:7d:00.3 on NUMA socket 0 EAL: probe driver: 19e5:a221 net_hns3 Starting lcores. Starting core 1 core 1: Received 1 Starting core 2 core 2: Received 3 Starting core 3 core 3: Received 5 Starting core 4 core 4: Received 8 Starting core 5 Waiting for lcores to finish. ----------------卡死了
[root@localhost ring_test]# ps -Leo pid,tid,args:30,psr,comm | grep dpdk_tes 50607 50607 ./build/app/dpdk_test -c 0x3f 0 dpdk_test 50607 50608 ./build/app/dpdk_test -c 0x3f 36 eal-intr-thread 50607 50609 ./build/app/dpdk_test -c 0x3f 7 rte_mp_handle 50607 50610 ./build/app/dpdk_test -c 0x3f 1 lcore-slave-1 50607 50611 ./build/app/dpdk_test -c 0x3f 2 lcore-slave-2 50607 50612 ./build/app/dpdk_test -c 0x3f 3 lcore-slave-3 50607 50613 ./build/app/dpdk_test -c 0x3f 4 lcore-slave-4 50607 50614 ./build/app/dpdk_test -c 0x3f 5 lcore-slave-5 51071 51071 grep --color=auto dpdk_tes 5 grep [root@localhost ring_test]# pstack 50609 Thread 1 (process 50609): #0 0x0000ffff9fdcf928 in recvmsg () at ../sysdeps/unix/syscall-template.S:83 #1 0x00000000005abd78 in read_msg (m=0xffff9f3dcf40, s=0xffff9f3dced0) at /data1/dpdk-19.11/lib/librte_eal/common/eal_common_proc.c:279 #2 0x00000000005ac190 in mp_handle (arg=0x0) at /data1/dpdk-19.11/lib/librte_eal/common/eal_common_proc.c:380 #3 0x00000000005ab7bc in rte_thread_init (arg=0xa071810) at /data1/dpdk-19.11/lib/librte_eal/common/eal_common_thread.c:165 #4 0x0000ffff9fdc7d38 in start_thread (arg=0xffff9f3dd910) at pthread_create.c:309 #5 0x0000ffff9fd0f5f0 in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:91