DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v7 00/11] eal: replace calls to rte_panic and refrain from new instances
@ 2018-04-24 22:16 Arnon Warshavsky
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 01/11] crypto/dpaa: replace rte_panic instances in crypto/dpaa driver Arnon Warshavsky
                   ` (11 more replies)
  0 siblings, 12 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-24 22:16 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

The purpose of this patch series is to cleanup the library code
from paths that end up aborting the process,
and move to checking error values, in order to allow the running process
perform an orderly teardown or other mitigation of the event.

This patch modifies the majority of rte_panic calls
under lib and drivers, and replaces them with a log message
and an error return code according to context,
that can be propagated up the call stack.

- Focus was given to the dpdk initialization path
- Some of the panic calls within drivers were left in place where
  the call is from within an interrupt or calls that are
  on the data path,where there is no simple applicative
  route to propagate the error to temination.
  These should be handled by the driver maintainers..
- local void functions with no api were changed to retrun a value
  where needed
- No change took place in example and test files
- No change took place for debug assertions calling panic
- A new function was added to devtools/checkpatches.sh
  in order to prevent new additions of calls to rte_panic
  under lib and drivers.

Keep calm and don't panic

---

v2:
- reformat error messages so that literal string are in the same line
- fix typo in commit message
- add new return code to doxigen of rte_memzone_free()

v3:
- submit  all 13 patches changed and unchanged in the same patchset

v4:
- remove 2 patches that are no more relevant
- fix split literal string in error message
- change return value -1 to enum
- split value and success code in a static function

v5:
- reword commit messages
- revert thread related instances back to panicing
- handle file descriptors with state to reset after eal init failure
  in case re initialization takes place

v6:
- Use pmd log macro rather than rte_log

v7:
- use bond specific , dpaa2 specific and eventdev specific log macros

Arnon Warshavsky (11):
  crypto/dpaa: replace rte_panic instances in crypto/dpaa driver
  bond: replace rte_panic instances in bonding driver
  e1000: replace rte_panic instances in e1000 driver
  ixgbe: replace rte_panic instances in ixgbe driver
  eal: replace rte_panic instances in eventdev
  kni: replace rte_panic instances in kni
  eal: replace rte_panic instances in hugepage_info
  eal: replace rte_panic instances in interrupts thread
  eal: replace rte_panic instances in ethdev
  eal: replace rte_panic instances in init sequence
  devtools: prevent new instances of rte_panic and rte_exit

 devtools/checkpatches.sh                          | 95 +++++++++++++++++++++-
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c       |  8 +-
 drivers/crypto/dpaa_sec/dpaa_sec.c                | 10 ++-
 drivers/net/bonding/rte_eth_bond_8023ad.c         | 29 ++++---
 drivers/net/bonding/rte_eth_bond_8023ad_private.h |  2 +-
 drivers/net/bonding/rte_eth_bond_api.c            | 22 +++--
 drivers/net/bonding/rte_eth_bond_pmd.c            |  9 ++-
 drivers/net/bonding/rte_eth_bond_private.h        |  2 +-
 drivers/net/e1000/e1000_ethdev.h                  |  2 +-
 drivers/net/e1000/igb_ethdev.c                    |  4 +-
 drivers/net/e1000/igb_pf.c                        | 15 ++--
 drivers/net/ixgbe/ixgbe_ethdev.c                  |  6 +-
 drivers/net/ixgbe/ixgbe_ethdev.h                  |  2 +-
 drivers/net/ixgbe/ixgbe_pf.c                      | 15 ++--
 lib/librte_eal/bsdapp/eal/eal.c                   | 78 +++++++++++++-----
 lib/librte_eal/linuxapp/eal/eal.c                 | 97 +++++++++++++++--------
 lib/librte_eal/linuxapp/eal/eal_hugepage_info.c   | 37 ++++++---
 lib/librte_eal/linuxapp/eal/eal_interrupts.c      | 25 ++++--
 lib/librte_ether/rte_ethdev.c                     | 42 +++++++---
 lib/librte_ether/rte_ethdev.h                     |  4 +-
 lib/librte_eventdev/rte_eventdev_pmd_pci.h        |  8 +-
 lib/librte_eventdev/rte_eventdev_pmd_vdev.h       |  8 +-
 lib/librte_kni/rte_kni.c                          | 18 +++--
 lib/librte_kni/rte_kni_fifo.h                     | 11 ++-
 24 files changed, 407 insertions(+), 142 deletions(-)

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v7 01/11] crypto/dpaa: replace rte_panic instances in crypto/dpaa driver
  2018-04-24 22:16 [dpdk-dev] [PATCH v7 00/11] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
@ 2018-04-24 22:16 ` Arnon Warshavsky
  2018-04-26 16:05   ` Kevin Traynor
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 02/11] bond: replace rte_panic instances in bonding driver Arnon Warshavsky
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-24 22:16 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

replace panic calls with log and return value.

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c |  8 +++++---
 drivers/crypto/dpaa_sec/dpaa_sec.c          | 10 ++++++----
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 58cbce8..a78f3a2 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -2883,9 +2883,11 @@ struct rte_security_ops dpaa2_sec_security_ops = {
 					RTE_CACHE_LINE_SIZE,
 					rte_socket_id());
 
-		if (cryptodev->data->dev_private == NULL)
-			rte_panic("Cannot allocate memzone for private "
-				  "device data");
+		if (cryptodev->data->dev_private == NULL) {
+			DPAA_SEC_ERR("%s() Cannot allocate memzone for private device data",
+			__func__);
+			return -ENOMEM;
+		}
 	}
 
 	dpaa2_dev->cryptodev = cryptodev;
diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index e456fd5..a4670bf 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -2352,7 +2352,7 @@ struct rte_security_ops dpaa_sec_security_ops = {
 		}
 	}
 
-	RTE_LOG(INFO, PMD, "%s cryptodev init\n", cryptodev->data->name);
+	DPAA_SEC_INFO("%s cryptodev init\n", cryptodev->data->name);
 	return 0;
 
 init_error:
@@ -2384,9 +2384,11 @@ struct rte_security_ops dpaa_sec_security_ops = {
 					RTE_CACHE_LINE_SIZE,
 					rte_socket_id());
 
-		if (cryptodev->data->dev_private == NULL)
-			rte_panic("Cannot allocate memzone for private "
-					"device data");
+		if (cryptodev->data->dev_private == NULL) {
+			DPAA_SEC_ERR("%s() Cannot allocate memzone for private device data",
+			__func__);
+			return -ENOMEM;
+		}
 	}
 
 	dpaa_dev->crypto_dev = cryptodev;
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v7 02/11] bond: replace rte_panic instances in bonding driver
  2018-04-24 22:16 [dpdk-dev] [PATCH v7 00/11] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 01/11] crypto/dpaa: replace rte_panic instances in crypto/dpaa driver Arnon Warshavsky
@ 2018-04-24 22:16 ` Arnon Warshavsky
  2018-04-24 22:51   ` Stephen Hemminger
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 03/11] e1000: replace rte_panic instances in e1000 driver Arnon Warshavsky
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-24 22:16 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

replace panic calls with log and return value.
Local functions to this file,
changing from void to int are non-abi-breaking

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c       |  2 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c         | 29 ++++++++++++++---------
 drivers/net/bonding/rte_eth_bond_8023ad_private.h |  2 +-
 drivers/net/bonding/rte_eth_bond_api.c            | 22 ++++++++++++-----
 drivers/net/bonding/rte_eth_bond_pmd.c            |  9 ++++---
 drivers/net/bonding/rte_eth_bond_private.h        |  2 +-
 6 files changed, 43 insertions(+), 23 deletions(-)

diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index a78f3a2..a19fb40 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -2884,7 +2884,7 @@ struct rte_security_ops dpaa2_sec_security_ops = {
 					rte_socket_id());
 
 		if (cryptodev->data->dev_private == NULL) {
-			DPAA_SEC_ERR("%s() Cannot allocate memzone for private device data",
+			DPAA2_SEC_ERR("%s() Cannot allocate memzone for private device data",
 			__func__);
 			return -ENOMEM;
 		}
diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
index c452318..308e623 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -893,7 +893,7 @@
 			bond_mode_8023ad_periodic_cb, arg);
 }
 
-void
+int
 bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev,
 				uint16_t slave_id)
 {
@@ -939,7 +939,7 @@
 	timer_cancel(&port->warning_timer);
 
 	if (port->mbuf_pool != NULL)
-		return;
+		return 0;
 
 	RTE_ASSERT(port->rx_ring == NULL);
 	RTE_ASSERT(port->tx_ring == NULL);
@@ -968,8 +968,9 @@
 	/* Any memory allocation failure in initialization is critical because
 	 * resources can't be free, so reinitialization is impossible. */
 	if (port->mbuf_pool == NULL) {
-		rte_panic("Slave %u: Failed to create memory pool '%s': %s\n",
-			slave_id, mem_name, rte_strerror(rte_errno));
+		RTE_BOND_LOG(ERR, "%s() Slave %u: Failed to create memory pool '%s': %s\n",
+			__func__, slave_id, mem_name, rte_strerror(rte_errno));
+		return -1;
 	}
 
 	snprintf(mem_name, RTE_DIM(mem_name), "slave_%u_rx", slave_id);
@@ -977,8 +978,9 @@
 			rte_align32pow2(BOND_MODE_8023AX_SLAVE_RX_PKTS), socket_id, 0);
 
 	if (port->rx_ring == NULL) {
-		rte_panic("Slave %u: Failed to create rx ring '%s': %s\n", slave_id,
-			mem_name, rte_strerror(rte_errno));
+		RTE_BOND_LOG(ERR, "%s() Slave %u: Failed to create rx ring '%s': %s\n",
+			__func__, slave_id, mem_name, rte_strerror(rte_errno));
+		return -1;
 	}
 
 	/* TX ring is at least one pkt longer to make room for marker packet. */
@@ -987,9 +989,12 @@
 			rte_align32pow2(BOND_MODE_8023AX_SLAVE_TX_PKTS + 1), socket_id, 0);
 
 	if (port->tx_ring == NULL) {
-		rte_panic("Slave %u: Failed to create tx ring '%s': %s\n", slave_id,
-			mem_name, rte_strerror(rte_errno));
+		RTE_BOND_LOG(ERR, "%s() Slave %u: Fail to create tx ring '%s': %s\n",
+			__func__, slave_id, mem_name, rte_strerror(rte_errno));
+		return -1;
 	}
+
+	return 0;
 }
 
 int
@@ -1143,9 +1148,11 @@
 	struct bond_dev_private *internals = bond_dev->data->dev_private;
 	uint8_t i;
 
-	for (i = 0; i < internals->active_slave_count; i++)
-		bond_mode_8023ad_activate_slave(bond_dev,
-				internals->active_slaves[i]);
+	for (i = 0; i < internals->active_slave_count; i++) {
+		if (!bond_mode_8023ad_activate_slave(bond_dev,
+						internals->active_slaves[i]))
+			return -1;
+	}
 
 	return 0;
 }
diff --git a/drivers/net/bonding/rte_eth_bond_8023ad_private.h b/drivers/net/bonding/rte_eth_bond_8023ad_private.h
index 0f490a5..96a42f2 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad_private.h
+++ b/drivers/net/bonding/rte_eth_bond_8023ad_private.h
@@ -263,7 +263,7 @@ struct mode8023ad_private {
  * @return
  *  0 on success, negative value otherwise.
  */
-void
+int
 bond_mode_8023ad_activate_slave(struct rte_eth_dev *dev, uint16_t port_id);
 
 /**
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index aa89425..657fd74 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -69,14 +69,15 @@
 	return 0;
 }
 
-void
+int
 activate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id)
 {
 	struct bond_dev_private *internals = eth_dev->data->dev_private;
 	uint8_t active_count = internals->active_slave_count;
 
 	if (internals->mode == BONDING_MODE_8023AD)
-		bond_mode_8023ad_activate_slave(eth_dev, port_id);
+		if (bond_mode_8023ad_activate_slave(eth_dev, port_id) != 0)
+			return -1;
 
 	if (internals->mode == BONDING_MODE_TLB
 			|| internals->mode == BONDING_MODE_ALB) {
@@ -94,6 +95,8 @@
 		bond_tlb_activate_slave(internals);
 	if (internals->mode == BONDING_MODE_ALB)
 		bond_mode_alb_client_list_upd(eth_dev);
+
+	return 0;
 }
 
 void
@@ -357,10 +360,17 @@
 				bond_ethdev_primary_set(internals,
 							slave_port_id);
 
-			if (find_slave_by_id(internals->active_slaves,
-					     internals->active_slave_count,
-					     slave_port_id) == internals->active_slave_count)
-				activate_slave(bonded_eth_dev, slave_port_id);
+			int rc =
+				find_slave_by_id(internals->active_slaves,
+					internals->active_slave_count,
+					slave_port_id);
+
+			if (rc == internals->active_slave_count) {
+				int rc = activate_slave(bonded_eth_dev,
+							slave_port_id);
+				if (rc != 0)
+					return -1;
+			}
 		}
 	}
 
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 09696ea..d2dbe4a 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -1741,8 +1741,10 @@ struct bwg_slave {
 		/* Any memory allocation failure in initialization is critical because
 		 * resources can't be free, so reinitialization is impossible. */
 		if (port->slow_pool == NULL) {
-			rte_panic("Slave %u: Failed to create memory pool '%s': %s\n",
-				slave_id, mem_name, rte_strerror(rte_errno));
+			RTE_BOND_LOG(ERR, "%s() Slave %u: Failed to create memory pool '%s': %s\n",
+				__func__, slave_id,
+				mem_name, rte_strerror(rte_errno));
+			return -1;
 		}
 	}
 
@@ -2673,7 +2675,8 @@ struct bwg_slave {
 			mac_address_slaves_update(bonded_eth_dev);
 		}
 
-		activate_slave(bonded_eth_dev, port_id);
+		if (activate_slave(bonded_eth_dev, port_id) != 0)
+			return -1;
 
 		/* If user has defined the primary port then default to using it */
 		if (internals->user_defined_primary_port &&
diff --git a/drivers/net/bonding/rte_eth_bond_private.h b/drivers/net/bonding/rte_eth_bond_private.h
index 94eca88..d99d42c 100644
--- a/drivers/net/bonding/rte_eth_bond_private.h
+++ b/drivers/net/bonding/rte_eth_bond_private.h
@@ -187,7 +187,7 @@ struct bond_dev_private {
 void
 deactivate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id);
 
-void
+int
 activate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id);
 
 void
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v7 03/11] e1000: replace rte_panic instances in e1000 driver
  2018-04-24 22:16 [dpdk-dev] [PATCH v7 00/11] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 01/11] crypto/dpaa: replace rte_panic instances in crypto/dpaa driver Arnon Warshavsky
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 02/11] bond: replace rte_panic instances in bonding driver Arnon Warshavsky
@ 2018-04-24 22:16 ` Arnon Warshavsky
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 04/11] ixgbe: replace rte_panic instances in ixgbe driver Arnon Warshavsky
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-24 22:16 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

replace panic calls with log and return value.
Local function to this file,
changing from void to int is non-abi-breaking

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 drivers/net/e1000/e1000_ethdev.h |  2 +-
 drivers/net/e1000/igb_ethdev.c   |  4 +++-
 drivers/net/e1000/igb_pf.c       | 15 +++++++++------
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h
index 6354b89..2e527de 100644
--- a/drivers/net/e1000/e1000_ethdev.h
+++ b/drivers/net/e1000/e1000_ethdev.h
@@ -411,7 +411,7 @@ int eth_igb_rss_hash_conf_get(struct rte_eth_dev *dev,
 /*
  * misc function prototypes
  */
-void igb_pf_host_init(struct rte_eth_dev *eth_dev);
+int igb_pf_host_init(struct rte_eth_dev *eth_dev);
 
 void igb_pf_mbx_process(struct rte_eth_dev *eth_dev);
 
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 9b808a9..67a32a2 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -833,7 +833,9 @@ static int igb_flex_filter_uninit(struct rte_eth_dev *eth_dev)
 	}
 
 	/* initialize PF if max_vfs not zero */
-	igb_pf_host_init(eth_dev);
+	error = igb_pf_host_init(eth_dev);
+	if (error != 0)
+		goto err_late;
 
 	ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
 	/* Set PF Reset Done bit so PF/VF Mail Ops can work */
diff --git a/drivers/net/e1000/igb_pf.c b/drivers/net/e1000/igb_pf.c
index b9f2e53..6e511a9 100644
--- a/drivers/net/e1000/igb_pf.c
+++ b/drivers/net/e1000/igb_pf.c
@@ -63,7 +63,7 @@ int igb_vf_perm_addr_gen(struct rte_eth_dev *dev, uint16_t vf_num)
 	return 0;
 }
 
-void igb_pf_host_init(struct rte_eth_dev *eth_dev)
+int igb_pf_host_init(struct rte_eth_dev *eth_dev)
 {
 	struct e1000_vf_info **vfinfo =
 		E1000_DEV_PRIVATE_TO_P_VFDATA(eth_dev->data->dev_private);
@@ -74,7 +74,7 @@ void igb_pf_host_init(struct rte_eth_dev *eth_dev)
 
 	RTE_ETH_DEV_SRIOV(eth_dev).active = 0;
 	if (0 == (vf_num = dev_num_vf(eth_dev)))
-		return;
+		return 0;
 
 	if (hw->mac.type == e1000_i350)
 		nb_queue = 1;
@@ -82,11 +82,14 @@ void igb_pf_host_init(struct rte_eth_dev *eth_dev)
 		/* per datasheet, it should be 2, but 1 seems correct */
 		nb_queue = 1;
 	else
-		return;
+		return 0;
 
 	*vfinfo = rte_zmalloc("vf_info", sizeof(struct e1000_vf_info) * vf_num, 0);
-	if (*vfinfo == NULL)
-		rte_panic("Cannot allocate memory for private VF data\n");
+	if (*vfinfo == NULL) {
+		PMD_DRV_LOG(CRIT, "%s(): Cannot allocate memory for private VF data\n",
+			__func__);
+		return -ENOMEM;
+	}
 
 	RTE_ETH_DEV_SRIOV(eth_dev).active = ETH_8_POOLS;
 	RTE_ETH_DEV_SRIOV(eth_dev).nb_q_per_pool = nb_queue;
@@ -98,7 +101,7 @@ void igb_pf_host_init(struct rte_eth_dev *eth_dev)
 	/* set mb interrupt mask */
 	igb_mb_intr_setup(eth_dev);
 
-	return;
+	return 0;
 }
 
 void igb_pf_host_uninit(struct rte_eth_dev *dev)
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v7 04/11] ixgbe: replace rte_panic instances in ixgbe driver
  2018-04-24 22:16 [dpdk-dev] [PATCH v7 00/11] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                   ` (2 preceding siblings ...)
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 03/11] e1000: replace rte_panic instances in e1000 driver Arnon Warshavsky
@ 2018-04-24 22:16 ` Arnon Warshavsky
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 05/11] eal: replace rte_panic instances in eventdev Arnon Warshavsky
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-24 22:16 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

replace panic calls with log and return value.
Local function to this file,
changing from void to int is non-abi-breaking

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c |  6 ++++--
 drivers/net/ixgbe/ixgbe_ethdev.h |  2 +-
 drivers/net/ixgbe/ixgbe_pf.c     | 15 ++++++++++-----
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index a5e2fc0..fb95cc7 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1061,7 +1061,7 @@ struct rte_ixgbe_xstats_name_off {
 		IXGBE_DEV_PRIVATE_TO_BW_CONF(eth_dev->data->dev_private);
 	uint32_t ctrl_ext;
 	uint16_t csum;
-	int diag, i;
+	int diag, i, error;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -1224,7 +1224,9 @@ struct rte_ixgbe_xstats_name_off {
 	memset(hwstrip, 0, sizeof(*hwstrip));
 
 	/* initialize PF if max_vfs not zero */
-	ixgbe_pf_host_init(eth_dev);
+	error = ixgbe_pf_host_init(eth_dev);
+	if (error != 0)
+		return error;
 
 	ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
 	/* let hardware know driver is loaded */
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 6550777..8bb41ec 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -661,7 +661,7 @@ int ixgbe_fdir_filter_program(struct rte_eth_dev *dev,
 
 void ixgbe_vlan_hw_strip_config(struct rte_eth_dev *dev);
 
-void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev);
+int ixgbe_pf_host_init(struct rte_eth_dev *eth_dev);
 
 void ixgbe_pf_host_uninit(struct rte_eth_dev *eth_dev);
 
diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
index 4e61310..81a9910 100644
--- a/drivers/net/ixgbe/ixgbe_pf.c
+++ b/drivers/net/ixgbe/ixgbe_pf.c
@@ -66,7 +66,7 @@ int ixgbe_vf_perm_addr_gen(struct rte_eth_dev *dev, uint16_t vf_num)
 	return 0;
 }
 
-void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
+int ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
 {
 	struct ixgbe_vf_info **vfinfo =
 		IXGBE_DEV_PRIVATE_TO_P_VFDATA(eth_dev->data->dev_private);
@@ -84,11 +84,14 @@ void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
 	RTE_ETH_DEV_SRIOV(eth_dev).active = 0;
 	vf_num = dev_num_vf(eth_dev);
 	if (vf_num == 0)
-		return;
+		return 0;
 
 	*vfinfo = rte_zmalloc("vf_info", sizeof(struct ixgbe_vf_info) * vf_num, 0);
-	if (*vfinfo == NULL)
-		rte_panic("Cannot allocate memory for private VF data\n");
+	if (*vfinfo == NULL) {
+		PMD_DRV_LOG(ERR, "%s() Cannot allocate memory for private VF data\n",
+				__func__);
+		return -ENOMEM;
+	}
 
 	memset(mirror_info, 0, sizeof(struct ixgbe_mirror_info));
 	memset(uta_info, 0, sizeof(struct ixgbe_uta_info));
@@ -116,6 +119,8 @@ void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
 
 	/* set mb interrupt mask */
 	ixgbe_mb_intr_setup(eth_dev);
+
+	return 0;
 }
 
 void ixgbe_pf_host_uninit(struct rte_eth_dev *eth_dev)
@@ -203,7 +208,7 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 
 	vf_num = dev_num_vf(eth_dev);
 	if (vf_num == 0)
-		return -1;
+		return -ENOMEM;
 
 	/* enable VMDq and set the default pool for PF */
 	vtctl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v7 05/11] eal: replace rte_panic instances in eventdev
  2018-04-24 22:16 [dpdk-dev] [PATCH v7 00/11] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                   ` (3 preceding siblings ...)
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 04/11] ixgbe: replace rte_panic instances in ixgbe driver Arnon Warshavsky
@ 2018-04-24 22:16 ` Arnon Warshavsky
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 06/11] kni: replace rte_panic instances in kni Arnon Warshavsky
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-24 22:16 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

replace panic calls with log and return value.

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 lib/librte_eventdev/rte_eventdev_pmd_pci.h  | 8 +++++---
 lib/librte_eventdev/rte_eventdev_pmd_vdev.h | 8 +++++---
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/lib/librte_eventdev/rte_eventdev_pmd_pci.h b/lib/librte_eventdev/rte_eventdev_pmd_pci.h
index 8fb6138..d4d10c8 100644
--- a/lib/librte_eventdev/rte_eventdev_pmd_pci.h
+++ b/lib/librte_eventdev/rte_eventdev_pmd_pci.h
@@ -66,9 +66,11 @@
 						RTE_CACHE_LINE_SIZE,
 						rte_socket_id());
 
-		if (eventdev->data->dev_private == NULL)
-			rte_panic("Cannot allocate memzone for private "
-					"device data");
+		if (eventdev->data->dev_private == NULL) {
+			RTE_EDEV_LOG_ERR("%s(): Cannot allocate memzone for private device data",
+				__func__);
+			return -ENOMEM;
+		}
 	}
 
 	eventdev->dev = &pci_dev->device;
diff --git a/lib/librte_eventdev/rte_eventdev_pmd_vdev.h b/lib/librte_eventdev/rte_eventdev_pmd_vdev.h
index 8c64a06..3c35aac 100644
--- a/lib/librte_eventdev/rte_eventdev_pmd_vdev.h
+++ b/lib/librte_eventdev/rte_eventdev_pmd_vdev.h
@@ -61,9 +61,11 @@
 						RTE_CACHE_LINE_SIZE,
 						socket_id);
 
-		if (eventdev->data->dev_private == NULL)
-			rte_panic("Cannot allocate memzone for private device"
-					" data");
+		if (eventdev->data->dev_private == NULL) {
+			RTE_EDEV_LOG_ERR("%s(): Cannot allocate memzone for private device data",
+				__func__);
+			return NULL;
+		}
 	}
 
 	return eventdev;
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v7 06/11] kni: replace rte_panic instances in kni
  2018-04-24 22:16 [dpdk-dev] [PATCH v7 00/11] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                   ` (4 preceding siblings ...)
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 05/11] eal: replace rte_panic instances in eventdev Arnon Warshavsky
@ 2018-04-24 22:16 ` Arnon Warshavsky
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 07/11] eal: replace rte_panic instances in hugepage_info Arnon Warshavsky
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-24 22:16 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

replace panic calls with log and return value.
Local function to this file,
changing from void to int is non-abi-breaking

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 lib/librte_kni/rte_kni.c      | 18 ++++++++++++------
 lib/librte_kni/rte_kni_fifo.h | 11 ++++++++---
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index 8a8f6c1..4dac407 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -353,37 +353,43 @@ struct rte_kni *
 	/* TX RING */
 	mz = slot->m_tx_q;
 	ctx->tx_q = mz->addr;
-	kni_fifo_init(ctx->tx_q, KNI_FIFO_COUNT_MAX);
+	if (kni_fifo_init(ctx->tx_q, KNI_FIFO_COUNT_MAX))
+		return NULL;
 	dev_info.tx_phys = mz->phys_addr;
 
 	/* RX RING */
 	mz = slot->m_rx_q;
 	ctx->rx_q = mz->addr;
-	kni_fifo_init(ctx->rx_q, KNI_FIFO_COUNT_MAX);
+	if (kni_fifo_init(ctx->rx_q, KNI_FIFO_COUNT_MAX))
+		return NULL;
 	dev_info.rx_phys = mz->phys_addr;
 
 	/* ALLOC RING */
 	mz = slot->m_alloc_q;
 	ctx->alloc_q = mz->addr;
-	kni_fifo_init(ctx->alloc_q, KNI_FIFO_COUNT_MAX);
+	if (kni_fifo_init(ctx->alloc_q, KNI_FIFO_COUNT_MAX))
+		return NULL;
 	dev_info.alloc_phys = mz->phys_addr;
 
 	/* FREE RING */
 	mz = slot->m_free_q;
 	ctx->free_q = mz->addr;
-	kni_fifo_init(ctx->free_q, KNI_FIFO_COUNT_MAX);
+	if (kni_fifo_init(ctx->free_q, KNI_FIFO_COUNT_MAX))
+		return NULL;
 	dev_info.free_phys = mz->phys_addr;
 
 	/* Request RING */
 	mz = slot->m_req_q;
 	ctx->req_q = mz->addr;
-	kni_fifo_init(ctx->req_q, KNI_FIFO_COUNT_MAX);
+	if (kni_fifo_init(ctx->req_q, KNI_FIFO_COUNT_MAX))
+		return NULL;
 	dev_info.req_phys = mz->phys_addr;
 
 	/* Response RING */
 	mz = slot->m_resp_q;
 	ctx->resp_q = mz->addr;
-	kni_fifo_init(ctx->resp_q, KNI_FIFO_COUNT_MAX);
+	if (kni_fifo_init(ctx->resp_q, KNI_FIFO_COUNT_MAX))
+		return NULL;
 	dev_info.resp_phys = mz->phys_addr;
 
 	/* Req/Resp sync mem area */
diff --git a/lib/librte_kni/rte_kni_fifo.h b/lib/librte_kni/rte_kni_fifo.h
index ac26a8c..5052015 100644
--- a/lib/librte_kni/rte_kni_fifo.h
+++ b/lib/librte_kni/rte_kni_fifo.h
@@ -7,17 +7,22 @@
 /**
  * Initializes the kni fifo structure
  */
-static void
+static int
 kni_fifo_init(struct rte_kni_fifo *fifo, unsigned size)
 {
 	/* Ensure size is power of 2 */
-	if (size & (size - 1))
-		rte_panic("KNI fifo size must be power of 2\n");
+	if (size & (size - 1)) {
+		RTE_LOG(CRIT, EAL, "%s(): KNI fifo size must be power of 2\n",
+				__func__);
+		return -1;
+	}
 
 	fifo->write = 0;
 	fifo->read = 0;
 	fifo->len = size;
 	fifo->elem_size = sizeof(void *);
+
+	return 0;
 }
 
 /**
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v7 07/11] eal: replace rte_panic instances in hugepage_info
  2018-04-24 22:16 [dpdk-dev] [PATCH v7 00/11] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                   ` (5 preceding siblings ...)
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 06/11] kni: replace rte_panic instances in kni Arnon Warshavsky
@ 2018-04-24 22:16 ` Arnon Warshavsky
  2018-04-25  8:58   ` Burakov, Anatoly
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 08/11] eal: replace rte_panic instances in interrupts thread Arnon Warshavsky
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-24 22:16 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

replace panic calls with log and return value.

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 lib/librte_eal/linuxapp/eal/eal_hugepage_info.c | 37 +++++++++++++++++--------
 1 file changed, 26 insertions(+), 11 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c
index db5aabd..797b8fa 100644
--- a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c
+++ b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c
@@ -145,8 +145,8 @@
 	return num_pages;
 }
 
-static uint64_t
-get_default_hp_size(void)
+static int
+get_default_hp_size(uint64_t *result)
 {
 	const char proc_meminfo[] = "/proc/meminfo";
 	const char str_hugepagesz[] = "Hugepagesize:";
@@ -155,8 +155,11 @@
 	unsigned long long size = 0;
 
 	FILE *fd = fopen(proc_meminfo, "r");
-	if (fd == NULL)
-		rte_panic("Cannot open %s\n", proc_meminfo);
+	if (fd == NULL) {
+		RTE_LOG(CRIT, EAL, "%s(): Cannot open %s\n",
+				__func__, proc_meminfo);
+		return -1;
+	}
 	while(fgets(buffer, sizeof(buffer), fd)){
 		if (strncmp(buffer, str_hugepagesz, hugepagesz_len) == 0){
 			size = rte_str_to_size(&buffer[hugepagesz_len]);
@@ -164,9 +167,13 @@
 		}
 	}
 	fclose(fd);
-	if (size == 0)
-		rte_panic("Cannot get default hugepage size from %s\n", proc_meminfo);
-	return size;
+	if (size == 0) {
+		RTE_LOG(CRIT, EAL, "%s(): Cannot get default hugepage size from %s\n",
+						 __func__, proc_meminfo);
+		return -1;
+	}
+	*result = size;
+	return 0;
 }
 
 static int
@@ -191,11 +198,19 @@
 	int retval = -1;
 
 	FILE *fd = fopen(proc_mounts, "r");
-	if (fd == NULL)
-		rte_panic("Cannot open %s\n", proc_mounts);
+	if (fd == NULL) {
+		RTE_LOG(CRIT, EAL, "%s(): Cannot open %s\n",
+				__func__, proc_mounts);
+		return -ENOENT;
+	}
 
-	if (default_size == 0)
-		default_size = get_default_hp_size();
+	if (default_size == 0) {
+		retval = get_default_hp_size(&default_size);
+		if (retval) {
+			fclose(fd);
+			return retval;
+		}
+	}
 
 	while (fgets(buf, sizeof(buf), fd)){
 		if (rte_strsplit(buf, sizeof(buf), splitstr, _FIELDNAME_MAX,
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v7 08/11] eal: replace rte_panic instances in interrupts thread
  2018-04-24 22:16 [dpdk-dev] [PATCH v7 00/11] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                   ` (6 preceding siblings ...)
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 07/11] eal: replace rte_panic instances in hugepage_info Arnon Warshavsky
@ 2018-04-24 22:16 ` Arnon Warshavsky
  2018-04-25  9:14   ` Burakov, Anatoly
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 09/11] eal: replace rte_panic instances in ethdev Arnon Warshavsky
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-24 22:16 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

replace panic calls with log and return value.
Thread function removes the noreturn attribute.

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 lib/librte_eal/linuxapp/eal/eal_interrupts.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
index 58e9328..77e6f2a 100644
--- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c
+++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
@@ -785,7 +785,7 @@ struct rte_intr_source {
  * @return
  *  never return;
  */
-static __attribute__((noreturn)) void *
+static void *
 eal_intr_thread_main(__rte_unused void *arg)
 {
 	struct epoll_event ev;
@@ -803,8 +803,11 @@ static __attribute__((noreturn)) void *
 
 		/* create epoll fd */
 		int pfd = epoll_create(1);
-		if (pfd < 0)
-			rte_panic("Cannot create epoll instance\n");
+		if (pfd < 0) {
+			RTE_LOG(CRIT, EAL, "%s(): Cannot create epoll instance\n",
+					__func__);
+			return NULL;
+		}
 
 		pipe_event.data.fd = intr_pipe.readfd;
 		/**
@@ -813,8 +816,11 @@ static __attribute__((noreturn)) void *
 		 */
 		if (epoll_ctl(pfd, EPOLL_CTL_ADD, intr_pipe.readfd,
 						&pipe_event) < 0) {
-			rte_panic("Error adding fd to %d epoll_ctl, %s\n",
+			RTE_LOG(CRIT, EAL, "%s(): Error adding fd to %d "
+					"epoll_ctl, %s\n",
+					__func__,
 					intr_pipe.readfd, strerror(errno));
+			return NULL;
 		}
 		numfds++;
 
@@ -831,9 +837,12 @@ static __attribute__((noreturn)) void *
 			 * into wait list.
 			 */
 			if (epoll_ctl(pfd, EPOLL_CTL_ADD,
-					src->intr_handle.fd, &ev) < 0){
-				rte_panic("Error adding fd %d epoll_ctl, %s\n",
-					src->intr_handle.fd, strerror(errno));
+					src->intr_handle.fd, &ev) < 0) {
+				RTE_LOG(CRIT, EAL, "%s(): Error adding fd %d epoll_ctl, %s\n",
+					__func__,
+					src->intr_handle.fd,
+					strerror(errno));
+				return NULL;
 			}
 			else
 				numfds++;
@@ -848,6 +857,8 @@ static __attribute__((noreturn)) void *
 		 */
 		close(pfd);
 	}
+
+	return NULL;
 }
 
 int
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v7 09/11] eal: replace rte_panic instances in ethdev
  2018-04-24 22:16 [dpdk-dev] [PATCH v7 00/11] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                   ` (7 preceding siblings ...)
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 08/11] eal: replace rte_panic instances in interrupts thread Arnon Warshavsky
@ 2018-04-24 22:16 ` Arnon Warshavsky
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 10/11] eal: replace rte_panic instances in init sequence Arnon Warshavsky
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-24 22:16 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

Local function to this file,
changing from void to int is non-abi-breaking

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 lib/librte_ether/rte_ethdev.c | 42 ++++++++++++++++++++++++++++++------------
 lib/librte_ether/rte_ethdev.h |  4 +++-
 2 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 7821a88..4ffdc54 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -194,7 +194,7 @@ enum {
 	return port_id;
 }
 
-static void
+static int
 rte_eth_dev_shared_data_prepare(void)
 {
 	const unsigned flags = 0;
@@ -210,8 +210,12 @@ enum {
 					rte_socket_id(), flags);
 		} else
 			mz = rte_memzone_lookup(MZ_RTE_ETH_DEV_DATA);
-		if (mz == NULL)
-			rte_panic("Cannot allocate ethdev shared data\n");
+		if (mz == NULL) {
+			rte_spinlock_unlock(&rte_eth_shared_data_lock);
+			RTE_LOG(CRIT, EAL, "%s(): Cannot allocate ethdev shared data\n",
+					__func__);
+			return -1;
+		}
 
 		rte_eth_dev_shared_data = mz->addr;
 		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
@@ -224,6 +228,8 @@ enum {
 	}
 
 	rte_spinlock_unlock(&rte_eth_shared_data_lock);
+
+	return 0;
 }
 
 struct rte_eth_dev *
@@ -274,7 +280,8 @@ struct rte_eth_dev *
 	uint16_t port_id;
 	struct rte_eth_dev *eth_dev = NULL;
 
-	rte_eth_dev_shared_data_prepare();
+	if (rte_eth_dev_shared_data_prepare() != 0)
+		return NULL;
 
 	/* Synchronize port creation between primary and secondary threads. */
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
@@ -317,7 +324,8 @@ struct rte_eth_dev *
 	uint16_t i;
 	struct rte_eth_dev *eth_dev = NULL;
 
-	rte_eth_dev_shared_data_prepare();
+	if (rte_eth_dev_shared_data_prepare() != 0)
+		return NULL;
 
 	/* Synchronize port attachment to primary port creation and release. */
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
@@ -345,7 +353,8 @@ struct rte_eth_dev *
 	if (eth_dev == NULL)
 		return -EINVAL;
 
-	rte_eth_dev_shared_data_prepare();
+	if (rte_eth_dev_shared_data_prepare() != 0)
+		return -1;
 
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
@@ -399,7 +408,8 @@ struct rte_eth_dev *
 int __rte_experimental
 rte_eth_dev_owner_new(uint64_t *owner_id)
 {
-	rte_eth_dev_shared_data_prepare();
+	if (rte_eth_dev_shared_data_prepare() != 0)
+		return -1;
 
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
@@ -450,7 +460,8 @@ struct rte_eth_dev *
 {
 	int ret;
 
-	rte_eth_dev_shared_data_prepare();
+	if (rte_eth_dev_shared_data_prepare() != 0)
+		return -1;
 
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
@@ -467,7 +478,8 @@ struct rte_eth_dev *
 			{.id = RTE_ETH_DEV_NO_OWNER, .name = ""};
 	int ret;
 
-	rte_eth_dev_shared_data_prepare();
+	if (rte_eth_dev_shared_data_prepare() != 0)
+		return -1;
 
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
@@ -477,12 +489,15 @@ struct rte_eth_dev *
 	return ret;
 }
 
-void __rte_experimental
+int __rte_experimental
 rte_eth_dev_owner_delete(const uint64_t owner_id)
 {
 	uint16_t port_id;
+	int error;
 
-	rte_eth_dev_shared_data_prepare();
+	error = rte_eth_dev_shared_data_prepare();
+	if (error != 0)
+		return error;
 
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
@@ -495,6 +510,8 @@ struct rte_eth_dev *
 	}
 
 	rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock);
+
+	return 0;
 }
 
 int __rte_experimental
