Skip to content

Commit 80565df

Browse files
committed
Add: Implement lcore shared memory cleanup check
1 parent e62c41b commit 80565df

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/src/mt_sch.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,21 @@ static inline bool sch_socket_match(int cpu_socket, int dev_socket,
641641
return mt_socket_match(cpu_socket, dev_socket);
642642
}
643643

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+
644659
int mt_sch_get_lcore(struct mtl_main_impl* impl, unsigned int* lcore,
645660
enum mt_lcore_type type, int socket) {
646661
unsigned int cur_lcore;
@@ -690,6 +705,7 @@ int mt_sch_get_lcore(struct mtl_main_impl* impl, unsigned int* lcore,
690705

691706
if ((cur_lcore < RTE_MAX_LCORE) &&
692707
sch_socket_match(rte_lcore_to_socket_id(cur_lcore), socket, skip_numa_check)) {
708+
lcore_shm_check_and_clean(shm_entry, info);
693709
if (!shm_entry->active) {
694710
*lcore = cur_lcore;
695711
shm_entry->active = true;

0 commit comments

Comments
 (0)