Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2FB3C43381 for ; Thu, 14 Feb 2019 14:39:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7F474222D9 for ; Thu, 14 Feb 2019 14:39:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="cM/hVglu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392396AbfBNOjM (ORCPT ); Thu, 14 Feb 2019 09:39:12 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:38364 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732362AbfBNOjM (ORCPT ); Thu, 14 Feb 2019 09:39:12 -0500 Received: by mail-wm1-f67.google.com with SMTP id v26so6335478wmh.3 for ; Thu, 14 Feb 2019 06:39:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=KTYP6GK1Csv2BgyCy9qQ4cKywdrtpglyDGCK7rOyQG8=; b=cM/hVgluG3tSD0AEdigHaoa898ZFZxX7uWM99ajRLHsDim2BM1ihEOK0SXGFITB1Xq 22xyKUTRWCi9eHPXUMxpM5NIWj+pUTgqCeeJDFUMXML0JFzYwNeY8no2MrzGFrbMpeyK +lw5iFTN0jjfzLjmWCCbdDjhIPU84qIzcClGrEXO0yZ8AHD2o8YpsssAxUBQTiD532Y3 PdbtTJWbmZUHaucGqnBuic/LVJGekSIawIRhgKyDk2tpSpjkfUuBX/x0Ax/+/8b/Xbsj OJCj1qapHXBj3Qk/Rt532d8VgdS1tbcnWbLm0UiCj2vg8Te3CdPUsiv5kE5uUcBB8/Pd ga2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=KTYP6GK1Csv2BgyCy9qQ4cKywdrtpglyDGCK7rOyQG8=; b=Uof1wMEvIKTBFrXNVKyjhvOuFAbG4I5TcEgqsjTjNHJ6DLbJDUNSbkq38avvrijxXo LVd5QPzyuM52Auk4ub3poQ1B/KDjfssNEslrMDqVKcSTWOsiGY5qfz2OHLZ6D8eIlswC x+PHChbdGkMX4LTHtsWbk1ZDShKiWlvlt4qGu9d+k8q7pfiaIE9iXy3czMbYRKMp43Lt aBZPCzP89MqqDB2v7k+7dwk5xns7J++5zff/NDwr/IY5GzelTP92ju4IYLQuhxMZlS4+ Lcp469sc7K+NxfZQ3WRjZ5iEKwmJrBj2+02qSvELM/DxtzwgIVw/sWs9yAFz8j5n6sqO IMyA== X-Gm-Message-State: AHQUAuZ+RvabWsWFzb+u//R/4NHVWvy2l99HwjZDyWybLVQABD5zJWSu aovTQVI+ZPh+3HSZxZIMiYyb5T/rvCY= X-Google-Smtp-Source: AHgI3IZ3k2vJefQBNQ1Iy/+YqTe8FtciMBU97ztR+M9cnC9NGc2hHAJSXZ6zkxQPzxO52k66h/+nRg== X-Received: by 2002:a1c:e187:: with SMTP id y129mr3042285wmg.53.1550155149602; Thu, 14 Feb 2019 06:39:09 -0800 (PST) Received: from localhost (amit2.rozhled.cz. [83.167.225.161]) by smtp.gmail.com with ESMTPSA id h13sm3032955wrs.42.2019.02.14.06.39.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Feb 2019 06:39:09 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, mlxsw@mellanox.com Subject: [patch net-next] lib: objagg: fix handling of object with 0 users when assembling hints Date: Thu, 14 Feb 2019 15:39:07 +0100 Message-Id: <20190214143907.3275-1-jiri@resnulli.us> X-Mailer: git-send-email 2.14.5 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jiri Pirko 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 --- 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