netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch net-next] lib: objagg: fix handling of object with 0 users when assembling hints
@ 2019-02-14 14:39 Jiri Pirko
  2019-02-14 14:47 ` Ido Schimmel
  2019-02-14 17:42 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Jiri Pirko @ 2019-02-14 14:39 UTC (permalink / raw)
  To: netdev; +Cc: davem, mlxsw

From: Jiri Pirko <jiri@mellanox.com>

It is possible that there might be an originally parent object with 0
direct users that is in hints no longer considered as parent. Then the
weight of this object is 0 and current code ignores him. That's why the
total amount of hint objects might be lower than for the original
objagg and WARN_ON is hit. Fix this be considering 0 weight valid.

Fixes: 9069a3817d82 ("lib: objagg: implement optimization hints assembly and use hints for object creation")
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 lib/objagg.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/objagg.c b/lib/objagg.c
index d552ec9c60ed..576be22e86de 100644
--- a/lib/objagg.c
+++ b/lib/objagg.c
@@ -744,8 +744,6 @@ static unsigned int objagg_tmp_graph_node_weight(struct objagg_tmp_graph *graph,
 	 * that this node can represent with delta.
 	 */
 
-	if (node->crossed_out)
-		return 0;
 	for (j = 0; j < graph->nodes_count; j++) {
 		if (!objagg_tmp_graph_is_edge(graph, index, j))
 			continue;
@@ -759,14 +757,18 @@ static unsigned int objagg_tmp_graph_node_weight(struct objagg_tmp_graph *graph,
 
 static int objagg_tmp_graph_node_max_weight(struct objagg_tmp_graph *graph)
 {
+	struct objagg_tmp_node *node;
 	unsigned int max_weight = 0;
 	unsigned int weight;
 	int max_index = -1;
 	int i;
 
 	for (i = 0; i < graph->nodes_count; i++) {
+		node = &graph->nodes[i];
+		if (node->crossed_out)
+			continue;
 		weight = objagg_tmp_graph_node_weight(graph, i);
-		if (weight > max_weight) {
+		if (weight >= max_weight) {
 			max_weight = weight;
 			max_index = i;
 		}
-- 
2.14.5


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

* Re: [patch net-next] lib: objagg: fix handling of object with 0 users when assembling hints
  2019-02-14 14:39 [patch net-next] lib: objagg: fix handling of object with 0 users when assembling hints Jiri Pirko
@ 2019-02-14 14:47 ` Ido Schimmel
  2019-02-14 17:42 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Ido Schimmel @ 2019-02-14 14:47 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: netdev, davem, mlxsw

On Thu, Feb 14, 2019 at 03:39:07PM +0100, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@mellanox.com>
> 
> It is possible that there might be an originally parent object with 0
> direct users that is in hints no longer considered as parent. Then the
> weight of this object is 0 and current code ignores him. That's why the
> total amount of hint objects might be lower than for the original
> objagg and WARN_ON is hit. Fix this be considering 0 weight valid.
> 
> Fixes: 9069a3817d82 ("lib: objagg: implement optimization hints assembly and use hints for object creation")
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>

Reviewed-by: Ido Schimmel <idosch@mellanox.com>

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

* Re: [patch net-next] lib: objagg: fix handling of object with 0 users when assembling hints
  2019-02-14 14:39 [patch net-next] lib: objagg: fix handling of object with 0 users when assembling hints Jiri Pirko
  2019-02-14 14:47 ` Ido Schimmel
@ 2019-02-14 17:42 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-02-14 17:42 UTC (permalink / raw)
  To: jiri; +Cc: netdev, mlxsw

From: Jiri Pirko <jiri@resnulli.us>
Date: Thu, 14 Feb 2019 15:39:07 +0100

> From: Jiri Pirko <jiri@mellanox.com>
> 
> It is possible that there might be an originally parent object with 0
> direct users that is in hints no longer considered as parent. Then the
> weight of this object is 0 and current code ignores him. That's why the
> total amount of hint objects might be lower than for the original
> objagg and WARN_ON is hit. Fix this be considering 0 weight valid.
> 
> Fixes: 9069a3817d82 ("lib: objagg: implement optimization hints assembly and use hints for object creation")
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>

Applied, thanks Jiri.

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

end of thread, other threads:[~2019-02-14 17:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-14 14:39 [patch net-next] lib: objagg: fix handling of object with 0 users when assembling hints Jiri Pirko
2019-02-14 14:47 ` Ido Schimmel
2019-02-14 17:42 ` David Miller

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