From patchwork Tue Apr 18 21:47:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 85103 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3165579vqo; Tue, 18 Apr 2023 15:28:25 -0700 (PDT) X-Google-Smtp-Source: AKy350ZaDeN/AEeGRqXY0z3u1jJ0usFm+hH5BQMdkkVS+VtGjyaPIJFy+bL9B85+QLlnXgN2KSLS X-Received: by 2002:a17:90b:1b47:b0:23b:bf03:397e with SMTP id nv7-20020a17090b1b4700b0023bbf03397emr1015341pjb.24.1681856905182; Tue, 18 Apr 2023 15:28:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681856905; cv=none; d=google.com; s=arc-20160816; b=ZT84R5Hy0Nt4GTWPIWNRex7sdAtLLdiiygIoWLMdJsGXPoY8nCLe1E1Xfmx2aktWZV J+yuLxYACb6v/OnWWepjRR5SjRQYhXAzpwMFBXwrRcqgkCqy2g0EkvbtfDApwKJs5/B2 8Ke34S1MHqycg3h5xbfJFIYL2tHudQNQd2233bz31ajMbfYG08N3Ta1fz7wD5NmGeaA/ Le/Wzr+Z3BwUw1qYhlkaW2vsMolS52Z9kqxoCbRttJn4M7uefROZWzzg4jx4JxuWFKLC 7i3vyv6p1U1nHeFLa2UbjHhICk/8rCFp4qoRK9wKU+rUGKod1Pke2kJHOZS50v6eYHxy jiLg== 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 :dkim-signature; bh=5nFJR0h70GQR0Ko+nO0rkf5eZC65EX0faGidYQRY60g=; b=J6lgSjo/HzY44HufQIkeEbs//lvGJyXkcsW8CTWCOSJ3bSy9sKcCT+ewgL8yp/XVkl XxuTAOY4SivG3xzO0sBuMWkqlzdHSTpgvvqteWryIY0oH+P3gyEtrLW2wVgkVoQcJRhw hCAD5apj09PiGH08wLTuqjBbosRcrkuyCmH+VJont490yCRscX9yrout3OGFln4LybMp 5KUL4y1GzAFkv9OCaiBondkrIt3GjtaxdAP3+MZHinUAKhIBG3oFum04RP6lNsvQik3+ r+Glk98o4+HriRed8SZmx7/iGrMunxZuQAWNVVl/vpVaXeNM7Myzhb4SwP+Cp/n+S+fB M2mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@orange.fr header.s=t20230301 header.b=SGJD6kpd; 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 l10-20020a17090a408a00b00246f485f95csi123632pjg.132.2023.04.18.15.28.11; Tue, 18 Apr 2023 15:28:25 -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; dkim=pass header.i=@orange.fr header.s=t20230301 header.b=SGJD6kpd; 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 S233100AbjDRVsR (ORCPT + 99 others); Tue, 18 Apr 2023 17:48:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233098AbjDRVsN (ORCPT ); Tue, 18 Apr 2023 17:48:13 -0400 Received: from smtp.smtpout.orange.fr (smtp-16.smtpout.orange.fr [80.12.242.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D20959EFB for ; Tue, 18 Apr 2023 14:47:58 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id otAtpDm3iuZFDotB6p5a64; Tue, 18 Apr 2023 23:47:56 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=orange.fr; s=t20230301; t=1681854476; bh=5nFJR0h70GQR0Ko+nO0rkf5eZC65EX0faGidYQRY60g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SGJD6kpdcFG3siGXwXatSPSLgp8ejiM/DpsU0DRCShAFXF9p75I4D6Aaz2ihl6++H E6lzkMtgp0OsHmvBfHFDxDGsb9mZaKAYhQ+CnA7R+FHXsOSQrZoVLpabWLWqOgra31 fSKjYs7qP7X1P8ulYsxPOdohKYUAr6CEei+GuDPN1+Jk87Yhp5ox7fGRGhW48aESB2 UnCkTxU9mT9eiAN9Vb9HftEWxgU51GMkuYxnCME4YJveOcX1bOcaHKHrtlbR0ft7wt D7sQPGwr0/6w0a0knZazPO3JTDTjVLj8Bbvb7dwabaHPxa1LuGY+EMyrHfOj/YWGvU Sg/Yrjj49e+8Q== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 18 Apr 2023 23:47:56 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Subject: [PATCH 2/2] KVM: arm64: Use the bitmap API to allocate bitmaps Date: Tue, 18 Apr 2023 23:47:38 +0200 Message-Id: <3c5043731db4d3635383e9326bc7e98e25de3288.1681854412.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <97bf2743f3a302b3066aced02218b9da60690dd3.1681854412.git.christophe.jaillet@wanadoo.fr> References: <97bf2743f3a302b3066aced02218b9da60690dd3.1681854412.git.christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1763554785712779301?= X-GMAIL-MSGID: =?utf-8?q?1763554785712779301?= Use bitmap_zalloc()/bitmap_free() instead of hand-writing them. It is less verbose and it improves the semantic. Signed-off-by: Christophe JAILLET --- arch/arm64/kvm/vmid.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kvm/vmid.c b/arch/arm64/kvm/vmid.c index bbf0677cfefa..7fe8ba1a2851 100644 --- a/arch/arm64/kvm/vmid.c +++ b/arch/arm64/kvm/vmid.c @@ -182,8 +182,7 @@ int __init kvm_arm_vmid_alloc_init(void) */ WARN_ON(NUM_USER_VMIDS - 1 <= num_possible_cpus()); atomic64_set(&vmid_generation, VMID_FIRST_VERSION); - vmid_map = kcalloc(BITS_TO_LONGS(NUM_USER_VMIDS), - sizeof(*vmid_map), GFP_KERNEL); + vmid_map = bitmap_zalloc(NUM_USER_VMIDS, GFP_KERNEL); if (!vmid_map) return -ENOMEM; @@ -192,5 +191,5 @@ int __init kvm_arm_vmid_alloc_init(void) void __init kvm_arm_vmid_alloc_free(void) { - kfree(vmid_map); + bitmap_free(vmid_map); }