@@ -502,7 +519,8 @@ struct rte_eth_dev *
 {
 	int ret = 0;
 
-	rte_eth_dev_shared_data_prepare();
+	if (rte_eth_dev_shared_data_prepare() != 0)
+		return -1;
 
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index b9eb8ae..46e5947 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1354,8 +1354,10 @@ int __rte_experimental rte_eth_dev_owner_unset(const uint16_t port_id,
  *
  * @param	owner_id
  *  The owner identifier.
+ *  @return
+ *  0 on success, negative errno value on error.
  */
-void __rte_experimental rte_eth_dev_owner_delete(const uint64_t owner_id);
+int __rte_experimental rte_eth_dev_owner_delete(const uint64_t owner_id);
 
 /**
  * @warning
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v7 10/11] eal: replace rte_panic instances in init sequence
  2018-04-24 22:16 [dpdk-dev] [PATCH v7 00/11] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                   ` (8 preceding siblings ...)
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 09/11] eal: replace rte_panic instances in ethdev Arnon Warshavsky
@ 2018-04-24 22:16 ` Arnon Warshavsky
  2018-04-25  9:07   ` Burakov, Anatoly
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 11/11] devtools: prevent new instances of rte_panic and rte_exit Arnon Warshavsky
  2018-04-25 13:45 ` [dpdk-dev] [PATCH v8 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
  11 siblings, 1 reply; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-24 22:16 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

Change some local functions return type from void to int.
This change does not break ABI as the functions are internal.
Panic thrown from threads was not handled in this patch

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 lib/librte_eal/bsdapp/eal/eal.c   | 78 +++++++++++++++++++++++--------
 lib/librte_eal/linuxapp/eal/eal.c | 97 ++++++++++++++++++++++++++-------------
 2 files changed, 125 insertions(+), 50 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index d315cde..bdda8c1 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -151,7 +151,7 @@ enum rte_iova_mode
  * We also don't lock the whole file, so that in future we can use read-locks
  * on other parts, e.g. memzones, to detect if there are running secondary
  * processes. */
-static void
+static int
 rte_eal_config_create(void)
 {
 	void *rte_mem_cfg_addr;
@@ -160,60 +160,81 @@ enum rte_iova_mode
 	const char *pathname = eal_runtime_config_path();
 
 	if (internal_config.no_shconf)
-		return;
+		return 0;
 
 	if (mem_cfg_fd < 0){
 		mem_cfg_fd = open(pathname, O_RDWR | O_CREAT, 0660);
-		if (mem_cfg_fd < 0)
-			rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
+		if (mem_cfg_fd < 0) {
+			RTE_LOG(CRIT, EAL, "%s(): Cannot open '%s' for rte_mem_config\n",
+					__func__, pathname);
+			return -1;
+		}
 	}
 
 	retval = ftruncate(mem_cfg_fd, sizeof(*rte_config.mem_config));
 	if (retval < 0){
 		close(mem_cfg_fd);
-		rte_panic("Cannot resize '%s' for rte_mem_config\n", pathname);
+		mem_cfg_fd = -1;
+		RTE_LOG(CRIT, EAL, "%s(): Cannot resize '%s' for rte_mem_config\n",
+				__func__, pathname);
+		return -1;
 	}
 
 	retval = fcntl(mem_cfg_fd, F_SETLK, &wr_lock);
 	if (retval < 0){
 		close(mem_cfg_fd);
-		rte_exit(EXIT_FAILURE, "Cannot create lock on '%s'. Is another primary "
-				"process running?\n", pathname);
+		mem_cfg_fd = -1;
+		RTE_LOG(CRIT, EAL, "%s(): Cannot create lock on '%s'. Is another primary process running?\n",
+				__func__, pathname);
+		return -1;
 	}
 
 	rte_mem_cfg_addr = mmap(NULL, sizeof(*rte_config.mem_config),
 				PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
 
 	if (rte_mem_cfg_addr == MAP_FAILED){
-		rte_panic("Cannot mmap memory for rte_config\n");
+		RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config\n",
+				__func__);
+		return -1;
 	}
 	memcpy(rte_mem_cfg_addr, &early_mem_config, sizeof(early_mem_config));
 	rte_config.mem_config = rte_mem_cfg_addr;
+
+	return 0;
 }
 
 /* attach to an existing shared memory config */
-static void
+static int
 rte_eal_config_attach(void)
 {
 	void *rte_mem_cfg_addr;
 	const char *pathname = eal_runtime_config_path();
 
 	if (internal_config.no_shconf)
-		return;
+		return 0;
 
 	if (mem_cfg_fd < 0){
 		mem_cfg_fd = open(pathname, O_RDWR);
-		if (mem_cfg_fd < 0)
-			rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
+		if (mem_cfg_fd < 0) {
+			RTE_LOG(CRIT, EAL, "%s(): Cannot open '%s' for rte_mem_config\n",
+					__func__, pathname);
+			return -1;
+		}
 	}
 
 	rte_mem_cfg_addr = mmap(NULL, sizeof(*rte_config.mem_config),
 				PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
 	close(mem_cfg_fd);
-	if (rte_mem_cfg_addr == MAP_FAILED)
-		rte_panic("Cannot mmap memory for rte_config\n");
+	if (rte_mem_cfg_addr == MAP_FAILED) {
+		mem_cfg_fd = -1;
+		RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config\n",
+				__func__);
+		return -1;
+	}
 
 	rte_config.mem_config = rte_mem_cfg_addr;
+
+	return 0;
 }
 
 /* Detect if we are a primary or a secondary process */
@@ -237,23 +258,29 @@ enum rte_proc_type_t
 }
 
 /* Sets up rte_config structure with the pointer to shared memory config.*/
-static void
+static int
 rte_config_init(void)
 {
 	rte_config.process_type = internal_config.process_type;
 
 	switch (rte_config.process_type){
 	case RTE_PROC_PRIMARY:
-		rte_eal_config_create();
+		if (rte_eal_config_create())
+			return -1;
 		break;
 	case RTE_PROC_SECONDARY:
-		rte_eal_config_attach();
+		if (rte_eal_config_attach())
+			return -1;
 		rte_eal_mcfg_wait_complete(rte_config.mem_config);
 		break;
 	case RTE_PROC_AUTO:
 	case RTE_PROC_INVALID:
-		rte_panic("Invalid process type\n");
+	default:
+		RTE_LOG(CRIT, EAL, "%s(): Invalid process type %d\n",
+				__func__, rte_config.process_type);
+		return -1;
 	}
+	return 0;
 }
 
 /* display usage */
@@ -608,6 +635,20 @@ static void rte_eal_init_alert(const char *msg)
 
 	rte_srand(rte_rdtsc());
 
+	if (rte_config_init() != 0) {
+		rte_eal_init_alert("Failed to init configuration");
+		rte_errno = EFAULT;
+		return -1;
+	}
+
+	if (rte_mp_channel_init() < 0) {
+		rte_eal_init_alert("failed to init mp channel\n");
+		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+			rte_errno = EFAULT;
+			return -1;
+		}
+	}
+
 	/* in secondary processes, memory init may allocate additional fbarrays
 	 * not present in primary processes, so to avoid any potential issues,
 	 * initialize memzones first.
@@ -671,6 +712,7 @@ static void rte_eal_init_alert(const char *msg)
 		 */
 		if (pipe(lcore_config[i].pipe_master2slave) < 0)
 			rte_panic("Cannot create pipe\n");
+
 		if (pipe(lcore_config[i].pipe_slave2master) < 0)
 			rte_panic("Cannot create pipe\n");
 
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 5b23bf0..54adaec 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -160,7 +160,7 @@ enum rte_iova_mode
  * We also don't lock the whole file, so that in future we can use read-locks
  * on other parts, e.g. memzones, to detect if there are running secondary
  * processes. */
-static void
+static int
 rte_eal_config_create(void)
 {
 	void *rte_mem_cfg_addr;
@@ -169,7 +169,7 @@ enum rte_iova_mode
 	const char *pathname = eal_runtime_config_path();
 
 	if (internal_config.no_shconf)
-		return;
+		return 0;
 
 	/* map the config before hugepage address so that we don't waste a page */
 	if (internal_config.base_virtaddr != 0)
@@ -179,30 +179,40 @@ enum rte_iova_mode
 	else
 		rte_mem_cfg_addr = NULL;
 
-	if (mem_cfg_fd < 0){
+	if (mem_cfg_fd < 0) {
 		mem_cfg_fd = open(pathname, O_RDWR | O_CREAT, 0660);
-		if (mem_cfg_fd < 0)
-			rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
+		if (mem_cfg_fd < 0) {
+			RTE_LOG(CRIT, EAL, "%s(): Cannot open '%s' for rte_mem_config\n",
+				__func__, pathname);
+			return -1;
+		}
 	}
 
 	retval = ftruncate(mem_cfg_fd, sizeof(*rte_config.mem_config));
-	if (retval < 0){
+	if (retval < 0) {
 		close(mem_cfg_fd);
-		rte_panic("Cannot resize '%s' for rte_mem_config\n", pathname);
+		mem_cfg_fd = -1;
+		RTE_LOG(CRIT, EAL, "%s(): Cannot resize '%s' for rte_mem_config\n",
+				__func__, pathname);
+		return -1;
 	}
 
 	retval = fcntl(mem_cfg_fd, F_SETLK, &wr_lock);
-	if (retval < 0){
+	if (retval < 0) {
 		close(mem_cfg_fd);
-		rte_exit(EXIT_FAILURE, "Cannot create lock on '%s'. Is another primary "
-				"process running?\n", pathname);
+		mem_cfg_fd = -1;
+		RTE_LOG(CRIT, EAL, "%s(): Cannot create lock on '%s'.Is another primary process running?\n",
+			__func__, pathname);
+		return -1;
 	}
 
 	rte_mem_cfg_addr = mmap(rte_mem_cfg_addr, sizeof(*rte_config.mem_config),
 				PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
 
-	if (rte_mem_cfg_addr == MAP_FAILED){
-		rte_panic("Cannot mmap memory for rte_config\n");
+	if (rte_mem_cfg_addr == MAP_FAILED) {
+		RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config\n",
+			__func__);
+		return -1;
 	}
 	memcpy(rte_mem_cfg_addr, &early_mem_config, sizeof(early_mem_config));
 	rte_config.mem_config = rte_mem_cfg_addr;
@@ -211,10 +221,11 @@ enum rte_iova_mode
 	 * processes could later map the config into this exact location */
 	rte_config.mem_config->mem_cfg_addr = (uintptr_t) rte_mem_cfg_addr;
 
+	return 0;
 }
 
 /* attach to an existing shared memory config */
-static void
+static int
 rte_eal_config_attach(void)
 {
 	struct rte_mem_config *mem_config;
@@ -222,33 +233,41 @@ enum rte_iova_mode
 	const char *pathname = eal_runtime_config_path();
 
 	if (internal_config.no_shconf)
-		return;
+		return 0;
 
-	if (mem_cfg_fd < 0){
+	if (mem_cfg_fd < 0) {
 		mem_cfg_fd = open(pathname, O_RDWR);
-		if (mem_cfg_fd < 0)
-			rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
+		if (mem_cfg_fd < 0) {
+			RTE_LOG(CRIT, EAL, "%s(): Cannot open '%s' for rte_mem_config\n",
+						__func__, pathname);
+			return -1;
+		}
 	}
 
 	/* map it as read-only first */
 	mem_config = (struct rte_mem_config *) mmap(NULL, sizeof(*mem_config),
 			PROT_READ, MAP_SHARED, mem_cfg_fd, 0);
-	if (mem_config == MAP_FAILED)
-		rte_panic("Cannot mmap memory for rte_config! error %i (%s)\n",
-			  errno, strerror(errno));
+	if (mem_config == MAP_FAILED) {
+		mem_cfg_fd = -1;
+		RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config! error %i (%s)\n",
+				__func__, errno, strerror(errno));
+		return -1;
+	}
 
 	rte_config.mem_config = mem_config;
+
+	return 0;
 }
 
 /* reattach the shared config at exact memory location primary process has it */
-static void
+static int
 rte_eal_config_reattach(void)
 {
 	struct rte_mem_config *mem_config;
 	void *rte_mem_cfg_addr;
 
 	if (internal_config.no_shconf)
-		return;
+		return 0;
 
 	/* save the address primary process has mapped shared config to */
 	rte_mem_cfg_addr = (void *) (uintptr_t) rte_config.mem_config->mem_cfg_addr;
@@ -263,16 +282,18 @@ enum rte_iova_mode
 	if (mem_config == MAP_FAILED || mem_config != rte_mem_cfg_addr) {
 		if (mem_config != MAP_FAILED)
 			/* errno is stale, don't use */
-			rte_panic("Cannot mmap memory for rte_config at [%p], got [%p]"
-				  " - please use '--base-virtaddr' option\n",
-				  rte_mem_cfg_addr, mem_config);
+			RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config at [%p], got [%p] - please use '--base-virtaddr' option\n",
+					__func__, rte_mem_cfg_addr, mem_config);
 		else
-			rte_panic("Cannot mmap memory for rte_config! error %i (%s)\n",
-				  errno, strerror(errno));
+			RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config! error %i (%s)\n",
+					__func__, errno, strerror(errno));
+		return -1;
 	}
 	close(mem_cfg_fd);
 
 	rte_config.mem_config = mem_config;
+
+	return 0;
 }
 
 /* Detect if we are a primary or a secondary process */
@@ -296,24 +317,32 @@ enum rte_proc_type_t
 }
 
 /* Sets up rte_config structure with the pointer to shared memory config.*/
-static void
+static int
 rte_config_init(void)
 {
 	rte_config.process_type = internal_config.process_type;
 
 	switch (rte_config.process_type){
 	case RTE_PROC_PRIMARY:
-		rte_eal_config_create();
+		if (rte_eal_config_create())
+			return -1;
 		break;
 	case RTE_PROC_SECONDARY:
-		rte_eal_config_attach();
+		if (rte_eal_config_attach())
+			return -1;
 		rte_eal_mcfg_wait_complete(rte_config.mem_config);
-		rte_eal_config_reattach();
+		if (rte_eal_config_reattach())
+			return -1;
 		break;
 	case RTE_PROC_AUTO:
 	case RTE_PROC_INVALID:
-		rte_panic("Invalid process type\n");
+	default:
+		RTE_LOG(CRIT, EAL, "%s(): Invalid process type %d\n",
+				__func__, rte_config.process_type);
+		return -1;
 	}
+
+	return 0;
 }
 
 /* Unlocks hugepage directories that were locked by eal_hugepage_info_init */
@@ -833,6 +862,9 @@ static void rte_eal_init_alert(const char *msg)
 
 	rte_srand(rte_rdtsc());
 
+	if (rte_config_init() != 0)
+		return -1;
+
 	if (rte_eal_log_init(logid, internal_config.syslog_facility) < 0) {
 		rte_eal_init_alert("Cannot init logging.");
 		rte_errno = ENOMEM;
@@ -914,6 +946,7 @@ static void rte_eal_init_alert(const char *msg)
 		 */
 		if (pipe(lcore_config[i].pipe_master2slave) < 0)
 			rte_panic("Cannot create pipe\n");
+
 		if (pipe(lcore_config[i].pipe_slave2master) < 0)
 			rte_panic("Cannot create pipe\n");
 
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v7 11/11] devtools: prevent new instances of rte_panic and rte_exit
  2018-04-24 22:16 [dpdk-dev] [PATCH v7 00/11] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                   ` (9 preceding siblings ...)
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 10/11] eal: replace rte_panic instances in init sequence Arnon Warshavsky
@ 2018-04-24 22:16 ` Arnon Warshavsky
  2018-04-24 22:52   ` Stephen Hemminger
  2018-04-25 13:45 ` [dpdk-dev] [PATCH v8 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
  11 siblings, 1 reply; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-24 22:16 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

This patch adds a new function that is called
per every checked patch,
and alerts for new instances of rte_panic/rte_exit.
The check excludes comments, and alerts in the case
of a positive balance between additions and removals.

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 devtools/checkpatches.sh | 95 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 94 insertions(+), 1 deletion(-)

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 7676a6b..48b2685 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -61,6 +61,91 @@ print_usage () {
 	END_OF_HELP
 }
 
+check_forbidden_additions() { # <file>
+    # ---------------------------------
+    #This awk script receives a list of expressions to monitor
+    #and a list of folders to search these expressions in
+    # - No search is done inside comments
+    # - Both additions and removals of the expressions are checked
+    #   A positive balance of additions fails the check
+	read -d '' awk_script << 'EOF'
+	BEGIN{
+		split(FOLDERS,deny_folders," ");
+		split(EXPRESSIONS,deny_expr," ");
+		in_file=0;
+		in_comment=0;
+		count=0;
+		comment_start="/*"
+		comment_end="*/"
+    }
+    # search for add/remove instances in current file
+    # state machine assumes the comments structure is enforced by
+    # checkpatches.pl
+    (in_file) {
+		# comment start
+		if (index($0,comment_start) > 0){
+			in_comment = 1
+		}
+		# non comment code
+		if (in_comment == 0) {
+			for (i in deny_expr) {
+				forbidden_added = "^\+.*" deny_expr[i];
+				forbidden_removed="^-.*" deny_expr[i];
+				current = expressions[deny_expr[i]]
+				if ($0 ~ forbidden_added) {
+					count = count + 1;
+					expressions[deny_expr[i]] = current + 1
+				}
+				if ($0 ~ forbidden_removed) {
+					count = count - 1;
+					expressions[deny_expr[i]] = current - 1
+				}
+			}
+		}
+
+		# comment end
+		if (index($0,comment_end) > 0)  {
+			in_comment = 0
+		}
+    }
+	# switch to next file , check if the balance of add/remove
+	# of previous filehad new additions
+	($0 ~ "^\+\+\+ b/") {
+		in_file = 0;
+		if (count > 0){
+			exit;
+		}
+		for (i in deny_folders){
+			re = "^\+\+\+ b/" deny_folders[i];
+			if ($0 ~ deny_folders[i]) {
+				in_file = 1
+				last_file = $0
+			}
+		}
+	}
+	END{
+		if (count > 0){
+			print "Warning: in " substr(last_file,6) ":"
+			print "are you sure you want to add the following:"
+			for (key in expressions) {
+				if (expressions[key] > 0) {
+					print key
+				}
+			}
+			exit 1
+		}
+	}
+EOF
+	# ---------------------------------
+
+	# refrain from new additions of rte_panic() and rte_exit()
+	# under lib and net
+	# multiple folders and expressions are separated by spaces
+	awk -v FOLDERS="lib net" \
+		-v EXPRESSIONS="rte_panic\\\( rte_exit\\\(" \
+		"$awk_script" -
+}
+
 number=0
 quiet=false
 verbose=false
@@ -89,11 +174,19 @@ check () { # <patch> <commit> <title>
 	total=$(($total + 1))
 	! $verbose || printf '\n### %s\n\n' "$3"
 	if [ -n "$1" ] ; then
+		cat "$1" | check_forbidden_additions
+		[ $? -eq 0 ] || return 0
 		report=$($DPDK_CHECKPATCH_PATH $options "$1" 2>/dev/null)
 	elif [ -n "$2" ] ; then
-		report=$(git format-patch --find-renames --no-stat --stdout -1 $commit |
+		params=$(echo "--find-renames --no-stat --stdout -1")
+		body=$(git format-patch $params $commit)
+		echo "$body" | check_forbidden_additions
+		[ $? -eq 0 ] || return 0
+		report=$(echo "$body" |
 			$DPDK_CHECKPATCH_PATH $options - 2>/dev/null)
 	else
+		check_forbidden_additions -
+		[ $? -eq 0 ] || return 0
 		report=$($DPDK_CHECKPATCH_PATH $options - 2>/dev/null)
 	fi
 	[ $? -ne 0 ] || return 0
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v7 02/11] bond: replace rte_panic instances in bonding driver
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 02/11] bond: replace rte_panic instances in bonding driver Arnon Warshavsky
@ 2018-04-24 22:51   ` Stephen Hemminger
  2018-04-25  9:38     ` Arnon Warshavsky
  0 siblings, 1 reply; 91+ messages in thread
From: Stephen Hemminger @ 2018-04-24 22:51 UTC (permalink / raw)
  To: Arnon Warshavsky
  Cc: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit, dev

On Wed, 25 Apr 2018 01:16:44 +0300
Arnon Warshavsky <arnon@qwilt.com> wrote:

> replace panic calls with log and return value.
> Local functions to this file,
> changing from void to int are non-abi-breaking
> 
> Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
> ---
>  drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c       |  2 +-
>  drivers/net/bonding/rte_eth_bond_8023ad.c         | 29 ++++++++++++++---------
>  drivers/net/bonding/rte_eth_bond_8023ad_private.h |  2 +-
>  drivers/net/bonding/rte_eth_bond_api.c            | 22 ++++++++++++-----
>  drivers/net/bonding/rte_eth_bond_pmd.c            |  9 ++++---
>  drivers/net/bonding/rte_eth_bond_private.h        |  2 +-
>  6 files changed, 43 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
> index a78f3a2..a19fb40 100644
> --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
> +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
> @@ -2884,7 +2884,7 @@ struct rte_security_ops dpaa2_sec_security_ops = {
>  					rte_socket_id());
>  
>  		if (cryptodev->data->dev_private == NULL) {
> -			DPAA_SEC_ERR("%s() Cannot allocate memzone for private device data",
> +			DPAA2_SEC_ERR("%s() Cannot allocate memzone for private device data",
>  			__func__);
>  			return -ENOMEM;

You mixed dpaa2 with bonding in this set.

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v7 11/11] devtools: prevent new instances of rte_panic and rte_exit
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 11/11] devtools: prevent new instances of rte_panic and rte_exit Arnon Warshavsky
@ 2018-04-24 22:52   ` Stephen Hemminger
  2018-04-24 23:03     ` Thomas Monjalon
  0 siblings, 1 reply; 91+ messages in thread
From: Stephen Hemminger @ 2018-04-24 22:52 UTC (permalink / raw)
  To: Arnon Warshavsky
  Cc: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit, dev

On Wed, 25 Apr 2018 01:16:53 +0300
Arnon Warshavsky <arnon@qwilt.com> wrote:

> This patch adds a new function that is called
> per every checked patch,
> and alerts for new instances of rte_panic/rte_exit.
> The check excludes comments, and alerts in the case
> of a positive balance between additions and removals.
> 
> Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>

Why not just mark the functions as deprecated with compiler attribute.

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v7 11/11] devtools: prevent new instances of rte_panic and rte_exit
  2018-04-24 22:52   ` Stephen Hemminger
@ 2018-04-24 23:03     ` Thomas Monjalon
  2018-04-24 23:15       ` Stephen Hemminger
  0 siblings, 1 reply; 91+ messages in thread
From: Thomas Monjalon @ 2018-04-24 23:03 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: Arnon Warshavsky, anatoly.burakov, wenzhuo.lu, declan.doherty,
	jerin.jacob, bruce.richardson, ferruh.yigit, dev

25/04/2018 00:52, Stephen Hemminger:
> On Wed, 25 Apr 2018 01:16:53 +0300
> Arnon Warshavsky <arnon@qwilt.com> wrote:
> 
> > This patch adds a new function that is called
> > per every checked patch,
> > and alerts for new instances of rte_panic/rte_exit.
> > The check excludes comments, and alerts in the case
> > of a positive balance between additions and removals.
> > 
> > Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
> 
> Why not just mark the functions as deprecated with compiler attribute.

No, the applications can use these functions.

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v7 11/11] devtools: prevent new instances of rte_panic and rte_exit
  2018-04-24 23:03     ` Thomas Monjalon
@ 2018-04-24 23:15       ` Stephen Hemminger
  0 siblings, 0 replies; 91+ messages in thread
From: Stephen Hemminger @ 2018-04-24 23:15 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: Arnon Warshavsky, anatoly.burakov, wenzhuo.lu, declan.doherty,
	jerin.jacob, bruce.richardson, ferruh.yigit, dev

On Wed, 25 Apr 2018 01:03:20 +0200
Thomas Monjalon <thomas@monjalon.net> wrote:

> 25/04/2018 00:52, Stephen Hemminger:
> > On Wed, 25 Apr 2018 01:16:53 +0300
> > Arnon Warshavsky <arnon@qwilt.com> wrote:
> >   
> > > This patch adds a new function that is called
> > > per every checked patch,
> > > and alerts for new instances of rte_panic/rte_exit.
> > > The check excludes comments, and alerts in the case
> > > of a positive balance between additions and removals.
> > > 
> > > Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>  
> > 
> > Why not just mark the functions as deprecated with compiler attribute.  
> 
> No, the applications can use these functions.

Yeah, fighting against that would be hard. They always seemed like internal
functions.

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v7 07/11] eal: replace rte_panic instances in hugepage_info
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 07/11] eal: replace rte_panic instances in hugepage_info Arnon Warshavsky
@ 2018-04-25  8:58   ` Burakov, Anatoly
  0 siblings, 0 replies; 91+ messages in thread
From: Burakov, Anatoly @ 2018-04-25  8:58 UTC (permalink / raw)
  To: Arnon Warshavsky, thomas, wenzhuo.lu, declan.doherty,
	jerin.jacob, bruce.richardson, ferruh.yigit
  Cc: dev

On 24-Apr-18 11:16 PM, Arnon Warshavsky wrote:
> replace panic calls with log and return value.
> 
> Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
> ---

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v7 10/11] eal: replace rte_panic instances in init sequence
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 10/11] eal: replace rte_panic instances in init sequence Arnon Warshavsky
@ 2018-04-25  9:07   ` Burakov, Anatoly
  2018-04-25  9:33     ` Arnon Warshavsky
  0 siblings, 1 reply; 91+ messages in thread
From: Burakov, Anatoly @ 2018-04-25  9:07 UTC (permalink / raw)
  To: Arnon Warshavsky, thomas, wenzhuo.lu, declan.doherty,
	jerin.jacob, bruce.richardson, ferruh.yigit
  Cc: dev

On 24-Apr-18 11:16 PM, Arnon Warshavsky wrote:
> Change some local functions return type from void to int.
> This change does not break ABI as the functions are internal.
> Panic thrown from threads was not handled in this patch
> 
> Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
> ---

<...>

>   
> +	if (rte_config_init() != 0) {
> +		rte_eal_init_alert("Failed to init configuration");
> +		rte_errno = EFAULT;
> +		return -1;
> +	}
> +
> +	if (rte_mp_channel_init() < 0) {
> +		rte_eal_init_alert("failed to init mp channel\n");
> +		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
> +			rte_errno = EFAULT;
> +			return -1;
> +		}
> +	}

^^^ this change looks unintended. Rebase artifact?

> +
>   	/* in secondary processes, memory init may allocate additional fbarrays
>   	 * not present in primary processes, so to avoid any potential issues,
>   	 * initialize memzones first.
> @@ -671,6 +712,7 @@ static void rte_eal_init_alert(const char *msg)
>   		 */
>   		if (pipe(lcore_config[i].pipe_master2slave) < 0)
>   			rte_panic("Cannot create pipe\n");
> +
>   		if (pipe(lcore_config[i].pipe_slave2master) < 0)
>   			rte_panic("Cannot create pipe\n");

^^^ this looks unintended as well.

>   
> diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
> index 5b23bf0..54adaec 100644
> --- a/lib/librte_eal/linuxapp/eal/eal.c
> +++ b/lib/librte_eal/linuxapp/eal/eal.c
> @@ -160,7 +160,7 @@ enum rte_iova_mode
>    * We also don't lock the whole file, so that in future we can use read-locks
>    * on other parts, e.g. memzones, to detect if there are running secondary
>    * processes. */
> -static void
> +static int
>   rte_eal_config_create(void)
>   {
>   	void *rte_mem_cfg_addr;
> @@ -169,7 +169,7 @@ enum rte_iova_mode
>   	const char *pathname = eal_runtime_config_path();
>   
>   	if (internal_config.no_shconf)
> -		return;

<...>

>   	}
>   
>   	rte_mem_cfg_addr = mmap(rte_mem_cfg_addr, sizeof(*rte_config.mem_config),
>   				PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
>   
> -	if (rte_mem_cfg_addr == MAP_FAILED){
> -		rte_panic("Cannot mmap memory for rte_config\n");
> +	if (rte_mem_cfg_addr == MAP_FAILED) {
> +		RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config\n",
> +			__func__);
> +		return -1;
>   	}

I think you forgot to close mem_cfg_fd and set it to -1 in case of error 
here.

>   	memcpy(rte_mem_cfg_addr, &early_mem_config, sizeof(early_mem_config));
>   	rte_config.mem_config = rte_mem_cfg_addr;
> @@ -211,10 +221,11 @@ enum rte_iova_mode
>   	 * processes could later map the config into this exact location */
>   	rte_config.mem_config->mem_cfg_addr = (uintptr_t) rte_mem_cfg_addr;
>   
> +	return 0;
>   }
>   

<...>

>   
>   	/* map it as read-only first */
>   	mem_config = (struct rte_mem_config *) mmap(NULL, sizeof(*mem_config),
>   			PROT_READ, MAP_SHARED, mem_cfg_fd, 0);
> -	if (mem_config == MAP_FAILED)
> -		rte_panic("Cannot mmap memory for rte_config! error %i (%s)\n",
> -			  errno, strerror(errno));
> +	if (mem_config == MAP_FAILED) {
> +		mem_cfg_fd = -1;

Forgot close() here, i think.

> +		RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config! error %i (%s)\n",
> +				__func__, errno, strerror(errno));
> +		return -1;
> +	}
>   
>   	rte_config.mem_config = mem_config;
> +
> +	return 0;
>   }
>   
>   /* reattach the shared config at exact memory location primary process has it */

<...>

> +	if (rte_config_init() != 0)
> +		return -1;
> +
>   	if (rte_eal_log_init(logid, internal_config.syslog_facility) < 0) {
>   		rte_eal_init_alert("Cannot init logging.");
>   		rte_errno = ENOMEM;
> @@ -914,6 +946,7 @@ static void rte_eal_init_alert(const char *msg)
>   		 */
>   		if (pipe(lcore_config[i].pipe_master2slave) < 0)
>   			rte_panic("Cannot create pipe\n");
> +
>   		if (pipe(lcore_config[i].pipe_slave2master) < 0)

Again, looks like unintended whitespace change.

>   			rte_panic("Cannot create pipe\n");
>   
> 


-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v7 08/11] eal: replace rte_panic instances in interrupts thread
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 08/11] eal: replace rte_panic instances in interrupts thread Arnon Warshavsky
@ 2018-04-25  9:14   ` Burakov, Anatoly
  2018-04-25  9:37     ` Arnon Warshavsky
  0 siblings, 1 reply; 91+ messages in thread
From: Burakov, Anatoly @ 2018-04-25  9:14 UTC (permalink / raw)
  To: Arnon Warshavsky, thomas, wenzhuo.lu, declan.doherty,
	jerin.jacob, bruce.richardson, ferruh.yigit
  Cc: dev

On 24-Apr-18 11:16 PM, Arnon Warshavsky wrote:
> replace panic calls with log and return value.
> Thread function removes the noreturn attribute.
> 
> Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
> ---

Just a general comment - i'm not too familiar with this code, but it 
looks like all of these failures will only happen on thread init. Can we 
make sure it starts?

You can use similar approach to Olivier's (recently merged) thread 
affinity patches, with pthread barriers etc. to ensure the thread has 
initialized properly, pthread_cancel() it if it didn't, and return -1 on 
thread init.

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v7 10/11] eal: replace rte_panic instances in init sequence
  2018-04-25  9:07   ` Burakov, Anatoly
@ 2018-04-25  9:33     ` Arnon Warshavsky
  0 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-25  9:33 UTC (permalink / raw)
  To: Burakov, Anatoly
  Cc: Thomas Monjalon, Lu, Wenzhuo, Doherty, Declan, jerin.jacob,
	Bruce Richardson, Yigit, Ferruh, dev

<...>

>
>   +     if (rte_config_init() != 0) {
>> +               rte_eal_init_alert("Failed to init configuration");
>> +               rte_errno = EFAULT;
>> +               return -1;
>> +       }
>> +
>> +       if (rte_mp_channel_init() < 0) {
>> +               rte_eal_init_alert("failed to init mp channel\n");
>> +               if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
>> +                       rte_errno = EFAULT;
>> +                       return -1;
>> +               }
>> +       }
>>
>
> ^^^ this change looks unintended. Rebase artifact?
>
> +
>>         /* in secondary processes, memory init may allocate additional
>> fbarrays
>>          * not present in primary processes, so to avoid any potential
>> issues,
>>          * initialize memzones first.
>> @@ -671,6 +712,7 @@ static void rte_eal_init_alert(const char *msg)
>>                  */
>>                 if (pipe(lcore_config[i].pipe_master2slave) < 0)
>>                         rte_panic("Cannot create pipe\n");
>> +
>>                 if (pipe(lcore_config[i].pipe_slave2master) < 0)
>>                         rte_panic("Cannot create pipe\n");
>>
>
> ^^^ this looks unintended as well.
>
>   diff --git a/lib/librte_eal/linuxapp/eal/eal.c
>> b/lib/librte_eal/linuxapp/eal/eal.c
>> index 5b23bf0..54adaec 100644
>> --- a/lib/librte_eal/linuxapp/eal/eal.c
>> +++ b/lib/librte_eal/linuxapp/eal/eal.c
>> @@ -160,7 +160,7 @@ enum rte_iova_mode
>>    * We also don't lock the whole file, so that in future we can use
>> read-locks
>>    * on other parts, e.g. memzones, to detect if there are running
>> secondary
>>    * processes. */
>> -static void
>> +static int
>>   rte_eal_config_create(void)
>>   {
>>         void *rte_mem_cfg_addr;
>> @@ -169,7 +169,7 @@ enum rte_iova_mode
>>         const char *pathname = eal_runtime_config_path();
>>         if (internal_config.no_shconf)
>> -               return;
>>
>
> <...>
>
>         }
>>         rte_mem_cfg_addr = mmap(rte_mem_cfg_addr,
>> sizeof(*rte_config.mem_config),
>>                                 PROT_READ | PROT_WRITE, MAP_SHARED,
>> mem_cfg_fd, 0);
>>   -     if (rte_mem_cfg_addr == MAP_FAILED){
>> -               rte_panic("Cannot mmap memory for rte_config\n");
>> +       if (rte_mem_cfg_addr == MAP_FAILED) {
>> +               RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for
>> rte_config\n",
>> +                       __func__);
>> +               return -1;
>>         }
>>
>
> I think you forgot to close mem_cfg_fd and set it to -1 in case of error
> here.
>
>         memcpy(rte_mem_cfg_addr, &early_mem_config,
>> sizeof(early_mem_config));
>>         rte_config.mem_config = rte_mem_cfg_addr;
>> @@ -211,10 +221,11 @@ enum rte_iova_mode
>>          * processes could later map the config into this exact location
>> */
>>         rte_config.mem_config->mem_cfg_addr = (uintptr_t)
>> rte_mem_cfg_addr;
>>   +     return 0;
>>   }
>>
>>
>
> <...>
>
>         /* map it as read-only first */
>>         mem_config = (struct rte_mem_config *) mmap(NULL,
>> sizeof(*mem_config),
>>                         PROT_READ, MAP_SHARED, mem_cfg_fd, 0);
>> -       if (mem_config == MAP_FAILED)
>> -               rte_panic("Cannot mmap memory for rte_config! error %i
>> (%s)\n",
>> -                         errno, strerror(errno));
>> +       if (mem_config == MAP_FAILED) {
>> +               mem_cfg_fd = -1;
>>
>
> Forgot close() here, i think.
>
> +               RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for
>> rte_config! error %i (%s)\n",
>> +                               __func__, errno, strerror(errno));
>> +               return -1;
>> +       }
>>         rte_config.mem_config = mem_config;
>> +
>> +       return 0;
>>   }
>>     /* reattach the shared config at exact memory location primary
>> process has it */
>>
>
> <...>
>
> +       if (rte_config_init() != 0)
>> +               return -1;
>> +
>>         if (rte_eal_log_init(logid, internal_config.syslog_facility) <
>> 0) {
>>                 rte_eal_init_alert("Cannot init logging.");
>>                 rte_errno = ENOMEM;
>> @@ -914,6 +946,7 @@ static void rte_eal_init_alert(const char *msg)
>>                  */
>>                 if (pipe(lcore_config[i].pipe_master2slave) < 0)
>>                         rte_panic("Cannot create pipe\n");
>> +
>>                 if (pipe(lcore_config[i].pipe_slave2master) < 0)
>>
>
> Again, looks like unintended whitespace change.
>
>                         rte_panic("Cannot create pipe\n");
>>
>>
>
> Thanks Anatoly

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v7 08/11] eal: replace rte_panic instances in interrupts thread
  2018-04-25  9:14   ` Burakov, Anatoly
@ 2018-04-25  9:37     ` Arnon Warshavsky
  0 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-25  9:37 UTC (permalink / raw)
  To: Burakov, Anatoly
  Cc: Thomas Monjalon, Lu, Wenzhuo, Doherty, Declan, jerin.jacob,
	Bruce Richardson, Yigit, Ferruh, dev

> Just a general comment - i'm not too familiar with this code, but it looks
> like all of these failures will only happen on thread init. Can we make
> sure it starts?
>
> You can use similar approach to Olivier's (recently merged) thread
> affinity patches, with pthread barriers etc. to ensure the thread has
> initialized properly, pthread_cancel() it if it didn't, and return -1 on
> thread init.


Thanks for catching this one. I am now reverting it as well from this set,
to be properly handled in a set dedicated to the threading issue

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v7 02/11] bond: replace rte_panic instances in bonding driver
  2018-04-24 22:51   ` Stephen Hemminger
@ 2018-04-25  9:38     ` Arnon Warshavsky
  0 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-25  9:38 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: Thomas Monjalon, Burakov, Anatoly, Lu, Wenzhuo, Doherty, Declan,
	jerin.jacob, Bruce Richardson, Yigit, Ferruh, dev

>
>
> You mixed dpaa2 with bonding in this set.
>

