eal: notify secondaries on primary exit
cover eal: notify secondaries on primary exit
Bugzilla 1942: when a primary process exits cleanly, secondary processes other than testpmd do not get notified. The notification mechanism added in 25.11 was placed in testpmd and used rte_mp_request_sync() with a testpmd-specific action name, so any non-testpmd secondary (dpdk-dumpcap, dpdk-pdump, dpdk-procinfo, or out-of-tree consumers) would log "Cannot find action: mp_testpmd" and the primary would block on the 5 second request timeout.
Putting application-specific IPC actions on a broadcast request path is the wrong layer. Notification of primary exit is something every secondary needs and should come from EAL, not from each application.
Patch 1 reverts the testpmd-side mechanism (commit f96273c8e9d3). The secondary-side primary alive monitor (enable_primary_monitor) is preserved and continues to handle detection of primary exit via the existing alarm-based polling of rte_eal_primary_proc_alive().
Patch 2 adds a generic EAL-level notification. On primary cleanup, rte_mp_channel_cleanup() broadcasts an MP_REQ_QUIT message to all known secondaries via rte_mp_sendmsg(). Secondaries register an internal action handler that tears down their own MP channel on receipt. No new public API; no application changes required for any secondary, in-tree or out.
This is the minimum fix suitable for backport to 25.11 stable. It addresses the clean exit case. The crash case (primary killed or signaled) continues to be handled by the existing rte_eal_primary_proc_alive() polling on the secondary side, which detects the primary's release of the config file lock.
A more complete solution using a connected socket type (SOCK_SEQPACKET) is planned since that can handle both planned and forced exiting of the primary.
Tested with testpmd (primary) and dpdk-dumpcap, dpdk-pdump, dpdk-procinfo (secondaries).
Stephen Hemminger (2):
Revert "app/testpmd: stop forwarding in secondary process"
eal: notify secondary on primary exit
app/test-pmd/testpmd.c | 103 ++----------------------------- lib/eal/common/eal_common_proc.c | 51 ++++++++++++++- 2 files changed, 53 insertions(+), 101 deletions(-)
Signature · 1 line
2.53.0
PATCH 1/2 Revert "app/testpmd: stop forwarding in secondary process"
Testpmd must not assume that the secondary process is testpmd. The notification needs to be done by EAL.
This reverts commit f96273c8e9d39e472bb07acc05e493b1e712e51b.
Bugzilla ID: 1942
Cc: [email protected]
--- app/test-pmd/testpmd.c | 103 ++--------------------------------------- 1 file changed, 4 insertions(+), 99 deletions(-)
app/test-pmd/testpmd.c +4 -99
@@ -3716,83 +3716,6 @@ detach_devargs(char *identifier)rte_devargs_reset (&da); } -#ifndef RTE_EXEC_ENV_WINDOWS - -enum testpmd_req_type { -TESTPMD_REQ_TYPE_EXIT , -}; - -struct testpmd_mp_req { -enum testpmd_req_type t; -}; - -struct testpmd_mp_resp { -int result; -}; - -#define TESTPMD_MP "mp_testpmd" - -/* Send reply to this peer when testpmd exits */ -static RTE_ATOMIC (const char *) primary_name; - -static void -reply_to_primary (const char *peer,int result) -{ -struct rte_mp_msg reply = { }; -struct testpmd_mp_resp *resp = (struct testpmd_mp_resp *) &reply.param; - -strlcpy (reply.name,TESTPMD_MP ,RTE_MP_MAX_NAME_LEN ); - reply.len_param =sizeof (*resp); - resp->result = result; - -printf ("Replying %d to primary\n" , result); -fflush (stdout); - -if (rte_mp_reply (&reply, peer) <0 ) -printf ("Failed to send response to primary:%s" ,strerror (rte_errno)); -} - -/* Primary process is exiting, stop secondary process */ -static void -pmd_notify_secondary (void ) -{ -struct testpmd_mp_req request = { - .t =TESTPMD_REQ_TYPE_EXIT , - }; -struct rte_mp_msg mp_req = { - .name =TESTPMD_MP , - .len_param =sizeof (request), - }; -struct rte_mp_reply reply; -struct timespec ts = {.tv_sec =5 , .tv_nsec =0 }; - -printf ("\nPrimary: Sending 'stop_req' request to secondary...\n" ); -fflush (stdout); - -memcpy (mp_req.param, &request,sizeof (request)); -rte_mp_request_sync (&mp_req, &reply, &ts); -} - -static int -handle_testpmd_request (const struct rte_mp_msg *request,const void *peer) -{ -const struct testpmd_mp_req *req = (const struct testpmd_mp_req *)request->param; - -if (req->t ==TESTPMD_REQ_TYPE_EXIT ) { -printf ("\nReceived notification of primary exiting\n" ); -fflush (stdout); - -/* Response is sent after forwarding loop exits */ -rte_atomic_store_explicit (&primary_name, peer, rte_memory_order_relaxed); - -kill (getpid (),SIGINT ); - }else { -reply_to_primary (peer, -EINVAL ); - } -return 0 ; -} -#endif -void pmd_test_exit (void ) {
@@ -3804,10 +3727,6 @@ pmd_test_exit(void)stop_packet_forwarding ();#ifndef RTE_EXEC_ENV_WINDOWS -/* Tell secondary to exit */ -if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) -pmd_notify_secondary (); -for (i =0 ; i <RTE_DIM (mempools) ; i++) {if (mempools[i]) {if (mp_alloc_type ==MP_ALLOC_ANON )
@@ -4623,12 +4542,9 @@ main(int argc, char** argv) rte_strerror(rte_errno));#ifndef RTE_EXEC_ENV_WINDOWS -if (rte_eal_process_type () ==RTE_PROC_SECONDARY ) { -if (enable_primary_monitor () <0 ) -rte_exit (EXIT_FAILURE ,"Cannot setup primary monitor" ); -if (rte_mp_action_register (TESTPMD_MP , handle_testpmd_request) <0 ) -rte_exit (EXIT_FAILURE ,"Failed to register message action\n" ); - } +if (rte_eal_process_type () ==RTE_PROC_SECONDARY && +enable_primary_monitor () <0 ) +rte_exit (EXIT_FAILURE ,"Cannot setup primary monitor" );#endif /* allocate port structures, and init them */
@@ -4830,23 +4746,12 @@ main(int argc, char** argv) }#ifndef RTE_EXEC_ENV_WINDOWS -if (rte_eal_process_type () ==RTE_PROC_SECONDARY ) { +if (rte_eal_process_type () ==RTE_PROC_SECONDARY )disable_primary_monitor (); -rte_mp_action_unregister (TESTPMD_MP ); - }#endif pmd_test_exit (); -#ifndef RTE_EXEC_ENV_WINDOWS -if (rte_eal_process_type () ==RTE_PROC_SECONDARY ) { -const char *peer =rte_atomic_exchange_explicit (&primary_name,NULL , - rte_memory_order_relaxed); -if (peer) -reply_to_primary (peer,0 ); - } -#endif -#ifdef RTE_LIB_PDUMP /* uninitialize packet capture framework */ rte_pdump_uninit ();
Signature · 1 line
2.53.0
Re: [PATCH 1/2] Revert "app/testpmd: stop forwarding in secondary process"
Quoted 10 lines · Stephen Hemminger
Testpmd must not assume that the secondary process is testpmd. The notification needs to be done by EAL.
This reverts commit
f96273c8e9d39e472bb07acc05e493b1e712e51b.Bugzilla ID: 1942
Cc: [email protected]Signed-off-by Stephen Hemminger <[email protected]>---
Signature · 2 lines
Thanks, Anatoly
PATCH 2/2 eal: notify secondary on primary exit
In reply to Stephen HemmingerWhen primary process exits, it should notify the secondary processes. This allows for clean shutdown and eliminates need for MP handling in applications (such as test-pmd).
Bugzilla ID: 1942
--- lib/eal/common/eal_common_proc.c | 51 ++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-)
lib/eal/common/eal_common_proc.c +49 -2
@@ -60,6 +60,15 @@ enum mp_type { MP_IGN, /* Response telling requester to ignore this response */ }; +/* Message sent from primary EAL to secondary EAL */ +#define EAL_MP "mp_eal" +struct eal_mp_req { +enum { +MP_REQ_NOP =0 , +MP_REQ_QUIT , + } type; +}; +struct mp_msg_internal {int type;struct rte_mp_msg msg;
@@ -614,6 +623,25 @@ close_socket_fd(int fd)unlink (path); } +/* callback in secondary when primary has exited */ +static int +mp_primary_exited(const struct rte_mp_msg *msg, const void *peer __rte_unused) +{ +const struct eal_mp_req *req; + +if (msg->len_param !=sizeof (*req)) { +EAL_LOG (ERR ,"invalid request from primary" ); +return -EINVAL ; + } + + req = (const struct eal_mp_req *)msg->param; +if (req->type ==MP_REQ_QUIT ) +rte_mp_channel_cleanup (); + +/* no reply needed */ +return 0 ; +} +int rte_mp_channel_init (void ) {
@@ -661,6 +689,10 @@ rte_mp_channel_init(void)return -1 ; } +/* listen for quit message from primary */ +if (rte_eal_process_type () ==RTE_PROC_SECONDARY ) +rte_mp_action_register (EAL_MP , mp_primary_exited); +if (rte_thread_create_internal_control (&mp_handle_tid,"mp-msg" , mp_handle,NULL ) <0 ) { EAL_LOG(ERR, "failed to create mp thread: %s",
@@ -682,12 +714,27 @@ rte_mp_channel_cleanup(void) {int fd; +/* Primary exiting, tell all secondary processes */ +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) { +struct rte_mp_msg msg = { .name =EAL_MP }; +struct eal_mp_req req = { .type =MP_REQ_QUIT }; + +memcpy (&msg.param, &req,sizeof (req)); + msg.len_param =sizeof (req); + +rte_mp_sendmsg (&msg); + }else { +rte_mp_action_unregister (EAL_MP ); + } + fd =rte_atomic_exchange_explicit (&mp_fd,-1 , rte_memory_order_relaxed);if (fd <0 )return ; -pthread_cancel ((pthread_t )mp_handle_tid.opaque_id); -rte_thread_join (mp_handle_tid,NULL ); +if (pthread_self () != (pthread_t )mp_handle_tid.opaque_id) { +pthread_cancel ((pthread_t )mp_handle_tid.opaque_id); +rte_thread_join (mp_handle_tid,NULL ); + }close_socket_fd (fd); }
Signature · 1 line
2.53.0
Re: [PATCH 2/2] eal: notify secondary on primary exit
Quoted 10 lines · Stephen Hemminger
When primary process exits, it should notify the secondary processes. This allows for clean shutdown and eliminates need for MP handling in applications (such as test-pmd).
Bugzilla ID: 1942
Fixes 85d6815fa6d0 ("eal: close multi-process socket during cleanup")Signed-off-by Stephen Hemminger <[email protected]>---
It would be cool to have some kind of event for this so that processes could react to primary/secondary going up/down, but this is 1) way beyond scope of this patch, and 2) of dubious usefulness given that the only thing testpmd did with the information was to stop forwarding.
Signature · 2 lines
Thanks, Anatoly
Quoted 38 lines · On Thu, 7 May 2026 13:58:35 -0700 Stephen Hemminger…
Bugzilla 1942: when a primary process exits cleanly, secondary processes other than testpmd do not get notified. The notification mechanism added in 25.11 was placed in testpmd and used
rte_mp_request_sync()with a testpmd-specific action name, so any non-testpmd secondary (dpdk-dumpcap, dpdk-pdump, dpdk-procinfo, or out-of-tree consumers) would log "Cannot find action:mp_testpmd" and the primary would block on the 5 second request timeout.Putting application-specific IPC actions on a broadcast request path is the wrong layer. Notification of primary exit is something every secondary needs and should come from EAL, not from each application.
Patch 1 reverts the testpmd-side mechanism (commit
f96273c8e9d3). The secondary-side primary alive monitor (enable_primary_monitor) is preserved and continues to handle detection of primary exit via the existing alarm-based polling ofrte_eal_primary_proc_alive().Patch 2 adds a generic EAL-level notification. On primary cleanup,
rte_mp_channel_cleanup()broadcasts anMP_REQ_QUITmessage to all known secondaries viarte_mp_sendmsg(). Secondaries register an internal action handler that tears down their own MP channel on receipt. No new public API; no application changes required for any secondary, in-tree or out.This is the minimum fix suitable for backport to 25.11 stable. It addresses the clean exit case. The crash case (primary killed or signaled) continues to be handled by the existing
rte_eal_primary_proc_alive()polling on the secondary side, which detects the primary's release of the config file lock.A more complete solution using a connected socket type (
SOCK_SEQPACKET) is planned since that can handle both planned and forced exiting of the primary.Tested with testpmd (primary) and dpdk-dumpcap, dpdk-pdump, dpdk-procinfo (secondaries).
Quoted 8 lines
Stephen Hemminger (2):
Revert "app/testpmd: stop forwarding in secondary process"
eal: notify secondary on primary exitapp/test-pmd/testpmd.c | 103 ++----------------------------- lib/eal/common/eal_common_proc.c | 51 ++++++++++++++- 2 files changed, 53 insertions(+), 101 deletions(-)
This is a real bug fix. Even if AI is being overly wordy in describing it; what it does is move the notification from being testpmd -> testpmd only to a more general primary -> secondary mechanism.
Without it can demonstrate the bug rather trivially with packet capture tools (pdump or dumpcap)
Could this get reviewed?
18/06/2026 18:09, Stephen Hemminger:
Quoted 50 lines
Quoted 38 lines · On Thu, 7 May 2026 13:58:35 -0700 Stephen Hemminger…
Bugzilla 1942: when a primary process exits cleanly, secondary processes other than testpmd do not get notified. The notification mechanism added in 25.11 was placed in testpmd and used
rte_mp_request_sync()with a testpmd-specific action name, so any non-testpmd secondary (dpdk-dumpcap, dpdk-pdump, dpdk-procinfo, or out-of-tree consumers) would log "Cannot find action:mp_testpmd" and the primary would block on the 5 second request timeout.Putting application-specific IPC actions on a broadcast request path is the wrong layer. Notification of primary exit is something every secondary needs and should come from EAL, not from each application.
Patch 1 reverts the testpmd-side mechanism (commit
f96273c8e9d3). The secondary-side primary alive monitor (enable_primary_monitor) is preserved and continues to handle detection of primary exit via the existing alarm-based polling ofrte_eal_primary_proc_alive().Patch 2 adds a generic EAL-level notification. On primary cleanup,
rte_mp_channel_cleanup()broadcasts anMP_REQ_QUITmessage to all known secondaries viarte_mp_sendmsg(). Secondaries register an internal action handler that tears down their own MP channel on receipt. No new public API; no application changes required for any secondary, in-tree or out.This is the minimum fix suitable for backport to 25.11 stable. It addresses the clean exit case. The crash case (primary killed or signaled) continues to be handled by the existing
rte_eal_primary_proc_alive()polling on the secondary side, which detects the primary's release of the config file lock.A more complete solution using a connected socket type (
SOCK_SEQPACKET) is planned since that can handle both planned and forced exiting of the primary.Tested with testpmd (primary) and dpdk-dumpcap, dpdk-pdump, dpdk-procinfo (secondaries).
Quoted 8 lines
Stephen Hemminger (2):
Revert "app/testpmd: stop forwarding in secondary process"
eal: notify secondary on primary exitapp/test-pmd/testpmd.c | 103 ++----------------------------- lib/eal/common/eal_common_proc.c | 51 ++++++++++++++- 2 files changed, 53 insertions(+), 101 deletions(-)
Quoted 8 lines
This is a real bug fix. Even if AI is being overly wordy in describing it; what it does is move the notification from being testpmd -> testpmd only to a more general primary -> secondary mechanism.
Without it can demonstrate the bug rather trivially with packet capture tools (pdump or dumpcap)
Could this get reviewed?
Anatoly reviewed.
Applied, thanks.