@@ -641,6 +641,21 @@ static inline bool sch_socket_match(int cpu_socket, int dev_socket,
641
641
return mt_socket_match (cpu_socket , dev_socket );
642
642
}
643
643
644
+ /*
645
+ * check if the lcore has not been properly released by previous(currently dead) process,
646
+ * if so, clean it up
647
+ */
648
+ static void lcore_shm_check_and_clean (struct mt_lcore_shm_entry * shm_entry ,
649
+ struct mt_user_info * info ) {
650
+ if (!shm_entry -> active ) return ;
651
+ struct mt_user_info * u_info = & shm_entry -> u_info ;
652
+ if (0 != strncmp (u_info -> hostname , info -> hostname , sizeof (u_info -> hostname ))) return ;
653
+ if (0 != strncmp (u_info -> user , info -> user , sizeof (u_info -> user ))) return ;
654
+ if (kill (shm_entry -> pid , 0 ) != 0 ) {
655
+ shm_entry -> active = false;
656
+ }
657
+ }
658
+
644
659
int mt_sch_get_lcore (struct mtl_main_impl * impl , unsigned int * lcore ,
645
660
enum mt_lcore_type type , int socket ) {
646
661
unsigned int cur_lcore ;
@@ -690,6 +705,7 @@ int mt_sch_get_lcore(struct mtl_main_impl* impl, unsigned int* lcore,
690
705
691
706
if ((cur_lcore < RTE_MAX_LCORE ) &&
692
707
sch_socket_match (rte_lcore_to_socket_id (cur_lcore ), socket , skip_numa_check )) {
708
+ lcore_shm_check_and_clean (shm_entry , info );
693
709
if (!shm_entry -> active ) {
694
710
* lcore = cur_lcore ;
695
711
shm_entry -> active = true;
0 commit comments