Indeed. Thanks

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v8 00/10] eal: replace calls to rte_panic and refrain from new instances
  2018-04-24 22:16 [dpdk-dev] [PATCH v7 00/11] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                   ` (10 preceding siblings ...)
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 11/11] devtools: prevent new instances of rte_panic and rte_exit Arnon Warshavsky
@ 2018-04-25 13:45 ` Arnon Warshavsky
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 01/10] crypto/dpaa: replace rte_panic instances in crypto/dpaa driver Arnon Warshavsky
                     ` (10 more replies)
  11 siblings, 11 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-25 13:45 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

The purpose of this patch series is to cleanup the library code
from paths that end up aborting the process,
and move to checking error values, in order to allow the running process
perform an orderly teardown or other mitigation of the event.

This patch modifies the majority of rte_panic calls
under lib and drivers, and replaces them with a log message
and an error return code according to context,
that can be propagated up the call stack.

- Focus was given to the dpdk initialization path
- Some of the panic calls within drivers were left in place where
  the call is from within an interrupt or calls that are
  on the data path,where there is no simple applicative
  route to propagate the error to temination.
  These should be handled by the driver maintainers..
- local void functions with no api were changed to retrun a value
  where needed
- No change took place in example and test files
- No change took place for debug assertions calling panic
- A new function was added to devtools/checkpatches.sh
  in order to prevent new additions of calls to rte_panic
  under lib and drivers.

Keep calm and don't panic

---

v2:
- reformat error messages so that literal string are in the same line
- fix typo in commit message
- add new return code to doxigen of rte_memzone_free()

v3:
- submit  all 13 patches changed and unchanged in the same patchset

v4:
- remove 2 patches that are no more relevant
- fix split literal string in error message
- change return value -1 to enum
- split value and success code in a static function

v5:
- reword commit messages
- revert thread related instances back to panicing
- handle file descriptors with state to reset after eal init failure
  in case re initialization takes place

v6:
- Use pmd log macro rather than rte_log

v7:
- use bond specific , dpaa2 specific and eventdev specific log macros

v8:
- Seperate the 2 drivers salad back to distinct bond and dpaa patches
- Add missing file descriptor closing when returnning an error
- Remove half baked thread patch to be handled in the next version
- Remove duplicate function call after rebase 

Arnon Warshavsky (10):
  crypto/dpaa: replace rte_panic instances in crypto/dpaa driver
  bond: replace rte_panic instances in bonding driver
  e1000: replace rte_panic instances in e1000 driver
  ixgbe: replace rte_panic instances in ixgbe driver
  eal: replace rte_panic instances in eventdev
  kni: replace rte_panic instances in kni
  eal: replace rte_panic instances in hugepage_info
  eal: replace rte_panic instances in ethdev
  eal: replace rte_panic instances in init sequence
  devtools: prevent new instances of rte_panic and rte_exit

 devtools/checkpatches.sh                          |  95 +++++++++++++++++++-
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c       |   8 +-
 drivers/crypto/dpaa_sec/dpaa_sec.c                |  10 ++-
 drivers/net/bonding/rte_eth_bond_8023ad.c         |  29 ++++---
 drivers/net/bonding/rte_eth_bond_8023ad_private.h |   2 +-
 drivers/net/bonding/rte_eth_bond_api.c            |  22 +++--
 drivers/net/bonding/rte_eth_bond_pmd.c            |   9 +-
 drivers/net/bonding/rte_eth_bond_private.h        |   2 +-
 drivers/net/e1000/e1000_ethdev.h                  |   2 +-
 drivers/net/e1000/igb_ethdev.c                    |   4 +-
 drivers/net/e1000/igb_pf.c                        |  15 ++--
 drivers/net/ixgbe/ixgbe_ethdev.c                  |   6 +-
 drivers/net/ixgbe/ixgbe_ethdev.h                  |   2 +-
 drivers/net/ixgbe/ixgbe_pf.c                      |  15 ++--
 lib/librte_eal/bsdapp/eal/eal.c                   |  69 +++++++++++----
 lib/librte_eal/linuxapp/eal/eal.c                 | 101 +++++++++++++++-------
 lib/librte_eal/linuxapp/eal/eal_hugepage_info.c   |  37 +++++---
 lib/librte_ether/rte_ethdev.c                     |  42 ++++++---
 lib/librte_ether/rte_ethdev.h                     |   4 +-
 lib/librte_eventdev/rte_eventdev_pmd_pci.h        |   8 +-
 lib/librte_eventdev/rte_eventdev_pmd_vdev.h       |   8 +-
 lib/librte_kni/rte_kni.c                          |  18 ++--
 lib/librte_kni/rte_kni_fifo.h                     |  11 ++-
 23 files changed, 383 insertions(+), 136 deletions(-)

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v8 01/10] crypto/dpaa: replace rte_panic instances in crypto/dpaa driver
  2018-04-25 13:45 ` [dpdk-dev] [PATCH v8 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
@ 2018-04-25 13:45   ` Arnon Warshavsky
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 02/10] bond: replace rte_panic instances in bonding driver Arnon Warshavsky
                     ` (9 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-25 13:45 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

replace panic calls with log and return value.

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c |  8 +++++---
 drivers/crypto/dpaa_sec/dpaa_sec.c          | 10 ++++++----
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 58cbce8..a19fb40 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -2883,9 +2883,11 @@ struct rte_security_ops dpaa2_sec_security_ops = {
 					RTE_CACHE_LINE_SIZE,
 					rte_socket_id());
 
-		if (cryptodev->data->dev_private == NULL)
-			rte_panic("Cannot allocate memzone for private "
-				  "device data");
+		if (cryptodev->data->dev_private == NULL) {
+			DPAA2_SEC_ERR("%s() Cannot allocate memzone for private device data",
+			__func__);
+			return -ENOMEM;
+		}
 	}
 
 	dpaa2_dev->cryptodev = cryptodev;
diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index e456fd5..a4670bf 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -2352,7 +2352,7 @@ struct rte_security_ops dpaa_sec_security_ops = {
 		}
 	}
 
-	RTE_LOG(INFO, PMD, "%s cryptodev init\n", cryptodev->data->name);
+	DPAA_SEC_INFO("%s cryptodev init\n", cryptodev->data->name);
 	return 0;
 
 init_error:
@@ -2384,9 +2384,11 @@ struct rte_security_ops dpaa_sec_security_ops = {
 					RTE_CACHE_LINE_SIZE,
 					rte_socket_id());
 
-		if (cryptodev->data->dev_private == NULL)
-			rte_panic("Cannot allocate memzone for private "
-					"device data");
+		if (cryptodev->data->dev_private == NULL) {
+			DPAA_SEC_ERR("%s() Cannot allocate memzone for private device data",
+			__func__);
+			return -ENOMEM;
+		}
 	}
 
 	dpaa_dev->crypto_dev = cryptodev;
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v8 02/10] bond: replace rte_panic instances in bonding driver
  2018-04-25 13:45 ` [dpdk-dev] [PATCH v8 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 01/10] crypto/dpaa: replace rte_panic instances in crypto/dpaa driver Arnon Warshavsky
@ 2018-04-25 13:45   ` Arnon Warshavsky
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 03/10] e1000: replace rte_panic instances in e1000 driver Arnon Warshavsky
                     ` (8 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-25 13:45 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

Replace panic calls with log and return value.
Local functions to this file,
changing from void to int are non-abi-breaking

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 drivers/net/bonding/rte_eth_bond_8023ad.c         | 29 ++++++++++++++---------
 drivers/net/bonding/rte_eth_bond_8023ad_private.h |  2 +-
 drivers/net/bonding/rte_eth_bond_api.c            | 22 ++++++++++++-----
 drivers/net/bonding/rte_eth_bond_pmd.c            |  9 ++++---
 drivers/net/bonding/rte_eth_bond_private.h        |  2 +-
 5 files changed, 42 insertions(+), 22 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
index c452318..308e623 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -893,7 +893,7 @@
 			bond_mode_8023ad_periodic_cb, arg);
 }
 
-void
+int
 bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev,
 				uint16_t slave_id)
 {
@@ -939,7 +939,7 @@
 	timer_cancel(&port->warning_timer);
 
 	if (port->mbuf_pool != NULL)
-		return;
+		return 0;
 
 	RTE_ASSERT(port->rx_ring == NULL);
 	RTE_ASSERT(port->tx_ring == NULL);
@@ -968,8 +968,9 @@
 	/* Any memory allocation failure in initialization is critical because
 	 * resources can't be free, so reinitialization is impossible. */
 	if (port->mbuf_pool == NULL) {
-		rte_panic("Slave %u: Failed to create memory pool '%s': %s\n",
-			slave_id, mem_name, rte_strerror(rte_errno));
+		RTE_BOND_LOG(ERR, "%s() Slave %u: Failed to create memory pool '%s': %s\n",
+			__func__, slave_id, mem_name, rte_strerror(rte_errno));
+		return -1;
 	}
 
 	snprintf(mem_name, RTE_DIM(mem_name), "slave_%u_rx", slave_id);
@@ -977,8 +978,9 @@
 			rte_align32pow2(BOND_MODE_8023AX_SLAVE_RX_PKTS), socket_id, 0);
 
 	if (port->rx_ring == NULL) {
-		rte_panic("Slave %u: Failed to create rx ring '%s': %s\n", slave_id,
-			mem_name, rte_strerror(rte_errno));
+		RTE_BOND_LOG(ERR, "%s() Slave %u: Failed to create rx ring '%s': %s\n",
+			__func__, slave_id, mem_name, rte_strerror(rte_errno));
+		return -1;
 	}
 
 	/* TX ring is at least one pkt longer to make room for marker packet. */
@@ -987,9 +989,12 @@
 			rte_align32pow2(BOND_MODE_8023AX_SLAVE_TX_PKTS + 1), socket_id, 0);
 
 	if (port->tx_ring == NULL) {
-		rte_panic("Slave %u: Failed to create tx ring '%s': %s\n", slave_id,
-			mem_name, rte_strerror(rte_errno));
+		RTE_BOND_LOG(ERR, "%s() Slave %u: Fail to create tx ring '%s': %s\n",
+			__func__, slave_id, mem_name, rte_strerror(rte_errno));
+		return -1;
 	}
+
+	return 0;
 }
 
 int
@@ -1143,9 +1148,11 @@
 	struct bond_dev_private *internals = bond_dev->data->dev_private;
 	uint8_t i;
 
-	for (i = 0; i < internals->active_slave_count; i++)
-		bond_mode_8023ad_activate_slave(bond_dev,
-				internals->active_slaves[i]);
+	for (i = 0; i < internals->active_slave_count; i++) {
+		if (!bond_mode_8023ad_activate_slave(bond_dev,
+						internals->active_slaves[i]))
+			return -1;
+	}
 
 	return 0;
 }
diff --git a/drivers/net/bonding/rte_eth_bond_8023ad_private.h b/drivers/net/bonding/rte_eth_bond_8023ad_private.h
index 0f490a5..96a42f2 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad_private.h
+++ b/drivers/net/bonding/rte_eth_bond_8023ad_private.h
@@ -263,7 +263,7 @@ struct mode8023ad_private {
  * @return
  *  0 on success, negative value otherwise.
  */
-void
+int
 bond_mode_8023ad_activate_slave(struct rte_eth_dev *dev, uint16_t port_id);
 
 /**
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index aa89425..657fd74 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -69,14 +69,15 @@
 	return 0;
 }
 
-void
+int
 activate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id)
 {
 	struct bond_dev_private *internals = eth_dev->data->dev_private;
 	uint8_t active_count = internals->active_slave_count;
 
 	if (internals->mode == BONDING_MODE_8023AD)
-		bond_mode_8023ad_activate_slave(eth_dev, port_id);
+		if (bond_mode_8023ad_activate_slave(eth_dev, port_id) != 0)
+			return -1;
 
 	if (internals->mode == BONDING_MODE_TLB
 			|| internals->mode == BONDING_MODE_ALB) {
@@ -94,6 +95,8 @@
 		bond_tlb_activate_slave(internals);
 	if (internals->mode == BONDING_MODE_ALB)
 		bond_mode_alb_client_list_upd(eth_dev);
+
+	return 0;
 }
 
 void
@@ -357,10 +360,17 @@
 				bond_ethdev_primary_set(internals,
 							slave_port_id);
 
-			if (find_slave_by_id(internals->active_slaves,
-					     internals->active_slave_count,
-					     slave_port_id) == internals->active_slave_count)
-				activate_slave(bonded_eth_dev, slave_port_id);
+			int rc =
+				find_slave_by_id(internals->active_slaves,
+					internals->active_slave_count,
+					slave_port_id);
+
+			if (rc == internals->active_slave_count) {
+				int rc = activate_slave(bonded_eth_dev,
+							slave_port_id);
+				if (rc != 0)
+					return -1;
+			}
 		}
 	}
 
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 09696ea..d2dbe4a 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -1741,8 +1741,10 @@ struct bwg_slave {
 		/* Any memory allocation failure in initialization is critical because
 		 * resources can't be free, so reinitialization is impossible. */
 		if (port->slow_pool == NULL) {
-			rte_panic("Slave %u: Failed to create memory pool '%s': %s\n",
-				slave_id, mem_name, rte_strerror(rte_errno));
+			RTE_BOND_LOG(ERR, "%s() Slave %u: Failed to create memory pool '%s': %s\n",
+				__func__, slave_id,
+				mem_name, rte_strerror(rte_errno));
+			return -1;
 		}
 	}
 
@@ -2673,7 +2675,8 @@ struct bwg_slave {
 			mac_address_slaves_update(bonded_eth_dev);
 		}
 
-		activate_slave(bonded_eth_dev, port_id);
+		if (activate_slave(bonded_eth_dev, port_id) != 0)
+			return -1;
 
 		/* If user has defined the primary port then default to using it */
 		if (internals->user_defined_primary_port &&
diff --git a/drivers/net/bonding/rte_eth_bond_private.h b/drivers/net/bonding/rte_eth_bond_private.h
index 94eca88..d99d42c 100644
--- a/drivers/net/bonding/rte_eth_bond_private.h
+++ b/drivers/net/bonding/rte_eth_bond_private.h
@@ -187,7 +187,7 @@ struct bond_dev_private {
 void
 deactivate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id);
 
-void
+int
 activate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id);
 
 void
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v8 03/10] e1000: replace rte_panic instances in e1000 driver
  2018-04-25 13:45 ` [dpdk-dev] [PATCH v8 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 01/10] crypto/dpaa: replace rte_panic instances in crypto/dpaa driver Arnon Warshavsky
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 02/10] bond: replace rte_panic instances in bonding driver Arnon Warshavsky
@ 2018-04-25 13:45   ` Arnon Warshavsky
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 04/10] ixgbe: replace rte_panic instances in ixgbe driver Arnon Warshavsky
                     ` (7 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-25 13:45 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

replace panic calls with log and return value.
Local function to this file,
changing from void to int is non-abi-breaking

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 drivers/net/e1000/e1000_ethdev.h |  2 +-
 drivers/net/e1000/igb_ethdev.c   |  4 +++-
 drivers/net/e1000/igb_pf.c       | 15 +++++++++------
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h
index 6354b89..2e527de 100644
--- a/drivers/net/e1000/e1000_ethdev.h
+++ b/drivers/net/e1000/e1000_ethdev.h
@@ -411,7 +411,7 @@ int eth_igb_rss_hash_conf_get(struct rte_eth_dev *dev,
 /*
  * misc function prototypes
  */
-void igb_pf_host_init(struct rte_eth_dev *eth_dev);
+int igb_pf_host_init(struct rte_eth_dev *eth_dev);
 
 void igb_pf_mbx_process(struct rte_eth_dev *eth_dev);
 
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 9b808a9..67a32a2 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -833,7 +833,9 @@ static int igb_flex_filter_uninit(struct rte_eth_dev *eth_dev)
 	}
 
 	/* initialize PF if max_vfs not zero */
-	igb_pf_host_init(eth_dev);
+	error = igb_pf_host_init(eth_dev);
+	if (error != 0)
+		goto err_late;
 
 	ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
 	/* Set PF Reset Done bit so PF/VF Mail Ops can work */
diff --git a/drivers/net/e1000/igb_pf.c b/drivers/net/e1000/igb_pf.c
index b9f2e53..6e511a9 100644
--- a/drivers/net/e1000/igb_pf.c
+++ b/drivers/net/e1000/igb_pf.c
@@ -63,7 +63,7 @@ int igb_vf_perm_addr_gen(struct rte_eth_dev *dev, uint16_t vf_num)
 	return 0;
 }
 
-void igb_pf_host_init(struct rte_eth_dev *eth_dev)
+int igb_pf_host_init(struct rte_eth_dev *eth_dev)
 {
 	struct e1000_vf_info **vfinfo =
 		E1000_DEV_PRIVATE_TO_P_VFDATA(eth_dev->data->dev_private);
@@ -74,7 +74,7 @@ void igb_pf_host_init(struct rte_eth_dev *eth_dev)
 
 	RTE_ETH_DEV_SRIOV(eth_dev).active = 0;
 	if (0 == (vf_num = dev_num_vf(eth_dev)))
-		return;
+		return 0;
 
 	if (hw->mac.type == e1000_i350)
 		nb_queue = 1;
@@ -82,11 +82,14 @@ void igb_pf_host_init(struct rte_eth_dev *eth_dev)
 		/* per datasheet, it should be 2, but 1 seems correct */
 		nb_queue = 1;
 	else
-		return;
+		return 0;
 
 	*vfinfo = rte_zmalloc("vf_info", sizeof(struct e1000_vf_info) * vf_num, 0);
-	if (*vfinfo == NULL)
-		rte_panic("Cannot allocate memory for private VF data\n");
+	if (*vfinfo == NULL) {
+		PMD_DRV_LOG(CRIT, "%s(): Cannot allocate memory for private VF data\n",
+			__func__);
+		return -ENOMEM;
+	}
 
 	RTE_ETH_DEV_SRIOV(eth_dev).active = ETH_8_POOLS;
 	RTE_ETH_DEV_SRIOV(eth_dev).nb_q_per_pool = nb_queue;
@@ -98,7 +101,7 @@ void igb_pf_host_init(struct rte_eth_dev *eth_dev)
 	/* set mb interrupt mask */
 	igb_mb_intr_setup(eth_dev);
 
-	return;
+	return 0;
 }
 
 void igb_pf_host_uninit(struct rte_eth_dev *dev)
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v8 04/10] ixgbe: replace rte_panic instances in ixgbe driver
  2018-04-25 13:45 ` [dpdk-dev] [PATCH v8 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                     ` (2 preceding siblings ...)
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 03/10] e1000: replace rte_panic instances in e1000 driver Arnon Warshavsky
@ 2018-04-25 13:45   ` Arnon Warshavsky
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 05/10] eal: replace rte_panic instances in eventdev Arnon Warshavsky
                     ` (6 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-25 13:45 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

replace panic calls with log and return value.
Local function to this file,
changing from void to int is non-abi-breaking

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c |  6 ++++--
 drivers/net/ixgbe/ixgbe_ethdev.h |  2 +-
 drivers/net/ixgbe/ixgbe_pf.c     | 15 ++++++++++-----
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index a5e2fc0..fb95cc7 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1061,7 +1061,7 @@ struct rte_ixgbe_xstats_name_off {
 		IXGBE_DEV_PRIVATE_TO_BW_CONF(eth_dev->data->dev_private);
 	uint32_t ctrl_ext;
 	uint16_t csum;
-	int diag, i;
+	int diag, i, error;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -1224,7 +1224,9 @@ struct rte_ixgbe_xstats_name_off {
 	memset(hwstrip, 0, sizeof(*hwstrip));
 
 	/* initialize PF if max_vfs not zero */
-	ixgbe_pf_host_init(eth_dev);
+	error = ixgbe_pf_host_init(eth_dev);
+	if (error != 0)
+		return error;
 
 	ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
 	/* let hardware know driver is loaded */
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 6550777..8bb41ec 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -661,7 +661,7 @@ int ixgbe_fdir_filter_program(struct rte_eth_dev *dev,
 
 void ixgbe_vlan_hw_strip_config(struct rte_eth_dev *dev);
 
-void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev);
+int ixgbe_pf_host_init(struct rte_eth_dev *eth_dev);
 
 void ixgbe_pf_host_uninit(struct rte_eth_dev *eth_dev);
 
diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
index 4e61310..81a9910 100644
--- a/drivers/net/ixgbe/ixgbe_pf.c
+++ b/drivers/net/ixgbe/ixgbe_pf.c
@@ -66,7 +66,7 @@ int ixgbe_vf_perm_addr_gen(struct rte_eth_dev *dev, uint16_t vf_num)
 	return 0;
 }
 
-void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
+int ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
 {
 	struct ixgbe_vf_info **vfinfo =
 		IXGBE_DEV_PRIVATE_TO_P_VFDATA(eth_dev->data->dev_private);
@@ -84,11 +84,14 @@ void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
 	RTE_ETH_DEV_SRIOV(eth_dev).active = 0;
 	vf_num = dev_num_vf(eth_dev);
 	if (vf_num == 0)
-		return;
+		return 0;
 
 	*vfinfo = rte_zmalloc("vf_info", sizeof(struct ixgbe_vf_info) * vf_num, 0);
-	if (*vfinfo == NULL)
-		rte_panic("Cannot allocate memory for private VF data\n");
+	if (*vfinfo == NULL) {
+		PMD_DRV_LOG(ERR, "%s() Cannot allocate memory for private VF data\n",
+				__func__);
+		return -ENOMEM;
+	}
 
 	memset(mirror_info, 0, sizeof(struct ixgbe_mirror_info));
 	memset(uta_info, 0, sizeof(struct ixgbe_uta_info));
@@ -116,6 +119,8 @@ void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
 
 	/* set mb interrupt mask */
 	ixgbe_mb_intr_setup(eth_dev);
+
+	return 0;
 }
 
 void ixgbe_pf_host_uninit(struct rte_eth_dev *eth_dev)
@@ -203,7 +208,7 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 
 	vf_num = dev_num_vf(eth_dev);
 	if (vf_num == 0)
-		return -1;
+		return -ENOMEM;
 
 	/* enable VMDq and set the default pool for PF */
 	vtctl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v8 05/10] eal: replace rte_panic instances in eventdev
  2018-04-25 13:45 ` [dpdk-dev] [PATCH v8 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                     ` (3 preceding siblings ...)
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 04/10] ixgbe: replace rte_panic instances in ixgbe driver Arnon Warshavsky
@ 2018-04-25 13:45   ` Arnon Warshavsky
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 06/10] kni: replace rte_panic instances in kni Arnon Warshavsky
                     ` (5 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-25 13:45 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

replace panic calls with log and return value.

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 lib/librte_eventdev/rte_eventdev_pmd_pci.h  | 8 +++++---
 lib/librte_eventdev/rte_eventdev_pmd_vdev.h | 8 +++++---
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/lib/librte_eventdev/rte_eventdev_pmd_pci.h b/lib/librte_eventdev/rte_eventdev_pmd_pci.h
index 8fb6138..d4d10c8 100644
--- a/lib/librte_eventdev/rte_eventdev_pmd_pci.h
+++ b/lib/librte_eventdev/rte_eventdev_pmd_pci.h
@@ -66,9 +66,11 @@
 						RTE_CACHE_LINE_SIZE,
 						rte_socket_id());
 
-		if (eventdev->data->dev_private == NULL)
-			rte_panic("Cannot allocate memzone for private "
-					"device data");
+		if (eventdev->data->dev_private == NULL) {
+			RTE_EDEV_LOG_ERR("%s(): Cannot allocate memzone for private device data",
+				__func__);
+			return -ENOMEM;
+		}
 	}
 
 	eventdev->dev = &pci_dev->device;
diff --git a/lib/librte_eventdev/rte_eventdev_pmd_vdev.h b/lib/librte_eventdev/rte_eventdev_pmd_vdev.h
index 8c64a06..3c35aac 100644
--- a/lib/librte_eventdev/rte_eventdev_pmd_vdev.h
+++ b/lib/librte_eventdev/rte_eventdev_pmd_vdev.h
@@ -61,9 +61,11 @@
 						RTE_CACHE_LINE_SIZE,
 						socket_id);
 
-		if (eventdev->data->dev_private == NULL)
-			rte_panic("Cannot allocate memzone for private device"
-					" data");
+		if (eventdev->data->dev_private == NULL) {
+			RTE_EDEV_LOG_ERR("%s(): Cannot allocate memzone for private device data",
+				__func__);
+			return NULL;
+		}
 	}
 
 	return eventdev;
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v8 06/10] kni: replace rte_panic instances in kni
  2018-04-25 13:45 ` [dpdk-dev] [PATCH v8 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                     ` (4 preceding siblings ...)
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 05/10] eal: replace rte_panic instances in eventdev Arnon Warshavsky
@ 2018-04-25 13:45   ` Arnon Warshavsky
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 07/10] eal: replace rte_panic instances in hugepage_info Arnon Warshavsky
                     ` (4 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-25 13:45 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

replace panic calls with log and return value.
Local function to this file,
changing from void to int is non-abi-breaking

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 lib/librte_kni/rte_kni.c      | 18 ++++++++++++------
 lib/librte_kni/rte_kni_fifo.h | 11 ++++++++---
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index 8a8f6c1..4dac407 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -353,37 +353,43 @@ struct rte_kni *
 	/* TX RING */
 	mz = slot->m_tx_q;
 	ctx->tx_q = mz->addr;
-	kni_fifo_init(ctx->tx_q, KNI_FIFO_COUNT_MAX);
+	if (kni_fifo_init(ctx->tx_q, KNI_FIFO_COUNT_MAX))
+		return NULL;
 	dev_info.tx_phys = mz->phys_addr;
 
 	/* RX RING */
 	mz = slot->m_rx_q;
 	ctx->rx_q = mz->addr;
-	kni_fifo_init(ctx->rx_q, KNI_FIFO_COUNT_MAX);
+	if (kni_fifo_init(ctx->rx_q, KNI_FIFO_COUNT_MAX))
+		return NULL;
 	dev_info.rx_phys = mz->phys_addr;
 
 	/* ALLOC RING */
 	mz = slot->m_alloc_q;
 	ctx->alloc_q = mz->addr;
-	kni_fifo_init(ctx->alloc_q, KNI_FIFO_COUNT_MAX);
+	if (kni_fifo_init(ctx->alloc_q, KNI_FIFO_COUNT_MAX))
+		return NULL;
 	dev_info.alloc_phys = mz->phys_addr;
 
 	/* FREE RING */
 	mz = slot->m_free_q;
 	ctx->free_q = mz->addr;
-	kni_fifo_init(ctx->free_q, KNI_FIFO_COUNT_MAX);
+	if (kni_fifo_init(ctx->free_q, KNI_FIFO_COUNT_MAX))
+		return NULL;
 	dev_info.free_phys = mz->phys_addr;
 
 	/* Request RING */
 	mz = slot->m_req_q;
 	ctx->req_q = mz->addr;
-	kni_fifo_init(ctx->req_q, KNI_FIFO_COUNT_MAX);
+	if (kni_fifo_init(ctx->req_q, KNI_FIFO_COUNT_MAX))
+		return NULL;
 	dev_info.req_phys = mz->phys_addr;
 
 	/* Response RING */
 	mz = slot->m_resp_q;
 	ctx->resp_q = mz->addr;
-	kni_fifo_init(ctx->resp_q, KNI_FIFO_COUNT_MAX);
+	if (kni_fifo_init(ctx->resp_q, KNI_FIFO_COUNT_MAX))
+		return NULL;
 	dev_info.resp_phys = mz->phys_addr;
 
 	/* Req/Resp sync mem area */
diff --git a/lib/librte_kni/rte_kni_fifo.h b/lib/librte_kni/rte_kni_fifo.h
index ac26a8c..5052015 100644
--- a/lib/librte_kni/rte_kni_fifo.h
+++ b/lib/librte_kni/rte_kni_fifo.h
@@ -7,17 +7,22 @@
 /**
  * Initializes the kni fifo structure
  */
-static void
+static int
 kni_fifo_init(struct rte_kni_fifo *fifo, unsigned size)
 {
 	/* Ensure size is power of 2 */
-	if (size & (size - 1))
-		rte_panic("KNI fifo size must be power of 2\n");
+	if (size & (size - 1)) {
+		RTE_LOG(CRIT, EAL, "%s(): KNI fifo size must be power of 2\n",
+				__func__);
+		return -1;
+	}
 
 	fifo->write = 0;
 	fifo->read = 0;
 	fifo->len = size;
 	fifo->elem_size = sizeof(void *);
+
+	return 0;
 }
 
 /**
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v8 07/10] eal: replace rte_panic instances in hugepage_info
  2018-04-25 13:45 ` [dpdk-dev] [PATCH v8 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                     ` (5 preceding siblings ...)
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 06/10] kni: replace rte_panic instances in kni Arnon Warshavsky
@ 2018-04-25 13:45   ` Arnon Warshavsky
  2018-04-25 13:50     ` Burakov, Anatoly
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 08/10] eal: replace rte_panic instances in ethdev Arnon Warshavsky
                     ` (3 subsequent siblings)
  10 siblings, 1 reply; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-25 13:45 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

replace panic calls with log and return value.

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 lib/librte_eal/linuxapp/eal/eal_hugepage_info.c | 37 +++++++++++++++++--------
 1 file changed, 26 insertions(+), 11 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c
index db5aabd..797b8fa 100644
--- a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c
+++ b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c
@@ -145,8 +145,8 @@
 	return num_pages;
 }
 
-static uint64_t
-get_default_hp_size(void)
+static int
+get_default_hp_size(uint64_t *result)
 {
 	const char proc_meminfo[] = "/proc/meminfo";
 	const char str_hugepagesz[] = "Hugepagesize:";
@@ -155,8 +155,11 @@
 	unsigned long long size = 0;
 
 	FILE *fd = fopen(proc_meminfo, "r");
-	if (fd == NULL)
-		rte_panic("Cannot open %s\n", proc_meminfo);
+	if (fd == NULL) {
+		RTE_LOG(CRIT, EAL, "%s(): Cannot open %s\n",
+				__func__, proc_meminfo);
+		return -1;
+	}
 	while(fgets(buffer, sizeof(buffer), fd)){
 		if (strncmp(buffer, str_hugepagesz, hugepagesz_len) == 0){
 			size = rte_str_to_size(&buffer[hugepagesz_len]);
@@ -164,9 +167,13 @@
 		}
 	}
 	fclose(fd);
-	if (size == 0)
-		rte_panic("Cannot get default hugepage size from %s\n", proc_meminfo);
-	return size;
+	if (size == 0) {
+		RTE_LOG(CRIT, EAL, "%s(): Cannot get default hugepage size from %s\n",
+						 __func__, proc_meminfo);
+		return -1;
+	}
+	*result = size;
+	return 0;
 }
 
 static int
@@ -191,11 +198,19 @@
 	int retval = -1;
 
 	FILE *fd = fopen(proc_mounts, "r");
-	if (fd == NULL)
-		rte_panic("Cannot open %s\n", proc_mounts);
+	if (fd == NULL) {
+		RTE_LOG(CRIT, EAL, "%s(): Cannot open %s\n",
+				__func__, proc_mounts);
+		return -ENOENT;
+	}
 
-	if (default_size == 0)
-		default_size = get_default_hp_size();
+	if (default_size == 0) {
+		retval = get_default_hp_size(&default_size);
+		if (retval) {
+			fclose(fd);
+			return retval;
+		}
+	}
 
 	while (fgets(buf, sizeof(buf), fd)){
 		if (rte_strsplit(buf, sizeof(buf), splitstr, _FIELDNAME_MAX,
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v8 08/10] eal: replace rte_panic instances in ethdev
  2018-04-25 13:45 ` [dpdk-dev] [PATCH v8 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                     ` (6 preceding siblings ...)
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 07/10] eal: replace rte_panic instances in hugepage_info Arnon Warshavsky
@ 2018-04-25 13:45   ` Arnon Warshavsky
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 09/10] eal: replace rte_panic instances in init sequence Arnon Warshavsky
                     ` (2 subsequent siblings)
  10 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-25 13:45 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

Local function to this file,
changing from void to int is non-abi-breaking

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 lib/librte_ether/rte_ethdev.c | 42 ++++++++++++++++++++++++++++++------------
 lib/librte_ether/rte_ethdev.h |  4 +++-
 2 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index f0f53d4..940de15 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -194,7 +194,7 @@ enum {
 	return port_id;
 }
 
-static void
+static int
 rte_eth_dev_shared_data_prepare(void)
 {
 	const unsigned flags = 0;
@@ -210,8 +210,12 @@ enum {
 					rte_socket_id(), flags);
 		} else
 			mz = rte_memzone_lookup(MZ_RTE_ETH_DEV_DATA);
-		if (mz == NULL)
-			rte_panic("Cannot allocate ethdev shared data\n");
+		if (mz == NULL) {
+			rte_spinlock_unlock(&rte_eth_shared_data_lock);
+			RTE_LOG(CRIT, EAL, "%s(): Cannot allocate ethdev shared data\n",
+					__func__);
+			return -1;
+		}
 
 		rte_eth_dev_shared_data = mz->addr;
 		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
@@ -224,6 +228,8 @@ enum {
 	}
 
 	rte_spinlock_unlock(&rte_eth_shared_data_lock);
+
+	return 0;
 }
 
 struct rte_eth_dev *
@@ -274,7 +280,8 @@ struct rte_eth_dev *
 	uint16_t port_id;
 	struct rte_eth_dev *eth_dev = NULL;
 
-	rte_eth_dev_shared_data_prepare();
+	if (rte_eth_dev_shared_data_prepare() != 0)
+		return NULL;
 
 	/* Synchronize port creation between primary and secondary threads. */
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
@@ -317,7 +324,8 @@ struct rte_eth_dev *
 	uint16_t i;
 	struct rte_eth_dev *eth_dev = NULL;
 
-	rte_eth_dev_shared_data_prepare();
+	if (rte_eth_dev_shared_data_prepare() != 0)
+		return NULL;
 
 	/* Synchronize port attachment to primary port creation and release. */
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
@@ -345,7 +353,8 @@ struct rte_eth_dev *
 	if (eth_dev == NULL)
 		return -EINVAL;
 
-	rte_eth_dev_shared_data_prepare();
+	if (rte_eth_dev_shared_data_prepare() != 0)
+		return -1;
 
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
@@ -399,7 +408,8 @@ struct rte_eth_dev *
 int __rte_experimental
 rte_eth_dev_owner_new(uint64_t *owner_id)
 {
-	rte_eth_dev_shared_data_prepare();
+	if (rte_eth_dev_shared_data_prepare() != 0)
+		return -1;
 
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
@@ -450,7 +460,8 @@ struct rte_eth_dev *
 {
 	int ret;
 
-	rte_eth_dev_shared_data_prepare();
+	if (rte_eth_dev_shared_data_prepare() != 0)
+		return -1;
 
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
@@ -467,7 +478,8 @@ struct rte_eth_dev *
 			{.id = RTE_ETH_DEV_NO_OWNER, .name = ""};
 	int ret;
 
-	rte_eth_dev_shared_data_prepare();
+	if (rte_eth_dev_shared_data_prepare() != 0)
+		return -1;
 
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
@@ -477,12 +489,15 @@ struct rte_eth_dev *
 	return ret;
 }
 
-void __rte_experimental
+int __rte_experimental
 rte_eth_dev_owner_delete(const uint64_t owner_id)
 {
 	uint16_t port_id;
+	int error;
 
-	rte_eth_dev_shared_data_prepare();
+	error = rte_eth_dev_shared_data_prepare();
+	if (error != 0)
+		return error;
 
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
@@ -495,6 +510,8 @@ struct rte_eth_dev *
 	}
 
 	rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock);
+
+	return 0;
 }
 
 int __rte_experimental
@@ -502,7 +519,8 @@ struct rte_eth_dev *
 {
 	int ret = 0;
 
-	rte_eth_dev_shared_data_prepare();
+	if (rte_eth_dev_shared_data_prepare() != 0)
+		return -1;
 
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index b9eb8ae..46e5947 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1354,8 +1354,10 @@ int __rte_experimental rte_eth_dev_owner_unset(const uint16_t port_id,
  *
  * @param	owner_id
  *  The owner identifier.
+ *  @return
+ *  0 on success, negative errno value on error.
  */
-void __rte_experimental rte_eth_dev_owner_delete(const uint64_t owner_id);
+int __rte_experimental rte_eth_dev_owner_delete(const uint64_t owner_id);
 
 /**
  * @warning
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v8 09/10] eal: replace rte_panic instances in init sequence
  2018-04-25 13:45 ` [dpdk-dev] [PATCH v8 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                     ` (7 preceding siblings ...)
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 08/10] eal: replace rte_panic instances in ethdev Arnon Warshavsky
@ 2018-04-25 13:45   ` Arnon Warshavsky
  2018-04-25 13:53     ` Burakov, Anatoly
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 10/10] devtools: prevent new instances of rte_panic and rte_exit Arnon Warshavsky
  2018-04-25 15:59   ` [dpdk-dev] [PATCH v8 " Stephen Hemminger
  10 siblings, 1 reply; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-25 13:45 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

Change some local functions return type from void to int.
This change does not break ABI as the functions are internal.
Panic thrown from threads was not handled in this patch

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 lib/librte_eal/bsdapp/eal/eal.c   |  69 +++++++++++++++++++-------
 lib/librte_eal/linuxapp/eal/eal.c | 101 ++++++++++++++++++++++++++------------
 2 files changed, 119 insertions(+), 51 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 10d8dc0..3110f53 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -151,7 +151,7 @@ enum rte_iova_mode
  * We also don't lock the whole file, so that in future we can use read-locks
  * on other parts, e.g. memzones, to detect if there are running secondary
  * processes. */
-static void
+static int
 rte_eal_config_create(void)
 {
 	void *rte_mem_cfg_addr;
@@ -160,60 +160,81 @@ enum rte_iova_mode
 	const char *pathname = eal_runtime_config_path();
 
 	if (internal_config.no_shconf)
-		return;
+		return 0;
 
 	if (mem_cfg_fd < 0){
 		mem_cfg_fd = open(pathname, O_RDWR | O_CREAT, 0660);
-		if (mem_cfg_fd < 0)
-			rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
+		if (mem_cfg_fd < 0) {
+			RTE_LOG(CRIT, EAL, "%s(): Cannot open '%s' for rte_mem_config\n",
+					__func__, pathname);
+			return -1;
+		}
 	}
 
 	retval = ftruncate(mem_cfg_fd, sizeof(*rte_config.mem_config));
 	if (retval < 0){
 		close(mem_cfg_fd);
-		rte_panic("Cannot resize '%s' for rte_mem_config\n", pathname);
+		mem_cfg_fd = -1;
+		RTE_LOG(CRIT, EAL, "%s(): Cannot resize '%s' for rte_mem_config\n",
+				__func__, pathname);
+		return -1;
 	}
 
 	retval = fcntl(mem_cfg_fd, F_SETLK, &wr_lock);
 	if (retval < 0){
 		close(mem_cfg_fd);
-		rte_exit(EXIT_FAILURE, "Cannot create lock on '%s'. Is another primary "
-				"process running?\n", pathname);
+		mem_cfg_fd = -1;
+		RTE_LOG(CRIT, EAL, "%s(): Cannot create lock on '%s'. Is another primary process running?\n",
+				__func__, pathname);
+		return -1;
 	}
 
 	rte_mem_cfg_addr = mmap(NULL, sizeof(*rte_config.mem_config),
 				PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
 
 	if (rte_mem_cfg_addr == MAP_FAILED){
-		rte_panic("Cannot mmap memory for rte_config\n");
+		RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config\n",
+				__func__);
+		return -1;
 	}
 	memcpy(rte_mem_cfg_addr, &early_mem_config, sizeof(early_mem_config));
 	rte_config.mem_config = rte_mem_cfg_addr;
+
+	return 0;
 }
 
 /* attach to an existing shared memory config */
-static void
+static int
 rte_eal_config_attach(void)
 {
 	void *rte_mem_cfg_addr;
 	const char *pathname = eal_runtime_config_path();
 
 	if (internal_config.no_shconf)
-		return;
+		return 0;
 
 	if (mem_cfg_fd < 0){
 		mem_cfg_fd = open(pathname, O_RDWR);
-		if (mem_cfg_fd < 0)
-			rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
+		if (mem_cfg_fd < 0) {
+			RTE_LOG(CRIT, EAL, "%s(): Cannot open '%s' for rte_mem_config\n",
+					__func__, pathname);
+			return -1;
+		}
 	}
 
 	rte_mem_cfg_addr = mmap(NULL, sizeof(*rte_config.mem_config),
 				PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
 	close(mem_cfg_fd);
-	if (rte_mem_cfg_addr == MAP_FAILED)
-		rte_panic("Cannot mmap memory for rte_config\n");
+	if (rte_mem_cfg_addr == MAP_FAILED) {
+		mem_cfg_fd = -1;
+		RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config\n",
+				__func__);
+		return -1;
+	}
 
 	rte_config.mem_config = rte_mem_cfg_addr;
+
+	return 0;
 }
 
 /* Detect if we are a primary or a secondary process */
@@ -237,23 +258,29 @@ enum rte_proc_type_t
 }
 
 /* Sets up rte_config structure with the pointer to shared memory config.*/
-static void
+static int
 rte_config_init(void)
 {
 	rte_config.process_type = internal_config.process_type;
 
 	switch (rte_config.process_type){
 	case RTE_PROC_PRIMARY:
-		rte_eal_config_create();
+		if (rte_eal_config_create())
+			return -1;
 		break;
 	case RTE_PROC_SECONDARY:
-		rte_eal_config_attach();
+		if (rte_eal_config_attach())
+			return -1;
 		rte_eal_mcfg_wait_complete(rte_config.mem_config);
 		break;
 	case RTE_PROC_AUTO:
 	case RTE_PROC_INVALID:
-		rte_panic("Invalid process type\n");
+	default:
+		RTE_LOG(CRIT, EAL, "%s(): Invalid process type %d\n",
+				__func__, rte_config.process_type);
+		return -1;
 	}
+	return 0;
 }
 
 /* display usage */
@@ -552,7 +579,11 @@ static void rte_eal_init_alert(const char *msg)
 		return -1;
 	}
 
