From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAD95C433FE for ; Thu, 25 Nov 2021 20:12:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357033AbhKYUPQ (ORCPT ); Thu, 25 Nov 2021 15:15:16 -0500 Received: from smtp02.smtpout.orange.fr ([80.12.242.124]:55056 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357111AbhKYUNP (ORCPT ); Thu, 25 Nov 2021 15:13:15 -0500 Received: from [192.168.1.18] ([86.243.171.122]) by smtp.orange.fr with ESMTPA id qL4EmblRQqYovqL4EmK9cw; Thu, 25 Nov 2021 21:10:03 +0100 X-ME-Helo: [192.168.1.18] X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Thu, 25 Nov 2021 21:10:03 +0100 X-ME-IP: 86.243.171.122 Subject: Re: [PATCH] RDMA/mlx4: Use bitmap_alloc() when applicable To: Joe Perches , yishaih@nvidia.com, selvin.xavier@broadcom.com, dledford@redhat.com, jgg@ziepe.ca Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: <4c93b4e02f5d784ddfd3efd4af9e673b9117d641.1637869328.git.christophe.jaillet@wanadoo.fr> From: Christophe JAILLET Message-ID: <142324ab-7696-e43d-2368-a18abebe7b09@wanadoo.fr> Date: Thu, 25 Nov 2021 21:10:02 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 25/11/2021 à 20:58, Joe Perches a écrit : > On Thu, 2021-11-25 at 20:42 +0100, Christophe JAILLET wrote: >> Use 'bitmap_alloc()' to simplify code, improve the semantic and avoid some >> open-coded arithmetic in allocator arguments. >> >> Also change the corresponding 'kfree()' into 'bitmap_free()' to keep >> consistency. > > Thanks. > >> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c > [] >> @@ -2784,10 +2784,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev) >> if (err) >> goto err_counter; >> >> - ibdev->ib_uc_qpns_bitmap = >> - kmalloc_array(BITS_TO_LONGS(ibdev->steer_qpn_count), >> - sizeof(long), >> - GFP_KERNEL); >> + ibdev->ib_uc_qpns_bitmap = bitmap_alloc(ibdev->steer_qpn_count, >> + GFP_KERNEL); > > I wonder if it'd be simpler/smaller to change this to bitmap_zalloc and > remove the bitmap_zero in the if below. > I asked myself the same question. It is easy to see that the bitmap is either cleared or set. So this is fine enough for me. Let see if a maintainer has a preference on it. CJ