From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BBD3346ED2 for ; Fri, 12 Sep 2025 07:59:58 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AE6304065F; Fri, 12 Sep 2025 07:59:58 +0200 (CEST) Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) by mails.dpdk.org (Postfix) with ESMTP id 637E340658 for ; Fri, 12 Sep 2025 07:59:56 +0200 (CEST) Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-8126c6c3564so156462085a.0 for ; Thu, 11 Sep 2025 22:59:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uetpeshawar-edu-pk.20230601.gappssmtp.com; s=20230601; t=1757656796; x=1758261596; darn=dpdk.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Ak2aE0J8X3sGkGV50B1OuA0LkEFwcTaCPXMlio2fep8=; b=KWpeM8FSyCoQgktfvLLG5bT8jy86BI8pAtVoLxa+1ijkAA+Nq1JJTN8MYwyfv6qXBS U38xt0cKAXZQqlqZd1ESWAy0N++sMYGGlma2uYK1LzkBKSNECkgBbrC3X0CsfwbCQTjB tIxsrj0Szpo5nZbLZ1MoyQDAW1L8LrPNOCn0u4883v4I4sdCUto2a03vhDLpSqMbef1f ejYnUOnWIyvKzTBJEu8M54isM+9wv8fSH3WJxT/fsPIDiAXKBjZaa4NIsC/sPyfR7+5Q SPLJLZr7V+GujxibHuv1MJt4VYuGz/AcwIlBLmkRDYWebdORsR3CHKPpAAruWNDWhfk9 qIOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757656796; x=1758261596; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ak2aE0J8X3sGkGV50B1OuA0LkEFwcTaCPXMlio2fep8=; b=uNqBpXmzWt528LaiCjuxETij6shi9Mxxl2NV+sJTscOvQXCEnbnLjnKLaKv5oidrc6 EmQXP4z8lgKxZ8xnXtRh2wm1hRBT3i0oAhflfeU9mMW/YtIRjOPJZVfutaiPGFZlty2z YbwSydqUlmD4wTkQH7lK6dU38U8+4vDyyNz9WJ+oQYqzO+uRuqjRYldHShwgZRFzI46b QQR2wHStdRhUO8jSUVoeHCGQ8tfZyC0mz8JCi9sRUliHYQx7hLCwrqrHtW3dSKOY32rG hgDz3QDh76bIpHQaK69v0YhwNpZX37i9lgLVbP8ogA6yK4sbJwt3vkJL2d5IsXZ/0SEx 6WCw== X-Forwarded-Encrypted: i=1; AJvYcCWzMXV1F25xuJwoGDb+wc/btaseaRtdnphPCXkS6drQ4VWtTuif3GdLLW7ipjm4m9EXACLjx2s=@dpdk.org X-Gm-Message-State: AOJu0Yyu2fhE0l2sxqyZLogW81AQN215UUmwLu1YOT8BuV9u90Q8Nu4Y gXqTH4a4hFwEWKXgESpL0O43bPSwWls/h/skrGQPsXKsdi8xfjcjNLQ9HFk+PBAioyB8g6pGd75 xRlYRIkpeuY5a3pXUGdl6NLAhkzRltnmlvtU9KZRqZQ== X-Gm-Gg: ASbGncu/Az43cohc5sYmIbOFkINCzLF3hNickCrhQHmTAjf1yTSMJzvbhmeHIHkTqes SZMbROMCtguqHV2eZ16gt/M4HyFPkEvw5T7bKiDfv5GDHk9qpDn7IDfmt0XXNjgdBf0CVch6wel C2bDiKkEPz7Dx5DljdNvK2qHP8JwCuM7IVC2e93zoLSWkLtxxFSkMCY2T7kXSXEFusuop8Ny/LY bLTpLETtR84EUUxT0RFWOuLU+w3omq4U4r/ENnP9Do5rMEjqZyhcnw/MtImAhkBGA1bwrL2k3DU dQGkE2dnitUUoBVIwvSZlKac X-Google-Smtp-Source: AGHT+IHCJcIoUx/SvVhucpQ8kHp4lXy38YWOXibzudXyaWe56Jq5XBlJqVKon7N2Dye4VId61mkxyf501+y2WY0XQAY= X-Received: by 2002:a05:620a:7101:b0:815:c19f:d140 with SMTP id af79cd13be357-823fa3f8f50mr268179985a.19.1757656795620; Thu, 11 Sep 2025 22:59:55 -0700 (PDT) MIME-Version: 1.0 References: <20250910110237.460825-1-14pwcse1224@uetpeshawar.edu.pk> <20250911102501.473167-1-14pwcse1224@uetpeshawar.edu.pk> <20250911165058.31fd0101@hermes.local> In-Reply-To: From: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk> Date: Fri, 12 Sep 2025 10:59:43 +0500 X-Gm-Features: AS18NWBjVtToM-sIvd2TvaCtaklmQkmE76qRKfwACBdeABX7Di87unUcVWoyvwQ Message-ID: Subject: Re: [PATCH v2] app/testpmd: stop secondary process fwd_lcores during primary teardown To: Stephen Hemminger Cc: Aman Singh , Anatoly Burakov , Ajit Khaparde , Lijun Ou , Ferruh Yigit , Andrew Rybchenko , dev@dpdk.org, dpdk stable Content-Type: multipart/alternative; boundary="000000000000f0b508063e945cca" X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org --000000000000f0b508063e945cca Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Sep 12, 2025 at 8:27=E2=80=AFAM Khadem Ullah <14pwcse1224@uetpeshaw= ar.edu.pk> wrote: > Hi Stephen, > > On Fri, Sep 12, 2025, 04:51 Stephen Hemminger > wrote: > >> >> Ok, the Windows #ifdef was confusing me then looked more closely. >> This patch is adding a set of rings so that primary and secondary >> can communicate, the adding one command. >> >> The idea is good, but there is a better way to handle this. >> There already exists a way for primary and secondary to communicate >> through the mp service. This is used for hotplug and pdump and probably >> other things as well. >> > Yeah, agree. Testpmd have also hutplug callbacks, I have tried that too, > but it is in lower layer to call any stopping fwd_engines. > >> >> The communication can be either way, for example I proposed patches >> to pdump so that primary can tell secondary to participate. >> >> >> https://patchwork.dpdk.org/project/dpdk/patch/20250814165307.12786-7-ste= phen@networkplumber.org/ >> >> This of testpmd can be done in similar way. >> The handler in secondary should be able to act same as >> when SIGINT is received. Set the flag f_exit which will cause the main >> loop to exit. >> >> This can then happen immediately, and the proc monitor alarm function >> is only then needed to handle when primary process crashes. >> > Yeah, we can try that, my only concern is that if it can handle and stop > any numbers of secondary processes fwd_engines as the current solution ca= n > stop. > > Please check the __handle_primary_request in https://elixir.bootlin.com/dpdk/v25.07/source/lib/eal/common/hotplug_mp.c#L= 225 , testpmd is calling this api during hutplug callbacks. I had tried a similar one as proposed in pdump but could not call stop_packet_forwarding from this lower layer as given below. There is only eal_bus_cleanup(), and local_dev_remove support. We only left with the ring solution to used if for IPC as in https://elixir.bootlin.com/dpdk/v25.07/source/examples/multi_process/simple= _mp/main.c#L75 git diff diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 0f58a31eb5..9155453efa 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -72,6 +72,7 @@ #endif #ifdef RTE_NET_MLX5 #include "mlx5_testpmd.h" +#include "hotplug_mp.h" #endif #include "testpmd.h" @@ -3634,6 +3635,11 @@ pmd_test_exit(void) printf("\nStopping port %d...\n", pt_id); fflush(stdout); stop_port(pt_id); + printf("Stopping secondary process...\n"); + struct eal_dev_mp_req req; + memset(&req, 0, sizeof(req)); + req.t =3D ETH_REQ_STOP; //EAL_DEV_REQ_TYPE_DETACH; + eal_dev_hotplug_request_to_secondary(&req); } RTE_ETH_FOREACH_DEV(pt_id) { printf("\nShutting down port %d...\n", pt_id); diff --git a/lib/eal/common/hotplug_mp.c b/lib/eal/common/hotplug_mp.c index 17089ca3db..d324db428f 100644 --- a/lib/eal/common/hotplug_mp.c +++ b/lib/eal/common/hotplug_mp.c @@ -239,6 +239,11 @@ static void __handle_primary_request(void *param) memset(&mp_resp, 0, sizeof(mp_resp)); switch (req->t) { + case ETH_REQ_STOP: + printf("__handle_secondary_request called " + "for secondary processes fwd_engine stopping...\n")= ; + //eal_bus_cleanup(); + break; case EAL_DEV_REQ_TYPE_ATTACH: case EAL_DEV_REQ_TYPE_DETACH_ROLLBACK: ret =3D local_dev_probe(req->devargs, &dev); diff --git a/lib/eal/common/hotplug_mp.h b/lib/eal/common/hotplug_mp.h index 7221284286..7a46285994 100644 --- a/lib/eal/common/hotplug_mp.h +++ b/lib/eal/common/hotplug_mp.h @@ -19,6 +19,7 @@ enum eal_dev_req_type { EAL_DEV_REQ_TYPE_DETACH, EAL_DEV_REQ_TYPE_ATTACH_ROLLBACK, EAL_DEV_REQ_TYPE_DETACH_ROLLBACK, + ETH_REQ_STOP, }; --000000000000f0b508063e945cca Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Fri, Sep 12,= 2025 at 8:27=E2=80=AFAM Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk> wrote:

The communication can be either way, for example I proposed patches
to pdump so that primary can tell secondary to participate.

https://patchwork.dpdk.org/project/dpdk/patch/20250814165307.12786-7= -stephen@networkplumber.org/

This of testpmd can be done in similar way.
The handler in secondary should be able to act same as
when SIGINT is received. Set the flag f_exit which will cause the main
loop to exit.

This can then happen immediately, and the proc monitor alarm function
is only then needed to handle when primary process crashes.
Yeah, we can try that, my only concern is th= at if it can handle and stop any numbers of secondary processes fwd_engines= as the current solution can stop.=C2=A0

<= /div>
Please check the __handle_primary_request in=C2=A0https://elixir.bootlin.com/dpdk/v25.07/source/lib/eal/common/= hotplug_mp.c#L225,=C2=A0
testpmd is calling this api during= =C2=A0hutplug callbacks.=C2=A0
I had tried a similar=C2=A0one= as proposed in pdump but could not call stop_packet_forwarding from this l= ower layer as given below.=C2=A0
There is only eal_bus_cleanup(),= and=C2=A0local_dev_remove=C2=A0support. We only left with the ring solutio= n


git diff
diff --git a/app/tes= t-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 0f58a31eb5..9155453efa 10= 0644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ = -72,6 +72,7 @@
=C2=A0#endif
=C2=A0#ifdef RTE_NET_MLX5
=C2=A0#inclu= de "mlx5_testpmd.h"
+#include "hotplug_mp.h"
=C2= =A0#endif
=C2=A0
=C2=A0#include "testpmd.h"
@@ -3634,6 += 3635,11 @@ pmd_test_exit(void)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 printf("\nStopping port %d.= ..\n", pt_id);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 fflush(stdout);
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 stop_port(pt_id= );
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 printf("Stopping secondary process...\n");
+ =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 stru= ct eal_dev_mp_req req;
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 memset(&req, 0, sizeof(req));
+ =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 r= eq.t =3D ETH_REQ_STOP; //EAL_DEV_REQ_TYPE_DETACH;
+ =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 eal_dev_hotplug_re= quest_to_secondary(&req);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = RTE_ETH_FOREACH_DEV(pt_id) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 printf("\nShutting down port= %d...\n", pt_id);
diff --git a/lib/eal/common/hotplug_mp.c b/lib/e= al/common/hotplug_mp.c
index 17089ca3db..d324db428f 100644
--- a/lib/= eal/common/hotplug_mp.c
+++ b/lib/eal/common/hotplug_mp.c
@@ -239,6 += 239,11 @@ static void __handle_primary_request(void *param)
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 memset(&mp_resp, 0, sizeof(mp_resp));
=C2=A0
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 switch (req->t) {
+ =C2=A0 =C2=A0 =C2=A0 = case ETH_REQ_STOP:
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 pr= intf("__handle_secondary_request called "
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "for secon= dary processes fwd_engine stopping...\n");
+ =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 //eal_bus_cleanup();
+ =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 case EAL_= DEV_REQ_TYPE_ATTACH:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 case EAL_DEV_REQ_TYPE_D= ETACH_ROLLBACK:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = ret =3D local_dev_probe(req->devargs, &dev);
diff --git a/lib/eal= /common/hotplug_mp.h b/lib/eal/common/hotplug_mp.h
index 7221284286..7a4= 6285994 100644
--- a/lib/eal/common/hotplug_mp.h
+++ b/lib/eal/common= /hotplug_mp.h
@@ -19,6 +19,7 @@ enum eal_dev_req_type {
=C2=A0 =C2=A0= =C2=A0 =C2=A0 EAL_DEV_REQ_TYPE_DETACH,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 EAL_= DEV_REQ_TYPE_ATTACH_ROLLBACK,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 EAL_DEV_REQ_TY= PE_DETACH_ROLLBACK,
+ =C2=A0 =C2=A0 =C2=A0 ETH_REQ_STOP,
=C2=A0};
=
=C2=A0


--000000000000f0b508063e945cca--