-	rte_config_init();
+	if (rte_config_init() != 0) {
+		rte_eal_init_alert("Failed to init configuration");
+		rte_errno = EFAULT;
+		return -1;
+	}
 
 	/* Put mp channel init before bus scan so that we can init the vdev
 	 * bus through mp channel in the secondary process before the bus scan.
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 200e879..c0d704b 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -160,7 +160,7 @@ enum rte_iova_mode
  * We also don't lock the whole file, so that in future we can use read-locks
  * on other parts, e.g. memzones, to detect if there are running secondary
  * processes. */
-static void
+static int
 rte_eal_config_create(void)
 {
 	void *rte_mem_cfg_addr;
@@ -169,7 +169,7 @@ enum rte_iova_mode
 	const char *pathname = eal_runtime_config_path();
 
 	if (internal_config.no_shconf)
-		return;
+		return 0;
 
 	/* map the config before hugepage address so that we don't waste a page */
 	if (internal_config.base_virtaddr != 0)
@@ -179,30 +179,42 @@ enum rte_iova_mode
 	else
 		rte_mem_cfg_addr = NULL;
 
-	if (mem_cfg_fd < 0){
+	if (mem_cfg_fd < 0) {
 		mem_cfg_fd = open(pathname, O_RDWR | O_CREAT, 0660);
-		if (mem_cfg_fd < 0)
-			rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
+		if (mem_cfg_fd < 0) {
+			RTE_LOG(CRIT, EAL, "%s(): Cannot open '%s' for rte_mem_config\n",
+				__func__, pathname);
+			return -1;
+		}
 	}
 
 	retval = ftruncate(mem_cfg_fd, sizeof(*rte_config.mem_config));
-	if (retval < 0){
+	if (retval < 0) {
 		close(mem_cfg_fd);
-		rte_panic("Cannot resize '%s' for rte_mem_config\n", pathname);
+		mem_cfg_fd = -1;
+		RTE_LOG(CRIT, EAL, "%s(): Cannot resize '%s' for rte_mem_config\n",
+				__func__, pathname);
+		return -1;
 	}
 
 	retval = fcntl(mem_cfg_fd, F_SETLK, &wr_lock);
-	if (retval < 0){
+	if (retval < 0) {
 		close(mem_cfg_fd);
-		rte_exit(EXIT_FAILURE, "Cannot create lock on '%s'. Is another primary "
-				"process running?\n", pathname);
+		mem_cfg_fd = -1;
+		RTE_LOG(CRIT, EAL, "%s(): Cannot create lock on '%s'.Is another primary process running?\n",
+			__func__, pathname);
+		return -1;
 	}
 
 	rte_mem_cfg_addr = mmap(rte_mem_cfg_addr, sizeof(*rte_config.mem_config),
 				PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
 
-	if (rte_mem_cfg_addr == MAP_FAILED){
-		rte_panic("Cannot mmap memory for rte_config\n");
+	if (rte_mem_cfg_addr == MAP_FAILED) {
+		RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config\n",
+			__func__);
+		close(mem_cfg_fd);
+		mem_cfg_fd = -1;
+		return -1;
 	}
 	memcpy(rte_mem_cfg_addr, &early_mem_config, sizeof(early_mem_config));
 	rte_config.mem_config = rte_mem_cfg_addr;
@@ -211,10 +223,11 @@ enum rte_iova_mode
 	 * processes could later map the config into this exact location */
 	rte_config.mem_config->mem_cfg_addr = (uintptr_t) rte_mem_cfg_addr;
 
+	return 0;
 }
 
 /* attach to an existing shared memory config */
-static void
+static int
 rte_eal_config_attach(void)
 {
 	struct rte_mem_config *mem_config;
@@ -222,33 +235,42 @@ enum rte_iova_mode
 	const char *pathname = eal_runtime_config_path();
 
 	if (internal_config.no_shconf)
-		return;
+		return 0;
 
-	if (mem_cfg_fd < 0){
+	if (mem_cfg_fd < 0) {
 		mem_cfg_fd = open(pathname, O_RDWR);
-		if (mem_cfg_fd < 0)
-			rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
+		if (mem_cfg_fd < 0) {
+			RTE_LOG(CRIT, EAL, "%s(): Cannot open '%s' for rte_mem_config\n",
+						__func__, pathname);
+			return -1;
+		}
 	}
 
 	/* map it as read-only first */
 	mem_config = (struct rte_mem_config *) mmap(NULL, sizeof(*mem_config),
 			PROT_READ, MAP_SHARED, mem_cfg_fd, 0);
-	if (mem_config == MAP_FAILED)
-		rte_panic("Cannot mmap memory for rte_config! error %i (%s)\n",
-			  errno, strerror(errno));
+	if (mem_config == MAP_FAILED) {
+		close(mem_cfg_fd);
+		mem_cfg_fd = -1;
+		RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config! error %i (%s)\n",
+				__func__, errno, strerror(errno));
+		return -1;
+	}
 
 	rte_config.mem_config = mem_config;
+
+	return 0;
 }
 
 /* reattach the shared config at exact memory location primary process has it */
-static void
+static int
 rte_eal_config_reattach(void)
 {
 	struct rte_mem_config *mem_config;
 	void *rte_mem_cfg_addr;
 
 	if (internal_config.no_shconf)
-		return;
+		return 0;
 
 	/* save the address primary process has mapped shared config to */
 	rte_mem_cfg_addr = (void *) (uintptr_t) rte_config.mem_config->mem_cfg_addr;
@@ -263,16 +285,20 @@ enum rte_iova_mode
 	if (mem_config == MAP_FAILED || mem_config != rte_mem_cfg_addr) {
 		if (mem_config != MAP_FAILED)
 			/* errno is stale, don't use */
-			rte_panic("Cannot mmap memory for rte_config at [%p], got [%p]"
-				  " - please use '--base-virtaddr' option\n",
-				  rte_mem_cfg_addr, mem_config);
+			RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config at [%p], got [%p] - please use '--base-virtaddr' option\n",
+					__func__, rte_mem_cfg_addr, mem_config);
 		else
-			rte_panic("Cannot mmap memory for rte_config! error %i (%s)\n",
-				  errno, strerror(errno));
+			RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config! error %i (%s)\n",
+					__func__, errno, strerror(errno));
+		close(mem_cfg_fd);
+		mem_cfg_fd = -1;
+		return -1;
 	}
 	close(mem_cfg_fd);
 
 	rte_config.mem_config = mem_config;
+
+	return 0;
 }
 
 /* Detect if we are a primary or a secondary process */
@@ -296,24 +322,32 @@ enum rte_proc_type_t
 }
 
 /* Sets up rte_config structure with the pointer to shared memory config.*/
-static void
+static int
 rte_config_init(void)
 {
 	rte_config.process_type = internal_config.process_type;
 
 	switch (rte_config.process_type){
 	case RTE_PROC_PRIMARY:
-		rte_eal_config_create();
+		if (rte_eal_config_create())
+			return -1;
 		break;
 	case RTE_PROC_SECONDARY:
-		rte_eal_config_attach();
+		if (rte_eal_config_attach())
+			return -1;
 		rte_eal_mcfg_wait_complete(rte_config.mem_config);
-		rte_eal_config_reattach();
+		if (rte_eal_config_reattach())
+			return -1;
 		break;
 	case RTE_PROC_AUTO:
 	case RTE_PROC_INVALID:
-		rte_panic("Invalid process type\n");
+	default:
+		RTE_LOG(CRIT, EAL, "%s(): Invalid process type %d\n",
+				__func__, rte_config.process_type);
+		return -1;
 	}
+
+	return 0;
 }
 
 /* Unlocks hugepage directories that were locked by eal_hugepage_info_init */
@@ -833,6 +867,9 @@ static void rte_eal_init_alert(const char *msg)
 
 	rte_srand(rte_rdtsc());
 
+	if (rte_config_init() != 0)
+		return -1;
+
 	if (rte_eal_log_init(logid, internal_config.syslog_facility) < 0) {
 		rte_eal_init_alert("Cannot init logging.");
 		rte_errno = ENOMEM;
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v8 10/10] devtools: prevent new instances of rte_panic and rte_exit
  2018-04-25 13:45 ` [dpdk-dev] [PATCH v8 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                     ` (8 preceding siblings ...)
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 09/10] eal: replace rte_panic instances in init sequence Arnon Warshavsky
@ 2018-04-25 13:45   ` Arnon Warshavsky
  2018-04-26  6:20     ` [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
  2018-04-25 15:59   ` [dpdk-dev] [PATCH v8 " Stephen Hemminger
  10 siblings, 1 reply; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-25 13:45 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

This patch adds a new function that is called
per every checked patch,
and alerts for new instances of rte_panic/rte_exit.
The check excludes comments, and alerts in the case
of a positive balance between additions and removals.

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 devtools/checkpatches.sh | 95 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 94 insertions(+), 1 deletion(-)

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 7676a6b..48b2685 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -61,6 +61,91 @@ print_usage () {
 	END_OF_HELP
 }
 
+check_forbidden_additions() { # <file>
+    # ---------------------------------
+    #This awk script receives a list of expressions to monitor
+    #and a list of folders to search these expressions in
+    # - No search is done inside comments
+    # - Both additions and removals of the expressions are checked
+    #   A positive balance of additions fails the check
+	read -d '' awk_script << 'EOF'
+	BEGIN{
+		split(FOLDERS,deny_folders," ");
+		split(EXPRESSIONS,deny_expr," ");
+		in_file=0;
+		in_comment=0;
+		count=0;
+		comment_start="/*"
+		comment_end="*/"
+    }
+    # search for add/remove instances in current file
+    # state machine assumes the comments structure is enforced by
+    # checkpatches.pl
+    (in_file) {
+		# comment start
+		if (index($0,comment_start) > 0){
+			in_comment = 1
+		}
+		# non comment code
+		if (in_comment == 0) {
+			for (i in deny_expr) {
+				forbidden_added = "^\+.*" deny_expr[i];
+				forbidden_removed="^-.*" deny_expr[i];
+				current = expressions[deny_expr[i]]
+				if ($0 ~ forbidden_added) {
+					count = count + 1;
+					expressions[deny_expr[i]] = current + 1
+				}
+				if ($0 ~ forbidden_removed) {
+					count = count - 1;
+					expressions[deny_expr[i]] = current - 1
+				}
+			}
+		}
+
+		# comment end
+		if (index($0,comment_end) > 0)  {
+			in_comment = 0
+		}
+    }
+	# switch to next file , check if the balance of add/remove
+	# of previous filehad new additions
+	($0 ~ "^\+\+\+ b/") {
+		in_file = 0;
+		if (count > 0){
+			exit;
+		}
+		for (i in deny_folders){
+			re = "^\+\+\+ b/" deny_folders[i];
+			if ($0 ~ deny_folders[i]) {
+				in_file = 1
+				last_file = $0
+			}
+		}
+	}
+	END{
+		if (count > 0){
+			print "Warning: in " substr(last_file,6) ":"
+			print "are you sure you want to add the following:"
+			for (key in expressions) {
+				if (expressions[key] > 0) {
+					print key
+				}
+			}
+			exit 1
+		}
+	}
+EOF
+	# ---------------------------------
+
+	# refrain from new additions of rte_panic() and rte_exit()
+	# under lib and net
+	# multiple folders and expressions are separated by spaces
+	awk -v FOLDERS="lib net" \
+		-v EXPRESSIONS="rte_panic\\\( rte_exit\\\(" \
+		"$awk_script" -
+}
+
 number=0
 quiet=false
 verbose=false
@@ -89,11 +174,19 @@ check () { # <patch> <commit> <title>
 	total=$(($total + 1))
 	! $verbose || printf '\n### %s\n\n' "$3"
 	if [ -n "$1" ] ; then
+		cat "$1" | check_forbidden_additions
+		[ $? -eq 0 ] || return 0
 		report=$($DPDK_CHECKPATCH_PATH $options "$1" 2>/dev/null)
 	elif [ -n "$2" ] ; then
-		report=$(git format-patch --find-renames --no-stat --stdout -1 $commit |
+		params=$(echo "--find-renames --no-stat --stdout -1")
+		body=$(git format-patch $params $commit)
+		echo "$body" | check_forbidden_additions
+		[ $? -eq 0 ] || return 0
+		report=$(echo "$body" |
 			$DPDK_CHECKPATCH_PATH $options - 2>/dev/null)
 	else
+		check_forbidden_additions -
+		[ $? -eq 0 ] || return 0
 		report=$($DPDK_CHECKPATCH_PATH $options - 2>/dev/null)
 	fi
 	[ $? -ne 0 ] || return 0
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v8 07/10] eal: replace rte_panic instances in hugepage_info
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 07/10] eal: replace rte_panic instances in hugepage_info Arnon Warshavsky
@ 2018-04-25 13:50     ` Burakov, Anatoly
  2018-04-25 14:02       ` Arnon Warshavsky
  0 siblings, 1 reply; 91+ messages in thread
From: Burakov, Anatoly @ 2018-04-25 13:50 UTC (permalink / raw)
  To: Arnon Warshavsky, thomas, wenzhuo.lu, declan.doherty,
	jerin.jacob, bruce.richardson, ferruh.yigit
  Cc: dev

On 25-Apr-18 2:45 PM, Arnon Warshavsky wrote:
> replace panic calls with log and return value.
> 
> Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
> ---

I think i've already acked this. You should keep acks etc. between 
versions (unless you're making significant enough changes that you think 
would invalidate a prior ack). Having acks makes it easier to track what 
still needs to be reviewed and what is good to go, and it makes it 
easier to see if the entire patchset is ready for apply.

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v8 09/10] eal: replace rte_panic instances in init sequence
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 09/10] eal: replace rte_panic instances in init sequence Arnon Warshavsky
@ 2018-04-25 13:53     ` Burakov, Anatoly
  0 siblings, 0 replies; 91+ messages in thread
From: Burakov, Anatoly @ 2018-04-25 13:53 UTC (permalink / raw)
  To: Arnon Warshavsky, thomas, wenzhuo.lu, declan.doherty,
	jerin.jacob, bruce.richardson, ferruh.yigit
  Cc: dev

On 25-Apr-18 2:45 PM, Arnon Warshavsky wrote:
> Change some local functions return type from void to int.
> This change does not break ABI as the functions are internal.
> Panic thrown from threads was not handled in this patch
> 
> Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
> ---

<...>

>   	retval = fcntl(mem_cfg_fd, F_SETLK, &wr_lock);
>   	if (retval < 0){
>   		close(mem_cfg_fd);
> -		rte_exit(EXIT_FAILURE, "Cannot create lock on '%s'. Is another primary "
> -				"process running?\n", pathname);
> +		mem_cfg_fd = -1;
> +		RTE_LOG(CRIT, EAL, "%s(): Cannot create lock on '%s'. Is another primary process running?\n",
> +				__func__, pathname);
> +		return -1;
>   	}
>   
>   	rte_mem_cfg_addr = mmap(NULL, sizeof(*rte_config.mem_config),
>   				PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
>   
>   	if (rte_mem_cfg_addr == MAP_FAILED){
> -		rte_panic("Cannot mmap memory for rte_config\n");
> +		RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config\n",
> +				__func__);
> +		return -1;

Still missing mem_cfg_fd close() and set to -1 here.

Once this is fixed,

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

And please keep my ack this time :)

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v8 07/10] eal: replace rte_panic instances in hugepage_info
  2018-04-25 13:50     ` Burakov, Anatoly
@ 2018-04-25 14:02       ` Arnon Warshavsky
  2018-04-25 14:14         ` Burakov, Anatoly
  0 siblings, 1 reply; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-25 14:02 UTC (permalink / raw)
  To: Burakov, Anatoly
  Cc: Thomas Monjalon, Lu, Wenzhuo, Doherty, Declan, jerin.jacob,
	Bruce Richardson, Yigit, Ferruh, dev

> I think i've already acked this. You should keep acks etc. between
> versions (unless you're making significant enough changes that you think
> would invalidate a prior ack). Having acks makes it easier to track what
> still needs to be reviewed and what is good to go, and it makes it easier
> to see if the entire patchset is ready for apply.


Hmm, so unless I am missing yet another thing - this needs to be done
manually?

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v8 07/10] eal: replace rte_panic instances in hugepage_info
  2018-04-25 14:02       ` Arnon Warshavsky
@ 2018-04-25 14:14         ` Burakov, Anatoly
  0 siblings, 0 replies; 91+ messages in thread
From: Burakov, Anatoly @ 2018-04-25 14:14 UTC (permalink / raw)
  To: Arnon Warshavsky
  Cc: Thomas Monjalon, Lu, Wenzhuo, Doherty, Declan, jerin.jacob,
	Bruce Richardson, Yigit, Ferruh, dev

On 25-Apr-18 3:02 PM, Arnon Warshavsky wrote:
> 
>     I think i've already acked this. You should keep acks etc. between
>     versions (unless you're making significant enough changes that you
>     think would invalidate a prior ack). Having acks makes it easier to
>     track what still needs to be reviewed and what is good to go, and it
>     makes it easier to see if the entire patchset is ready for apply.
> 
> 
> Hmm, so unless I am missing yet another thing - this needs to be done 
> manually?
> 

Yes. Well, if someone series-acks your patch, you can do "git 
filter-branch", but for individual patches, yes, you need to do this 
manually by editing the commit message.

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v8 00/10] eal: replace calls to rte_panic and refrain from new instances
  2018-04-25 13:45 ` [dpdk-dev] [PATCH v8 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                     ` (9 preceding siblings ...)
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 10/10] devtools: prevent new instances of rte_panic and rte_exit Arnon Warshavsky
@ 2018-04-25 15:59   ` Stephen Hemminger
  10 siblings, 0 replies; 91+ messages in thread
From: Stephen Hemminger @ 2018-04-25 15:59 UTC (permalink / raw)
  To: Arnon Warshavsky
  Cc: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit, dev

On Wed, 25 Apr 2018 16:45:34 +0300
Arnon Warshavsky <arnon@qwilt.com> wrote:

> The purpose of this patch series is to cleanup the library code
> from paths that end up aborting the process,
> and move to checking error values, in order to allow the running process
> perform an orderly teardown or other mitigation of the event.
> 
> This patch modifies the majority of rte_panic calls
> under lib and drivers, and replaces them with a log message
> and an error return code according to context,
> that can be propagated up the call stack.
> 
> - Focus was given to the dpdk initialization path
> - Some of the panic calls within drivers were left in place where
>   the call is from within an interrupt or calls that are
>   on the data path,where there is no simple applicative
>   route to propagate the error to temination.
>   These should be handled by the driver maintainers..
> - local void functions with no api were changed to retrun a value
>   where needed
> - No change took place in example and test files
> - No change took place for debug assertions calling panic
> - A new function was added to devtools/checkpatches.sh
>   in order to prevent new additions of calls to rte_panic
>   under lib and drivers.
> 
> Keep calm and don't panic
> 
> ---
> 
> v2:
> - reformat error messages so that literal string are in the same line
> - fix typo in commit message
> - add new return code to doxigen of rte_memzone_free()
> 
> v3:
> - submit  all 13 patches changed and unchanged in the same patchset
> 
> v4:
> - remove 2 patches that are no more relevant
> - fix split literal string in error message
> - change return value -1 to enum
> - split value and success code in a static function
> 
> v5:
> - reword commit messages
> - revert thread related instances back to panicing
> - handle file descriptors with state to reset after eal init failure
>   in case re initialization takes place
> 
> v6:
> - Use pmd log macro rather than rte_log
> 
> v7:
> - use bond specific , dpaa2 specific and eventdev specific log macros
> 
> v8:
> - Seperate the 2 drivers salad back to distinct bond and dpaa patches
> - Add missing file descriptor closing when returnning an error
> - Remove half baked thread patch to be handled in the next version
> - Remove duplicate function call after rebase 
> 
> Arnon Warshavsky (10):
>   crypto/dpaa: replace rte_panic instances in crypto/dpaa driver
>   bond: replace rte_panic instances in bonding driver
>   e1000: replace rte_panic instances in e1000 driver
>   ixgbe: replace rte_panic instances in ixgbe driver
>   eal: replace rte_panic instances in eventdev
>   kni: replace rte_panic instances in kni
>   eal: replace rte_panic instances in hugepage_info
>   eal: replace rte_panic instances in ethdev
>   eal: replace rte_panic instances in init sequence
>   devtools: prevent new instances of rte_panic and rte_exit
> 
>  devtools/checkpatches.sh                          |  95 +++++++++++++++++++-
>  drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c       |   8 +-
>  drivers/crypto/dpaa_sec/dpaa_sec.c                |  10 ++-
>  drivers/net/bonding/rte_eth_bond_8023ad.c         |  29 ++++---
>  drivers/net/bonding/rte_eth_bond_8023ad_private.h |   2 +-
>  drivers/net/bonding/rte_eth_bond_api.c            |  22 +++--
>  drivers/net/bonding/rte_eth_bond_pmd.c            |   9 +-
>  drivers/net/bonding/rte_eth_bond_private.h        |   2 +-
>  drivers/net/e1000/e1000_ethdev.h                  |   2 +-
>  drivers/net/e1000/igb_ethdev.c                    |   4 +-
>  drivers/net/e1000/igb_pf.c                        |  15 ++--
>  drivers/net/ixgbe/ixgbe_ethdev.c                  |   6 +-
>  drivers/net/ixgbe/ixgbe_ethdev.h                  |   2 +-
>  drivers/net/ixgbe/ixgbe_pf.c                      |  15 ++--
>  lib/librte_eal/bsdapp/eal/eal.c                   |  69 +++++++++++----
>  lib/librte_eal/linuxapp/eal/eal.c                 | 101 +++++++++++++++-------
>  lib/librte_eal/linuxapp/eal/eal_hugepage_info.c   |  37 +++++---
>  lib/librte_ether/rte_ethdev.c                     |  42 ++++++---
>  lib/librte_ether/rte_ethdev.h                     |   4 +-
>  lib/librte_eventdev/rte_eventdev_pmd_pci.h        |   8 +-
>  lib/librte_eventdev/rte_eventdev_pmd_vdev.h       |   8 +-
>  lib/librte_kni/rte_kni.c                          |  18 ++--
>  lib/librte_kni/rte_kni_fifo.h                     |  11 ++-
>  23 files changed, 383 insertions(+), 136 deletions(-)
> 

Looks good.

Thanks for following through and fixing this.

Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances
  2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 10/10] devtools: prevent new instances of rte_panic and rte_exit Arnon Warshavsky
