From patchwork Fri Nov 25 12:23:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 25968 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3977959wrr; Fri, 25 Nov 2022 04:29:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf7nulvqTXLwe0LSrNI3dL+1Wj4JFsJCLxGURpO8h37oaPUimyZ3VJ20z8y2qMp6zZShkAUQ X-Received: by 2002:a62:1ad6:0:b0:574:b2f1:2fbc with SMTP id a205-20020a621ad6000000b00574b2f12fbcmr3554463pfa.26.1669379396333; Fri, 25 Nov 2022 04:29:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669379396; cv=none; d=google.com; s=arc-20160816; b=zRmQ/WIjzD0pLgia64nU4BNf48w4ZXepfqXTLZ5QDmaj/B2amC0XAZ5rqDw1/5nA/o RSI/qPpo6E3hTPRofIctMtHH+VOl+L6jeG2PN0e3apHw0nvjmL82c5FmBD71sGZw6z7e QTqpGQT6RFA6k6GIIla5AkrOMuZps/jlugqUpdXN5yZpfsjHtcRK68f8i0npOe70DTQH 93GJV34ZZTFgQwoarpr+Yr1OK17ADkTVdDEZoDZBXASywNl9b1xUWndB+DP5fnThPs+v nSQuM3CM9rtMzCRy57WtbMymXk10m1UYtIB3OLRYs6Iwa4sRIL2XAQT6sjGlbActAxRp toew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Gko7Lae01/IvX1CBHbX5sjbvJwG3PeZJfkdkqz8yjl0=; b=O7BwnDeoIhym/nmxd/ptA6ohcRTe+l/6FONpQCVyMAqsvSPtV4e3NCeKrquoUydscl r1ic8cKzvMCE+wVujkxIDEaJ17HpJ2lSE0VkJv96zlMdfaOK2UyCfHnPoNrLClD73mCM SbebJqAFF7JOWKhpt65H5U1T1jonQihrGWGtGol93RD4Gk/wAFMUu8lGiS/4pbH9bE7A Vw0IS7aQFC+GdjKRV7q2Hgq1yLt6w49mekzulGFhqVdj3UtT+aSs9SlLOjsXDG7COATk lCtduC6am2m7a7DfK6U/vZWB3GyPHsFCwXlumwBk7JeY3/Vfs6QHqhI4g+l2a99U1t1W WIpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i8-20020a17090332c800b00176808b0a3asi2865831plr.441.2022.11.25.04.29.42; Fri, 25 Nov 2022 04:29:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229832AbiKYMYJ (ORCPT + 99 others); Fri, 25 Nov 2022 07:24:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229734AbiKYMYH (ORCPT ); Fri, 25 Nov 2022 07:24:07 -0500 Received: from smtp.smtpout.orange.fr (smtp-14.smtpout.orange.fr [80.12.242.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2617F30F74 for ; Fri, 25 Nov 2022 04:24:07 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id yXkRoPBKkY4XVyXkRoE1zY; Fri, 25 Nov 2022 13:24:05 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 25 Nov 2022 13:24:05 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET To: Sunil Goutham , Linu Cherian , Geetha sowjanya , Jerin Jacob , hariprasad , Subbaraya Sundeep , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , netdev@vger.kernel.org Subject: [PATCH 1/5] octeontx2-af: Fix a potentially spurious error message Date: Fri, 25 Nov 2022 13:23:57 +0100 Message-Id: <5ce01c402f86412dc57884ff0994b63f0c5b3871.1669378798.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750471169848090044?= X-GMAIL-MSGID: =?utf-8?q?1750471169848090044?= When this error message is displayed, we know that the all the bits in the bitmap are set. So, bitmap_weight() will return the number of bits of the bitmap, which is 'table->tot_ids'. It is unlikely that a bit will be cleared between mutex_unlock() and dev_err(), but, in order to simplify the code and avoid this possibility, just take 'table->tot_ids'. Signed-off-by: Christophe JAILLET --- drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c index 594029007f85..5e6c54577a97 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c @@ -490,7 +490,7 @@ static bool rvu_npc_exact_alloc_id(struct rvu *rvu, u32 *seq_id) if (idx == table->tot_ids) { mutex_unlock(&table->lock); dev_err(rvu->dev, "%s: No space in id bitmap (%d)\n", - __func__, bitmap_weight(table->id_bmap, table->tot_ids)); + __func__, table->tot_ids); return false; } From patchwork Fri Nov 25 12:23:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 25969 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3978056wrr; Fri, 25 Nov 2022 04:30:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf4VUOm/z5s2nkDT+y/7Efu+oyfgj+MWeg44mGv5lur6lDVmqO2gw4O0DuQoOE6exQPm+yus X-Received: by 2002:a17:906:a189:b0:7bb:8d9f:bd2f with SMTP id s9-20020a170906a18900b007bb8d9fbd2fmr5369371ejy.578.1669379408120; Fri, 25 Nov 2022 04:30:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669379408; cv=none; d=google.com; s=arc-20160816; b=OJkfjHJlT23+F5COPYb2kAjIKAuJmjoqzJIinoLcJGOrYi2JurKlqFMe8Z9+R9BxGP Sau2lCki7jOa85jxWL35Trb8wLGfcWX9PzOVOBU4SS81uASXH663td84MvPSyc5YUP5M ORtukdyTIizrrXKQ8hNN9DHre+FR+csUKa3edxh9T+qGMk8Fz73XNtf6dgKRWb6jiEgg Nzgu4c9IMdZug0V2qw6Ie48t+5j6bsroEFyrZVe2DRz1mb749M3BrW2FyyCHbalO3CMY 8+7fjGCI08veoZtSDQpenX7ev/2tKG5jCkeZ3H+JUiQSKY72LLX9IiZuN0/Pz79IeZ2T neFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=O+C8TgUqxnjF714FzSsABDCQahLAyubk/1XP5y/0qXE=; b=0vkbEXu3qMX3LMTkczfar1PWk8W/YpLsLxazxfLpmbB0n0MXg5/Eh6E5E/Hrg4Q07V zs4CHjE30Rw8oqwt5mPxavDFkNV25C5Tvy3f3fjHpr8vj5XTwQeYKATT7FzafrSsFcpp mv9wN3i+BhLd0xSLJG7C4I3QkbKr1xDL9L+e/XF/2SmRxheQfz3tEcD3pRNbmdEdq+GX IkVYkWILtkSHl6oAsC1IhP/vGHZg7uQGyxq1Us7Kouc8iHAEV1EuZPTfqAJiaJ8U1tOb OvuvZUQD/2zI9bTbeq46yyhbe8H9hsnjxfrjnMNyXZ1p3tO8/+fg81WvNDxpYRP53Gmy Ho/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hd11-20020a170907968b00b0078e11a20640si3128489ejc.2.2022.11.25.04.29.44; Fri, 25 Nov 2022 04:30:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229469AbiKYMYN (ORCPT + 99 others); Fri, 25 Nov 2022 07:24:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229764AbiKYMYJ (ORCPT ); Fri, 25 Nov 2022 07:24:09 -0500 Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81ED331DD3 for ; Fri, 25 Nov 2022 04:24:08 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id yXkRoPBKkY4XVyXkUoE205; Fri, 25 Nov 2022 13:24:07 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 25 Nov 2022 13:24:07 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET To: Sunil Goutham , Linu Cherian , Geetha sowjanya , Jerin Jacob , hariprasad , Subbaraya Sundeep , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , netdev@vger.kernel.org Subject: [PATCH 2/5] octeontx2-af: Slightly simplify rvu_npc_exact_init() Date: Fri, 25 Nov 2022 13:23:58 +0100 Message-Id: <60ea220ccf3b61963f7d5a97e3df2c76a5feb837.1669378798.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750471182237764580?= X-GMAIL-MSGID: =?utf-8?q?1750471182237764580?= Use kzalloc() instead of kmalloc()/memset(). Signed-off-by: Christophe JAILLET --- drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c index 5e6c54577a97..c584680f2d2b 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c @@ -1870,12 +1870,11 @@ int rvu_npc_exact_init(struct rvu *rvu) /* Set capability to true */ rvu->hw->cap.npc_exact_match_enabled = true; - table = kmalloc(sizeof(*table), GFP_KERNEL); + table = kzalloc(sizeof(*table), GFP_KERNEL); if (!table) return -ENOMEM; dev_dbg(rvu->dev, "%s: Memory allocation for table success\n", __func__); - memset(table, 0, sizeof(*table)); rvu->hw->table = table; /* Read table size, ways and depth */ From patchwork Fri Nov 25 12:23:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 25970 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3978710wrr; Fri, 25 Nov 2022 04:31:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf6KoDVdLdn5slPBRPMv/d8+rPjl0P3GsZuroS6r0wBgImam3i4AUFS5it81U6d24zyV27j2 X-Received: by 2002:a17:906:29cc:b0:78d:a836:1d88 with SMTP id y12-20020a17090629cc00b0078da8361d88mr16553694eje.470.1669379462804; Fri, 25 Nov 2022 04:31:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669379462; cv=none; d=google.com; s=arc-20160816; b=dopt5F+q+rx0tr/le4kBlZCOftm3cU3OPiUlKNV5vjTiFk34BMcCrv67H3VqPRRNTc 58eCxCCGxqixSKNjdMn/zswdYD0jEh+kFKpSQS0LoPbfcn8NYF04B5KwpmxcA5oWtVEO qWS986V5TCxCYWisM3bEYcEMdYTT7AEzXbabLfRvwP3mZcTd0s0ZcLg2dN1e3eTiKw6/ 2gpeuX3/ql76cfdjAzNBTg0LS2FX9Ukg1HJjNSVJ2eElbIyWqPbFh5xfofu5B2qS5gD6 p/3rDnKs2p5EbhUgmJPKcnrxtDfz496L4Y+Lb4BYpYe3CCBUgJatPgcNZGYnrEf53N/z TGcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=7R9mpIXHyBPeGtkxRESt6d6aXPmuP0MG/O2UNaCjUv4=; b=vekiNcCeQ4uRFNBpP5dF/DKHPbZ3pu9fHNT6aXWYJOkN5EJOaaEw/qN7SFNBoCd4EO SEVAEin/KZwuH/WqJ3/rte0CxGaa5q3O+1denUQtDDujFj9bcEQ3NCqfscbfgt2rnKxZ rJnAlHEat+n8SwzWJa2pvztG1TicsbC5OISpj53YJvgzFlAp76QD/bbAE6O31Z2YJPQT rVzJcKM9ptD5KInfe/ne5NEw3k2ImuZ5TR6uZQM1edCtgkmZ6EC3N+EklhKGOJCyz7UD ujlRvJVHpBdy2grgmURpuhm5QKfCbo1fA5TmPTMYxOtGxFsb8t53c2REVCwZ9xf1/2Wm +YnQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd39-20020a17090762a700b0078dce2b1985si3300854ejc.134.2022.11.25.04.30.33; Fri, 25 Nov 2022 04:31:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229572AbiKYMYX (ORCPT + 99 others); Fri, 25 Nov 2022 07:24:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229883AbiKYMYL (ORCPT ); Fri, 25 Nov 2022 07:24:11 -0500 Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30D9F4A071 for ; Fri, 25 Nov 2022 04:24:11 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id yXkRoPBKkY4XVyXkXoE20c; Fri, 25 Nov 2022 13:24:09 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 25 Nov 2022 13:24:09 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET To: Sunil Goutham , Linu Cherian , Geetha sowjanya , Jerin Jacob , hariprasad , Subbaraya Sundeep , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , netdev@vger.kernel.org Subject: [PATCH 3/5] octeontx2-af: Use the bitmap API to allocate bitmaps Date: Fri, 25 Nov 2022 13:23:59 +0100 Message-Id: <24177a9ee7043259448b735263d9cfd6a70e89a4.1669378798.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750471239793056126?= X-GMAIL-MSGID: =?utf-8?q?1750471239793056126?= Use devm_bitmap_zalloc() instead of hand-writing it. This also makes the comment "Allocate bitmap for 32 entry mcam" more explicit because now 32 is really used in the allocation function, instead of an obscure 'sizeof(long)'. Signed-off-by: Christophe JAILLET --- drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c index c584680f2d2b..3f94b620ef5a 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c @@ -1898,15 +1898,15 @@ int rvu_npc_exact_init(struct rvu *rvu) table_size = table->mem_table.depth * table->mem_table.ways; /* Allocate bitmap for 4way 2K table */ - table->mem_table.bmap = devm_kcalloc(rvu->dev, BITS_TO_LONGS(table_size), - sizeof(long), GFP_KERNEL); + table->mem_table.bmap = devm_bitmap_zalloc(rvu->dev, table_size, + GFP_KERNEL); if (!table->mem_table.bmap) return -ENOMEM; dev_dbg(rvu->dev, "%s: Allocated bitmap for 4way 2K entry table\n", __func__); /* Allocate bitmap for 32 entry mcam */ - table->cam_table.bmap = devm_kcalloc(rvu->dev, 1, sizeof(long), GFP_KERNEL); + table->cam_table.bmap = devm_bitmap_zalloc(rvu->dev, 32, GFP_KERNEL); if (!table->cam_table.bmap) return -ENOMEM; From patchwork Fri Nov 25 12:24:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 25971 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3978751wrr; Fri, 25 Nov 2022 04:31:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf51AP1nbCFbG8859ilyY7X2MhaSJBShsvFKO/wqLhyL5Xiq8E4CN3TBtsfgD4vICEZ19hrq X-Received: by 2002:a17:906:1682:b0:78d:6ba1:74dd with SMTP id s2-20020a170906168200b0078d6ba174ddmr32945645ejd.119.1669379465397; Fri, 25 Nov 2022 04:31:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669379465; cv=none; d=google.com; s=arc-20160816; b=e8OxVscn0ccoeF+cIQNon1Hid0viS8sVcCSjSpar87Mx7c75AzAaiuAhXg+zvrgH8Q jAodrTfJwcT1N7e6aVJetpIWclVSbM/U/xbghiN66TDsUlFxyq0FnuuE231Jck4oaMOV lyx4+0r38PMJRsFD3sOUsDwOxnvk1ucPYrdRw3aR0+lNWOIyuQKvfmY3GDODulR8n5tM +9aDkW8/fQSgMVhzh9Yk0YhRN2wljFZJ8z1IBENj0xjsBoPqtx5gGssvohM8K49q+RHX 76prsPpi39NkeG3M6vIeJnviORLeRtDP0nPKaoreA/xud8318qs1ETmy9jaQxmyAM/X3 Ra6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=RlG5JNM/2fHjw2Db+Zc6WfpvLX4HjCE9oPzkR3La0Oc=; b=xzo6/gZ9TGaI13A3bpGXnxqT0Min3PmpCijglF3m60InbHmCKjm90Ek0Ql1qTcE+pV 6utFSdO2gD8453KhMbjRBNV4GWCUWzRJgdZQIhHCTXHOOKwzSHayOYed3TOzqoJzFXnF 0p2I666F/44c1TojUFELzUtjJYENQeI0/k5E52VElR8yQpKDx4bCmh97Vl07ITHFRAs3 odzAZWRu2qjce9x7igcVIuXhBpO/ZxoBcUIZk+T+mcQMSSwsDZ8oUCUQNeph2bIM8V1P y1yBRqpEiX5r9zQ6THsh/KvtfXzU8wC8gfYCOw3bncw4cjfJN6VpHA3eY9vU2UJQ7tNf cUOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dz16-20020a0564021d5000b0046a341e2c1fsi3342886edb.500.2022.11.25.04.30.41; Fri, 25 Nov 2022 04:31:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229972AbiKYMY1 (ORCPT + 99 others); Fri, 25 Nov 2022 07:24:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229891AbiKYMYS (ORCPT ); Fri, 25 Nov 2022 07:24:18 -0500 Received: from smtp.smtpout.orange.fr (smtp-14.smtpout.orange.fr [80.12.242.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D823D4A5BE for ; Fri, 25 Nov 2022 04:24:12 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id yXkRoPBKkY4XVyXkZoE20z; Fri, 25 Nov 2022 13:24:11 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 25 Nov 2022 13:24:11 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET To: Sunil Goutham , Linu Cherian , Geetha sowjanya , Jerin Jacob , hariprasad , Subbaraya Sundeep , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , netdev@vger.kernel.org Subject: [PATCH 4/5] octeontx2-af: Fix the size of memory allocated for the 'id_bmap' bitmap Date: Fri, 25 Nov 2022 13:24:00 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750471242139362785?= X-GMAIL-MSGID: =?utf-8?q?1750471242139362785?= This allocation is really spurious. The size of the bitmap is 'tot_ids' and it is used as such in the driver. So we could expect something like: table->id_bmap = devm_kcalloc(rvu->dev, BITS_TO_LONGS(table->tot_ids), sizeof(long), GFP_KERNEL); However, when the bitmap is allocated, we allocate: BITS_TO_LONGS(table->tot_ids) * table->tot_ids ~= table->tot_ids / 32 * table->tot_ids ~= table->tot_ids^2 / 32 It is proportional to the square of 'table->tot_ids' which seems to potentially be big. Allocate the expected amount of memory, and switch to the bitmap API to have it more straightforward. Signed-off-by: Christophe JAILLET --- This patch is speculative. If I'm right, I'm curious to know if 'able->tot_ids' can really get big (I'm just guessing) , and if yes, how much. --- drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c index 3f94b620ef5a..ae34746341c4 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c @@ -1914,8 +1914,8 @@ int rvu_npc_exact_init(struct rvu *rvu) dev_dbg(rvu->dev, "%s: Allocated bitmap for 32 entry cam\n", __func__); table->tot_ids = (table->mem_table.depth * table->mem_table.ways) + table->cam_table.depth; - table->id_bmap = devm_kcalloc(rvu->dev, BITS_TO_LONGS(table->tot_ids), - table->tot_ids, GFP_KERNEL); + table->id_bmap = devm_bitmap_zalloc(rvu->dev, table->tot_ids, + GFP_KERNEL); if (!table->id_bmap) return -ENOMEM; From patchwork Fri Nov 25 12:24:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 25972 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3978881wrr; Fri, 25 Nov 2022 04:31:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf4BBHlED1i/a1Ut4WaQVkF5h4Up0SloM7iWOi3ffv6nv1EkVCJEiyvKMTmZaSfNa2c8mNoJ X-Received: by 2002:a17:907:9190:b0:78a:52bb:d904 with SMTP id bp16-20020a170907919000b0078a52bbd904mr15334883ejb.630.1669379474112; Fri, 25 Nov 2022 04:31:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669379474; cv=none; d=google.com; s=arc-20160816; b=cgcNdY+j8sR3ThTdi4K/WiRATMyEKFEKkXl8PsdtAeIlNcZ2ewoYEMcOPY8yEG65Qa XNPMyBxtdboYRM7Q2dUQ8B2xmEYaMQbAHMgdWAkTeXZRwFMmBR2n6KqltF/69LQkkfX2 eGW3eZeXlc+kAkk89JKp9eiaxGcWlelCHxKtAUimCu2zFAKE3nPYkJE4o5l8QKzCcTrD V+KZHecrL25p+aj2c53PhZt6hFMrBeWLbPU1iI0gZueFaWCFLQ+R8reXSOTlkCrxdmRB sGtBm4DZzFWUWYhKH9mO0FnoA5zxnHA2RuzYihD6b4VZCDkUbrbvaulexlOFqA4d7nnf VXuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=mWofOACcUsQqmpXGZXWbhxEeO0Y5wvu0jfpPx+iEMDw=; b=nRlWWwVjeT5KDAnk7rRZc0CZoJUbLCeNK90vodZaKzZK98hsNT/TIRwsGiVki7JxyK aCWbfmN4PQ1q5k8H3m05GRG6aPgyrSuegyzjq8DV77v2JgmDlymro02MNVy3BmLw7r/l eSz3J0vyW9MpaKhfQOfCv/7oB5/jmhj/A/3NoukLFk8LxQ4Z40CMnqNK+vpXyF4i2LKu /ScrZL7XlNy18HHbLRWNQ2fkfOGzjJTtJtcnAAsEn0f5cZ6JhwcSyXSaPSS0LrSjCo2Z YW0Ax/OMuhlQ4HwlbBeeKyzc3+KR7WFsVUxuVX4MjmN05Blk+8OFuiI4Bd1MRNfEkhAm 0nRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hr11-20020a1709073f8b00b007ad8140c60asi3656836ejc.492.2022.11.25.04.30.49; Fri, 25 Nov 2022 04:31:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229926AbiKYMYd (ORCPT + 99 others); Fri, 25 Nov 2022 07:24:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229977AbiKYMYT (ORCPT ); Fri, 25 Nov 2022 07:24:19 -0500 Received: from smtp.smtpout.orange.fr (smtp-14.smtpout.orange.fr [80.12.242.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7E004A9C2 for ; Fri, 25 Nov 2022 04:24:14 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id yXkRoPBKkY4XVyXkaoE21L; Fri, 25 Nov 2022 13:24:13 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 25 Nov 2022 13:24:13 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET To: Sunil Goutham , Linu Cherian , Geetha sowjanya , Jerin Jacob , hariprasad , Subbaraya Sundeep , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , netdev@vger.kernel.org Subject: [PATCH 5/5] octeontx2-af: Simplify a size computation in rvu_npc_exact_init() Date: Fri, 25 Nov 2022 13:24:01 +0100 Message-Id: <5230dabe27f48948a9fd0f50a62e2437b65e6a6e.1669378798.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750471251582887402?= X-GMAIL-MSGID: =?utf-8?q?1750471251582887402?= We know that table_size = table->mem_table.depth * table->mem_table.ways, so use it instead, it is less verbose. Signed-off-by: Christophe JAILLET --- drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c index ae34746341c4..00aef8f5ac29 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c @@ -1913,7 +1913,7 @@ int rvu_npc_exact_init(struct rvu *rvu) dev_dbg(rvu->dev, "%s: Allocated bitmap for 32 entry cam\n", __func__); - table->tot_ids = (table->mem_table.depth * table->mem_table.ways) + table->cam_table.depth; + table->tot_ids = table_size + table->cam_table.depth; table->id_bmap = devm_bitmap_zalloc(rvu->dev, table->tot_ids, GFP_KERNEL);