Skip to contentSkip to conversation

lib: objagg: fix handling of object with 0 users when assembling hints

PATCH Applied Jiri Pirko 3 participants 3 messages Feb 14, 2019

Subsystems (4)
lore
Share & tools
lore

Jiri Pirko

author maintainer
#0 lore raw

PATCH 1/1 lib: objagg: fix handling of object with 0 users when assembling hints

From: Jiri Pirko <[email protected]>

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")
---
 lib/objagg.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
lib/objagg.c +5 -3
index d552ec9c60ed..576be22e86de 100644
@@ -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;
 		}
Signature · 1 line
2.14.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Jiri Pirko

From: Jiri Pirko <[email protected]>

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")
maintainer Applied
#2 lore raw
In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>
Date: Thu, 14 Feb 2019 15:39:07 +0100

Quoted 10 lines

From: Jiri Pirko <[email protected]>

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

Applied, thanks Jiri.