@ 2018-04-26  6:20     ` Arnon Warshavsky
  2018-04-26  6:20       ` [dpdk-dev] [PATCH v9 01/10] crypto/dpaa: replace rte_panic instances in crypto/dpaa driver Arnon Warshavsky
                         ` (11 more replies)
  0 siblings, 12 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-26  6:20 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

The purpose of this patch series is to cleanup the library code
from paths that end up aborting the process,
and move to checking error values, in order to allow the running process
perform an orderly teardown or other mitigation of the event.

This patch modifies the majority of rte_panic calls
under lib and drivers, and replaces them with a log message
and an error return code according to context,
that can be propagated up the call stack.

- Focus was given to the dpdk initialization path
- Some of the panic calls within drivers were left in place where
  the call is from within an interrupt or calls that are
  on the data path,where there is no simple applicative
  route to propagate the error to temination.
  These should be handled by the driver maintainers..
- local void functions with no api were changed to retrun a value
  where needed
- No change took place in example and test files
- No change took place for debug assertions calling panic
- A new function was added to devtools/checkpatches.sh
  in order to prevent new additions of calls to rte_panic
  under lib and drivers.

Keep calm and don't panic

---

v2:
- reformat error messages so that literal string are in the same line
- fix typo in commit message
- add new return code to doxigen of rte_memzone_free()

v3:
- submit  all 13 patches changed and unchanged in the same patchset

v4:
- remove 2 patches that are no more relevant
- fix split literal string in error message
- change return value -1 to enum
- split value and success code in a static function

v5:
- reword commit messages
- revert thread related instances back to panicing
- handle file descriptors with state to reset after eal init failure
  in case re initialization takes place

v6:
- Use pmd log macro rather than rte_log

v7:
- use bond specific , dpaa2 specific and eventdev specific log macros

v8:
- Seperate the 2 drivers salad back to distinct bond and dpaa patches
- Add missing file descriptor closing when returnning an error
- Remove half baked thread patch to be handled in the next version
- Remove duplicate function call after rebase

v9:
- Add missing file descriptor closing when retruning with error


Arnon Warshavsky (10):
  crypto/dpaa: replace rte_panic instances in crypto/dpaa driver
  bond: replace rte_panic instances in bonding driver
  e1000: replace rte_panic instances in e1000 driver
  ixgbe: replace rte_panic instances in ixgbe driver
  eal: replace rte_panic instances in eventdev
  kni: replace rte_panic instances in kni
  eal: replace rte_panic instances in hugepage_info
  eal: replace rte_panic instances in ethdev
  eal: replace rte_panic instances in init sequence
  devtools: prevent new instances of rte_panic and rte_exit

 devtools/checkpatches.sh                          |  95 +++++++++++++++++++-
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c       |   8 +-
 drivers/crypto/dpaa_sec/dpaa_sec.c                |  10 ++-
 drivers/net/bonding/rte_eth_bond_8023ad.c         |  29 ++++---
 drivers/net/bonding/rte_eth_bond_8023ad_private.h |   2 +-
 drivers/net/bonding/rte_eth_bond_api.c            |  22 +++--
 drivers/net/bonding/rte_eth_bond_pmd.c            |   9 +-
 drivers/net/bonding/rte_eth_bond_private.h        |   2 +-
 drivers/net/e1000/e1000_ethdev.h                  |   2 +-
 drivers/net/e1000/igb_ethdev.c                    |   4 +-
 drivers/net/e1000/igb_pf.c                        |  15 ++--
 drivers/net/ixgbe/ixgbe_ethdev.c                  |   6 +-
 drivers/net/ixgbe/ixgbe_ethdev.h                  |   2 +-
 drivers/net/ixgbe/ixgbe_pf.c                      |  15 ++--
 lib/librte_eal/bsdapp/eal/eal.c                   |  71 +++++++++++----
 lib/librte_eal/linuxapp/eal/eal.c                 | 101 +++++++++++++++-------
 lib/librte_eal/linuxapp/eal/eal_hugepage_info.c   |  37 +++++---
 lib/librte_ether/rte_ethdev.c                     |  42 ++++++---
 lib/librte_ether/rte_ethdev.h                     |   4 +-
 lib/librte_eventdev/rte_eventdev_pmd_pci.h        |   8 +-
 lib/librte_eventdev/rte_eventdev_pmd_vdev.h       |   8 +-
 lib/librte_kni/rte_kni.c                          |  18 ++--
 lib/librte_kni/rte_kni_fifo.h                     |  11 ++-
 23 files changed, 385 insertions(+), 136 deletions(-)

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v9 01/10] crypto/dpaa: replace rte_panic instances in crypto/dpaa driver
  2018-04-26  6:20     ` [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
@ 2018-04-26  6:20       ` Arnon Warshavsky
  2018-04-26  6:20       ` [dpdk-dev] [PATCH v9 02/10] bond: replace rte_panic instances in bonding driver Arnon Warshavsky
                         ` (10 subsequent siblings)
  11 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-26  6:20 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

replace panic calls with log and return value.

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c |  8 +++++---
 drivers/crypto/dpaa_sec/dpaa_sec.c          | 10 ++++++----
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 58cbce8..a19fb40 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -2883,9 +2883,11 @@ struct rte_security_ops dpaa2_sec_security_ops = {
 					RTE_CACHE_LINE_SIZE,
 					rte_socket_id());
 
-		if (cryptodev->data->dev_private == NULL)
-			rte_panic("Cannot allocate memzone for private "
-				  "device data");
+		if (cryptodev->data->dev_private == NULL) {
+			DPAA2_SEC_ERR("%s() Cannot allocate memzone for private device data",
+			__func__);
+			return -ENOMEM;
+		}
 	}
 
 	dpaa2_dev->cryptodev = cryptodev;
diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index e456fd5..a4670bf 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -2352,7 +2352,7 @@ struct rte_security_ops dpaa_sec_security_ops = {
 		}
 	}
 
-	RTE_LOG(INFO, PMD, "%s cryptodev init\n", cryptodev->data->name);
+	DPAA_SEC_INFO("%s cryptodev init\n", cryptodev->data->name);
 	return 0;
 
 init_error:
@@ -2384,9 +2384,11 @@ struct rte_security_ops dpaa_sec_security_ops = {
 					RTE_CACHE_LINE_SIZE,
 					rte_socket_id());
 
-		if (cryptodev->data->dev_private == NULL)
-			rte_panic("Cannot allocate memzone for private "
-					"device data");
+		if (cryptodev->data->dev_private == NULL) {
+			DPAA_SEC_ERR("%s() Cannot allocate memzone for private device data",
+			__func__);
+			return -ENOMEM;
+		}
 	}
 
 	dpaa_dev->crypto_dev = cryptodev;
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v9 02/10] bond: replace rte_panic instances in bonding driver
  2018-04-26  6:20     ` [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
  2018-04-26  6:20       ` [dpdk-dev] [PATCH v9 01/10] crypto/dpaa: replace rte_panic instances in crypto/dpaa driver Arnon Warshavsky
@ 2018-04-26  6:20       ` Arnon Warshavsky
  2018-04-26 16:06         ` Kevin Traynor
  2018-04-26  6:20       ` [dpdk-dev] [PATCH v9 03/10] e1000: replace rte_panic instances in e1000 driver Arnon Warshavsky
                         ` (9 subsequent siblings)
  11 siblings, 1 reply; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-26  6:20 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

Replace panic calls with log and return value.
Local functions to this file,
changing from void to int are non-abi-breaking

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 drivers/net/bonding/rte_eth_bond_8023ad.c         | 29 ++++++++++++++---------
 drivers/net/bonding/rte_eth_bond_8023ad_private.h |  2 +-
 drivers/net/bonding/rte_eth_bond_api.c            | 22 ++++++++++++-----
 drivers/net/bonding/rte_eth_bond_pmd.c            |  9 ++++---
 drivers/net/bonding/rte_eth_bond_private.h        |  2 +-
 5 files changed, 42 insertions(+), 22 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
index c452318..308e623 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -893,7 +893,7 @@
 			bond_mode_8023ad_periodic_cb, arg);
 }
 
-void
+int
 bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev,
 				uint16_t slave_id)
 {
@@ -939,7 +939,7 @@
 	timer_cancel(&port->warning_timer);
 
 	if (port->mbuf_pool != NULL)
-		return;
+		return 0;
 
 	RTE_ASSERT(port->rx_ring == NULL);
 	RTE_ASSERT(port->tx_ring == NULL);
@@ -968,8 +968,9 @@
 	/* Any memory allocation failure in initialization is critical because
 	 * resources can't be free, so reinitialization is impossible. */
 	if (port->mbuf_pool == NULL) {
-		rte_panic("Slave %u: Failed to create memory pool '%s': %s\n",
-			slave_id, mem_name, rte_strerror(rte_errno));
+		RTE_BOND_LOG(ERR, "%s() Slave %u: Failed to create memory pool '%s': %s\n",
+			__func__, slave_id, mem_name, rte_strerror(rte_errno));
+		return -1;
 	}
 
 	snprintf(mem_name, RTE_DIM(mem_name), "slave_%u_rx", slave_id);
@@ -977,8 +978,9 @@
 			rte_align32pow2(BOND_MODE_8023AX_SLAVE_RX_PKTS), socket_id, 0);
 
 	if (port->rx_ring == NULL) {
-		rte_panic("Slave %u: Failed to create rx ring '%s': %s\n", slave_id,
-			mem_name, rte_strerror(rte_errno));
+		RTE_BOND_LOG(ERR, "%s() Slave %u: Failed to create rx ring '%s': %s\n",
+			__func__, slave_id, mem_name, rte_strerror(rte_errno));
+		return -1;
 	}
 
 	/* TX ring is at least one pkt longer to make room for marker packet. */
@@ -987,9 +989,12 @@
 			rte_align32pow2(BOND_MODE_8023AX_SLAVE_TX_PKTS + 1), socket_id, 0);
 
 	if (port->tx_ring == NULL) {
-		rte_panic("Slave %u: Failed to create tx ring '%s': %s\n", slave_id,
-			mem_name, rte_strerror(rte_errno));
+		RTE_BOND_LOG(ERR, "%s() Slave %u: Fail to create tx ring '%s': %s\n",
+			__func__, slave_id, mem_name, rte_strerror(rte_errno));
+		return -1;
 	}
+
+	return 0;
 }
 
 int
@@ -1143,9 +1148,11 @@
 	struct bond_dev_private *internals = bond_dev->data->dev_private;
 	uint8_t i;
 
-	for (i = 0; i < internals->active_slave_count; i++)
-		bond_mode_8023ad_activate_slave(bond_dev,
-				internals->active_slaves[i]);
+	for (i = 0; i < internals->active_slave_count; i++) {
+		if (!bond_mode_8023ad_activate_slave(bond_dev,
+						internals->active_slaves[i]))
+			return -1;
+	}
 
 	return 0;
 }
diff --git a/drivers/net/bonding/rte_eth_bond_8023ad_private.h b/drivers/net/bonding/rte_eth_bond_8023ad_private.h
index 0f490a5..96a42f2 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad_private.h
+++ b/drivers/net/bonding/rte_eth_bond_8023ad_private.h
@@ -263,7 +263,7 @@ struct mode8023ad_private {
  * @return
  *  0 on success, negative value otherwise.
  */
-void
+int
 bond_mode_8023ad_activate_slave(struct rte_eth_dev *dev, uint16_t port_id);
 
 /**
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index aa89425..657fd74 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -69,14 +69,15 @@
 	return 0;
 }
 
-void
+int
 activate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id)
 {
 	struct bond_dev_private *internals = eth_dev->data->dev_private;
 	uint8_t active_count = internals->active_slave_count;
 
 	if (internals->mode == BONDING_MODE_8023AD)
-		bond_mode_8023ad_activate_slave(eth_dev, port_id);
+		if (bond_mode_8023ad_activate_slave(eth_dev, port_id) != 0)
+			return -1;
 
 	if (internals->mode == BONDING_MODE_TLB
 			|| internals->mode == BONDING_MODE_ALB) {
@@ -94,6 +95,8 @@
 		bond_tlb_activate_slave(internals);
 	if (internals->mode == BONDING_MODE_ALB)
 		bond_mode_alb_client_list_upd(eth_dev);
+
+	return 0;
 }
 
 void
@@ -357,10 +360,17 @@
 				bond_ethdev_primary_set(internals,
 							slave_port_id);
 
-			if (find_slave_by_id(internals->active_slaves,
-					     internals->active_slave_count,
-					     slave_port_id) == internals->active_slave_count)
-				activate_slave(bonded_eth_dev, slave_port_id);
+			int rc =
+				find_slave_by_id(internals->active_slaves,
+					internals->active_slave_count,
+					slave_port_id);
+
+			if (rc == internals->active_slave_count) {
+				int rc = activate_slave(bonded_eth_dev,
+							slave_port_id);
+				if (rc != 0)
+					return -1;
+			}
 		}
 	}
 
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 09696ea..d2dbe4a 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -1741,8 +1741,10 @@ struct bwg_slave {
 		/* Any memory allocation failure in initialization is critical because
 		 * resources can't be free, so reinitialization is impossible. */
 		if (port->slow_pool == NULL) {
-			rte_panic("Slave %u: Failed to create memory pool '%s': %s\n",
-				slave_id, mem_name, rte_strerror(rte_errno));
+			RTE_BOND_LOG(ERR, "%s() Slave %u: Failed to create memory pool '%s': %s\n",
+				__func__, slave_id,
+				mem_name, rte_strerror(rte_errno));
+			return -1;
 		}
 	}
 
@@ -2673,7 +2675,8 @@ struct bwg_slave {
 			mac_address_slaves_update(bonded_eth_dev);
 		}
 
-		activate_slave(bonded_eth_dev, port_id);
+		if (activate_slave(bonded_eth_dev, port_id) != 0)
+			return -1;
 
 		/* If user has defined the primary port then default to using it */
 		if (internals->user_defined_primary_port &&
diff --git a/drivers/net/bonding/rte_eth_bond_private.h b/drivers/net/bonding/rte_eth_bond_private.h
index 94eca88..d99d42c 100644
--- a/drivers/net/bonding/rte_eth_bond_private.h
+++ b/drivers/net/bonding/rte_eth_bond_private.h
@@ -187,7 +187,7 @@ struct bond_dev_private {
 void
 deactivate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id);
 
-void
+int
 activate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id);
 
 void
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v9 03/10] e1000: replace rte_panic instances in e1000 driver
  2018-04-26  6:20     ` [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
  2018-04-26  6:20       ` [dpdk-dev] [PATCH v9 01/10] crypto/dpaa: replace rte_panic instances in crypto/dpaa driver Arnon Warshavsky
  2018-04-26  6:20       ` [dpdk-dev] [PATCH v9 02/10] bond: replace rte_panic instances in bonding driver Arnon Warshavsky
@ 2018-04-26  6:20       ` Arnon Warshavsky
  2018-04-26  6:20       ` [dpdk-dev] [PATCH v9 04/10] ixgbe: replace rte_panic instances in ixgbe driver Arnon Warshavsky
                         ` (8 subsequent siblings)
  11 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-26  6:20 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

replace panic calls with log and return value.
Local function to this file,
changing from void to int is non-abi-breaking

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 drivers/net/e1000/e1000_ethdev.h |  2 +-
 drivers/net/e1000/igb_ethdev.c   |  4 +++-
 drivers/net/e1000/igb_pf.c       | 15 +++++++++------
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h
index 6354b89..2e527de 100644
--- a/drivers/net/e1000/e1000_ethdev.h
+++ b/drivers/net/e1000/e1000_ethdev.h
@@ -411,7 +411,7 @@ int eth_igb_rss_hash_conf_get(struct rte_eth_dev *dev,
 /*
  * misc function prototypes
  */
-void igb_pf_host_init(struct rte_eth_dev *eth_dev);
+int igb_pf_host_init(struct rte_eth_dev *eth_dev);
 
 void igb_pf_mbx_process(struct rte_eth_dev *eth_dev);
 
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 9b808a9..67a32a2 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -833,7 +833,9 @@ static int igb_flex_filter_uninit(struct rte_eth_dev *eth_dev)
 	}
 
 	/* initialize PF if max_vfs not zero */
-	igb_pf_host_init(eth_dev);
+	error = igb_pf_host_init(eth_dev);
+	if (error != 0)
+		goto err_late;
 
 	ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
 	/* Set PF Reset Done bit so PF/VF Mail Ops can work */
diff --git a/drivers/net/e1000/igb_pf.c b/drivers/net/e1000/igb_pf.c
index b9f2e53..6e511a9 100644
--- a/drivers/net/e1000/igb_pf.c
+++ b/drivers/net/e1000/igb_pf.c
@@ -63,7 +63,7 @@ int igb_vf_perm_addr_gen(struct rte_eth_dev *dev, uint16_t vf_num)
 	return 0;
 }
 
-void igb_pf_host_init(struct rte_eth_dev *eth_dev)
+int igb_pf_host_init(struct rte_eth_dev *eth_dev)
 {
 	struct e1000_vf_info **vfinfo =
 		E1000_DEV_PRIVATE_TO_P_VFDATA(eth_dev->data->dev_private);
@@ -74,7 +74,7 @@ void igb_pf_host_init(struct rte_eth_dev *eth_dev)
 
 	RTE_ETH_DEV_SRIOV(eth_dev).active = 0;
 	if (0 == (vf_num = dev_num_vf(eth_dev)))
-		return;
+		return 0;
 
 	if (hw->mac.type == e1000_i350)
 		nb_queue = 1;
@@ -82,11 +82,14 @@ void igb_pf_host_init(struct rte_eth_dev *eth_dev)
 		/* per datasheet, it should be 2, but 1 seems correct */
 		nb_queue = 1;
 	else
-		return;
+		return 0;
 
 	*vfinfo = rte_zmalloc("vf_info", sizeof(struct e1000_vf_info) * vf_num, 0);
-	if (*vfinfo == NULL)
-		rte_panic("Cannot allocate memory for private VF data\n");
+	if (*vfinfo == NULL) {
+		PMD_DRV_LOG(CRIT, "%s(): Cannot allocate memory for private VF data\n",
+			__func__);
+		return -ENOMEM;
+	}
 
 	RTE_ETH_DEV_SRIOV(eth_dev).active = ETH_8_POOLS;
 	RTE_ETH_DEV_SRIOV(eth_dev).nb_q_per_pool = nb_queue;
@@ -98,7 +101,7 @@ void igb_pf_host_init(struct rte_eth_dev *eth_dev)
 	/* set mb interrupt mask */
 	igb_mb_intr_setup(eth_dev);
 
-	return;
+	return 0;
 }
 
 void igb_pf_host_uninit(struct rte_eth_dev *dev)
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v9 04/10] ixgbe: replace rte_panic instances in ixgbe driver
  2018-04-26  6:20     ` [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                         ` (2 preceding siblings ...)
  2018-04-26  6:20       ` [dpdk-dev] [PATCH v9 03/10] e1000: replace rte_panic instances in e1000 driver Arnon Warshavsky
@ 2018-04-26  6:20       ` Arnon Warshavsky
  2018-04-26  6:20       ` [dpdk-dev] [PATCH v9 05/10] eal: replace rte_panic instances in eventdev Arnon Warshavsky
                         ` (7 subsequent siblings)
  11 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-26  6:20 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

replace panic calls with log and return value.
Local function to this file,
changing from void to int is non-abi-breaking

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c |  6 ++++--
 drivers/net/ixgbe/ixgbe_ethdev.h |  2 +-
 drivers/net/ixgbe/ixgbe_pf.c     | 15 ++++++++++-----
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index a5e2fc0..fb95cc7 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1061,7 +1061,7 @@ struct rte_ixgbe_xstats_name_off {
 		IXGBE_DEV_PRIVATE_TO_BW_CONF(eth_dev->data->dev_private);
 	uint32_t ctrl_ext;
 	uint16_t csum;
-	int diag, i;
+	int diag, i, error;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -1224,7 +1224,9 @@ struct rte_ixgbe_xstats_name_off {
 	memset(hwstrip, 0, sizeof(*hwstrip));
 
 	/* initialize PF if max_vfs not zero */
-	ixgbe_pf_host_init(eth_dev);
+	error = ixgbe_pf_host_init(eth_dev);
+	if (error != 0)
+		return error;
 
 	ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
 	/* let hardware know driver is loaded */
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 6550777..8bb41ec 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -661,7 +661,7 @@ int ixgbe_fdir_filter_program(struct rte_eth_dev *dev,
 
 void ixgbe_vlan_hw_strip_config(struct rte_eth_dev *dev);
 
-void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev);
+int ixgbe_pf_host_init(struct rte_eth_dev *eth_dev);
 
 void ixgbe_pf_host_uninit(struct rte_eth_dev *eth_dev);
 
diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
index 4e61310..81a9910 100644
--- a/drivers/net/ixgbe/ixgbe_pf.c
+++ b/drivers/net/ixgbe/ixgbe_pf.c
@@ -66,7 +66,7 @@ int ixgbe_vf_perm_addr_gen(struct rte_eth_dev *dev, uint16_t vf_num)
 	return 0;
 }
 
-void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
+int ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
 {
 	struct ixgbe_vf_info **vfinfo =
 		IXGBE_DEV_PRIVATE_TO_P_VFDATA(eth_dev->data->dev_private);
@@ -84,11 +84,14 @@ void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
 	RTE_ETH_DEV_SRIOV(eth_dev).active = 0;
 	vf_num = dev_num_vf(eth_dev);
 	if (vf_num == 0)
-		return;
+		return 0;
 
 	*vfinfo = rte_zmalloc("vf_info", sizeof(struct ixgbe_vf_info) * vf_num, 0);
-	if (*vfinfo == NULL)
-		rte_panic("Cannot allocate memory for private VF data\n");
+	if (*vfinfo == NULL) {
+		PMD_DRV_LOG(ERR, "%s() Cannot allocate memory for private VF data\n",
+				__func__);
+		return -ENOMEM;
+	}
 
 	memset(mirror_info, 0, sizeof(struct ixgbe_mirror_info));
 	memset(uta_info, 0, sizeof(struct ixgbe_uta_info));
@@ -116,6 +119,8 @@ void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
 
 	/* set mb interrupt mask */
 	ixgbe_mb_intr_setup(eth_dev);
+
+	return 0;
 }
 
 void ixgbe_pf_host_uninit(struct rte_eth_dev *eth_dev)
@@ -203,7 +208,7 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 
 	vf_num = dev_num_vf(eth_dev);
 	if (vf_num == 0)
-		return -1;
+		return -ENOMEM;
 
 	/* enable VMDq and set the default pool for PF */
 	vtctl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v9 05/10] eal: replace rte_panic instances in eventdev
  2018-04-26  6:20     ` [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                         ` (3 preceding siblings ...)
  2018-04-26  6:20       ` [dpdk-dev] [PATCH v9 04/10] ixgbe: replace rte_panic instances in ixgbe driver Arnon Warshavsky
@ 2018-04-26  6:20       ` Arnon Warshavsky
  2018-04-26  6:21       ` [dpdk-dev] [PATCH v9 06/10] kni: replace rte_panic instances in kni Arnon Warshavsky
                         ` (6 subsequent siblings)
  11 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-26  6:20 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

replace panic calls with log and return value.

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 lib/librte_eventdev/rte_eventdev_pmd_pci.h  | 8 +++++---
 lib/librte_eventdev/rte_eventdev_pmd_vdev.h | 8 +++++---
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/lib/librte_eventdev/rte_eventdev_pmd_pci.h b/lib/librte_eventdev/rte_eventdev_pmd_pci.h
index 8fb6138..d4d10c8 100644
--- a/lib/librte_eventdev/rte_eventdev_pmd_pci.h
+++ b/lib/librte_eventdev/rte_eventdev_pmd_pci.h
@@ -66,9 +66,11 @@
 						RTE_CACHE_LINE_SIZE,
 						rte_socket_id());
 
-		if (eventdev->data->dev_private == NULL)
-			rte_panic("Cannot allocate memzone for private "
-					"device data");
+		if (eventdev->data->dev_private == NULL) {
+			RTE_EDEV_LOG_ERR("%s(): Cannot allocate memzone for private device data",
+				__func__);
+			return -ENOMEM;
+		}
 	}
 
 	eventdev->dev = &pci_dev->device;
diff --git a/lib/librte_eventdev/rte_eventdev_pmd_vdev.h b/lib/librte_eventdev/rte_eventdev_pmd_vdev.h
index 8c64a06..3c35aac 100644
--- a/lib/librte_eventdev/rte_eventdev_pmd_vdev.h
+++ b/lib/librte_eventdev/rte_eventdev_pmd_vdev.h
@@ -61,9 +61,11 @@
 						RTE_CACHE_LINE_SIZE,
 						socket_id);
 
-		if (eventdev->data->dev_private == NULL)
-			rte_panic("Cannot allocate memzone for private device"
-					" data");
+		if (eventdev->data->dev_private == NULL) {
+			RTE_EDEV_LOG_ERR("%s(): Cannot allocate memzone for private device data",
+				__func__);
+			return NULL;
+		}
 	}
 
 	return eventdev;
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v9 06/10] kni: replace rte_panic instances in kni
  2018-04-26  6:20     ` [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                         ` (4 preceding siblings ...)
  2018-04-26  6:20       ` [dpdk-dev] [PATCH v9 05/10] eal: replace rte_panic instances in eventdev Arnon Warshavsky
@ 2018-04-26  6:21       ` Arnon Warshavsky
  2018-04-26  6:21       ` [dpdk-dev] [PATCH v9 07/10] eal: replace rte_panic instances in hugepage_info Arnon Warshavsky
                         ` (5 subsequent siblings)
  11 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-26  6:21 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

replace panic calls with log and return value.
Local function to this file,
changing from void to int is non-abi-breaking

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 lib/librte_kni/rte_kni.c      | 18 ++++++++++++------
 lib/librte_kni/rte_kni_fifo.h | 11 ++++++++---
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index 8a8f6c1..4dac407 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -353,37 +353,43 @@ struct rte_kni *
 	/* TX RING */
 	mz = slot->m_tx_q;
 	ctx->tx_q = mz->addr;
-	kni_fifo_init(ctx->tx_q, KNI_FIFO_COUNT_MAX);
+	if (kni_fifo_init(ctx->tx_q, KNI_FIFO_COUNT_MAX))
+		return NULL;
 	dev_info.tx_phys = mz->phys_addr;
 
 	/* RX RING */
 	mz = slot->m_rx_q;
 	ctx->rx_q = mz->addr;
-	kni_fifo_init(ctx->rx_q, KNI_FIFO_COUNT_MAX);
+	if (kni_fifo_init(ctx->rx_q, KNI_FIFO_COUNT_MAX))
+		return NULL;
 	dev_info.rx_phys = mz->phys_addr;
 
 	/* ALLOC RING */
 	mz = slot->m_alloc_q;
 	ctx->alloc_q = mz->addr;
-	kni_fifo_init(ctx->alloc_q, KNI_FIFO_COUNT_MAX);
+	if (kni_fifo_init(ctx->alloc_q, KNI_FIFO_COUNT_MAX))
+		return NULL;
 	dev_info.alloc_phys = mz->phys_addr;
 
 	/* FREE RING */
 	mz = slot->m_free_q;
 	ctx->free_q = mz->addr;
-	kni_fifo_init(ctx->free_q, KNI_FIFO_COUNT_MAX);
+	if (kni_fifo_init(ctx->free_q, KNI_FIFO_COUNT_MAX))
+		return NULL;
 	dev_info.free_phys = mz->phys_addr;
 
 	/* Request RING */
 	mz = slot->m_req_q;
 	ctx->req_q = mz->addr;
-	kni_fifo_init(ctx->req_q, KNI_FIFO_COUNT_MAX);
+	if (kni_fifo_init(ctx->req_q, KNI_FIFO_COUNT_MAX))
+		return NULL;
 	dev_info.req_phys = mz->phys_addr;
 
 	/* Response RING */
 	mz = slot->m_resp_q;
 	ctx->resp_q = mz->addr;
-	kni_fifo_init(ctx->resp_q, KNI_FIFO_COUNT_MAX);
+	if (kni_fifo_init(ctx->resp_q, KNI_FIFO_COUNT_MAX))
+		return NULL;
 	dev_info.resp_phys = mz->phys_addr;
 
 	/* Req/Resp sync mem area */
diff --git a/lib/librte_kni/rte_kni_fifo.h b/lib/librte_kni/rte_kni_fifo.h
index ac26a8c..5052015 100644
--- a/lib/librte_kni/rte_kni_fifo.h
+++ b/lib/librte_kni/rte_kni_fifo.h
@@ -7,17 +7,22 @@
 /**
  * Initializes the kni fifo structure
  */
-static void
+static int
 kni_fifo_init(struct rte_kni_fifo *fifo, unsigned size)
 {
 	/* Ensure size is power of 2 */
-	if (size & (size - 1))
-		rte_panic("KNI fifo size must be power of 2\n");
+	if (size & (size - 1)) {
+		RTE_LOG(CRIT, EAL, "%s(): KNI fifo size must be power of 2\n",
+				__func__);
+		return -1;
+	}
 
 	fifo->write = 0;
 	fifo->read = 0;
 	fifo->len = size;
 	fifo->elem_size = sizeof(void *);
+
+	return 0;
 }
 
 /**
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v9 07/10] eal: replace rte_panic instances in hugepage_info
  2018-04-26  6:20     ` [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                         ` (5 preceding siblings ...)
  2018-04-26  6:21       ` [dpdk-dev] [PATCH v9 06/10] kni: replace rte_panic instances in kni Arnon Warshavsky
@ 2018-04-26  6:21       ` Arnon Warshavsky
  2018-04-26  6:21       ` [dpdk-dev] [PATCH v9 08/10] eal: replace rte_panic instances in ethdev Arnon Warshavsky
                         ` (4 subsequent siblings)
  11 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-26  6:21 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

replace panic calls with log and return value.

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/linuxapp/eal/eal_hugepage_info.c | 37 +++++++++++++++++--------
 1 file changed, 26 insertions(+), 11 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c
index db5aabd..797b8fa 100644
--- a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c
+++ b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c
@@ -145,8 +145,8 @@
 	return num_pages;
 }
 
-static uint64_t
-get_default_hp_size(void)
+static int
+get_default_hp_size(uint64_t *result)
 {
 	const char proc_meminfo[] = "/proc/meminfo";
 	const char str_hugepagesz[] = "Hugepagesize:";
@@ -155,8 +155,11 @@
 	unsigned long long size = 0;
 
 	FILE *fd = fopen(proc_meminfo, "r");
-	if (fd == NULL)
-		rte_panic("Cannot open %s\n", proc_meminfo);
+	if (fd == NULL) {
+		RTE_LOG(CRIT, EAL, "%s(): Cannot open %s\n",
+				__func__, proc_meminfo);
+		return -1;
+	}
 	while(fgets(buffer, sizeof(buffer), fd)){
 		if (strncmp(buffer, str_hugepagesz, hugepagesz_len) == 0){
 			size = rte_str_to_size(&buffer[hugepagesz_len]);
@@ -164,9 +167,13 @@
 		}
 	}
 	fclose(fd);
-	if (size == 0)
-		rte_panic("Cannot get default hugepage size from %s\n", proc_meminfo);
-	return size;
+	if (size == 0) {
+		RTE_LOG(CRIT, EAL, "%s(): Cannot get default hugepage size from %s\n",
+						 __func__, proc_meminfo);
+		return -1;
+	}
+	*result = size;
+	return 0;
 }
 
 static int
@@ -191,11 +198,19 @@
 	int retval = -1;
 
 	FILE *fd = fopen(proc_mounts, "r");
-	if (fd == NULL)
-		rte_panic("Cannot open %s\n", proc_mounts);
+	if (fd == NULL) {
+		RTE_LOG(CRIT, EAL, "%s(): Cannot open %s\n",
+				__func__, proc_mounts);
+		return -ENOENT;
+	}
 
-	if (default_size == 0)
-		default_size = get_default_hp_size();
+	if (default_size == 0) {
+		retval = get_default_hp_size(&default_size);
+		if (retval) {
+			fclose(fd);
+			return retval;
+		}
+	}
 
 	while (fgets(buf, sizeof(buf), fd)){
 		if (rte_strsplit(buf, sizeof(buf), splitstr, _FIELDNAME_MAX,
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v9 08/10] eal: replace rte_panic instances in ethdev
  2018-04-26  6:20     ` [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                         ` (6 preceding siblings ...)
  2018-04-26  6:21       ` [dpdk-dev] [PATCH v9 07/10] eal: replace rte_panic instances in hugepage_info Arnon Warshavsky
@ 2018-04-26  6:21       ` Arnon Warshavsky
  2018-04-26 16:07         ` Kevin Traynor
  2018-04-26  6:21       ` [dpdk-dev] [PATCH v9 09/10] eal: replace rte_panic instances in init sequence Arnon Warshavsky
                         ` (3 subsequent siblings)
  11 siblings, 1 reply; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-26  6:21 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

Local function to this file,
changing from void to int is non-abi-breaking

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 lib/librte_ether/rte_ethdev.c | 42 ++++++++++++++++++++++++++++++------------
 lib/librte_ether/rte_ethdev.h |  4 +++-
 2 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index f0f53d4..940de15 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -194,7 +194,7 @@ enum {
 	return port_id;
 }
 
-static void
+static int
 rte_eth_dev_shared_data_prepare(void)
 {
 	const unsigned flags = 0;
@@ -210,8 +210,12 @@ enum {
 					rte_socket_id(), flags);
 		} else
 			mz = rte_memzone_lookup(MZ_RTE_ETH_DEV_DATA);
-		if (mz == NULL)
-			rte_panic("Cannot allocate ethdev shared data\n");
+		if (mz == NULL) {
+			rte_spinlock_unlock(&rte_eth_shared_data_lock);
+			RTE_LOG(CRIT, EAL, "%s(): Cannot allocate ethdev shared data\n",
+					__func__);
+			return -1;
+		}
 
 		rte_eth_dev_shared_data = mz->addr;
 		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
@@ -224,6 +228,8 @@ enum {
 	}
 
 	rte_spinlock_unlock(&rte_eth_shared_data_lock);
+
+	return 0;
 }
 
 struct rte_eth_dev *
@@ -274,7 +280,8 @@ struct rte_eth_dev *
 	uint16_t port_id;
 	struct rte_eth_dev *eth_dev = NULL;
 
-	rte_eth_dev_shared_data_prepare();
+	if (rte_eth_dev_shared_data_prepare() != 0)
+		return NULL;
 
 	/* Synchronize port creation between primary and secondary threads. */
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
@@ -317,7 +324,8 @@ struct rte_eth_dev *
 	uint16_t i;
 	struct rte_eth_dev *eth_dev = NULL;
 
-	rte_eth_dev_shared_data_prepare();
+	if (rte_eth_dev_shared_data_prepare() != 0)
+		return NULL;
 
 	/* Synchronize port attachment to primary port creation and release. */
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
@@ -345,7 +353,8 @@ struct rte_eth_dev *
 	if (eth_dev == NULL)
 		return -EINVAL;
 
-	rte_eth_dev_shared_data_prepare();
+	if (rte_eth_dev_shared_data_prepare() != 0)
+		return -1;
 
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
@@ -399,7 +408,8 @@ struct rte_eth_dev *
 int __rte_experimental
 rte_eth_dev_owner_new(uint64_t *owner_id)
 {
-	rte_eth_dev_shared_data_prepare();
+	if (rte_eth_dev_shared_data_prepare() != 0)
+		return -1;
 
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
@@ -450,7 +460,8 @@ struct rte_eth_dev *
 {
 	int ret;
 
-	rte_eth_dev_shared_data_prepare();
+	if (rte_eth_dev_shared_data_prepare() != 0)
+		return -1;
 
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
@@ -467,7 +478,8 @@ struct rte_eth_dev *
 			{.id = RTE_ETH_DEV_NO_OWNER, .name = ""};
 	int ret;
 
-	rte_eth_dev_shared_data_prepare();
+	if (rte_eth_dev_shared_data_prepare() != 0)
+		return -1;
 
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
@@ -477,12 +489,15 @@ struct rte_eth_dev *
 	return ret;
 }
 
-void __rte_experimental
+int __rte_experimental
 rte_eth_dev_owner_delete(const uint64_t owner_id)
 {
 	uint16_t port_id;
+	int error;
 
-	rte_eth_dev_shared_data_prepare();
+	error = rte_eth_dev_shared_data_prepare();
+	if (error != 0)
+		return error;
 
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
@@ -495,6 +510,8 @@ struct rte_eth_dev *
 	}
 
 	rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock);
+
+	return 0;
 }
 
 int __rte_experimental
@@ -502,7 +519,8 @@ struct rte_eth_dev *
 {
 	int ret = 0;
 
-	rte_eth_dev_shared_data_prepare();
+	if (rte_eth_dev_shared_data_prepare() != 0)
+		return -1;
 
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index b9eb8ae..46e5947 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1354,8 +1354,10 @@ int __rte_experimental rte_eth_dev_owner_unset(const uint16_t port_id,
  *
  * @param	owner_id
  *  The owner identifier.
+ *  @return
+ *  0 on success, negative errno value on error.
  */
-void __rte_experimental rte_eth_dev_owner_delete(const uint64_t owner_id);
+int __rte_experimental rte_eth_dev_owner_delete(const uint64_t owner_id);
 
 /**
  * @warning
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v9 09/10] eal: replace rte_panic instances in init sequence
  2018-04-26  6:20     ` [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                         ` (7 preceding siblings ...)
  2018-04-26  6:21       ` [dpdk-dev] [PATCH v9 08/10] eal: replace rte_panic instances in ethdev Arnon Warshavsky
@ 2018-04-26  6:21       ` Arnon Warshavsky
  2018-04-26 16:07         ` Kevin Traynor
  2018-04-26  6:21       ` [dpdk-dev] [PATCH v9 10/10] devtools: prevent new instances of rte_panic and rte_exit Arnon Warshavsky
                         ` (2 subsequent siblings)
  11 siblings, 1 reply; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-26  6:21 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

Change some local functions return type from void to int.
This change does not break ABI as the functions are internal.
Panic thrown from threads was not handled in this patch

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/bsdapp/eal/eal.c   |  71 ++++++++++++++++++++-------
 lib/librte_eal/linuxapp/eal/eal.c | 101 ++++++++++++++++++++++++++------------
 2 files changed, 121 insertions(+), 51 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 10d8dc0..c958ed9 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -151,7 +151,7 @@ enum rte_iova_mode
  * We also don't lock the whole file, so that in future we can use read-locks
  * on other parts, e.g. memzones, to detect if there are running secondary
  * processes. */
-static void
+static int
 rte_eal_config_create(void)
 {
 	void *rte_mem_cfg_addr;
@@ -160,60 +160,83 @@ enum rte_iova_mode
 	const char *pathname = eal_runtime_config_path();
 
 	if (internal_config.no_shconf)
-		return;
+		return 0;
 
 	if (mem_cfg_fd < 0){
 		mem_cfg_fd = open(pathname, O_RDWR | O_CREAT, 0660);
-		if (mem_cfg_fd < 0)
-			rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
+		if (mem_cfg_fd < 0) {
+			RTE_LOG(CRIT, EAL, "%s(): Cannot open '%s' for rte_mem_config\n",
+					__func__, pathname);
+			return -1;
+		}
 	}
 
 	retval = ftruncate(mem_cfg_fd, sizeof(*rte_config.mem_config));
 	if (retval < 0){
 		close(mem_cfg_fd);
-		rte_panic("Cannot resize '%s' for rte_mem_config\n", pathname);
+		mem_cfg_fd = -1;
+		RTE_LOG(CRIT, EAL, "%s(): Cannot resize '%s' for rte_mem_config\n",
+				__func__, pathname);
+		return -1;
 	}
 
 	retval = fcntl(mem_cfg_fd, F_SETLK, &wr_lock);
 	if (retval < 0){
 		close(mem_cfg_fd);
-		rte_exit(EXIT_FAILURE, "Cannot create lock on '%s'. Is another primary "
-				"process running?\n", pathname);
+		mem_cfg_fd = -1;
+		RTE_LOG(CRIT, EAL, "%s(): Cannot create lock on '%s'. Is another primary process running?\n",
+				__func__, pathname);
+		return -1;
 	}
 
 	rte_mem_cfg_addr = mmap(NULL, sizeof(*rte_config.mem_config),
 				PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
 
 	if (rte_mem_cfg_addr == MAP_FAILED){
-		rte_panic("Cannot mmap memory for rte_config\n");
+		RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config\n",
+				__func__);
+		close(mem_cfg_fd);
+		mem_cfg_fd = -1;
+		return -1;
 	}
 	memcpy(rte_mem_cfg_addr, &early_mem_config, sizeof(early_mem_config));
 	rte_config.mem_config = rte_mem_cfg_addr;
+
+	return 0;
 }
 
 /* attach to an existing shared memory config */
-static void
+static int
 rte_eal_config_attach(void)
 {
 	void *rte_mem_cfg_addr;
 	const char *pathname = eal_runtime_config_path();
 
 	if (internal_config.no_shconf)
-		return;
+		return 0;
 
 	if (mem_cfg_fd < 0){
 		mem_cfg_fd = open(pathname, O_RDWR);
-		if (mem_cfg_fd < 0)
-			rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
+		if (mem_cfg_fd < 0) {
+			RTE_LOG(CRIT, EAL, "%s(): Cannot open '%s' for rte_mem_config\n",
+					__func__, pathname);
+			return -1;
+		}
 	}
 
 	rte_mem_cfg_addr = mmap(NULL, sizeof(*rte_config.mem_config),
 				PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
 	close(mem_cfg_fd);
-	if (rte_mem_cfg_addr == MAP_FAILED)
-		rte_panic("Cannot mmap memory for rte_config\n");
+	if (rte_mem_cfg_addr == MAP_FAILED) {
+		mem_cfg_fd = -1;
+		RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config\n",
+				__func__);
+		return -1;
+	}
 
 	rte_config.mem_config = rte_mem_cfg_addr;
+
+	return 0;
 }
 
 /* Detect if we are a primary or a secondary process */
@@ -237,23 +260,29 @@ enum rte_proc_type_t
 }
 
 /* Sets up rte_config structure with the pointer to shared memory config.*/
-static void
+static int
 rte_config_init(void)
 {
 	rte_config.process_type = internal_config.process_type;
 
 	switch (rte_config.process_type){
 	case RTE_PROC_PRIMARY:
-		rte_eal_config_create();
+		if (rte_eal_config_create())
+			return -1;
 		break;
 	case RTE_PROC_SECONDARY:
-		rte_eal_config_attach();
+		if (rte_eal_config_attach())
+			return -1;
 		rte_eal_mcfg_wait_complete(rte_config.mem_config);
 		break;
 	case RTE_PROC_AUTO:
 	case RTE_PROC_INVALID:
-		rte_panic("Invalid process type\n");
+	default:
+		RTE_LOG(CRIT, EAL, "%s(): Invalid process type %d\n",
+				__func__, rte_config.process_type);
+		return -1;
 	}
+	return 0;
 }
 
 /* display usage */
@@ -552,7 +581,11 @@ static void rte_eal_init_alert(const char *msg)
 		return -1;
 	}
 
-	rte_config_init();
+	if (rte_config_init() != 0) {
+		rte_eal_init_alert("Failed to init configuration");
+		rte_errno = EFAULT;
+		return -1;
+	}
 
 	/* Put mp channel init before bus scan so that we can init the vdev
 	 * bus through mp channel in the secondary process before the bus scan.
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 200e879..c0d704b 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -160,7 +160,7 @@ enum rte_iova_mode
  * We also don't lock the whole file, so that in future we can use read-locks
  * on other parts, e.g. memzones, to detect if there are running secondary
  * processes. */
-static void
+static int
 rte_eal_config_create(void)
 {
 	void *rte_mem_cfg_addr;
@@ -169,7 +169,7 @@ enum rte_iova_mode
 	const char *pathname = eal_runtime_config_path();
 
 	if (internal_config.no_shconf)
-		return;
+		return 0;
 
 	/* map the config before hugepage address so that we don't waste a page */
 	if (internal_config.base_virtaddr != 0)
@@ -179,30 +179,42 @@ enum rte_iova_mode
 	else
 		rte_mem_cfg_addr = NULL;
 
-	if (mem_cfg_fd < 0){
+	if (mem_cfg_fd < 0) {
 		mem_cfg_fd = open(pathname, O_RDWR | O_CREAT, 0660);
-		if (mem_cfg_fd < 0)
-			rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
+		if (mem_cfg_fd < 0) {
+			RTE_LOG(CRIT, EAL, "%s(): Cannot open '%s' for rte_mem_config\n",
+				__func__, pathname);
+			return -1;
+		}
 	}
 
 	retval = ftruncate(mem_cfg_fd, sizeof(*rte_config.mem_config));
-	if (retval < 0){
+	if (retval < 0) {
 		close(mem_cfg_fd);
-		rte_panic("Cannot resize '%s' for rte_mem_config\n", pathname);
+		mem_cfg_fd = -1;
+		RTE_LOG(CRIT, EAL, "%s(): Cannot resize '%s' for rte_mem_config\n",
+				__func__, pathname);
+		return -1;
 	}
 
 	retval = fcntl(mem_cfg_fd, F_SETLK, &wr_lock);
-	if (retval < 0){
+	if (retval < 0) {
 		close(mem_cfg_fd);
-		rte_exit(EXIT_FAILURE, "Cannot create lock on '%s'. Is another primary "
-				"process running?\n", pathname);
+		mem_cfg_fd = -1;
+		RTE_LOG(CRIT, EAL, "%s(): Cannot create lock on '%s'.Is another primary process running?\n",
+			__func__, pathname);
+		return -1;
 	}
 
 	rte_mem_cfg_addr = mmap(rte_mem_cfg_addr, sizeof(*rte_config.mem_config),
 				PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
 
-	if (rte_mem_cfg_addr == MAP_FAILED){
-		rte_panic("Cannot mmap memory for rte_config\n");
+	if (rte_mem_cfg_addr == MAP_FAILED) {
+		RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config\n",
+			__func__);
+		close(mem_cfg_fd);
+		mem_cfg_fd = -1;
+		return -1;
 	}
 	memcpy(rte_mem_cfg_addr, &early_mem_config, sizeof(early_mem_config));
 	rte_config.mem_config = rte_mem_cfg_addr;
@@ -211,10 +223,11 @@ enum rte_iova_mode
 	 * processes could later map the config into this exact location */
 	rte_config.mem_config->mem_cfg_addr = (uintptr_t) rte_mem_cfg_addr;
 
+	return 0;
 }
 
 /* attach to an existing shared memory config */
-static void
+static int
 rte_eal_config_attach(void)
 {
 	struct rte_mem_config *mem_config;
@@ -222,33 +235,42 @@ enum rte_iova_mode
 	const char *pathname = eal_runtime_config_path();
 
 	if (internal_config.no_shconf)
-		return;
+		return 0;
 
-	if (mem_cfg_fd < 0){
+	if (mem_cfg_fd < 0) {
 		mem_cfg_fd = open(pathname, O_RDWR);
-		if (mem_cfg_fd < 0)
-			rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
+		if (mem_cfg_fd < 0) {
+			RTE_LOG(CRIT, EAL, "%s(): Cannot open '%s' for rte_mem_config\n",
+						__func__, pathname);
+			return -1;
+		}
 	}
 
 	/* map it as read-only first */
 	mem_config = (struct rte_mem_config *) mmap(NULL, sizeof(*mem_config),
 			PROT_READ, MAP_SHARED, mem_cfg_fd, 0);
-	if (mem_config == MAP_FAILED)
-		rte_panic("Cannot mmap memory for rte_config! error %i (%s)\n",
-			  errno, strerror(errno));
+	if (mem_config == MAP_FAILED) {
+		close(mem_cfg_fd);
+		mem_cfg_fd = -1;
+		RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config! error %i (%s)\n",
+				__func__, errno, strerror(errno));
+		return -1;
+	}
 
 	rte_config.mem_config = mem_config;
+
+	return 0;
 }
 
 /* reattach the shared config at exact memory location primary process has it */
-static void
+static int
 rte_eal_config_reattach(void)
 {
 	struct rte_mem_config *mem_config;
 	void *rte_mem_cfg_addr;
 
 	if (internal_config.no_shconf)
-		return;
+		return 0;
 
 	/* save the address primary process has mapped shared config to */
 	rte_mem_cfg_addr = (void *) (uintptr_t) rte_config.mem_config->mem_cfg_addr;
@@ -263,16 +285,20 @@ enum rte_iova_mode
 	if (mem_config == MAP_FAILED || mem_config != rte_mem_cfg_addr) {
 		if (mem_config != MAP_FAILED)
 			/* errno is stale, don't use */
-			rte_panic("Cannot mmap memory for rte_config at [%p], got [%p]"
-				  " - please use '--base-virtaddr' option\n",
-				  rte_mem_cfg_addr, mem_config);
+			RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config at [%p], got [%p] - please use '--base-virtaddr' option\n",
+					__func__, rte_mem_cfg_addr, mem_config);
 		else
-			rte_panic("Cannot mmap memory for rte_config! error %i (%s)\n",
-				  errno, strerror(errno));
+			RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config! error %i (%s)\n",
+					__func__, errno, strerror(errno));
+		close(mem_cfg_fd);
+		mem_cfg_fd = -1;
+		return -1;
 	}
 	close(mem_cfg_fd);
 
 	rte_config.mem_config = mem_config;
+
+	return 0;
 }
 
 /* Detect if we are a primary or a secondary process */
@@ -296,24 +322,32 @@ enum rte_proc_type_t
 }
 
 /* Sets up rte_config structure with the pointer to shared memory config.*/
-static void
+static int
 rte_config_init(void)
 {
 	rte_config.process_type = internal_config.process_type;
 
 	switch (rte_config.process_type){
 	case RTE_PROC_PRIMARY:
-		rte_eal_config_create();
+		if (rte_eal_config_create())
+			return -1;
 		break;
 	case RTE_PROC_SECONDARY:
-		rte_eal_config_attach();
+		if (rte_eal_config_attach())
+			return -1;
 		rte_eal_mcfg_wait_complete(rte_config.mem_config);
-		rte_eal_config_reattach();
+		if (rte_eal_config_reattach())
+			return -1;
 		break;
 	case RTE_PROC_AUTO:
 	case RTE_PROC_INVALID:
-		rte_panic("Invalid process type\n");
+	default:
+		RTE_LOG(CRIT, EAL, "%s(): Invalid process type %d\n",
+				__func__, rte_config.process_type);
+		return -1;
 	}
+
+	return 0;
 }
 
 /* Unlocks hugepage directories that were locked by eal_hugepage_info_init */
@@ -833,6 +867,9 @@ static void rte_eal_init_alert(const char *msg)
 
 	rte_srand(rte_rdtsc());
 
+	if (rte_config_init() != 0)
+		return -1;
+
 	if (rte_eal_log_init(logid, internal_config.syslog_facility) < 0) {
 		rte_eal_init_alert("Cannot init logging.");
 		rte_errno = ENOMEM;
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v9 10/10] devtools: prevent new instances of rte_panic and rte_exit
  2018-04-26  6:20     ` [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                         ` (8 preceding siblings ...)
  2018-04-26  6:21       ` [dpdk-dev] [PATCH v9 09/10] eal: replace rte_panic instances in init sequence Arnon Warshavsky
@ 2018-04-26  6:21       ` Arnon Warshavsky
  2018-04-26 16:08         ` Kevin Traynor
  2018-04-30  6:45         ` [dpdk-dev] [PATCH v10] devtools: alert on " Arnon Warshavsky
  2018-04-27 14:22       ` [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances Thomas Monjalon
  2018-04-27 14:30       ` Thomas Monjalon
  11 siblings, 2 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-26  6:21 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

This patch adds a new function that is called
per every checked patch,
and alerts for new instances of rte_panic/rte_exit.
The check excludes comments, and alerts in the case
of a positive balance between additions and removals.

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 devtools/checkpatches.sh | 95 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 94 insertions(+), 1 deletion(-)

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 7676a6b..48b2685 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -61,6 +61,91 @@ print_usage () {
 	END_OF_HELP
 }
 
+check_forbidden_additions() { # <file>
+    # ---------------------------------
+    #This awk script receives a list of expressions to monitor
+    #and a list of folders to search these expressions in
+    # - No search is done inside comments
+    # - Both additions and removals of the expressions are checked
+    #   A positive balance of additions fails the check
+	read -d '' awk_script << 'EOF'
+	BEGIN{
+		split(FOLDERS,deny_folders," ");
+		split(EXPRESSIONS,deny_expr," ");
+		in_file=0;
+		in_comment=0;
+		count=0;
+		comment_start="/*"
+		comment_end="*/"
+    }
+    # search for add/remove instances in current file
+    # state machine assumes the comments structure is enforced by
+    # checkpatches.pl
+    (in_file) {
+		# comment start
+		if (index($0,comment_start) > 0){
+			in_comment = 1
+		}
+		# non comment code
+		if (in_comment == 0) {
+			for (i in deny_expr) {
+				forbidden_added = "^\+.*" deny_expr[i];
+				forbidden_removed="^-.*" deny_expr[i];
+				current = expressions[deny_expr[i]]
+				if ($0 ~ forbidden_added) {
+					count = count + 1;
+					expressions[deny_expr[i]] = current + 1
+				}
+				if ($0 ~ forbidden_removed) {
+					count = count - 1;
+					expressions[deny_expr[i]] = current - 1
+				}
+			}
+		}
+
+		# comment end
+		if (index($0,comment_end) > 0)  {
+			in_comment = 0
+		}
+    }
+	# switch to next file , check if the balance of add/remove
+	# of previous filehad new additions
+	($0 ~ "^\+\+\+ b/") {
+		in_file = 0;
+		if (count > 0){
+			exit;
+		}
+		for (i in deny_folders){
+			re = "^\+\+\+ b/" deny_folders[i];
+			if ($0 ~ deny_folders[i]) {
+				in_file = 1
+				last_file = $0
+			}
+		}
+	}
+	END{
+		if (count > 0){
+			print "Warning: in " substr(last_file,6) ":"
+			print "are you sure you want to add the following:"
+			for (key in expressions) {
+				if (expressions[key] > 0) {
+					print key
+				}
+			}
+			exit 1
+		}
+	}
+EOF
+	# ---------------------------------
+
+	# refrain from new additions of rte_panic() and rte_exit()
+	# under lib and net
+	# multiple folders and expressions are separated by spaces
+	awk -v FOLDERS="lib net" \
+		-v EXPRESSIONS="rte_panic\\\( rte_exit\\\(" \
+		"$awk_script" -
+}
+
 number=0
 quiet=false
 verbose=false
@@ -89,11 +174,19 @@ check () { # <patch> <commit> <title>
 	total=$(($total + 1))
 	! $verbose || printf '\n### %s\n\n' "$3"
 	if [ -n "$1" ] ; then
+		cat "$1" | check_forbidden_additions
+		[ $? -eq 0 ] || return 0
 		report=$($DPDK_CHECKPATCH_PATH $options "$1" 2>/dev/null)
 	elif [ -n "$2" ] ; then
-		report=$(git format-patch --find-renames --no-stat --stdout -1 $commit |
+		params=$(echo "--find-renames --no-stat --stdout -1")
+		body=$(git format-patch $params $commit)
+		echo "$body" | check_forbidden_additions
+		[ $? -eq 0 ] || return 0
+		report=$(echo "$body" |
 			$DPDK_CHECKPATCH_PATH $options - 2>/dev/null)
 	else
+		check_forbidden_additions -
+		[ $? -eq 0 ] || return 0
 		report=$($DPDK_CHECKPATCH_PATH $options - 2>/dev/null)
 	fi
 	[ $? -ne 0 ] || return 0
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v7 01/11] crypto/dpaa: replace rte_panic instances in crypto/dpaa driver
  2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 01/11] crypto/dpaa: replace rte_panic instances in crypto/dpaa driver Arnon Warshavsky
@ 2018-04-26 16:05   ` Kevin Traynor
  2018-04-26 16:16     ` Kevin Traynor
  2018-04-26 21:28     ` Arnon Warshavsky
  0 siblings, 2 replies; 91+ messages in thread
From: Kevin Traynor @ 2018-04-26 16:05 UTC (permalink / raw)
  To: Arnon Warshavsky, thomas, anatoly.burakov, wenzhuo.lu,
	declan.doherty, jerin.jacob, bruce.richardson, ferruh.yigit
  Cc: dev

On 04/24/2018 11:16 PM, Arnon Warshavsky wrote:
> replace panic calls with log and return value.
> 
> Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
> ---
>  drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c |  8 +++++---
>  drivers/crypto/dpaa_sec/dpaa_sec.c          | 10 ++++++----
>  2 files changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
> index 58cbce8..a78f3a2 100644
> --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
> +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
> @@ -2883,9 +2883,11 @@ struct rte_security_ops dpaa2_sec_security_ops = {
>  					RTE_CACHE_LINE_SIZE,
>  					rte_socket_id());
>  
> -		if (cryptodev->data->dev_private == NULL)
> -			rte_panic("Cannot allocate memzone for private "
> -				  "device data");
> +		if (cryptodev->data->dev_private == NULL) {
> +			DPAA_SEC_ERR("%s() Cannot allocate memzone for private device data",
> +			__func__);
> +			return -ENOMEM;

I'm not familiar with the code but there was a successful allocate
already, so it seems you should jump to the cleanup section at the end
of the function before returning.

> +		}
>  	}
>  
>  	dpaa2_dev->cryptodev = cryptodev;
> diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
> index e456fd5..a4670bf 100644
> --- a/drivers/crypto/dpaa_sec/dpaa_sec.c
> +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
> @@ -2352,7 +2352,7 @@ struct rte_security_ops dpaa_sec_security_ops = {
>  		}
>  	}
>  
> -	RTE_LOG(INFO, PMD, "%s cryptodev init\n", cryptodev->data->name);
> +	DPAA_SEC_INFO("%s cryptodev init\n", cryptodev->data->name);

This fix is an unrelated to the patchset. Perhaps as it's trivial the
maintainer will allow it

>  	return 0;
>  
>  init_error:
> @@ -2384,9 +2384,11 @@ struct rte_security_ops dpaa_sec_security_ops = {
>  					RTE_CACHE_LINE_SIZE,
>  					rte_socket_id());
>  
> -		if (cryptodev->data->dev_private == NULL)
> -			rte_panic("Cannot allocate memzone for private "
> -					"device data");
> +		if (cryptodev->data->dev_private == NULL) {
> +			DPAA_SEC_ERR("%s() Cannot allocate memzone for private device data",
> +			__func__);
> +			return -ENOMEM;

Same comment as above

> +		}
>  	}
>  
>  	dpaa_dev->crypto_dev = cryptodev;
> 

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v9 02/10] bond: replace rte_panic instances in bonding driver
  2018-04-26  6:20       ` [dpdk-dev] [PATCH v9 02/10] bond: replace rte_panic instances in bonding driver Arnon Warshavsky
@ 2018-04-26 16:06         ` Kevin Traynor
  2018-04-26 21:06           ` Arnon Warshavsky
  0 siblings, 1 reply; 91+ messages in thread
From: Kevin Traynor @ 2018-04-26 16:06 UTC (permalink / raw)
  To: Arnon Warshavsky, thomas, anatoly.burakov, wenzhuo.lu,
	declan.doherty, jerin.jacob, bruce.richardson, ferruh.yigit
  Cc: dev

On 04/26/2018 07:20 AM, Arnon Warshavsky wrote:
> Replace panic calls with log and return value.
> Local functions to this file,
> changing from void to int are non-abi-breaking
> 
> Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
> ---
>  drivers/net/bonding/rte_eth_bond_8023ad.c         | 29 ++++++++++++++---------
>  drivers/net/bonding/rte_eth_bond_8023ad_private.h |  2 +-
>  drivers/net/bonding/rte_eth_bond_api.c            | 22 ++++++++++++-----
>  drivers/net/bonding/rte_eth_bond_pmd.c            |  9 ++++---
>  drivers/net/bonding/rte_eth_bond_private.h        |  2 +-
>  5 files changed, 42 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
> index c452318..308e623 100644
> --- a/drivers/net/bonding/rte_eth_bond_8023ad.c
> +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
> @@ -893,7 +893,7 @@
>  			bond_mode_8023ad_periodic_cb, arg);
>  }
>  
> -void
> +int
>  bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev,
>  				uint16_t slave_id)
>  {
> @@ -939,7 +939,7 @@
>  	timer_cancel(&port->warning_timer);
>  
>  	if (port->mbuf_pool != NULL)
> -		return;
> +		return 0;
>  
>  	RTE_ASSERT(port->rx_ring == NULL);
>  	RTE_ASSERT(port->tx_ring == NULL);
> @@ -968,8 +968,9 @@
>  	/* Any memory allocation failure in initialization is critical because
>  	 * resources can't be free, so reinitialization is impossible. */

What about this comment? Not sure if it is just stale or if there is
something else you need to do.

>  	if (port->mbuf_pool == NULL) {
> -		rte_panic("Slave %u: Failed to create memory pool '%s': %s\n",
> -			slave_id, mem_name, rte_strerror(rte_errno));
> +		RTE_BOND_LOG(ERR, "%s() Slave %u: Failed to create memory pool '%s': %s\n",
> +			__func__, slave_id, mem_name, rte_strerror(rte_errno));
> +		return -1;
>  	}
>  
>  	snprintf(mem_name, RTE_DIM(mem_name), "slave_%u_rx", slave_id);
> @@ -977,8 +978,9 @@
>  			rte_align32pow2(BOND_MODE_8023AX_SLAVE_RX_PKTS), socket_id, 0);
>  
>  	if (port->rx_ring == NULL) {
> -		rte_panic("Slave %u: Failed to create rx ring '%s': %s\n", slave_id,
> -			mem_name, rte_strerror(rte_errno));
> +		RTE_BOND_LOG(ERR, "%s() Slave %u: Failed to create rx ring '%s': %s\n",
> +			__func__, slave_id, mem_name, rte_strerror(rte_errno));
> +		return -1;
>  	}
>  
>  	/* TX ring is at least one pkt longer to make room for marker packet. */
> @@ -987,9 +989,12 @@
>  			rte_align32pow2(BOND_MODE_8023AX_SLAVE_TX_PKTS + 1), socket_id, 0);
>  
>  	if (port->tx_ring == NULL) {
> -		rte_panic("Slave %u: Failed to create tx ring '%s': %s\n", slave_id,
> -			mem_name, rte_strerror(rte_errno));
> +		RTE_BOND_LOG(ERR, "%s() Slave %u: Fail to create tx ring '%s': %s\n",
> +			__func__, slave_id, mem_name, rte_strerror(rte_errno));
> +		return -1;
>  	}
> +
> +	return 0;
>  }
>  
>  int
> @@ -1143,9 +1148,11 @@
>  	struct bond_dev_private *internals = bond_dev->data->dev_private;
>  	uint8_t i;
>  
> -	for (i = 0; i < internals->active_slave_count; i++)
> -		bond_mode_8023ad_activate_slave(bond_dev,
> -				internals->active_slaves[i]);
> +	for (i = 0; i < internals->active_slave_count; i++) {
> +		if (!bond_mode_8023ad_activate_slave(bond_dev,
> +						internals->active_slaves[i]))
> +			return -1;
> +	}
>  
>  	return 0;
>  }
> diff --git a/drivers/net/bonding/rte_eth_bond_8023ad_private.h b/drivers/net/bonding/rte_eth_bond_8023ad_private.h
> index 0f490a5..96a42f2 100644
> --- a/drivers/net/bonding/rte_eth_bond_8023ad_private.h
> +++ b/drivers/net/bonding/rte_eth_bond_8023ad_private.h
> @@ -263,7 +263,7 @@ struct mode8023ad_private {
>   * @return
>   *  0 on success, negative value otherwise.

      ^^^ you inadvertently fixed a doxygen bug :-)

>   */
> -void
> +int
>  bond_mode_8023ad_activate_slave(struct rte_eth_dev *dev, uint16_t port_id);
>  
>  /**
> diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
> index aa89425..657fd74 100644
> --- a/drivers/net/bonding/rte_eth_bond_api.c
> +++ b/drivers/net/bonding/rte_eth_bond_api.c
> @@ -69,14 +69,15 @@
>  	return 0;
>  }
>  
> -void
> +int
>  activate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id)
>  {
>  	struct bond_dev_private *internals = eth_dev->data->dev_private;
>  	uint8_t active_count = internals->active_slave_count;
>  
>  	if (internals->mode == BONDING_MODE_8023AD)
> -		bond_mode_8023ad_activate_slave(eth_dev, port_id);
> +		if (bond_mode_8023ad_activate_slave(eth_dev, port_id) != 0)
> +			return -1;
>  
>  	if (internals->mode == BONDING_MODE_TLB
>  			|| internals->mode == BONDING_MODE_ALB) {
> @@ -94,6 +95,8 @@
>  		bond_tlb_activate_slave(internals);
>  	if (internals->mode == BONDING_MODE_ALB)
>  		bond_mode_alb_client_list_upd(eth_dev);
> +
> +	return 0;
>  }
>  
>  void
> @@ -357,10 +360,17 @@
>  				bond_ethdev_primary_set(internals,
>  							slave_port_id);
>  
> -			if (find_slave_by_id(internals->active_slaves,
> -					     internals->active_slave_count,
> -					     slave_port_id) == internals->active_slave_count)
> -				activate_slave(bonded_eth_dev, slave_port_id);
> +			int rc =
> +				find_slave_by_id(internals->active_slaves,
> +					internals->active_slave_count,
> +					slave_port_id);
> +
> +			if (rc == internals->active_slave_count) {
> +				int rc = activate_slave(bonded_eth_dev,
> +							slave_port_id);
> +				if (rc != 0)
> +					return -1;
> +			}

Not functionally wrong, but commented about no need for variables here
in v4 and seems to have been missed

>  		}
>  	}
>  
> diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
> index 09696ea..d2dbe4a 100644
> --- a/drivers/net/bonding/rte_eth_bond_pmd.c
> +++ b/drivers/net/bonding/rte_eth_bond_pmd.c
> @@ -1741,8 +1741,10 @@ struct bwg_slave {
>  		/* Any memory allocation failure in initialization is critical because
>  		 * resources can't be free, so reinitialization is impossible. */
>  		if (port->slow_pool == NULL) {
> -			rte_panic("Slave %u: Failed to create memory pool '%s': %s\n",
> -				slave_id, mem_name, rte_strerror(rte_errno));
> +			RTE_BOND_LOG(ERR, "%s() Slave %u: Failed to create memory pool '%s': %s\n",
> +				__func__, slave_id,
> +				mem_name, rte_strerror(rte_errno));
> +			return -1;
>  		}
>  	}
>  
> @@ -2673,7 +2675,8 @@ struct bwg_slave {
>  			mac_address_slaves_update(bonded_eth_dev);
>  		}
>  
> -		activate_slave(bonded_eth_dev, port_id);
> +		if (activate_slave(bonded_eth_dev, port_id) != 0)
> +			return -1;
>  
>  		/* If user has defined the primary port then default to using it */
>  		if (internals->user_defined_primary_port &&
> diff --git a/drivers/net/bonding/rte_eth_bond_private.h b/drivers/net/bonding/rte_eth_bond_private.h
> index 94eca88..d99d42c 100644
> --- a/drivers/net/bonding/rte_eth_bond_private.h
> +++ b/drivers/net/bonding/rte_eth_bond_private.h
> @@ -187,7 +187,7 @@ struct bond_dev_private {
>  void
>  deactivate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id);
>  
> -void
> +int
>  activate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id);
>  
>  void
> 

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v9 08/10] eal: replace rte_panic instances in ethdev
  2018-04-26  6:21       ` [dpdk-dev] [PATCH v9 08/10] eal: replace rte_panic instances in ethdev Arnon Warshavsky
@ 2018-04-26 16:07         ` Kevin Traynor
  2018-04-26 21:38           ` Arnon Warshavsky
  0 siblings, 1 reply; 91+ messages in thread
From: Kevin Traynor @ 2018-04-26 16:07 UTC (permalink / raw)
  To: Arnon Warshavsky, thomas, anatoly.burakov, wenzhuo.lu,
	declan.doherty, jerin.jacob, bruce.richardson, ferruh.yigit
  Cc: dev

On 04/26/2018 07:21 AM, Arnon Warshavsky wrote:
> Local function to this file,
> changing from void to int is non-abi-breaking
> 
> Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
> ---
>  lib/librte_ether/rte_ethdev.c | 42 ++++++++++++++++++++++++++++++------------
>  lib/librte_ether/rte_ethdev.h |  4 +++-
>  2 files changed, 33 insertions(+), 13 deletions(-)
> 
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index f0f53d4..940de15 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -194,7 +194,7 @@ enum {
>  	return port_id;
>  }
>  
> -static void
> +static int
>  rte_eth_dev_shared_data_prepare(void)
>  {
>  	const unsigned flags = 0;
> @@ -210,8 +210,12 @@ enum {
>  					rte_socket_id(), flags);
>  		} else
>  			mz = rte_memzone_lookup(MZ_RTE_ETH_DEV_DATA);
> -		if (mz == NULL)
> -			rte_panic("Cannot allocate ethdev shared data\n");
> +		if (mz == NULL) {
> +			rte_spinlock_unlock(&rte_eth_shared_data_lock);
> +			RTE_LOG(CRIT, EAL, "%s(): Cannot allocate ethdev shared data\n",
> +					__func__);
> +			return -1;
> +		}
>  
>  		rte_eth_dev_shared_data = mz->addr;
>  		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
> @@ -224,6 +228,8 @@ enum {
>  	}
>  
>  	rte_spinlock_unlock(&rte_eth_shared_data_lock);
> +
> +	return 0;
>  }
>  
>  struct rte_eth_dev *
> @@ -274,7 +280,8 @@ struct rte_eth_dev *
>  	uint16_t port_id;
>  	struct rte_eth_dev *eth_dev = NULL;
>  
> -	rte_eth_dev_shared_data_prepare();
> +	if (rte_eth_dev_shared_data_prepare() != 0)
> +		return NULL;
>  
>  	/* Synchronize port creation between primary and secondary threads. */
>  	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
> @@ -317,7 +324,8 @@ struct rte_eth_dev *
>  	uint16_t i;
>  	struct rte_eth_dev *eth_dev = NULL;
>  
> -	rte_eth_dev_shared_data_prepare();
> +	if (rte_eth_dev_shared_data_prepare() != 0)
> +		return NULL;
>  
>  	/* Synchronize port attachment to primary port creation and release. */
>  	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
> @@ -345,7 +353,8 @@ struct rte_eth_dev *
>  	if (eth_dev == NULL)
>  		return -EINVAL;
>  
> -	rte_eth_dev_shared_data_prepare();
> +	if (rte_eth_dev_shared_data_prepare() != 0)
> +		return -1;
>  
>  	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
>  
> @@ -399,7 +408,8 @@ struct rte_eth_dev *
>  int __rte_experimental
>  rte_eth_dev_owner_new(uint64_t *owner_id)
>  {
> -	rte_eth_dev_shared_data_prepare();
> +	if (rte_eth_dev_shared_data_prepare() != 0)
> +		return -1;
>  
>  	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
>  
> @@ -450,7 +460,8 @@ struct rte_eth_dev *
>  {
>  	int ret;
>  
> -	rte_eth_dev_shared_data_prepare();
> +	if (rte_eth_dev_shared_data_prepare() != 0)
> +		return -1;
>  
>  	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
>  
> @@ -467,7 +478,8 @@ struct rte_eth_dev *
>  			{.id = RTE_ETH_DEV_NO_OWNER, .name = ""};
>  	int ret;
>  
> -	rte_eth_dev_shared_data_prepare();
> +	if (rte_eth_dev_shared_data_prepare() != 0)
> +		return -1;
>  
>  	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
>  
> @@ -477,12 +489,15 @@ struct rte_eth_dev *
>  	return ret;
>  }
>  
> -void __rte_experimental
> +int __rte_experimental
>  rte_eth_dev_owner_delete(const uint64_t owner_id)
>  {
>  	uint16_t port_id;
> +	int error;

it's inconsistent that this function returns the error code from
rte_eth_dev_shared_data_prepare() and all these other functions return -1

>  
> -	rte_eth_dev_shared_data_prepare();
> +	error = rte_eth_dev_shared_data_prepare();
> +	if (error != 0)
> +		return error;
>  
>  	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
>  
> @@ -495,6 +510,8 @@ struct rte_eth_dev *
>  	}
>  
>  	rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock);
> +
> +	return 0;
>  }
>  
>  int __rte_experimental
> @@ -502,7 +519,8 @@ struct rte_eth_dev *
>  {
>  	int ret = 0;
>  
> -	rte_eth_dev_shared_data_prepare();
> +	if (rte_eth_dev_shared_data_prepare() != 0)
> +		return -1;
>  
>  	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
>  
> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> index b9eb8ae..46e5947 100644
> --- a/lib/librte_ether/rte_ethdev.h
> +++ b/lib/librte_ether/rte_ethdev.h
> @@ -1354,8 +1354,10 @@ int __rte_experimental rte_eth_dev_owner_unset(const uint16_t port_id,
>   *
>   * @param	owner_id
>   *  The owner identifier.
> + *  @return
> + *  0 on success, negative errno value on error.
>   */
> -void __rte_experimental rte_eth_dev_owner_delete(const uint64_t owner_id);
> +int __rte_experimental rte_eth_dev_owner_delete(const uint64_t owner_id);
>  
>  /**
>   * @warning
> 

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v9 09/10] eal: replace rte_panic instances in init sequence
  2018-04-26  6:21       ` [dpdk-dev] [PATCH v9 09/10] eal: replace rte_panic instances in init sequence Arnon Warshavsky
