Received: by 2002:ac0:de83:0:0:0:0:0 with SMTP id b3csp826278imk; Sun, 3 Jul 2022 09:48:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s3enWTrL8cFUpKXSPbJt00WNc2nKAuTGr03lSMY1/cajjwAS9Pjh/H+lOR1NzSPU4LhAgk X-Received: by 2002:a17:90a:4484:b0:1ef:68ea:483 with SMTP id t4-20020a17090a448400b001ef68ea0483mr11400442pjg.57.1656866888508; Sun, 03 Jul 2022 09:48:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656866888; cv=none; d=google.com; s=arc-20160816; b=Hu++s032s+G7GlEtJLgqQqqXUXas+EO4aNemgHgvU5R0xToUwKaTADWr0IBzP78Eb4 kYB2bj2qP/LJcuqztUMK66aZ691RvFCzYgZ6ZL3dQncOpytbJRdN11huinfLrPiZQ/Rl TCS9BNG13BbdMaRv3/ZWoOXFSSJOKVB1a4xiAGi/CTWkNZvFX9ViDPEkc2r5GScSGibW T8zDaJ2AQCCzy7ccUAh+FmVi86I6TFu8NOm3Hgf7pjL2Gaq9lAAS043uUiw9Zb2+mavW ZdP8dwFZkvGWvgbylT13XQUU4HBtEX6vt4SH0pWpWDpSM2EpyLgFXva5Bd41gV6qRYMl GhjQ== 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 :message-id:date:subject:cc:to:from; bh=3ckG0PgfVpAXAfP+Kvj59WP6Z9Unn70x1qU0bR1fPsU=; b=CEyHA4sPiKso/qdOP3EMXv4G1IGKv+85xzdwRzjzEYMe7/3qP8woofB9Kx1lxG3SMN f91uwGC9TxSTpp8GKFPB/r212eZ9g+9vg39uJX9EvQIWaph7VcZWHbYYli9e3tFNnGVd vPcqwguM+Z1jCP7ShJxDKMzmo5F/CK36hJ01qSbJLprm/YUHQCkQtXfCHtkZd8wqAQ+p 82HjaMQ6SX/pdSJyB6fxJwvh22AJ9siqNMkm03axlqLrq3YmdOgncTc31vRw9liTDpR0 2xNWSoom3sp9LcOLKFIGinXHcfRjuTUUx4Dhs70D7M3daSd1Ua5AWXHJNpfkIh9T74Jv nYIA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z12-20020a63e10c000000b00403fbc9167csi35558916pgh.305.2022.07.03.09.47.57; Sun, 03 Jul 2022 09:48:08 -0700 (PDT) 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 S232761AbiGCQFw (ORCPT + 99 others); Sun, 3 Jul 2022 12:05:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232625AbiGCQFv (ORCPT ); Sun, 3 Jul 2022 12:05:51 -0400 Received: from smtp.smtpout.orange.fr (smtp06.smtpout.orange.fr [80.12.242.128]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CB63558E for ; Sun, 3 Jul 2022 09:05:47 -0700 (PDT) Received: from pop-os.home ([90.11.190.129]) by smtp.orange.fr with ESMTPA id 826ToL9zNWo1m826TovmZ7; Sun, 03 Jul 2022 18:05:46 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sun, 03 Jul 2022 18:05:46 +0200 X-ME-IP: 90.11.190.129 From: Christophe JAILLET To: Jens Axboe Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-block@vger.kernel.org Subject: [PATCH] block: null_blk: Use the bitmap API to allocate bitmaps Date: Sun, 3 Jul 2022 18:05:43 +0200 Message-Id: <7c4d3116ba843fc4a8ae557dd6176352a6cd0985.1656864320.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Use bitmap_zalloc()/bitmap_free() instead of hand-writing them. It is less verbose and it improves the semantic. Signed-off-by: Christophe JAILLET --- drivers/block/null_blk/main.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index d695ea29efa6..f76fedf64449 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -1656,7 +1656,7 @@ static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx, static void cleanup_queue(struct nullb_queue *nq) { - kfree(nq->tag_map); + bitmap_free(nq->tag_map); kfree(nq->cmds); } @@ -1783,14 +1783,13 @@ static const struct block_device_operations null_rq_ops = { static int setup_commands(struct nullb_queue *nq) { struct nullb_cmd *cmd; - int i, tag_size; + int i; nq->cmds = kcalloc(nq->queue_depth, sizeof(*cmd), GFP_KERNEL); if (!nq->cmds) return -ENOMEM; - tag_size = ALIGN(nq->queue_depth, BITS_PER_LONG) / BITS_PER_LONG; - nq->tag_map = kcalloc(tag_size, sizeof(unsigned long), GFP_KERNEL); + nq->tag_map = bitmap_zalloc(nq->queue_depth, GFP_KERNEL); if (!nq->tag_map) { kfree(nq->cmds); return -ENOMEM; -- 2.34.1