DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/2] bugfix for sched
@ 2021-04-23 11:01 Min Hu (Connor)
  2021-04-23 11:01 ` [dpdk-dev] [PATCH 1/2] lib/sched: fix return value judgment Min Hu (Connor)
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Min Hu (Connor) @ 2021-04-23 11:01 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, cristian.dumitrescu, jasvinder.singh

This patch set contains two bugfixes for sched.

Huisong Li (2):
  lib/sched: fix return value judgment
  lib/sched: optimize exception handling code

 lib/sched/rte_sched.c | 60 +++++++++++++++++++++++++++------------------------
 1 file changed, 32 insertions(+), 28 deletions(-)

-- 
2.7.4


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

* [dpdk-dev] [PATCH 1/2] lib/sched: fix return value judgment
  2021-04-23 11:01 [dpdk-dev] [PATCH 0/2] bugfix for sched Min Hu (Connor)
@ 2021-04-23 11:01 ` Min Hu (Connor)
  2021-07-13 22:16   ` Cristian Dumitrescu
  2021-04-23 11:01 ` [dpdk-dev] [PATCH 2/2] lib/sched: optimize exception handling code Min Hu (Connor)
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Min Hu (Connor) @ 2021-04-23 11:01 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, cristian.dumitrescu, jasvinder.singh

From: Huisong Li <lihuisong@huawei.com>

This patch fixes return value judgment when allocate memory to store the
subport profile, and releases memory of 'rte_sched_port' if code fails to
apply for this memory.

Fixes: 0ea4c6afcaf1 ("sched: add subport profile table")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 lib/sched/rte_sched.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/sched/rte_sched.c b/lib/sched/rte_sched.c
index cd87e68..df0ab5c 100644
--- a/lib/sched/rte_sched.c
+++ b/lib/sched/rte_sched.c
@@ -961,9 +961,9 @@ rte_sched_port_config(struct rte_sched_port_params *params)
 	/* Allocate memory to store the subport profile */
 	port->subport_profiles  = rte_zmalloc_socket("subport_profile", size2,
 					RTE_CACHE_LINE_SIZE, params->socket);