@ 2018-04-26 16:07         ` Kevin Traynor
  2018-04-26 22:08           ` Arnon Warshavsky
  0 siblings, 1 reply; 91+ messages in thread
From: Kevin Traynor @ 2018-04-26 16:07 UTC (permalink / raw)
  To: Arnon Warshavsky, thomas, anatoly.burakov, wenzhuo.lu,
	declan.doherty, jerin.jacob, bruce.richardson, ferruh.yigit
  Cc: dev

On 04/26/2018 07:21 AM, Arnon Warshavsky wrote:
> Change some local functions return type from void to int.
> This change does not break ABI as the functions are internal.
> Panic thrown from threads was not handled in this patch
> 
> Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
>  lib/librte_eal/bsdapp/eal/eal.c   |  71 ++++++++++++++++++++-------
>  lib/librte_eal/linuxapp/eal/eal.c | 101 ++++++++++++++++++++++++++------------
>  2 files changed, 121 insertions(+), 51 deletions(-)
> 
> diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
> index 10d8dc0..c958ed9 100644
> --- a/lib/librte_eal/bsdapp/eal/eal.c
> +++ b/lib/librte_eal/bsdapp/eal/eal.c
> @@ -151,7 +151,7 @@ enum rte_iova_mode
>   * We also don't lock the whole file, so that in future we can use read-locks
>   * on other parts, e.g. memzones, to detect if there are running secondary
>   * processes. */
> -static void
> +static int
>  rte_eal_config_create(void)
>  {
>  	void *rte_mem_cfg_addr;
> @@ -160,60 +160,83 @@ enum rte_iova_mode
>  	const char *pathname = eal_runtime_config_path();
>  
>  	if (internal_config.no_shconf)
> -		return;
> +		return 0;
>  
>  	if (mem_cfg_fd < 0){
>  		mem_cfg_fd = open(pathname, O_RDWR | O_CREAT, 0660);
> -		if (mem_cfg_fd < 0)
> -			rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
> +		if (mem_cfg_fd < 0) {
> +			RTE_LOG(CRIT, EAL, "%s(): Cannot open '%s' for rte_mem_config\n",
> +					__func__, pathname);
> +			return -1;
> +		}
>  	}
>  
>  	retval = ftruncate(mem_cfg_fd, sizeof(*rte_config.mem_config));
>  	if (retval < 0){
>  		close(mem_cfg_fd);
> -		rte_panic("Cannot resize '%s' for rte_mem_config\n", pathname);
> +		mem_cfg_fd = -1;
> +		RTE_LOG(CRIT, EAL, "%s(): Cannot resize '%s' for rte_mem_config\n",
> +				__func__, pathname);
> +		return -1;
>  	}
>  
>  	retval = fcntl(mem_cfg_fd, F_SETLK, &wr_lock);
>  	if (retval < 0){
>  		close(mem_cfg_fd);
> -		rte_exit(EXIT_FAILURE, "Cannot create lock on '%s'. Is another primary "
> -				"process running?\n", pathname);
> +		mem_cfg_fd = -1;
> +		RTE_LOG(CRIT, EAL, "%s(): Cannot create lock on '%s'. Is another primary process running?\n",
> +				__func__, pathname);
> +		return -1;
>  	}
>  
>  	rte_mem_cfg_addr = mmap(NULL, sizeof(*rte_config.mem_config),
>  				PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
>  
>  	if (rte_mem_cfg_addr == MAP_FAILED){
> -		rte_panic("Cannot mmap memory for rte_config\n");
> +		RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config\n",
> +				__func__);
> +		close(mem_cfg_fd);
> +		mem_cfg_fd = -1;
> +		return -1;
>  	}
>  	memcpy(rte_mem_cfg_addr, &early_mem_config, sizeof(early_mem_config));
>  	rte_config.mem_config = rte_mem_cfg_addr;
> +
> +	return 0;
>  }
>  
>  /* attach to an existing shared memory config */
> -static void
> +static int
>  rte_eal_config_attach(void)
>  {
>  	void *rte_mem_cfg_addr;
>  	const char *pathname = eal_runtime_config_path();
>  
>  	if (internal_config.no_shconf)
> -		return;
> +		return 0;
>  
>  	if (mem_cfg_fd < 0){
>  		mem_cfg_fd = open(pathname, O_RDWR);
> -		if (mem_cfg_fd < 0)
> -			rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
> +		if (mem_cfg_fd < 0) {
> +			RTE_LOG(CRIT, EAL, "%s(): Cannot open '%s' for rte_mem_config\n",
> +					__func__, pathname);
> +			return -1;
> +		}
>  	}
>  
>  	rte_mem_cfg_addr = mmap(NULL, sizeof(*rte_config.mem_config),
>  				PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
>  	close(mem_cfg_fd);
> -	if (rte_mem_cfg_addr == MAP_FAILED)
> -		rte_panic("Cannot mmap memory for rte_config\n");
> +	if (rte_mem_cfg_addr == MAP_FAILED) {
> +		mem_cfg_fd = -1;
> +		RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config\n",
> +				__func__);
> +		return -1;
> +	}
>  
>  	rte_config.mem_config = rte_mem_cfg_addr;
> +
> +	return 0;
>  }
>  
>  /* Detect if we are a primary or a secondary process */
> @@ -237,23 +260,29 @@ enum rte_proc_type_t
>  }
>  
>  /* Sets up rte_config structure with the pointer to shared memory config.*/
> -static void
> +static int
>  rte_config_init(void)
>  {
>  	rte_config.process_type = internal_config.process_type;
>  
>  	switch (rte_config.process_type){
>  	case RTE_PROC_PRIMARY:
> -		rte_eal_config_create();
> +		if (rte_eal_config_create())
> +			return -1;
>  		break;
>  	case RTE_PROC_SECONDARY:
> -		rte_eal_config_attach();
> +		if (rte_eal_config_attach())
> +			return -1;
>  		rte_eal_mcfg_wait_complete(rte_config.mem_config);
>  		break;
>  	case RTE_PROC_AUTO:
>  	case RTE_PROC_INVALID:
> -		rte_panic("Invalid process type\n");
> +	default:
> +		RTE_LOG(CRIT, EAL, "%s(): Invalid process type %d\n",
> +				__func__, rte_config.process_type);
> +		return -1;
>  	}
> +	return 0;
>  }
>  
>  /* display usage */
> @@ -552,7 +581,11 @@ static void rte_eal_init_alert(const char *msg)
>  		return -1;
>  	}
>  
> -	rte_config_init();
> +	if (rte_config_init() != 0) {
> +		rte_eal_init_alert("Failed to init configuration");
> +		rte_errno = EFAULT;
> +		return -1;
> +	}
>  
>  	/* Put mp channel init before bus scan so that we can init the vdev
>  	 * bus through mp channel in the secondary process before the bus scan.
> diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
> index 200e879..c0d704b 100644
> --- a/lib/librte_eal/linuxapp/eal/eal.c
> +++ b/lib/librte_eal/linuxapp/eal/eal.c
> @@ -160,7 +160,7 @@ enum rte_iova_mode
>   * We also don't lock the whole file, so that in future we can use read-locks
>   * on other parts, e.g. memzones, to detect if there are running secondary
>   * processes. */
> -static void
> +static int
>  rte_eal_config_create(void)
>  {
>  	void *rte_mem_cfg_addr;
> @@ -169,7 +169,7 @@ enum rte_iova_mode
>  	const char *pathname = eal_runtime_config_path();
>  
>  	if (internal_config.no_shconf)
> -		return;
> +		return 0;
>  
>  	/* map the config before hugepage address so that we don't waste a page */
>  	if (internal_config.base_virtaddr != 0)
> @@ -179,30 +179,42 @@ enum rte_iova_mode
>  	else
>  		rte_mem_cfg_addr = NULL;
>  
> -	if (mem_cfg_fd < 0){
> +	if (mem_cfg_fd < 0) {
>  		mem_cfg_fd = open(pathname, O_RDWR | O_CREAT, 0660);
> -		if (mem_cfg_fd < 0)
> -			rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
> +		if (mem_cfg_fd < 0) {
> +			RTE_LOG(CRIT, EAL, "%s(): Cannot open '%s' for rte_mem_config\n",
> +				__func__, pathname);
> +			return -1;
> +		}
>  	}
>  
>  	retval = ftruncate(mem_cfg_fd, sizeof(*rte_config.mem_config));
> -	if (retval < 0){
> +	if (retval < 0) {
>  		close(mem_cfg_fd);
> -		rte_panic("Cannot resize '%s' for rte_mem_config\n", pathname);
> +		mem_cfg_fd = -1;
> +		RTE_LOG(CRIT, EAL, "%s(): Cannot resize '%s' for rte_mem_config\n",
> +				__func__, pathname);
> +		return -1;
>  	}
>  
>  	retval = fcntl(mem_cfg_fd, F_SETLK, &wr_lock);
> -	if (retval < 0){
> +	if (retval < 0) {
>  		close(mem_cfg_fd);
> -		rte_exit(EXIT_FAILURE, "Cannot create lock on '%s'. Is another primary "
> -				"process running?\n", pathname);
> +		mem_cfg_fd = -1;
> +		RTE_LOG(CRIT, EAL, "%s(): Cannot create lock on '%s'.Is another primary process running?\n",
> +			__func__, pathname);
> +		return -1;
>  	}
>  
>  	rte_mem_cfg_addr = mmap(rte_mem_cfg_addr, sizeof(*rte_config.mem_config),
>  				PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
>  
> -	if (rte_mem_cfg_addr == MAP_FAILED){
> -		rte_panic("Cannot mmap memory for rte_config\n");
> +	if (rte_mem_cfg_addr == MAP_FAILED) {
> +		RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config\n",
> +			__func__);
> +		close(mem_cfg_fd);
> +		mem_cfg_fd = -1;
> +		return -1;
>  	}
>  	memcpy(rte_mem_cfg_addr, &early_mem_config, sizeof(early_mem_config));
>  	rte_config.mem_config = rte_mem_cfg_addr;
> @@ -211,10 +223,11 @@ enum rte_iova_mode
>  	 * processes could later map the config into this exact location */
>  	rte_config.mem_config->mem_cfg_addr = (uintptr_t) rte_mem_cfg_addr;
>  
> +	return 0;
>  }
>  
>  /* attach to an existing shared memory config */
> -static void
> +static int
>  rte_eal_config_attach(void)
>  {
>  	struct rte_mem_config *mem_config;
> @@ -222,33 +235,42 @@ enum rte_iova_mode
>  	const char *pathname = eal_runtime_config_path();
>  
>  	if (internal_config.no_shconf)
> -		return;
> +		return 0;
>  
> -	if (mem_cfg_fd < 0){
> +	if (mem_cfg_fd < 0) {
>  		mem_cfg_fd = open(pathname, O_RDWR);
> -		if (mem_cfg_fd < 0)
> -			rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
> +		if (mem_cfg_fd < 0) {
> +			RTE_LOG(CRIT, EAL, "%s(): Cannot open '%s' for rte_mem_config\n",
> +						__func__, pathname);
> +			return -1;
> +		}
>  	}
>  
>  	/* map it as read-only first */
>  	mem_config = (struct rte_mem_config *) mmap(NULL, sizeof(*mem_config),
>  			PROT_READ, MAP_SHARED, mem_cfg_fd, 0);
> -	if (mem_config == MAP_FAILED)
> -		rte_panic("Cannot mmap memory for rte_config! error %i (%s)\n",
> -			  errno, strerror(errno));
> +	if (mem_config == MAP_FAILED) {
> +		close(mem_cfg_fd);
> +		mem_cfg_fd = -1;
> +		RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config! error %i (%s)\n",
> +				__func__, errno, strerror(errno));
> +		return -1;
> +	}
>  
>  	rte_config.mem_config = mem_config;
> +
> +	return 0;
>  }
>  
>  /* reattach the shared config at exact memory location primary process has it */
> -static void
> +static int
>  rte_eal_config_reattach(void)
>  {
>  	struct rte_mem_config *mem_config;
>  	void *rte_mem_cfg_addr;
>  
>  	if (internal_config.no_shconf)
> -		return;
> +		return 0;
>  
>  	/* save the address primary process has mapped shared config to */
>  	rte_mem_cfg_addr = (void *) (uintptr_t) rte_config.mem_config->mem_cfg_addr;
> @@ -263,16 +285,20 @@ enum rte_iova_mode
>  	if (mem_config == MAP_FAILED || mem_config != rte_mem_cfg_addr) {
>  		if (mem_config != MAP_FAILED)
>  			/* errno is stale, don't use */
> -			rte_panic("Cannot mmap memory for rte_config at [%p], got [%p]"
> -				  " - please use '--base-virtaddr' option\n",
> -				  rte_mem_cfg_addr, mem_config);
> +			RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config at [%p], got [%p] - please use '--base-virtaddr' option\n",
> +					__func__, rte_mem_cfg_addr, mem_config);
>  		else
> -			rte_panic("Cannot mmap memory for rte_config! error %i (%s)\n",
> -				  errno, strerror(errno));
> +			RTE_LOG(CRIT, EAL, "%s(): Cannot mmap memory for rte_config! error %i (%s)\n",
> +					__func__, errno, strerror(errno));
> +		close(mem_cfg_fd);
> +		mem_cfg_fd = -1;
> +		return -1;
>  	}
>  	close(mem_cfg_fd);
>  
>  	rte_config.mem_config = mem_config;
> +
> +	return 0;
>  }
>  
>  /* Detect if we are a primary or a secondary process */
> @@ -296,24 +322,32 @@ enum rte_proc_type_t
>  }
>  
>  /* Sets up rte_config structure with the pointer to shared memory config.*/
> -static void
> +static int
>  rte_config_init(void)
>  {
>  	rte_config.process_type = internal_config.process_type;
>  
>  	switch (rte_config.process_type){
>  	case RTE_PROC_PRIMARY:
> -		rte_eal_config_create();
> +		if (rte_eal_config_create())
> +			return -1;
>  		break;
>  	case RTE_PROC_SECONDARY:
> -		rte_eal_config_attach();
> +		if (rte_eal_config_attach())
> +			return -1;
>  		rte_eal_mcfg_wait_complete(rte_config.mem_config);
> -		rte_eal_config_reattach();
> +		if (rte_eal_config_reattach())
> +			return -1;
>  		break;
>  	case RTE_PROC_AUTO:
>  	case RTE_PROC_INVALID:
> -		rte_panic("Invalid process type\n");
> +	default:
> +		RTE_LOG(CRIT, EAL, "%s(): Invalid process type %d\n",
> +				__func__, rte_config.process_type);
> +		return -1;
>  	}
> +
> +	return 0;
>  }
>  
>  /* Unlocks hugepage directories that were locked by eal_hugepage_info_init */
> @@ -833,6 +867,9 @@ static void rte_eal_init_alert(const char *msg)
>  
>  	rte_srand(rte_rdtsc());
>  
> +	if (rte_config_init() != 0)
> +		return -1;
> +

I'm confused, is this deliberate? there is now two rte_config_init()
calls. Aaron's comments on v4 about rte_eal_init_alert() are missed? and
it's missing the clear once and error number like the other returns.

>  	if (rte_eal_log_init(logid, internal_config.syslog_facility) < 0) {
>  		rte_eal_init_alert("Cannot init logging.");
>  		rte_errno = ENOMEM;
> 

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v9 10/10] devtools: prevent new instances of rte_panic and rte_exit
  2018-04-26  6:21       ` [dpdk-dev] [PATCH v9 10/10] devtools: prevent new instances of rte_panic and rte_exit Arnon Warshavsky
@ 2018-04-26 16:08         ` Kevin Traynor
  2018-04-26 21:57           ` Arnon Warshavsky
  2018-04-30  6:45         ` [dpdk-dev] [PATCH v10] devtools: alert on " Arnon Warshavsky
  1 sibling, 1 reply; 91+ messages in thread
From: Kevin Traynor @ 2018-04-26 16:08 UTC (permalink / raw)
  To: Arnon Warshavsky, thomas, anatoly.burakov, wenzhuo.lu,
	declan.doherty, jerin.jacob, bruce.richardson, ferruh.yigit
  Cc: dev

I think the first line of the commit msg ^^^ should change as it no
longer prevents but just warns

On 04/26/2018 07:21 AM, Arnon Warshavsky wrote:
> This patch adds a new function that is called
> per every checked patch,
> and alerts for new instances of rte_panic/rte_exit.
> The check excludes comments, and alerts in the case
> of a positive balance between additions and removals.
> 

Seems to drop the patch name if it finds a match

> Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
> ---
>  devtools/checkpatches.sh | 95 +++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 94 insertions(+), 1 deletion(-)
> 
> diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
> index 7676a6b..48b2685 100755
> --- a/devtools/checkpatches.sh
> +++ b/devtools/checkpatches.sh
> @@ -61,6 +61,91 @@ print_usage () {
>  	END_OF_HELP
>  }
>  
> +check_forbidden_additions() { # <file>
> +    # ---------------------------------
> +    #This awk script receives a list of expressions to monitor
> +    #and a list of folders to search these expressions in
> +    # - No search is done inside comments
> +    # - Both additions and removals of the expressions are checked
> +    #   A positive balance of additions fails the check
> +	read -d '' awk_script << 'EOF'
> +	BEGIN{
> +		split(FOLDERS,deny_folders," ");
> +		split(EXPRESSIONS,deny_expr," ");
> +		in_file=0;
> +		in_comment=0;
> +		count=0;
> +		comment_start="/*"
> +		comment_end="*/"
> +    }
> +    # search for add/remove instances in current file
> +    # state machine assumes the comments structure is enforced by
> +    # checkpatches.pl
> +    (in_file) {
> +		# comment start
> +		if (index($0,comment_start) > 0){
> +			in_comment = 1
> +		}
> +		# non comment code
> +		if (in_comment == 0) {
> +			for (i in deny_expr) {
> +				forbidden_added = "^\+.*" deny_expr[i];
> +				forbidden_removed="^-.*" deny_expr[i];
> +				current = expressions[deny_expr[i]]
> +				if ($0 ~ forbidden_added) {
> +					count = count + 1;
> +					expressions[deny_expr[i]] = current + 1
> +				}
> +				if ($0 ~ forbidden_removed) {
> +					count = count - 1;
> +					expressions[deny_expr[i]] = current - 1
> +				}
> +			}
> +		}
> +
> +		# comment end
> +		if (index($0,comment_end) > 0)  {
> +			in_comment = 0
> +		}
> +    }
> +	# switch to next file , check if the balance of add/remove
> +	# of previous filehad new additions
> +	($0 ~ "^\+\+\+ b/") {
> +		in_file = 0;
> +		if (count > 0){
> +			exit;
> +		}
> +		for (i in deny_folders){
> +			re = "^\+\+\+ b/" deny_folders[i];
> +			if ($0 ~ deny_folders[i]) {
> +				in_file = 1
> +				last_file = $0
> +			}
> +		}
> +	}
> +	END{
> +		if (count > 0){
> +			print "Warning: in " substr(last_file,6) ":"
> +			print "are you sure you want to add the following:"
> +			for (key in expressions) {
> +				if (expressions[key] > 0) {
> +					print key
> +				}
> +			}
> +			exit 1
> +		}
> +	}
> +EOF
> +	# ---------------------------------
> +
> +	# refrain from new additions of rte_panic() and rte_exit()
> +	# under lib and net
> +	# multiple folders and expressions are separated by spaces
> +	awk -v FOLDERS="lib net" \
> +		-v EXPRESSIONS="rte_panic\\\( rte_exit\\\(" \
> +		"$awk_script" -
> +}
> +
>  number=0
>  quiet=false
>  verbose=false
> @@ -89,11 +174,19 @@ check () { # <patch> <commit> <title>
>  	total=$(($total + 1))
>  	! $verbose || printf '\n### %s\n\n' "$3"
>  	if [ -n "$1" ] ; then
> +		cat "$1" | check_forbidden_additions
> +		[ $? -eq 0 ] || return 0
>  		report=$($DPDK_CHECKPATCH_PATH $options "$1" 2>/dev/null)
>  	elif [ -n "$2" ] ; then
> -		report=$(git format-patch --find-renames --no-stat --stdout -1 $commit |
> +		params=$(echo "--find-renames --no-stat --stdout -1")
> +		body=$(git format-patch $params $commit)
> +		echo "$body" | check_forbidden_additions
> +		[ $? -eq 0 ] || return 0
> +		report=$(echo "$body" |
>  			$DPDK_CHECKPATCH_PATH $options - 2>/dev/null)
>  	else
> +		check_forbidden_additions -
> +		[ $? -eq 0 ] || return 0
>  		report=$($DPDK_CHECKPATCH_PATH $options - 2>/dev/null)
>  	fi
>  	[ $? -ne 0 ] || return 0
> 

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v7 01/11] crypto/dpaa: replace rte_panic instances in crypto/dpaa driver
  2018-04-26 16:05   ` Kevin Traynor
@ 2018-04-26 16:16     ` Kevin Traynor
  2018-04-26 21:28     ` Arnon Warshavsky
  1 sibling, 0 replies; 91+ messages in thread
From: Kevin Traynor @ 2018-04-26 16:16 UTC (permalink / raw)
  To: Arnon Warshavsky, thomas, anatoly.burakov, wenzhuo.lu,
	declan.doherty, jerin.jacob, bruce.richardson, ferruh.yigit
  Cc: dev

On 04/26/2018 05:05 PM, Kevin Traynor wrote:
> On 04/24/2018 11:16 PM, Arnon Warshavsky wrote:
>> replace panic calls with log and return value.
>>

Replied to wrong version. Comments are still relevant for v9,

Kevin.

>> Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
>> ---
>>  drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c |  8 +++++---
>>  drivers/crypto/dpaa_sec/dpaa_sec.c          | 10 ++++++----
>>  2 files changed, 11 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
>> index 58cbce8..a78f3a2 100644
>> --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
>> +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
>> @@ -2883,9 +2883,11 @@ struct rte_security_ops dpaa2_sec_security_ops = {
>>  					RTE_CACHE_LINE_SIZE,
>>  					rte_socket_id());
>>  
>> -		if (cryptodev->data->dev_private == NULL)
>> -			rte_panic("Cannot allocate memzone for private "
>> -				  "device data");
>> +		if (cryptodev->data->dev_private == NULL) {
>> +			DPAA_SEC_ERR("%s() Cannot allocate memzone for private device data",
>> +			__func__);
>> +			return -ENOMEM;
> 
> I'm not familiar with the code but there was a successful allocate
> already, so it seems you should jump to the cleanup section at the end
> of the function before returning.
> 
>> +		}
>>  	}
>>  
>>  	dpaa2_dev->cryptodev = cryptodev;
>> diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
>> index e456fd5..a4670bf 100644
>> --- a/drivers/crypto/dpaa_sec/dpaa_sec.c
>> +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
>> @@ -2352,7 +2352,7 @@ struct rte_security_ops dpaa_sec_security_ops = {
>>  		}
>>  	}
>>  
>> -	RTE_LOG(INFO, PMD, "%s cryptodev init\n", cryptodev->data->name);
>> +	DPAA_SEC_INFO("%s cryptodev init\n", cryptodev->data->name);
> 
> This fix is an unrelated to the patchset. Perhaps as it's trivial the
> maintainer will allow it
> 
>>  	return 0;
>>  
>>  init_error:
>> @@ -2384,9 +2384,11 @@ struct rte_security_ops dpaa_sec_security_ops = {
>>  					RTE_CACHE_LINE_SIZE,
>>  					rte_socket_id());
>>  
>> -		if (cryptodev->data->dev_private == NULL)
>> -			rte_panic("Cannot allocate memzone for private "
>> -					"device data");
>> +		if (cryptodev->data->dev_private == NULL) {
>> +			DPAA_SEC_ERR("%s() Cannot allocate memzone for private device data",
>> +			__func__);
>> +			return -ENOMEM;
> 
> Same comment as above
> 
>> +		}
>>  	}
>>  
>>  	dpaa_dev->crypto_dev = cryptodev;
>>
> 

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v9 02/10] bond: replace rte_panic instances in bonding driver
  2018-04-26 16:06         ` Kevin Traynor
@ 2018-04-26 21:06           ` Arnon Warshavsky
  2018-04-26 21:26             ` Thomas Monjalon
  0 siblings, 1 reply; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-26 21:06 UTC (permalink / raw)
  To: Kevin Traynor
  Cc: Thomas Monjalon, Burakov, Anatoly, Lu, Wenzhuo, Doherty, Declan,
	jerin.jacob, Bruce Richardson, Yigit, Ferruh, dev

Hi Kevin

>       /* Any memory allocation failure in initialization is critical
> because
> >        * resources can't be free, so reinitialization is impossible. */
>
> What about this comment? Not sure if it is just stale or if there is
> something else you need to do.
>

This comment was originally in the code  to explain why is a panic being
thrown.
By returning from this function in this patch I also aim to terminate the
process, but through the door rather than out the window,
so It still makes sense there

>
> >   * @return
> >   *  0 on success, negative value otherwise.
>
>       ^^^ you inadvertently fixed a doxygen bug :-)
> I consider this doxygen tightly coupled with the code in this change so I
> will not charge twice here :)
>


>
> > +                     if (rc == internals->active_slave_count) {
> > +                             int rc = activate_slave(bonded_eth_dev,
> > +                                                     slave_port_id);
> > +                             if (rc != 0)
> > +                                     return -1;
> > +                     }
>
> Not functionally wrong, but commented about no need for variables here
> in v4 and seems to have been missed
>

Indeed missed that one. Will fix

Thanks
/Arnon

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v9 02/10] bond: replace rte_panic instances in bonding driver
  2018-04-26 21:06           ` Arnon Warshavsky
@ 2018-04-26 21:26             ` Thomas Monjalon
  0 siblings, 0 replies; 91+ messages in thread
