[dpdk-dev,v4,2/2] app/testpmd: improve handling of multiprocess

Message ID 1474974783-4861-3-git-send-email-marcinx.kerlin@intel.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Marcin Kerlin Sept. 27, 2016, 11:13 a.m. UTC
  Added lookup for pool name because secondary process should attach to
mempool created by primary process rather than create new one.

Added function free_shared_dev_data() used at the exit of the testpmd.
This causes detach devices data from array rte_eth_dev_data[] shared
between all processes. This allows to have a up-to-date list of devices
data and run again secondary application with the same name.

Signed-off-by: Marcin Kerlin <marcinx.kerlin@intel.com>
---
 app/test-pmd/testpmd.c | 36 ++++++++++++++++++++++++++++++++++--
 app/test-pmd/testpmd.h |  1 +
 2 files changed, 35 insertions(+), 2 deletions(-)
  

Comments

Pattan, Reshma Sept. 28, 2016, 10:57 a.m. UTC | #1
Hi,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Marcin Kerlin
> Sent: Tuesday, September 27, 2016 12:13 PM
> To: dev@dpdk.org
> Cc: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>;
> thomas.monjalon@6wind.com; Kerlin, MarcinX <marcinx.kerlin@intel.com>
> Subject: [dpdk-dev] [PATCH v4 2/2] app/testpmd: improve handling of
> multiprocess
> 

Check patch issues for lines over 80. Please run check patch for next versions

WARNING:LONG_LINE: line over 80 characters
#40: FILE: app/test-pmd/testpmd.c:457:
+                               rte_mp = rte_pktmbuf_pool_create(pool_name, nb_mbuf,

WARNING:LONG_LINE: line over 80 characters
#41: FILE: app/test-pmd/testpmd.c:458:
+                                               mb_mempool_cache, 0, mbuf_seg_size, socket_id);

total: 0 errors, 2 warnings, 61 lines checked

Thanks,
Reshma
  
Marcin Kerlin Sept. 28, 2016, 11:34 a.m. UTC | #2
Hi

> -----Original Message-----
> From: Pattan, Reshma
> Sent: Wednesday, September 28, 2016 12:58 PM
> To: Kerlin, MarcinX <marcinx.kerlin@intel.com>; dev@dpdk.org
> Cc: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>;
> thomas.monjalon@6wind.com; Kerlin, MarcinX <marcinx.kerlin@intel.com>
> Subject: RE: [dpdk-dev] [PATCH v4 2/2] app/testpmd: improve handling of
> multiprocess
> 
> Hi,
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Marcin Kerlin
> > Sent: Tuesday, September 27, 2016 12:13 PM
> > To: dev@dpdk.org
> > Cc: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>;
> > thomas.monjalon@6wind.com; Kerlin, MarcinX <marcinx.kerlin@intel.com>
> > Subject: [dpdk-dev] [PATCH v4 2/2] app/testpmd: improve handling of
> > multiprocess
> >
> 
> Check patch issues for lines over 80. Please run check patch for next versions
> 
> WARNING:LONG_LINE: line over 80 characters
> #40: FILE: app/test-pmd/testpmd.c:457:
> +                               rte_mp =
> + rte_pktmbuf_pool_create(pool_name, nb_mbuf,
> 
> WARNING:LONG_LINE: line over 80 characters
> #41: FILE: app/test-pmd/testpmd.c:458:
> +                                               mb_mempool_cache, 0,
> + mbuf_seg_size, socket_id);
> 
> total: 0 errors, 2 warnings, 61 lines checked

I did checkpatch test before and everything is fine if you look to source code. 

Checkpatch interprets tab as 8 chars but should as 4. Everything is in the 80 characters.

Regards,
Marcin
> 
> Thanks,
> Reshma
  
Pattan, Reshma Sept. 28, 2016, 12:08 p.m. UTC | #3
Hi,

> -----Original Message-----
> From: Kerlin, MarcinX
> Sent: Wednesday, September 28, 2016 12:35 PM
> To: Pattan, Reshma <reshma.pattan@intel.com>; dev@dpdk.org
> Cc: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>;
> thomas.monjalon@6wind.com
> Subject: RE: [dpdk-dev] [PATCH v4 2/2] app/testpmd: improve handling of
> multiprocess
> 
> Hi
> I did checkpatch test before and everything is fine if you look to source code.
> 
> Checkpatch interprets tab as 8 chars but should as 4. Everything is in the 80
> characters.

Tab  should  be 8 characters wide as per DDK coding guidelines.
"Line length is recommended to be not more than 80 characters, including comments. [Tab stop size should be assumed to be 8-characters wide"
http://dpdk.org/doc/guides/contributing/coding_style.html

Thanks,
Reshma
  

Patch

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index e2403c3..6418cf2 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -452,8 +452,10 @@  mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf,
 			rte_mempool_obj_iter(rte_mp, rte_pktmbuf_init, NULL);
 		} else {
 			/* wrapper to rte_mempool_create() */
-			rte_mp = rte_pktmbuf_pool_create(pool_name, nb_mbuf,
-				mb_mempool_cache, 0, mbuf_seg_size, socket_id);
+			rte_mp = rte_mempool_lookup(pool_name);
+			if (rte_mp == NULL)
+				rte_mp = rte_pktmbuf_pool_create(pool_name, nb_mbuf,
+						mb_mempool_cache, 0, mbuf_seg_size, socket_id);
 		}
 	}
 
@@ -1611,6 +1613,35 @@  detach_port(uint8_t port_id)
 	return;
 }
 
+void free_shared_dev_data(portid_t pid)
+{
+	portid_t pi;
+
+	if (port_id_is_invalid(pid, ENABLED_WARN))
+		return;
+
+	/* free data only if the secondary process exits */
+	if (rte_eal_process_type() != RTE_PROC_SECONDARY)
+		return;
+
+	printf("Cleaning device data...\n");
+
+	FOREACH_PORT(pi, ports)
+	{
+		if (pid != pi && pid != (portid_t) RTE_PORT_ALL)
+			continue;
+
+		if (!port_is_closed(pi)) {
+			printf("Port %d is not closed now\n", pi);
+			continue;
+		}
+
+		if (rte_eth_dev_release_dev_data(pi) < 0)
+			return;
+	}
+	printf("Done\n");
+}
+
 void
 pmd_test_exit(void)
 {
@@ -1626,6 +1657,7 @@  pmd_test_exit(void)
 			fflush(stdout);
 			stop_port(pt_id);
 			close_port(pt_id);
+			free_shared_dev_data(pt_id);
 		}
 	}
 	printf("\nBye...\n");
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 2b281cc..3915a06 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -553,6 +553,7 @@  void attach_port(char *identifier);
 void detach_port(uint8_t port_id);
 int all_ports_stopped(void);
 int port_is_started(portid_t port_id);
+void free_shared_dev_data(portid_t pid);
 void pmd_test_exit(void);
 void fdir_get_infos(portid_t port_id);
 void fdir_set_flex_mask(portid_t port_id,