-	if (port == NULL) {
+	if (port->subport_profiles == NULL) {
 		RTE_LOG(ERR, SCHED, "%s: Memory allocation fails\n", __func__);
-
+		rte_free(port);
 		return NULL;
 	}
 
-- 
2.7.4


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

* [dpdk-dev] [PATCH 2/2] lib/sched: optimize exception handling code
  2021-04-23 11:01 [dpdk-dev] [PATCH 0/2] bugfix for sched Min Hu (Connor)
  2021-04-23 11:01 ` [dpdk-dev] [PATCH 1/2] lib/sched: fix return value judgment Min Hu (Connor)
@ 2021-04-23 11:01 ` Min Hu (Connor)
  2021-07-13 22:20   ` Cristian Dumitrescu
  2021-05-24 12:16 ` [dpdk-dev] [PATCH 0/2] bugfix for sched Min Hu (Connor)
  2021-07-24  8:40 ` Thomas Monjalon
  3 siblings, 1 reply; 7+ messages in thread
From: Min Hu (Connor) @ 2021-04-23 11:01 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, cristian.dumitrescu, jasvinder.singh

From: Huisong Li <lihuisong@huawei.com>

Currently, rte_sched_free_memory() is called multiple times by the
exception handling code in rte_sched_subport_config() and
rte_sched_pipe_config().

This patch optimizes them into a unified outlet to free memory.

Fixes: ac6fcb841b0f ("sched: update subport rate dynamically")
Fixes: 34a90f86657c ("sched: modify pipe functions for config flexibility")
Fixes: ce7c4fd7c2ac ("sched: add pipe config to subport level")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 lib/sched/rte_sched.c | 56 +++++++++++++++++++++++++++------------------------
 1 file changed, 30 insertions(+), 26 deletions(-)

diff --git a/lib/sched/rte_sched.c b/lib/sched/rte_sched.c
index df0ab5c..a858f61 100644
--- a/lib/sched/rte_sched.c
+++ b/lib/sched/rte_sched.c
@@ -1090,6 +1090,7 @@ rte_sched_subport_config(struct rte_sched_port *port,
 	uint32_t n_subport_pipe_queues, i;
 	uint32_t size0, size1, bmp_mem_size;
 	int status;
+	int ret;
 
 	/* Check user parameters */
 	if (port == NULL) {
@@ -1101,17 +1102,16 @@ rte_sched_subport_config(struct rte_sched_port *port,
 	if (subport_id >= port->n_subports_per_port) {
 		RTE_LOG(ERR, SCHED,
 			"%s: Incorrect value for subport id\n", __func__);
-
-		rte_sched_free_memory(port, n_subports);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto out;
 	}
 
 	if (subport_profile_id >= port->n_max_subport_profiles) {
 		RTE_LOG(ERR, SCHED, "%s: "
 			"Number of subport profile exceeds the max limit\n",
 			__func__);
-		rte_sched_free_memory(port, n_subports);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto out;
 	}
 
 	/** Memory is allocated only on first invocation of the api for a
@@ -1127,9 +1127,8 @@ rte_sched_subport_config(struct rte_sched_port *port,
 			RTE_LOG(NOTICE, SCHED,
 				"%s: Port scheduler params check failed (%d)\n",
 				__func__, status);
-
-			rte_sched_free_memory(port, n_subports);
-			return -EINVAL;
+			ret = -EINVAL;
+			goto out;
 		}
 
 		/* Determine the amount of memory to allocate */
@@ -1143,9 +1142,8 @@ rte_sched_subport_config(struct rte_sched_port *port,
 		if (s == NULL) {
 			RTE_LOG(ERR, SCHED,
 				"%s: Memory allocation fails\n", __func__);
-
-			rte_sched_free_memory(port, n_subports);
-			return -ENOMEM;
+			ret = -ENOMEM;
+			goto out;
 		}
 
 		n_subports++;
@@ -1185,12 +1183,11 @@ rte_sched_subport_config(struct rte_sched_port *port,
 				    params->red_params[i][j].min_th,
 				    params->red_params[i][j].max_th,
 				    params->red_params[i][j].maxp_inv) != 0) {
-					rte_sched_free_memory(port, n_subports);
-
 					RTE_LOG(NOTICE, SCHED,
 					"%s: RED configuration init fails\n",
 					__func__);
-					return -EINVAL;
+					ret = -EINVAL;
+					goto out;
 				}
 			}
 		}
@@ -1238,9 +1235,8 @@ rte_sched_subport_config(struct rte_sched_port *port,
 		if (s->bmp == NULL) {
 			RTE_LOG(ERR, SCHED,
 				"%s: Subport bitmap init error\n", __func__);
-
-			rte_sched_free_memory(port, n_subports);
-			return -EINVAL;
+			ret = -EINVAL;
+			goto out;
 		}
 
 		for (i = 0; i < RTE_SCHED_PORT_N_GRINDERS; i++)
@@ -1285,6 +1281,11 @@ rte_sched_subport_config(struct rte_sched_port *port,
 	rte_sched_port_log_subport_profile(port, subport_profile_id);
 
 	return 0;
+
+out:
+	rte_sched_free_memory(port, n_subports);
+
+	return ret;
 }
 
 int
@@ -1299,6 +1300,7 @@ rte_sched_pipe_config(struct rte_sched_port *port,
 	struct rte_sched_pipe_profile *params;
 	uint32_t n_subports = subport_id + 1;
 	uint32_t deactivate, profile, i;
+	int ret;
 
 	/* Check user parameters */
 	profile = (uint32_t) pipe_profile;
@@ -1313,26 +1315,23 @@ rte_sched_pipe_config(struct rte_sched_port *port,
 	if (subport_id >= port->n_subports_per_port) {
 		RTE_LOG(ERR, SCHED,
 			"%s: Incorrect value for parameter subport id\n", __func__);
-
-		rte_sched_free_memory(port, n_subports);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto out;
 	}
 
 	s = port->subports[subport_id];
 	if (pipe_id >= s->n_pipes_per_subport_enabled) {
 		RTE_LOG(ERR, SCHED,
 			"%s: Incorrect value for parameter pipe id\n", __func__);
-
-		rte_sched_free_memory(port, n_subports);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto out;
 	}
 
 	if (!deactivate && profile >= s->n_pipe_profiles) {
 		RTE_LOG(ERR, SCHED,
 			"%s: Incorrect value for parameter pipe profile\n", __func__);
-
-		rte_sched_free_memory(port, n_subports);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto out;
 	}
 
 	sp = port->subport_profiles + s->profile;
@@ -1406,6 +1405,11 @@ rte_sched_pipe_config(struct rte_sched_port *port,
 	}
 
 	return 0;
+
+out:
+	rte_sched_free_memory(port, n_subports);
+
+	return ret;
 }
 
 int
-- 
2.7.4


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

* Re: [dpdk-dev] [PATCH 0/2] bugfix for sched
  2021-04-23 11:01 [dpdk-dev] [PATCH 0/2] bugfix for sched Min Hu (Connor)
  2021-04-23 11:01 ` [dpdk-dev] [PATCH 1/2] lib/sched: fix return value judgment Min Hu (Connor)
  2021-04-23 11:01 ` [dpdk-dev] [PATCH 2/2] lib/sched: optimize exception handling code Min Hu (Connor)
@ 2021-05-24 12:16 ` Min Hu (Connor)
  2021-07-24  8:40 ` Thomas Monjalon
  3 siblings, 0 replies; 7+ messages in thread
From: Min Hu (Connor) @ 2021-05-24 12:16 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, cristian.dumitrescu, jasvinder.singh

Hi, all,
	any comments for this set?


在 2021/4/23 19:01, Min Hu (Connor) 写道:
> This patch set contains two bugfixes for sched.
> 
> Huisong Li (2):
>    lib/sched: fix return value judgment
>    lib/sched: optimize exception handling code
> 
>   lib/sched/rte_sched.c | 60 +++++++++++++++++++++++++++------------------------
>   1 file changed, 32 insertions(+), 28 deletions(-)
> 

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

* Re: [dpdk-dev] [PATCH 1/2] lib/sched: fix return value judgment
  2021-04-23 11:01 ` [dpdk-dev] [PATCH 1/2] lib/sched: fix return value judgment Min Hu (Connor)
@ 2021-07-13 22:16   ` Cristian Dumitrescu
  0 siblings, 0 replies; 7+ messages in thread
From: Cristian Dumitrescu @ 2021-07-13 22:16 UTC (permalink / raw)
  To: humin29; +Cc: cristian.dumitrescu, dev, ferruh.yigit, jasvinder.singh

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>


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

* Re: [dpdk-dev] [PATCH 2/2] lib/sched: optimize exception handling code
  2021-04-23 11:01 ` [dpdk-dev] [PATCH 2/2] lib/sched: optimize exception handling code Min Hu (Connor)
@ 2021-07-13 22:20   ` Cristian Dumitrescu
  0 siblings, 0 replies; 7+ messages in thread
From: Cristian Dumitrescu @ 2021-07-13 22:20 UTC (permalink / raw)
  To: humin29; +Cc: cristian.dumitrescu, dev, ferruh.yigit, jasvinder.singh

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>


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

* Re: [dpdk-dev] [PATCH 0/2] bugfix for sched
  2021-04-23 11:01 [dpdk-dev] [PATCH 0/2] bugfix for sched Min Hu (Connor)
                   ` (2 preceding siblings ...)
  2021-05-24 12:16 ` [dpdk-dev] [PATCH 0/2] bugfix for sched Min Hu (Connor)
@ 2021-07-24  8:40 ` Thomas Monjalon
  3 siblings, 0 replies; 7+ messages in thread
From: Thomas Monjalon @ 2021-07-24  8:40 UTC (permalink / raw)
  To: Min Hu (Connor); +Cc: dev, ferruh.yigit, cristian.dumitrescu, jasvinder.singh

23/04/2021 13:01, Min Hu (Connor):
> This patch set contains two bugfixes for sched.
> 
> Huisong Li (2):
>   lib/sched: fix return value judgment
>   lib/sched: optimize exception handling code

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Applied, thanks.



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

end of thread, other threads:[~2021-07-24  8:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-23 11:01 [dpdk-dev] [PATCH 0/2] bugfix for sched Min Hu (Connor)
2021-04-23 11:01 ` [dpdk-dev] [PATCH 1/2] lib/sched: fix return value judgment Min Hu (Connor)
2021-07-13 22:16   ` Cristian Dumitrescu
2021-04-23 11:01 ` [dpdk-dev] [PATCH 2/2] lib/sched: optimize exception handling code Min Hu (Connor)
2021-07-13 22:20   ` Cristian Dumitrescu
2021-05-24 12:16 ` [dpdk-dev] [PATCH 0/2] bugfix for sched Min Hu (Connor)
2021-07-24  8:40 ` Thomas Monjalon

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).