From: Thomas Monjalon @ 2018-04-26 21:26 UTC (permalink / raw)
  To: Arnon Warshavsky
  Cc: Kevin Traynor, Burakov, Anatoly, Lu, Wenzhuo, Doherty, Declan,
	jerin.jacob, Bruce Richardson, Yigit, Ferruh, dev

26/04/2018 23:06, Arnon Warshavsky:
> By returning from this function in this patch I also aim to terminate the
> process, but through the door rather than out the window,

:D
Thanks for the laugh. Where is the button "Like"?

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v7 01/11] crypto/dpaa: replace rte_panic instances in crypto/dpaa driver
  2018-04-26 16:05   ` Kevin Traynor
  2018-04-26 16:16     ` Kevin Traynor
@ 2018-04-26 21:28     ` Arnon Warshavsky
  2018-04-27 10:08       ` Kevin Traynor
  1 sibling, 1 reply; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-26 21:28 UTC (permalink / raw)
  To: Kevin Traynor
  Cc: Thomas Monjalon, Burakov, Anatoly, Lu, Wenzhuo, Doherty, Declan,
	jerin.jacob, Bruce Richardson, Yigit, Ferruh, dev

> > -             if (cryptodev->data->dev_private == NULL)
> > -                     rte_panic("Cannot allocate memzone for private "
> > -                               "device data");
> > +             if (cryptodev->data->dev_private == NULL) {
> > +                     DPAA_SEC_ERR("%s() Cannot allocate memzone for
> private device data",
> > +                     __func__);
> > +                     return -ENOMEM;
>
> I'm not familiar with the code but there was a successful allocate
> already, so it seems you should jump to the cleanup section at the end
> of the function before returning.
>
> Hi Kevin,
The purpose of this patchset is not to offer a recoverable alternative for
panic,
rather allow the process to abort in an orderly manner.
It does not cover in this version all the panic instances on the init
sequence.
Other than in places where it seemed straight forward I tend not to perform
in this patchset
partial resource release where panic was before.

Thanks
/Arnon

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v9 08/10] eal: replace rte_panic instances in ethdev
  2018-04-26 16:07         ` Kevin Traynor
@ 2018-04-26 21:38           ` Arnon Warshavsky
  0 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-26 21:38 UTC (permalink / raw)
  To: Kevin Traynor
  Cc: Thomas Monjalon, Burakov, Anatoly, Lu, Wenzhuo, Doherty, Declan,
	jerin.jacob, Bruce Richardson, Yigit, Ferruh, dev

> > -void __rte_experimental
> > +int __rte_experimental
> >  rte_eth_dev_owner_delete(const uint64_t owner_id)
> >  {
> >       uint16_t port_id;
> > +     int error;
>
> it's inconsistent that this function returns the error code from
> rte_eth_dev_shared_data_prepare() and all these other functions return -1
>
> >
> > -     rte_eth_dev_shared_data_prepare();
> > +     error = rte_eth_dev_shared_data_prepare();
> > +     if (error != 0)
> > +             return error;
> >
>

Thanks Kevin, that's a valid point.
Since the function itself returns either 0 or -1 I will align this one
instance with the rest of the calls.
thanks
/Arnon

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v9 10/10] devtools: prevent new instances of rte_panic and rte_exit
  2018-04-26 16:08         ` Kevin Traynor
@ 2018-04-26 21:57           ` Arnon Warshavsky
  2018-04-27 10:02             ` Kevin Traynor
  0 siblings, 1 reply; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-26 21:57 UTC (permalink / raw)
  To: Kevin Traynor
  Cc: Thomas Monjalon, Burakov, Anatoly, Lu, Wenzhuo, Doherty, Declan,
	jerin.jacob, Bruce Richardson, Yigit, Ferruh, dev

On Thu, Apr 26, 2018 at 7:08 PM, Kevin Traynor <ktraynor@redhat.com> wrote:

> I think the first line of the commit msg ^^^ should change as it no
> longer prevents but just warns
>
> Actually the return value did not change, only the warning text did.
I would rather keep the word 'prevents' as an intention declaration that
puts the fact that a panic is undesired first, and the technical ability of
a maintainer to allow it second.
This is just in terms of how one positions the usage of panic.



> >
>
> Seems to drop the patch name if it finds a match


Not sure I understand what you meant here. Can you please elaborate?

Thanks
/Arnon

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v9 09/10] eal: replace rte_panic instances in init sequence
  2018-04-26 16:07         ` Kevin Traynor
@ 2018-04-26 22:08           ` Arnon Warshavsky
  2018-04-26 22:27             ` Arnon Warshavsky
  2018-04-27  9:56             ` Kevin Traynor
  0 siblings, 2 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-26 22:08 UTC (permalink / raw)
  To: Kevin Traynor
  Cc: Thomas Monjalon, Burakov, Anatoly, Lu, Wenzhuo, Doherty, Declan,
	jerin.jacob, Bruce Richardson, Yigit, Ferruh, dev

Hi Kevin

> > +     if (rte_config_init() != 0)
> > +             return -1;
> > +
>
> I'm confused, is this deliberate? there is now two rte_config_init()
> calls.


Please note that there are 2 eal.c files. One under linux and one under bsd
There is a copy of rte_config_init() in each.


> Aaron's comments on v4 about rte_eal_init_alert() are missed? and
> it's missing the clear once and error number like the other returns.
>

These comments were for code that I reverted to call panic again.
As Aaron pointed out, the partial treatment of v4 did not only not-improve
things, rather made them worst.
This code along with other panic instances thrown from within threads will
have a dedicated patchset.

Thanks
/Arnon

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v9 09/10] eal: replace rte_panic instances in init sequence
  2018-04-26 22:08           ` Arnon Warshavsky
@ 2018-04-26 22:27             ` Arnon Warshavsky
  2018-04-27  9:56             ` Kevin Traynor
  1 sibling, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-26 22:27 UTC (permalink / raw)
  To: Kevin Traynor
  Cc: Thomas Monjalon, Burakov, Anatoly, Lu, Wenzhuo, Doherty, Declan,
	jerin.jacob, Bruce Richardson, Yigit, Ferruh, dev

On Fri, Apr 27, 2018 at 1:08 AM, Arnon Warshavsky <arnon@qwilt.com> wrote:

> Hi Kevin
>
>> > +     if (rte_config_init() != 0)
>> > +             return -1;
>> > +
>>
>> I'm confused, is this deliberate? there is now two rte_config_init()
>> calls.
>
>
> Please note that there are 2 eal.c files. One under linux and one under bsd
> There is a copy of rte_config_init() in each.
>
>

My bad here here Kevin. You are right!
Was looking at the patch rather than the file. Will fix
Thanks
/Arnon

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v9 09/10] eal: replace rte_panic instances in init sequence
  2018-04-26 22:08           ` Arnon Warshavsky
  2018-04-26 22:27             ` Arnon Warshavsky
@ 2018-04-27  9:56             ` Kevin Traynor
  1 sibling, 0 replies; 91+ messages in thread
From: Kevin Traynor @ 2018-04-27  9:56 UTC (permalink / raw)
  To: Arnon Warshavsky
  Cc: Thomas Monjalon, Burakov, Anatoly, Lu, Wenzhuo, Doherty, Declan,
	jerin.jacob, Bruce Richardson, Yigit, Ferruh, dev

On 04/26/2018 11:08 PM, Arnon Warshavsky wrote:
> Hi Kevin
> 
>     > +     if (rte_config_init() != 0)
>     > +             return -1;
>     > +
> 
>     I'm confused, is this deliberate? there is now two rte_config_init()
>     calls. 
> 
> 
> Please note that there are 2 eal.c files. One under linux and one under bsd
> There is a copy of rte_config_init() in each.
>  
> 
>     Aaron's comments on v4 about rte_eal_init_alert() are missed? and
>     it's missing the clear once and error number like the other returns.
> 
> 
> These comments were for code that I reverted to call panic again.
> As Aaron pointed out, the partial treatment of v4 did not only
> not-improve things, rather made them worst.
> This code along with other panic instances thrown from within threads
> will have a dedicated patchset.
> 

I was referencing the code above (but as it's a duplicate call, I don't
know if it was merge leftovers from a previous version). Other returns
from rte_eal_init() have something like:
		rte_eal_init_alert("Cannot init logging.");
		rte_errno = ENOMEM;
		rte_atomic32_clear(&run_once);
		return -1;

> Thanks
> /Arnon
> 

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v9 10/10] devtools: prevent new instances of rte_panic and rte_exit
  2018-04-26 21:57           ` Arnon Warshavsky
@ 2018-04-27 10:02             ` Kevin Traynor
  2018-04-29  6:23               ` Arnon Warshavsky
  0 siblings, 1 reply; 91+ messages in thread
From: Kevin Traynor @ 2018-04-27 10:02 UTC (permalink / raw)
  To: Arnon Warshavsky
  Cc: Thomas Monjalon, Burakov, Anatoly, Lu, Wenzhuo, Doherty, Declan,
	jerin.jacob, Bruce Richardson, Yigit, Ferruh, dev

On 04/26/2018 10:57 PM, Arnon Warshavsky wrote:
> 
> 
> On Thu, Apr 26, 2018 at 7:08 PM, Kevin Traynor <ktraynor@redhat.com
> <mailto:ktraynor@redhat.com>> wrote:
> 
>     I think the first line of the commit msg ^^^ should change as it no
>     longer prevents but just warns
> 
> Actually the return value did not change, only the warning text did.

So will it fail checkpatch in patchwork? I agree with Aaron and Anatoly
that patches with rte_panic/exit should flag some warning message, but
the maintainer should have final say. I don't think failing checkpatch
is the solution for that.

> I would rather keep the word 'prevents' as an intention declaration that
> puts the fact that a panic is undesired first, and the technical ability
> of a maintainer to allow it second.

It's only words, but to me 'prevents' does not indicate that it is
undesirable - it indicates it is not allowed.

> This is just in terms of how one positions the usage of panic.
> 
>  
> 
>     > 
> 
>     Seems to drop the patch name if it finds a match
> 
> 
> Not sure I understand what you meant here. Can you please elaborate?
> 

Sure, I made a patch with an rte_panic and ran checkpatch on a bunch of
patches. It gave me the name of all the patches except the one with the
rte_panic.

> Thanks
> /Arnon
> 

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v7 01/11] crypto/dpaa: replace rte_panic instances in crypto/dpaa driver
  2018-04-26 21:28     ` Arnon Warshavsky
@ 2018-04-27 10:08       ` Kevin Traynor
  0 siblings, 0 replies; 91+ messages in thread
From: Kevin Traynor @ 2018-04-27 10:08 UTC (permalink / raw)
  To: Arnon Warshavsky
  Cc: Thomas Monjalon, Burakov, Anatoly, Lu, Wenzhuo, Doherty, Declan,
	jerin.jacob, Bruce Richardson, Yigit, Ferruh, dev

On 04/26/2018 10:28 PM, Arnon Warshavsky wrote:
> 
>     > -             if (cryptodev->data->dev_private == NULL)
>     > -                     rte_panic("Cannot allocate memzone for private "
>     > -                               "device data");
>     > +             if (cryptodev->data->dev_private == NULL) {
>     > +                     DPAA_SEC_ERR("%s() Cannot allocate memzone for private device data",
>     > +                     __func__);
>     > +                     return -ENOMEM;
> 
>     I'm not familiar with the code but there was a successful allocate
>     already, so it seems you should jump to the cleanup section at the end
>     of the function before returning.
> 
> Hi Kevin,
> The purpose of this patchset is not to offer a recoverable alternative
> for panic,
> rather allow the process to abort in an orderly manner.
> It does not cover in this version all the panic instances on the init
> sequence.
> Other than in places where it seemed straight forward I tend not to
> perform in this patchset
> partial resource release where panic was before.
> 

Ok, I understand the intention better now.

> Thanks
> /Arnon
> 
> 
>  

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances
  2018-04-26  6:20     ` [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                         ` (9 preceding siblings ...)
  2018-04-26  6:21       ` [dpdk-dev] [PATCH v9 10/10] devtools: prevent new instances of rte_panic and rte_exit Arnon Warshavsky
@ 2018-04-27 14:22       ` Thomas Monjalon
  2018-04-27 16:31         ` Arnon Warshavsky
  2018-04-27 14:30       ` Thomas Monjalon
  11 siblings, 1 reply; 91+ messages in thread
From: Thomas Monjalon @ 2018-04-27 14:22 UTC (permalink / raw)
  To: Arnon Warshavsky
  Cc: dev, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit

26/04/2018 08:20, Arnon Warshavsky:
> The purpose of this patch series is to cleanup the library code
> from paths that end up aborting the process,
> and move to checking error values, in order to allow the running process
> perform an orderly teardown or other mitigation of the event.
> 
> This patch modifies the majority of rte_panic calls
> under lib and drivers, and replaces them with a log message
> and an error return code according to context,
> that can be propagated up the call stack.
> 
> - Focus was given to the dpdk initialization path
> - Some of the panic calls within drivers were left in place where
>   the call is from within an interrupt or calls that are
>   on the data path,where there is no simple applicative
>   route to propagate the error to temination.
>   These should be handled by the driver maintainers..
> - local void functions with no api were changed to retrun a value
>   where needed
> - No change took place in example and test files
> - No change took place for debug assertions calling panic
> - A new function was added to devtools/checkpatches.sh
>   in order to prevent new additions of calls to rte_panic
>   under lib and drivers.
> 
> Keep calm and don't panic

What is the status of this patchset?
It seems not ready for RC1 (today).
I don't want to push it in RC2 because it changes too many things.
So it's today or wait for 18.08. What do you think?

The last patch for check tooling can be separated and pushed at anytime.

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances
  2018-04-26  6:20     ` [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
                         ` (10 preceding siblings ...)
  2018-04-27 14:22       ` [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances Thomas Monjalon
@ 2018-04-27 14:30       ` Thomas Monjalon
  11 siblings, 0 replies; 91+ messages in thread
From: Thomas Monjalon @ 2018-04-27 14:30 UTC (permalink / raw)
  To: Arnon Warshavsky
  Cc: dev, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit

26/04/2018 08:20, Arnon Warshavsky:
> v8:
> - Seperate the 2 drivers salad back to distinct bond and dpaa patches
> - Add missing file descriptor closing when returnning an error
> - Remove half baked thread patch to be handled in the next version
> - Remove duplicate function call after rebase

You forgot the ack from Stephen on the series

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances
  2018-04-27 14:22       ` [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances Thomas Monjalon
@ 2018-04-27 16:31         ` Arnon Warshavsky
  2018-04-27 16:40           ` Thomas Monjalon
  0 siblings, 1 reply; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-27 16:31 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: anatoly.burakov, bruce.richardson, declan.doherty, dev,
	ferruh.yigit, jerin.jacob, wenzhuo.lu

On Fri, Apr 27, 2018, 17:22 Thomas Monjalon <thomas@monjalon.net> wrote:

> 26/04/2018 08:20, Arnon Warshavsky:
> > The purpose of this patch series is to cleanup the library code
> > from paths that end up aborting the process,
> > and move to checking error values, in order to allow the running process
> > perform an orderly teardown or other mitigation of the event.
> >
> > This patch modifies the majority of rte_panic calls
> > under lib and drivers, and replaces them with a log message
> > and an error return code according to context,
> > that can be propagated up the call stack.
> >
> > - Focus was given to the dpdk initialization path
> > - Some of the panic calls within drivers were left in place where
> >   the call is from within an interrupt or calls that are
> >   on the data path,where there is no simple applicative
> >   route to propagate the error to temination.
> >   These should be handled by the driver maintainers..
> > - local void functions with no api were changed to retrun a value
> >   where needed
> > - No change took place in example and test files
> > - No change took place for debug assertions calling panic
> > - A new function was added to devtools/checkpatches.sh
> >   in order to prevent new additions of calls to rte_panic
> >   under lib and drivers.
> >
> > Keep calm and don't panic
>
> What is the status of this patchset?
> It seems not ready for RC1 (today).
> I don't want to push it in RC2 because it changes too many things.
> So it's today or wait for 18.08. What do you think?
>
> The last patch for check tooling can be separated and pushed at anytime.
>

Yes,unfortunately its 18.08.I am away the entire weekend from any means of
getting  the code fixed, so only on Sunday I will split the last patch from
the rest.
Should I put the tooling patch as a new set and refer both patchsets to the
current v9?

>
>
>

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances
  2018-04-27 16:31         ` Arnon Warshavsky
@ 2018-04-27 16:40           ` Thomas Monjalon
  2018-04-27 17:16             ` Arnon Warshavsky
  0 siblings, 1 reply; 91+ messages in thread
From: Thomas Monjalon @ 2018-04-27 16:40 UTC (permalink / raw)
  To: Arnon Warshavsky
  Cc: anatoly.burakov, bruce.richardson, declan.doherty, dev,
	ferruh.yigit, jerin.jacob, wenzhuo.lu

27/04/2018 18:31, Arnon Warshavsky:
> On Fri, Apr 27, 2018, 17:22 Thomas Monjalon <thomas@monjalon.net> wrote:
> > What is the status of this patchset?
> > It seems not ready for RC1 (today).
> > I don't want to push it in RC2 because it changes too many things.
> > So it's today or wait for 18.08. What do you think?
> >
> > The last patch for check tooling can be separated and pushed at anytime.
> >
> 
> Yes,unfortunately its 18.08.I am away the entire weekend from any means of
> getting  the code fixed, so only on Sunday I will split the last patch from
> the rest.

So you are OK with considering this patchset for 18.08?
And take the tool in 18.05?

> Should I put the tooling patch as a new set and refer both patchsets to the
> current v9?

Yes you can split and keep v9 numbering for both.

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances
  2018-04-27 16:40           ` Thomas Monjalon
@ 2018-04-27 17:16             ` Arnon Warshavsky
  0 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-27 17:16 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: anatoly.burakov, bruce.richardson, declan.doherty, dev,
	ferruh.yigit, jerin.jacob, wenzhuo.lu

On Fri, Apr 27, 2018, 19:40 Thomas Monjalon <thomas@monjalon.net> wrote:

> 27/04/2018 18:31, Arnon Warshavsky:
> > On Fri, Apr 27, 2018, 17:22 Thomas Monjalon <thomas@monjalon.net> wrote:
> > > What is the status of this patchset?
> > > It seems not ready for RC1 (today).
> > > I don't want to push it in RC2 because it changes too many things.
> > > So it's today or wait for 18.08. What do you think?
> > >
> > > The last patch for check tooling can be separated and pushed at
> anytime.
> > >
> >
> > Yes,unfortunately its 18.08.I am away the entire weekend from any means
> of
> > getting  the code fixed, so only on Sunday I will split the last patch
> from
> > the rest.
>
> So you are OK with considering this patchset for 18.08?
> And take the tool in 18.05?
>
> Yes, it looks like the best option here.

Thanks
/Arnon

>
>
>

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v9 10/10] devtools: prevent new instances of rte_panic and rte_exit
  2018-04-27 10:02             ` Kevin Traynor
@ 2018-04-29  6:23               ` Arnon Warshavsky
  0 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-29  6:23 UTC (permalink / raw)
  To: Kevin Traynor
  Cc: Thomas Monjalon, Burakov, Anatoly, Lu, Wenzhuo, Doherty, Declan,
	jerin.jacob, Bruce Richardson, Yigit, Ferruh, dev

So will it fail checkpatch in patchwork? I agree with Aaron and Anatoly
> that patches with rte_panic/exit should flag some warning message, but
> the maintainer should have final say. I don't think failing checkpatch
> is the solution for that.
>
Ok. will leave that to the maintainers and change that not to fail


> > I would rather keep the word 'prevents' as an intention declaration that
> > puts the fact that a panic is undesired first, and the technical ability
> > of a maintainer to allow it second.
>
> It's only words, but to me 'prevents' does not indicate that it is
> undesirable - it indicates it is not allowed.
>
They say words create reality, but since we agreed on reality, I'll reword
:)

>
> > Not sure I understand what you meant here. Can you please elaborate?
> >
>
> Sure, I made a patch with an rte_panic and ran checkpatch on a bunch of
> patches. It gave me the name of all the patches except the one with the
> rte_panic.
>
> Got it now. I wasn't using -v .Will fix
Thanks
/Arnon
--

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v10] devtools: alert on new instances of rte_panic and rte_exit
  2018-04-26  6:21       ` [dpdk-dev] [PATCH v9 10/10] devtools: prevent new instances of rte_panic and rte_exit Arnon Warshavsky
  2018-04-26 16:08         ` Kevin Traynor
@ 2018-04-30  6:45         ` Arnon Warshavsky
  2018-05-04 16:42           ` Kevin Traynor
                             ` (2 more replies)
  1 sibling, 3 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-04-30  6:45 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, Arnon Warshavsky

This patch adds a new function that is called
per every checked patch,
and alerts for new instances of rte_panic/rte_exit.
The check excludes comments, and alerts in the case
of a positive balance between additions and removals.

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
---
 devtools/checkpatches.sh | 96 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 95 insertions(+), 1 deletion(-)

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 7676a6b..c7d927b 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -61,6 +61,92 @@ print_usage () {
 	END_OF_HELP
 }
 
+check_forbidden_additions() { # <file>
+    # ---------------------------------
+    #This awk script receives a list of expressions to monitor
+    #and a list of folders to search these expressions in
+    # - No search is done inside comments
+    # - Both additions and removals of the expressions are checked
+    #   A positive balance of additions fails the check
+	read -d '' awk_script << 'EOF'
+	BEGIN{
+		split(FOLDERS,deny_folders," ");
+		split(EXPRESSIONS,deny_expr," ");
+		in_file=0;
+		in_comment=0;
+		count=0;
+		comment_start="/*"
+		comment_end="*/"
+    }
+    # search for add/remove instances in current file
+    # state machine assumes the comments structure is enforced by
+    # checkpatches.pl
+    (in_file) {
+		# comment start
+		if (index($0,comment_start) > 0){
+			in_comment = 1
+		}
+		# non comment code
+		if (in_comment == 0) {
+			for (i in deny_expr) {
+				forbidden_added = "^\+.*" deny_expr[i];
+				forbidden_removed="^-.*" deny_expr[i];
+				current = expressions[deny_expr[i]]
+				if ($0 ~ forbidden_added) {
+					count = count + 1;
+					expressions[deny_expr[i]] = current + 1
+				}
+				if ($0 ~ forbidden_removed) {
+					count = count - 1;
+					expressions[deny_expr[i]] = current - 1
+				}
+			}
+		}
+
+		# comment end
+		if (index($0,comment_end) > 0)  {
+			in_comment = 0
+		}
+    }
+	# switch to next file , check if the balance of add/remove
+	# of previous filehad new additions
+	($0 ~ "^\+\+\+ b/") {
+		in_file = 0;
+		if (count > 0){
+			exit;
+		}
+		for (i in deny_folders){
+			re = "^\+\+\+ b/" deny_folders[i];
+			if ($0 ~ deny_folders[i]) {
+				in_file = 1
+				last_file = $0
+			}
+		}
+	}
+	END{
+		if (count > 0){
+			warnText = "\\033[1;31m" "Warning:" "\\033[0m"
+			print warnText " in " substr(last_file,6) ":"
+			print "are you sure you want to add the following:"
+			for (key in expressions) {
+				if (expressions[key] > 0) {
+					print key
+				}
+			}
+			exit 0
+		}
+	}
+EOF
+	# ---------------------------------
+
+	# refrain from new additions of rte_panic() and rte_exit()
+	# under lib and net
+	# multiple folders and expressions are separated by spaces
+	awk -v FOLDERS="lib net" \
+		-v EXPRESSIONS="rte_panic\\\( rte_exit\\\(" \
+		"$awk_script" -
+}
+
 number=0
 quiet=false
 verbose=false
@@ -89,11 +175,19 @@ check () { # <patch> <commit> <title>
 	total=$(($total + 1))
 	! $verbose || printf '\n### %s\n\n' "$3"
 	if [ -n "$1" ] ; then
+		cat "$1" | check_forbidden_additions
+		[ $? -eq 0 ] || return 0
 		report=$($DPDK_CHECKPATCH_PATH $options "$1" 2>/dev/null)
 	elif [ -n "$2" ] ; then
-		report=$(git format-patch --find-renames --no-stat --stdout -1 $commit |
+		params=$(echo "--find-renames --no-stat --stdout -1")
+		body=$(git format-patch $params $commit)
+		echo "$body" | check_forbidden_additions
+		[ $? -eq 0 ] || return 0
+		report=$(echo "$body" |
 			$DPDK_CHECKPATCH_PATH $options - 2>/dev/null)
 	else
+		check_forbidden_additions -
+		[ $? -eq 0 ] || return 0
 		report=$($DPDK_CHECKPATCH_PATH $options - 2>/dev/null)
 	fi
 	[ $? -ne 0 ] || return 0
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v10] devtools: alert on new instances of rte_panic and rte_exit
  2018-04-30  6:45         ` [dpdk-dev] [PATCH v10] devtools: alert on " Arnon Warshavsky
@ 2018-05-04 16:42           ` Kevin Traynor
  2018-05-27 19:47           ` Thomas Monjalon
  2018-07-16 11:37           ` [dpdk-dev] [PATCH v11] " Arnon Warshavsky
  2 siblings, 0 replies; 91+ messages in thread
From: Kevin Traynor @ 2018-05-04 16:42 UTC (permalink / raw)
  To: Arnon Warshavsky, thomas, anatoly.burakov, wenzhuo.lu,
	declan.doherty, jerin.jacob, bruce.richardson, ferruh.yigit
  Cc: dev

On 04/30/2018 07:45 AM, Arnon Warshavsky wrote:
> This patch adds a new function that is called
> per every checked patch,
> and alerts for new instances of rte_panic/rte_exit.
> The check excludes comments, and alerts in the case
> of a positive balance between additions and removals.
> 
> Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
> Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>

Tested-by: Kevin Traynor <ktraynor@redhat.com>

> ---
>  devtools/checkpatches.sh | 96 +++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 95 insertions(+), 1 deletion(-)
> 
> diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
> index 7676a6b..c7d927b 100755
> --- a/devtools/checkpatches.sh
> +++ b/devtools/checkpatches.sh
> @@ -61,6 +61,92 @@ print_usage () {
>  	END_OF_HELP
>  }
>  
> +check_forbidden_additions() { # <file>
> +    # ---------------------------------
> +    #This awk script receives a list of expressions to monitor
> +    #and a list of folders to search these expressions in
> +    # - No search is done inside comments
> +    # - Both additions and removals of the expressions are checked
> +    #   A positive balance of additions fails the check
> +	read -d '' awk_script << 'EOF'
> +	BEGIN{
> +		split(FOLDERS,deny_folders," ");
> +		split(EXPRESSIONS,deny_expr," ");
> +		in_file=0;
> +		in_comment=0;
> +		count=0;
> +		comment_start="/*"
> +		comment_end="*/"
> +    }
> +    # search for add/remove instances in current file
> +    # state machine assumes the comments structure is enforced by
> +    # checkpatches.pl
> +    (in_file) {
> +		# comment start
> +		if (index($0,comment_start) > 0){
> +			in_comment = 1
> +		}
> +		# non comment code
> +		if (in_comment == 0) {
> +			for (i in deny_expr) {
> +				forbidden_added = "^\+.*" deny_expr[i];
> +				forbidden_removed="^-.*" deny_expr[i];
> +				current = expressions[deny_expr[i]]
> +				if ($0 ~ forbidden_added) {
> +					count = count + 1;
> +					expressions[deny_expr[i]] = current + 1
> +				}
> +				if ($0 ~ forbidden_removed) {
> +					count = count - 1;
> +					expressions[deny_expr[i]] = current - 1
> +				}
> +			}
> +		}
> +
> +		# comment end
> +		if (index($0,comment_end) > 0)  {
> +			in_comment = 0
> +		}
> +    }
> +	# switch to next file , check if the balance of add/remove
> +	# of previous filehad new additions
> +	($0 ~ "^\+\+\+ b/") {
> +		in_file = 0;
> +		if (count > 0){
> +			exit;
> +		}
> +		for (i in deny_folders){
> +			re = "^\+\+\+ b/" deny_folders[i];
> +			if ($0 ~ deny_folders[i]) {
> +				in_file = 1
> +				last_file = $0
> +			}
> +		}
> +	}
> +	END{
> +		if (count > 0){
> +			warnText = "\\033[1;31m" "Warning:" "\\033[0m"
> +			print warnText " in " substr(last_file,6) ":"
> +			print "are you sure you want to add the following:"
> +			for (key in expressions) {
> +				if (expressions[key] > 0) {
> +					print key
> +				}
> +			}
> +			exit 0
> +		}
> +	}
> +EOF
> +	# ---------------------------------
> +
> +	# refrain from new additions of rte_panic() and rte_exit()
> +	# under lib and net
> +	# multiple folders and expressions are separated by spaces
> +	awk -v FOLDERS="lib net" \
> +		-v EXPRESSIONS="rte_panic\\\( rte_exit\\\(" \
> +		"$awk_script" -
> +}
> +
>  number=0
>  quiet=false
>  verbose=false
> @@ -89,11 +175,19 @@ check () { # <patch> <commit> <title>
>  	total=$(($total + 1))
>  	! $verbose || printf '\n### %s\n\n' "$3"
>  	if [ -n "$1" ] ; then
> +		cat "$1" | check_forbidden_additions
> +		[ $? -eq 0 ] || return 0
>  		report=$($DPDK_CHECKPATCH_PATH $options "$1" 2>/dev/null)
>  	elif [ -n "$2" ] ; then
> -		report=$(git format-patch --find-renames --no-stat --stdout -1 $commit |
> +		params=$(echo "--find-renames --no-stat --stdout -1")
> +		body=$(git format-patch $params $commit)
> +		echo "$body" | check_forbidden_additions
> +		[ $? -eq 0 ] || return 0
> +		report=$(echo "$body" |
>  			$DPDK_CHECKPATCH_PATH $options - 2>/dev/null)
>  	else
> +		check_forbidden_additions -
> +		[ $? -eq 0 ] || return 0
>  		report=$($DPDK_CHECKPATCH_PATH $options - 2>/dev/null)
>  	fi
>  	[ $? -ne 0 ] || return 0
> 

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v10] devtools: alert on new instances of rte_panic and rte_exit
  2018-04-30  6:45         ` [dpdk-dev] [PATCH v10] devtools: alert on " Arnon Warshavsky
  2018-05-04 16:42           ` Kevin Traynor
@ 2018-05-27 19:47           ` Thomas Monjalon
  2018-05-27 20:34             ` Arnon Warshavsky
  2018-07-16 11:37           ` [dpdk-dev] [PATCH v11] " Arnon Warshavsky
  2 siblings, 1 reply; 91+ messages in thread
From: Thomas Monjalon @ 2018-05-27 19:47 UTC (permalink / raw)
  To: Arnon Warshavsky
  Cc: dev, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit, Neil Horman

Hi,

30/04/2018 08:45, Arnon Warshavsky:
> --- a/devtools/checkpatches.sh
> +++ b/devtools/checkpatches.sh
> +		check_forbidden_additions -

This is consuming stdin.
I guess the checkpatch.pl will have nothing to check in the next step.
We should merge Neil's patch first, because he is adding a tmpfile
to solve the issue of stdin read only once.

> +		[ $? -eq 0 ] || return 0

This test looks reversed: if the result is not 0, we should not return 0.
And by the way, I think it is better to continue with other checks.
Neil's patch is setting ret=1, continue and return at the end.

>  		report=$($DPDK_CHECKPATCH_PATH $options - 2>/dev/null)

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v10] devtools: alert on new instances of rte_panic and rte_exit
  2018-05-27 19:47           ` Thomas Monjalon
@ 2018-05-27 20:34             ` Arnon Warshavsky
  2018-07-15 23:15               ` Thomas Monjalon
  0 siblings, 1 reply; 91+ messages in thread
From: Arnon Warshavsky @ 2018-05-27 20:34 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, Burakov, Anatoly, Lu, Wenzhuo, Doherty, Declan, jerin.jacob,
	Bruce Richardson, Yigit, Ferruh, Neil Horman

This is consuming stdin.
> I guess the checkpatch.pl will have nothing to check in the next step.
> We should merge Neil's patch first, because he is adding a tmpfile
> to solve the issue of stdin read only once.
>

Yup. Missed the fact stdin is consumed. temp file is a good idea

>
> > +             [ $? -eq 0 ] || return 0
>
> This test looks reversed: if the result is not 0, we should not return 0.
> And by the way, I think it is better to continue with other checks.
> Neil's patch is setting ret=1, continue and return at the end.
>
> >               report=$($DPDK_CHECKPATCH_PATH $options - 2>/dev/null)
>

As it was agreed that this check should only warn and not fail the tests,
The actual situation is that the function check_forbidden_additions()
always returns zero.
Once Neils patch is in, I can align to the return value propagation,
but the current code never fails  (that may change of course for future
different tokens)


thanks
/Arnon

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v10] devtools: alert on new instances of rte_panic and rte_exit
  2018-05-27 20:34             ` Arnon Warshavsky
@ 2018-07-15 23:15               ` Thomas Monjalon
  0 siblings, 0 replies; 91+ messages in thread
From: Thomas Monjalon @ 2018-07-15 23:15 UTC (permalink / raw)
  To: Arnon Warshavsky
  Cc: dev, Burakov, Anatoly, Lu, Wenzhuo, Doherty, Declan, jerin.jacob,
	Bruce Richardson, Yigit, Ferruh, Neil Horman

27/05/2018 22:34, Arnon Warshavsky:
> This is consuming stdin.
> > I guess the checkpatch.pl will have nothing to check in the next step.
> > We should merge Neil's patch first, because he is adding a tmpfile
> > to solve the issue of stdin read only once.
> >
> 
> Yup. Missed the fact stdin is consumed. temp file is a good idea
> 
> >
> > > +             [ $? -eq 0 ] || return 0
> >
> > This test looks reversed: if the result is not 0, we should not return 0.
> > And by the way, I think it is better to continue with other checks.
> > Neil's patch is setting ret=1, continue and return at the end.
> >
> > >               report=$($DPDK_CHECKPATCH_PATH $options - 2>/dev/null)
> >
> 
> As it was agreed that this check should only warn and not fail the tests,
> The actual situation is that the function check_forbidden_additions()
> always returns zero.
> Once Neils patch is in, I can align to the return value propagation,
> but the current code never fails  (that may change of course for future
> different tokens)

Neil's patch is merged. Please would you like to resume your work?

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v11] devtools: alert on new instances of rte_panic and rte_exit
  2018-04-30  6:45         ` [dpdk-dev] [PATCH v10] devtools: alert on " Arnon Warshavsky
  2018-05-04 16:42           ` Kevin Traynor
  2018-05-27 19:47           ` Thomas Monjalon
@ 2018-07-16 11:37           ` Arnon Warshavsky
  2018-07-16 12:44             ` [dpdk-dev] [PATCH v12] " Arnon Warshavsky
  2 siblings, 1 reply; 91+ messages in thread
From: Arnon Warshavsky @ 2018-07-16 11:37 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

This patch adds a new function that is called
per every checked patch,
and alerts for new instances of rte_panic/rte_exit.
The check excludes comments, and alerts in the case
of a positive balance between additions and removals.

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
---

v11 
- Use Neils tmpfile infrastructure to consume the patches
- Allow different calls to the awk script decide if they want
  to fail the check or just warn

 devtools/checkpatches.sh | 95 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 1439bce..22832ef 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -43,6 +43,94 @@ print_usage () {
 	END_OF_HELP
 }
 
+
+check_forbidden_additions() { # <file>
+    # ---------------------------------
+    #This awk script receives a list of expressions to monitor
+    #and a list of folders to search these expressions in
+    # - No search is done inside comments
+    # - Both additions and removals of the expressions are checked
+    #   A positive balance of additions fails the check
+	read -d '' awk_script << 'EOF'
+	BEGIN{
+		split(FOLDERS,deny_folders," ");
+		split(EXPRESSIONS,deny_expr," ");
+		in_file=0;
+		in_comment=0;
+		count=0;
+		comment_start="/*"
+		comment_end="*/"
+	}
+	# search for add/remove instances in current file
+	# state machine assumes the comments structure is enforced by
+	# checkpatches.pl
+	(in_file) {
+		# comment start
+		if (index($0,comment_start) > 0){
+			in_comment = 1
+		}
+		# non comment code
+		if (in_comment == 0) {
+			for (i in deny_expr) {
+				forbidden_added = "^\+.*" deny_expr[i];
+				forbidden_removed="^-.*" deny_expr[i];
+				current = expressions[deny_expr[i]]
+				if ($0 ~ forbidden_added) {
+					count = count + 1;
+					expressions[deny_expr[i]] = current + 1
+				}
+				if ($0 ~ forbidden_removed) {
+					count = count - 1;
+					expressions[deny_expr[i]] = current - 1
+				}
+			}
+		}
+
+		# comment end
+		if (index($0,comment_end) > 0)  {
+			in_comment = 0
+		}
+	}
+	# switch to next file , check if the balance of add/remove
+	# of previous filehad new additions
+	($0 ~ "^\+\+\+ b/") {
+		in_file = 0;
+		if (count > 0){
+			exit;
+		}
+		for (i in deny_folders){
+			re = "^\+\+\+ b/" deny_folders[i];
+			if ($0 ~ deny_folders[i]) {
+				in_file = 1
+				last_file = $0
+			}
+		}
+	}
+	END{
+		if (count > 0){
+			warnText = "\\033[1;31m" "Warning:" "\\033[0m"
+			print warnText " in " substr(last_file,6) ":"
+			print "are you sure you want to add the following:"
+			for (key in expressions) {
+				if (expressions[key] > 0) {
+					print key
+				}
+			}
+			exit RET_ON_FAIL
+		}
+	}
+EOF
+	# ---------------------------------
+
+	# refrain from new additions of rte_panic() and rte_exit()
+	# under lib and net
+	# multiple folders and expressions are separated by spaces
+	awk -v FOLDERS="lib net" \
+		-v EXPRESSIONS="rte_panic\\\( rte_exit\\\(" \
+		-v RET_ON_FAIL=0 \
+		"$awk_script" -
+}
+
 number=0
 quiet=false
 verbose=false
@@ -97,6 +185,13 @@ check () { # <patch> <commit> <title>
 		ret=1
 	fi
 
+	! $verbose || printf '\nChecking forbidden tokens additions/removals:\n'
+	report=$(cat $tmpinput | check_forbidden_additions)
+	if [ $? -ne 0 ] ; then
+		ret=1
+	fi
+	printf '%s\n' "$report"
+
 	clean_tmp_files
 	[ $ret -eq 0 ] && return 0
 
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v12] devtools: alert on new instances of rte_panic and rte_exit
  2018-07-16 11:37           ` [dpdk-dev] [PATCH v11] " Arnon Warshavsky
@ 2018-07-16 12:44             ` Arnon Warshavsky
  2018-07-26 20:29               ` Thomas Monjalon
  2018-07-26 22:10               ` [dpdk-dev] [PATCH v13] " Arnon Warshavsky
  0 siblings, 2 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-07-16 12:44 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

This patch adds a new function that is called
per every checked patch,
and alerts for new instances of rte_panic/rte_exit.
The check excludes comments, and alerts in the case
of a positive balance between additions and removals.

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
Tested-by: Kevin Traynor <ktraynor@redhat.com>
---

v11
- Use Neils tmpfile infrastructure to consume the patches
- Allow different calls to the awk script decide if they want
  to fail the check or just warn
v12
- Restored Tested message

 devtools/checkpatches.sh | 95 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 1439bce..22832ef 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -43,6 +43,94 @@ print_usage () {
 	END_OF_HELP
 }
 
+
+check_forbidden_additions() { # <file>
+    # ---------------------------------
+    #This awk script receives a list of expressions to monitor
+    #and a list of folders to search these expressions in
+    # - No search is done inside comments
+    # - Both additions and removals of the expressions are checked
+    #   A positive balance of additions fails the check
+	read -d '' awk_script << 'EOF'
+	BEGIN{
+		split(FOLDERS,deny_folders," ");
+		split(EXPRESSIONS,deny_expr," ");
+		in_file=0;
+		in_comment=0;
+		count=0;
+		comment_start="/*"
+		comment_end="*/"
+	}
+	# search for add/remove instances in current file
+	# state machine assumes the comments structure is enforced by
+	# checkpatches.pl
+	(in_file) {
+		# comment start
+		if (index($0,comment_start) > 0){
+			in_comment = 1
+		}
+		# non comment code
+		if (in_comment == 0) {
+			for (i in deny_expr) {
+				forbidden_added = "^\+.*" deny_expr[i];
+				forbidden_removed="^-.*" deny_expr[i];
+				current = expressions[deny_expr[i]]
+				if ($0 ~ forbidden_added) {
+					count = count + 1;
+					expressions[deny_expr[i]] = current + 1
+				}
+				if ($0 ~ forbidden_removed) {
+					count = count - 1;
+					expressions[deny_expr[i]] = current - 1
+				}
+			}
+		}
+
+		# comment end
+		if (index($0,comment_end) > 0)  {
+			in_comment = 0
+		}
+	}
+	# switch to next file , check if the balance of add/remove
+	# of previous filehad new additions
+	($0 ~ "^\+\+\+ b/") {
+		in_file = 0;
+		if (count > 0){
+			exit;
+		}
+		for (i in deny_folders){
+			re = "^\+\+\+ b/" deny_folders[i];
+			if ($0 ~ deny_folders[i]) {
+				in_file = 1
+				last_file = $0
+			}
+		}
+	}
+	END{
+		if (count > 0){
+			warnText = "\\033[1;31m" "Warning:" "\\033[0m"
+			print warnText " in " substr(last_file,6) ":"
+			print "are you sure you want to add the following:"
+			for (key in expressions) {
+				if (expressions[key] > 0) {
+					print key
+				}
+			}
+			exit RET_ON_FAIL
+		}
+	}
+EOF
+	# ---------------------------------
+
+	# refrain from new additions of rte_panic() and rte_exit()
+	# under lib and net
+	# multiple folders and expressions are separated by spaces
+	awk -v FOLDERS="lib net" \
+		-v EXPRESSIONS="rte_panic\\\( rte_exit\\\(" \
+		-v RET_ON_FAIL=0 \
+		"$awk_script" -
+}
+
 number=0
 quiet=false
 verbose=false
@@ -97,6 +185,13 @@ check () { # <patch> <commit> <title>
 		ret=1
 	fi
 
+	! $verbose || printf '\nChecking forbidden tokens additions/removals:\n'
+	report=$(cat $tmpinput | check_forbidden_additions)
+	if [ $? -ne 0 ] ; then
+		ret=1
+	fi
+	printf '%s\n' "$report"
+
 	clean_tmp_files
 	[ $ret -eq 0 ] && return 0
 
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v12] devtools: alert on new instances of rte_panic and rte_exit
  2018-07-16 12:44             ` [dpdk-dev] [PATCH v12] " Arnon Warshavsky
@ 2018-07-26 20:29               ` Thomas Monjalon
  2018-07-26 20:57                 ` Arnon Warshavsky
                                   ` (2 more replies)
  2018-07-26 22:10               ` [dpdk-dev] [PATCH v13] " Arnon Warshavsky
  1 sibling, 3 replies; 91+ messages in thread
From: Thomas Monjalon @ 2018-07-26 20:29 UTC (permalink / raw)
  To: Arnon Warshavsky
  Cc: dev, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit

Hi,

I am sorry, I always give low priority to tooling review.
I was going to apply this one, but I've seen some details to improve.

16/07/2018 14:44, Arnon Warshavsky:
> +check_forbidden_additions() { # <file>

This function looks to work with stdin, not a file.
Better to remove the comment about a <file>.

> +    # ---------------------------------

A split line at the beginning is visually strange.

> +    #This awk script receives a list of expressions to monitor
> +    #and a list of folders to search these expressions in

Please insert a space after #

> +    # - No search is done inside comments
> +    # - Both additions and removals of the expressions are checked
> +    #   A positive balance of additions fails the check
> +	read -d '' awk_script << 'EOF'

EOF must be quoted?

> +	BEGIN{

Please insert a space before {

> +		split(FOLDERS,deny_folders," ");
> +		split(EXPRESSIONS,deny_expr," ");
> +		in_file=0;
> +		in_comment=0;
> +		count=0;
> +		comment_start="/*"
> +		comment_end="*/"
> +	}
> +	# search for add/remove instances in current file
> +	# state machine assumes the comments structure is enforced by
> +	# checkpatches.pl
> +	(in_file) {
> +		# comment start
> +		if (index($0,comment_start) > 0){
> +			in_comment = 1
> +		}
> +		# non comment code
> +		if (in_comment == 0) {
> +			for (i in deny_expr) {
> +				forbidden_added = "^\+.*" deny_expr[i];
> +				forbidden_removed="^-.*" deny_expr[i];
> +				current = expressions[deny_expr[i]]
> +				if ($0 ~ forbidden_added) {
> +					count = count + 1;
> +					expressions[deny_expr[i]] = current + 1
> +				}
> +				if ($0 ~ forbidden_removed) {
> +					count = count - 1;
> +					expressions[deny_expr[i]] = current - 1
> +				}
> +			}
> +		}
> +

This is the only blank line in the awk script.
Can be removed.

> +		# comment end
> +		if (index($0,comment_end) > 0)  {
> +			in_comment = 0
> +		}
> +	}
> +	# switch to next file , check if the balance of add/remove
> +	# of previous filehad new additions
> +	($0 ~ "^\+\+\+ b/") {
> +		in_file = 0;
> +		if (count > 0){
> +			exit;
> +		}
> +		for (i in deny_folders){
> +			re = "^\+\+\+ b/" deny_folders[i];
> +			if ($0 ~ deny_folders[i]) {
> +				in_file = 1
> +				last_file = $0
> +			}
> +		}
> +	}
> +	END{
> +		if (count > 0){
> +			warnText = "\\033[1;31m" "Warning:" "\\033[0m"

Please no color in the warning.
It will look strange in a file.

> +			print warnText " in " substr(last_file,6) ":"
> +			print "are you sure you want to add the following:"
> +			for (key in expressions) {
> +				if (expressions[key] > 0) {
> +					print key
> +				}
> +			}
> +			exit RET_ON_FAIL
> +		}
> +	}
> +EOF
> +	# ---------------------------------
> +
> +	# refrain from new additions of rte_panic() and rte_exit()
> +	# under lib and net
> +	# multiple folders and expressions are separated by spaces
> +	awk -v FOLDERS="lib net" \

Why not looking in drivers directory?

> +		-v EXPRESSIONS="rte_panic\\\( rte_exit\\\(" \
> +		-v RET_ON_FAIL=0 \
> +		"$awk_script" -
> +}
> +
>  number=0
>  quiet=false
>  verbose=false
> @@ -97,6 +185,13 @@ check () { # <patch> <commit> <title>
>  		ret=1
>  	fi
>  
> +	! $verbose || printf '\nChecking forbidden tokens additions/removals:\n'
> +	report=$(cat $tmpinput | check_forbidden_additions)

Another way of writing it without cat:
	check_forbidden_additions <"tmpinput"

In any case, please quote "tmpinput" to prevent from space.

> +	if [ $? -ne 0 ] ; then
> +		ret=1
> +	fi
> +	printf '%s\n' "$report"

You are printing the report, no matter of the result? Why?
Is it because a warning does not return as an error?
There is maybe an improvement required here.

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v12] devtools: alert on new instances of rte_panic and rte_exit
  2018-07-26 20:29               ` Thomas Monjalon
@ 2018-07-26 20:57                 ` Arnon Warshavsky
  2018-07-26 21:00                   ` Thomas Monjalon
  2018-07-26 21:42                 ` Arnon Warshavsky
  2018-07-26 21:56                 ` Thomas Monjalon
  2 siblings, 1 reply; 91+ messages in thread
From: Arnon Warshavsky @ 2018-07-26 20:57 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, Burakov, Anatoly, Lu, Wenzhuo, Doherty, Declan, jerin.jacob,
	Bruce Richardson, Yigit, Ferruh

> > +check_forbidden_additions() { # <file>
>
> This function looks to work with stdin, not a file.
> Better to remove the comment about a <file>.
>

It can actually work with both  but you are right. The comment is not
beneficial there
Will fix with the rest of the list below
...

>
> > +     if [ $? -ne 0 ] ; then
> > +             ret=1
> > +     fi
> > +     printf '%s\n' "$report"
>
> You are printing the report, no matter of the result? Why?
> Is it because a warning does not return as an error?
>
There is maybe an improvement required here.
>

Yes this is indeed the reason.
Sticking to a simple success/fail in the return value with the price of
printing an empty string in the case of no-warning seemed better than
handling multiple (>2) return codes .
Do you have a preferred way here?

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v12] devtools: alert on new instances of rte_panic and rte_exit
  2018-07-26 20:57                 ` Arnon Warshavsky
@ 2018-07-26 21:00                   ` Thomas Monjalon
  0 siblings, 0 replies; 91+ messages in thread
From: Thomas Monjalon @ 2018-07-26 21:00 UTC (permalink / raw)
  To: Arnon Warshavsky
  Cc: dev, Burakov, Anatoly, Lu, Wenzhuo, Doherty, Declan, jerin.jacob,
	Bruce Richardson, Yigit, Ferruh

26/07/2018 22:57, Arnon Warshavsky:
> > > +     if [ $? -ne 0 ] ; then
> > > +             ret=1
> > > +     fi
> > > +     printf '%s\n' "$report"
> >
> > You are printing the report, no matter of the result? Why?
> > Is it because a warning does not return as an error?
> >
> There is maybe an improvement required here.
> >
> 
> Yes this is indeed the reason.
> Sticking to a simple success/fail in the return value with the price of
> printing an empty string in the case of no-warning seemed better than
> handling multiple (>2) return codes .
> Do you have a preferred way here?

My preference is to return an error if there is a warning.
The script itself must return an error code.

Thank you

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v12] devtools: alert on new instances of rte_panic and rte_exit
  2018-07-26 20:29               ` Thomas Monjalon
  2018-07-26 20:57                 ` Arnon Warshavsky
@ 2018-07-26 21:42                 ` Arnon Warshavsky
  2018-07-26 21:56                 ` Thomas Monjalon
  2 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-07-26 21:42 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, Burakov, Anatoly, Lu, Wenzhuo, Doherty, Declan, jerin.jacob,
	Bruce Richardson, Yigit, Ferruh

> > +     read -d '' awk_script << 'EOF'
>
> EOF must be quoted?
>

Missed that one. Yes, the quotes are there to prevent parameter expansion
of the awk variables.
The script breaks without them

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v12] devtools: alert on new instances of rte_panic and rte_exit
  2018-07-26 20:29               ` Thomas Monjalon
  2018-07-26 20:57                 ` Arnon Warshavsky
  2018-07-26 21:42                 ` Arnon Warshavsky
@ 2018-07-26 21:56                 ` Thomas Monjalon
  2018-07-26 22:00                   ` Arnon Warshavsky
  2 siblings, 1 reply; 91+ messages in thread
From: Thomas Monjalon @ 2018-07-26 21:56 UTC (permalink / raw)
  To: Arnon Warshavsky
  Cc: dev, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit

> 16/07/2018 14:44, Arnon Warshavsky:
> > +	! $verbose || printf '\nChecking forbidden tokens additions/removals:\n'
> > +	report=$(cat $tmpinput | check_forbidden_additions)

One more nit: the title says "additions/removals" but the function is
only about additions.

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v12] devtools: alert on new instances of rte_panic and rte_exit
  2018-07-26 21:56                 ` Thomas Monjalon
@ 2018-07-26 22:00                   ` Arnon Warshavsky
  0 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-07-26 22:00 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, Burakov, Anatoly, Lu, Wenzhuo, Doherty, Declan, jerin.jacob,
	Bruce Richardson, Yigit, Ferruh

>
> One more nit: the title says "additions/removals" but the function is
> only about additions.
>
>
> Yup. No removals there..

^ permalink raw reply	[flat|nested] 91+ messages in thread

* [dpdk-dev] [PATCH v13] devtools: alert on new instances of rte_panic and rte_exit
  2018-07-16 12:44             ` [dpdk-dev] [PATCH v12] " Arnon Warshavsky
  2018-07-26 20:29               ` Thomas Monjalon
@ 2018-07-26 22:10               ` Arnon Warshavsky
  2018-07-31 12:11                 ` Thomas Monjalon
  2018-07-31 12:38                 ` Thomas Monjalon
  1 sibling, 2 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-07-26 22:10 UTC (permalink / raw)
  To: thomas, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit
  Cc: dev, arnon

This patch adds a new function that is called
per every checked patch,
and alerts for new instances of rte_panic/rte_exit.
The check excludes comments, and alerts in the case
of a positive balance between additions and removals.

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
Tested-by: Kevin Traynor <ktraynor@redhat.com>
---

v11
- Use Neils tmpfile infrastructure to consume the patches
- Allow different calls to the awk script decide if they want
  to fail the check or just warn
v12
- Restored Tested message
V13
- Multiple formatting comments by Thomas
- Refrain from printing blank success string

 devtools/checkpatches.sh | 92 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index e97a4f2..e8e0bab 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -43,6 +43,91 @@ print_usage () {
 	END_OF_HELP
 }
 
+
+check_forbidden_additions() {
+    # This awk script receives a list of expressions to monitor
+    # and a list of folders to search these expressions in
+    # - No search is done inside comments
+    # - Both additions and removals of the expressions are checked
+    #   A positive balance of additions fails the check
+	read -d '' awk_script << 'EOF'
+	BEGIN {
+		split(FOLDERS,deny_folders," ");
+		split(EXPRESSIONS,deny_expr," ");
+		in_file=0;
+		in_comment=0;
+		count=0;
+		comment_start="/*"
+		comment_end="*/"
+	}
+	# search for add/remove instances in current file
+	# state machine assumes the comments structure is enforced by
+	# checkpatches.pl
+	(in_file) {
+		# comment start
+		if (index($0,comment_start) > 0){
+			in_comment = 1
+		}
+		# non comment code
+		if (in_comment == 0) {
+			for (i in deny_expr) {
+				forbidden_added = "^\+.*" deny_expr[i];
+				forbidden_removed="^-.*" deny_expr[i];
+				current = expressions[deny_expr[i]]
+				if ($0 ~ forbidden_added) {
+					count = count + 1;
+					expressions[deny_expr[i]] = current + 1
+				}
+				if ($0 ~ forbidden_removed) {
+					count = count - 1;
+					expressions[deny_expr[i]] = current - 1
+				}
+			}
+		}
+		# comment end
+		if (index($0,comment_end) > 0)  {
+			in_comment = 0
+		}
+	}
+	# switch to next file , check if the balance of add/remove
+	# of previous filehad new additions
+	($0 ~ "^\+\+\+ b/") {
+		in_file = 0;
+		if (count > 0){
+			exit;
+		}
+		for (i in deny_folders){
+			re = "^\+\+\+ b/" deny_folders[i];
+			if ($0 ~ deny_folders[i]) {
+				in_file = 1
+				last_file = $0
+			}
+		}
+	}
+	END{
+		if (count > 0){
+			print "Warning in " substr(last_file,6) ":"
+			print "are you sure you want to add the following:"
+			for (key in expressions) {
+				if (expressions[key] > 0) {
+					print key
+				}
+			}
+			exit RET_ON_FAIL
+		}
+	}
+EOF
+	# ---------------------------------
+
+	# refrain from new additions of rte_panic() and rte_exit()
+	# under lib and net
+	# multiple folders and expressions are separated by spaces
+	awk -v FOLDERS="lib net drivers" \
+		-v EXPRESSIONS="rte_panic\\\( rte_exit\\\(" \
+		-v RET_ON_FAIL=1 \
+		"$awk_script" -
+}
+
 number=0
 quiet=false
 verbose=false
@@ -97,6 +182,13 @@ check () { # <patch> <commit> <title>
 		ret=1
 	fi
 
+	! $verbose || printf '\nChecking forbidden tokens additions:\n'
+	report=$(check_forbidden_additions <"$tmpinput")
+	if [ $? -ne 0 ] ; then
+		printf '%s\n' "$report"
+		ret=1
+	fi
+
 	clean_tmp_files
 	[ $ret -eq 0 ] && return 0
 
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v13] devtools: alert on new instances of rte_panic and rte_exit
  2018-07-26 22:10               ` [dpdk-dev] [PATCH v13] " Arnon Warshavsky
@ 2018-07-31 12:11                 ` Thomas Monjalon
  2018-07-31 12:32                   ` Arnon Warshavsky
  2018-07-31 12:38                 ` Thomas Monjalon
  1 sibling, 1 reply; 91+ messages in thread
From: Thomas Monjalon @ 2018-07-31 12:11 UTC (permalink / raw)
  To: Arnon Warshavsky
  Cc: dev, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit

27/07/2018 00:10, Arnon Warshavsky:
> +	# refrain from new additions of rte_panic() and rte_exit()
> +	# under lib and net
> +	# multiple folders and expressions are separated by spaces
> +	awk -v FOLDERS="lib net drivers" \

I don't know why net is listed as a root directory here?
I am going to apply the patch without the "net" directory. OK?

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v13] devtools: alert on new instances of rte_panic and rte_exit
  2018-07-31 12:11                 ` Thomas Monjalon
@ 2018-07-31 12:32                   ` Arnon Warshavsky
  0 siblings, 0 replies; 91+ messages in thread
From: Arnon Warshavsky @ 2018-07-31 12:32 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, Burakov, Anatoly, Lu, Wenzhuo, Doherty, Declan, jerin.jacob,
	Bruce Richardson, Yigit, Ferruh

> +     awk -v FOLDERS="lib net drivers" \
>
> I don't know why net is listed as a root directory here?
> I am going to apply the patch without the "net" directory. OK?
>

Yes please. Its not necessarily root rather in any location of the path,
but having added drivers, net is now redundant.

thanks
/Arnon

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v13] devtools: alert on new instances of rte_panic and rte_exit
  2018-07-26 22:10               ` [dpdk-dev] [PATCH v13] " Arnon Warshavsky
  2018-07-31 12:11                 ` Thomas Monjalon
@ 2018-07-31 12:38                 ` Thomas Monjalon
  2018-09-10  6:06                   ` David Marchand
  1 sibling, 1 reply; 91+ messages in thread
From: Thomas Monjalon @ 2018-07-31 12:38 UTC (permalink / raw)
  To: Arnon Warshavsky
  Cc: dev, anatoly.burakov, wenzhuo.lu, declan.doherty, jerin.jacob,
	bruce.richardson, ferruh.yigit

27/07/2018 00:10, Arnon Warshavsky:
> This patch adds a new function that is called
> per every checked patch,
> and alerts for new instances of rte_panic/rte_exit.
> The check excludes comments, and alerts in the case
> of a positive balance between additions and removals.
> 
> Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
> Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
> Tested-by: Kevin Traynor <ktraynor@redhat.com>

Applied, with small adjustments, thanks

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v13] devtools: alert on new instances of rte_panic and rte_exit
  2018-07-31 12:38                 ` Thomas Monjalon
@ 2018-09-10  6:06                   ` David Marchand
  2018-09-10  6:17                     ` Arnon Warshavsky
  0 siblings, 1 reply; 91+ messages in thread
From: David Marchand @ 2018-09-10  6:06 UTC (permalink / raw)
  To: Thomas Monjalon, Arnon Warshavsky
  Cc: dev, Burakov, Anatoly, Lu, Wenzhuo, Declan Doherty, Jerin Jacob,
	Richardson, Bruce, Ferruh Yigit

On Tue, Jul 31, 2018 at 2:38 PM, Thomas Monjalon <thomas@monjalon.net> wrote:
> 27/07/2018 00:10, Arnon Warshavsky:
>> This patch adds a new function that is called
>> per every checked patch,
>> and alerts for new instances of rte_panic/rte_exit.
>> The check excludes comments, and alerts in the case
>> of a positive balance between additions and removals.
>>
>> Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
>> Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
>> Tested-by: Kevin Traynor <ktraynor@redhat.com>
>
> Applied, with small adjustments, thanks

I get some warning when running this on Ubuntu 18.04.

marchand@gribouille:~/git/dpdk$ ./devtools/checkpatches.sh
sanity/0001-mbuf-add-sanity-checks-on-segment-metadata.patch
./devtools/checkpatches.sh: 52: read: Illegal option -d

1/1 valid patch


+ false
+ check_forbidden_additions
+ read -d  awk_script
./devtools/checkpatches.sh: 52: read: Illegal option -d
+ awk -v FOLDERS=lib drivers -v EXPRESSIONS=rte_panic\\( rte_exit\\(
-v RET_ON_FAIL=1  -
+ report=
+ [ 0 -ne 0 ]


-- 
David Marchand

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v13] devtools: alert on new instances of rte_panic and rte_exit
  2018-09-10  6:06                   ` David Marchand
@ 2018-09-10  6:17                     ` Arnon Warshavsky
  2018-09-10  6:24                       ` David Marchand
  0 siblings, 1 reply; 91+ messages in thread
From: Arnon Warshavsky @ 2018-09-10  6:17 UTC (permalink / raw)
  To: David Marchand
  Cc: Thomas Monjalon, dev, Burakov, Anatoly, Lu, Wenzhuo,
	Declan Doherty, Jerin Jacob, Richardson, Bruce, Ferruh Yigit

I get some warning when running this on Ubuntu 18.04.

>
> marchand@gribouille:~/git/dpdk$ ./devtools/checkpatches.sh
> sanity/0001-mbuf-add-sanity-checks-on-segment-metadata.patch
> ./devtools/checkpatches.sh: 52: read: Illegal option -d
>
> Hi,
A patch that fixes that was already sent a few days ago by Andrzej
Ostruszka
http://patches.dpdk.org/patch/44020/

/Arnon

^ permalink raw reply	[flat|nested] 91+ messages in thread

* Re: [dpdk-dev] [PATCH v13] devtools: alert on new instances of rte_panic and rte_exit
  2018-09-10  6:17                     ` Arnon Warshavsky
@ 2018-09-10  6:24                       ` David Marchand
  0 siblings, 0 replies; 91+ messages in thread
From: David Marchand @ 2018-09-10  6:24 UTC (permalink / raw)
  To: Arnon Warshavsky
  Cc: Thomas Monjalon, dev, Burakov, Anatoly, Lu, Wenzhuo,
	Declan Doherty, Jerin Jacob, Richardson, Bruce, Ferruh Yigit

On Mon, Sep 10, 2018 at 8:17 AM, Arnon Warshavsky <arnon@qwilt.com> wrote:
> I get some warning when running this on Ubuntu 18.04.
>>
>>
>> marchand@gribouille:~/git/dpdk$ ./devtools/checkpatches.sh
>> sanity/0001-mbuf-add-sanity-checks-on-segment-metadata.patch
>> ./devtools/checkpatches.sh: 52: read: Illegal option -d
>>
> Hi,
> A patch that fixes that was already sent a few days ago by Andrzej Ostruszka
> http://patches.dpdk.org/patch/44020/

Ok, will test, thanks.

-- 
David Marchand

^ permalink raw reply	[flat|nested] 91+ messages in thread

end of thread, other threads:[~2018-09-10  6:25 UTC | newest]

Thread overview: 91+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-24 22:16 [dpdk-dev] [PATCH v7 00/11] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 01/11] crypto/dpaa: replace rte_panic instances in crypto/dpaa driver Arnon Warshavsky
2018-04-26 16:05   ` Kevin Traynor
2018-04-26 16:16     ` Kevin Traynor
2018-04-26 21:28     ` Arnon Warshavsky
2018-04-27 10:08       ` Kevin Traynor
2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 02/11] bond: replace rte_panic instances in bonding driver Arnon Warshavsky
2018-04-24 22:51   ` Stephen Hemminger
2018-04-25  9:38     ` Arnon Warshavsky
2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 03/11] e1000: replace rte_panic instances in e1000 driver Arnon Warshavsky
2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 04/11] ixgbe: replace rte_panic instances in ixgbe driver Arnon Warshavsky
2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 05/11] eal: replace rte_panic instances in eventdev Arnon Warshavsky
2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 06/11] kni: replace rte_panic instances in kni Arnon Warshavsky
2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 07/11] eal: replace rte_panic instances in hugepage_info Arnon Warshavsky
2018-04-25  8:58   ` Burakov, Anatoly
2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 08/11] eal: replace rte_panic instances in interrupts thread Arnon Warshavsky
2018-04-25  9:14   ` Burakov, Anatoly
2018-04-25  9:37     ` Arnon Warshavsky
2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 09/11] eal: replace rte_panic instances in ethdev Arnon Warshavsky
2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 10/11] eal: replace rte_panic instances in init sequence Arnon Warshavsky
2018-04-25  9:07   ` Burakov, Anatoly
2018-04-25  9:33     ` Arnon Warshavsky
2018-04-24 22:16 ` [dpdk-dev] [PATCH v7 11/11] devtools: prevent new instances of rte_panic and rte_exit Arnon Warshavsky
2018-04-24 22:52   ` Stephen Hemminger
2018-04-24 23:03     ` Thomas Monjalon
2018-04-24 23:15       ` Stephen Hemminger
2018-04-25 13:45 ` [dpdk-dev] [PATCH v8 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 01/10] crypto/dpaa: replace rte_panic instances in crypto/dpaa driver Arnon Warshavsky
2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 02/10] bond: replace rte_panic instances in bonding driver Arnon Warshavsky
2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 03/10] e1000: replace rte_panic instances in e1000 driver Arnon Warshavsky
2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 04/10] ixgbe: replace rte_panic instances in ixgbe driver Arnon Warshavsky
2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 05/10] eal: replace rte_panic instances in eventdev Arnon Warshavsky
2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 06/10] kni: replace rte_panic instances in kni Arnon Warshavsky
2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 07/10] eal: replace rte_panic instances in hugepage_info Arnon Warshavsky
2018-04-25 13:50     ` Burakov, Anatoly
2018-04-25 14:02       ` Arnon Warshavsky
2018-04-25 14:14         ` Burakov, Anatoly
2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 08/10] eal: replace rte_panic instances in ethdev Arnon Warshavsky
2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 09/10] eal: replace rte_panic instances in init sequence Arnon Warshavsky
2018-04-25 13:53     ` Burakov, Anatoly
2018-04-25 13:45   ` [dpdk-dev] [PATCH v8 10/10] devtools: prevent new instances of rte_panic and rte_exit Arnon Warshavsky
2018-04-26  6:20     ` [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances Arnon Warshavsky
2018-04-26  6:20       ` [dpdk-dev] [PATCH v9 01/10] crypto/dpaa: replace rte_panic instances in crypto/dpaa driver Arnon Warshavsky
2018-04-26  6:20       ` [dpdk-dev] [PATCH v9 02/10] bond: replace rte_panic instances in bonding driver Arnon Warshavsky
2018-04-26 16:06         ` Kevin Traynor
2018-04-26 21:06           ` Arnon Warshavsky
2018-04-26 21:26             ` Thomas Monjalon
2018-04-26  6:20       ` [dpdk-dev] [PATCH v9 03/10] e1000: replace rte_panic instances in e1000 driver Arnon Warshavsky
2018-04-26  6:20       ` [dpdk-dev] [PATCH v9 04/10] ixgbe: replace rte_panic instances in ixgbe driver Arnon Warshavsky
2018-04-26  6:20       ` [dpdk-dev] [PATCH v9 05/10] eal: replace rte_panic instances in eventdev Arnon Warshavsky
2018-04-26  6:21       ` [dpdk-dev] [PATCH v9 06/10] kni: replace rte_panic instances in kni Arnon Warshavsky
2018-04-26  6:21       ` [dpdk-dev] [PATCH v9 07/10] eal: replace rte_panic instances in hugepage_info Arnon Warshavsky
2018-04-26  6:21       ` [dpdk-dev] [PATCH v9 08/10] eal: replace rte_panic instances in ethdev Arnon Warshavsky
2018-04-26 16:07         ` Kevin Traynor
2018-04-26 21:38           ` Arnon Warshavsky
2018-04-26  6:21       ` [dpdk-dev] [PATCH v9 09/10] eal: replace rte_panic instances in init sequence Arnon Warshavsky
2018-04-26 16:07         ` Kevin Traynor
2018-04-26 22:08           ` Arnon Warshavsky
2018-04-26 22:27             ` Arnon Warshavsky
2018-04-27  9:56             ` Kevin Traynor
2018-04-26  6:21       ` [dpdk-dev] [PATCH v9 10/10] devtools: prevent new instances of rte_panic and rte_exit Arnon Warshavsky
2018-04-26 16:08         ` Kevin Traynor
2018-04-26 21:57           ` Arnon Warshavsky
2018-04-27 10:02             ` Kevin Traynor
2018-04-29  6:23               ` Arnon Warshavsky
2018-04-30  6:45         ` [dpdk-dev] [PATCH v10] devtools: alert on " Arnon Warshavsky
2018-05-04 16:42           ` Kevin Traynor
2018-05-27 19:47           ` Thomas Monjalon
2018-05-27 20:34             ` Arnon Warshavsky
2018-07-15 23:15               ` Thomas Monjalon
2018-07-16 11:37           ` [dpdk-dev] [PATCH v11] " Arnon Warshavsky
2018-07-16 12:44             ` [dpdk-dev] [PATCH v12] " Arnon Warshavsky
2018-07-26 20:29               ` Thomas Monjalon
2018-07-26 20:57                 ` Arnon Warshavsky
2018-07-26 21:00                   ` Thomas Monjalon
2018-07-26 21:42                 ` Arnon Warshavsky
2018-07-26 21:56                 ` Thomas Monjalon
2018-07-26 22:00                   ` Arnon Warshavsky
2018-07-26 22:10               ` [dpdk-dev] [PATCH v13] " Arnon Warshavsky
2018-07-31 12:11                 ` Thomas Monjalon
2018-07-31 12:32                   ` Arnon Warshavsky
2018-07-31 12:38                 ` Thomas Monjalon
2018-09-10  6:06                   ` David Marchand
2018-09-10  6:17                     ` Arnon Warshavsky
2018-09-10  6:24                       ` David Marchand
2018-04-27 14:22       ` [dpdk-dev] [PATCH v9 00/10] eal: replace calls to rte_panic and refrain from new instances Thomas Monjalon
2018-04-27 16:31         ` Arnon Warshavsky
2018-04-27 16:40           ` Thomas Monjalon
2018-04-27 17:16             ` Arnon Warshavsky
2018-04-27 14:30       ` Thomas Monjalon
2018-04-25 15:59   ` [dpdk-dev] [PATCH v8 " Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).