From patchwork Tue Apr 18 21:47:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13216167 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2757BC6FD18 for ; Tue, 18 Apr 2023 21:48:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=zdgKvqN7IWVUFl7SiKAVCaW2FUYINBC9fkQww0L8TBk=; b=pksiGyxsdeTQyw T89Gtu73eqvIuiKPReCCDKVczF7nFfTh4dGsULJj9KkWU8boUkswIqh2yvvujRqVfSzrv0Kq/92JQ Uv15qZvavqn5ILFkX5f8bk3Vvs2Cv0c7yS7JVpOuRcm1aYKva0EpWshdD3Mi/RBavDI/rPcC0D3dg VswqzPnx2rIQTY6jBGKuGefHFi2v+QcJb1V6oIGyDfGDstWz5BIJw+dToj8m9MHvbDdBSa0e6gALI Nc3TIKYr+g0CfoUQz1ZXAZlUifkSA85aj9G52Q6sM9rf4+FXQQ/qKoNfgm7u7kVSieA1b7OseGabs EyCOE8PqGb+WI46kgCCg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1potB6-003R3z-0P; Tue, 18 Apr 2023 21:47:56 +0000 Received: from smtp-15.smtpout.orange.fr ([80.12.242.15] helo=smtp.smtpout.orange.fr) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1potB2-003R3S-0W for linux-arm-kernel@lists.infradead.org; Tue, 18 Apr 2023 21:47:54 +0000 Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id otAtpDm3iuZFDotAtp5a56; Tue, 18 Apr 2023 23:47:48 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=orange.fr; s=t20230301; t=1681854468; bh=cZSjVGZIUlYLIpCjOhOc0/Sg4X8Jz8GjKGH9/AcwNB8=; h=From:To:Cc:Subject:Date; b=Q6sEsKrhFoWuQ2stk0aG1FI8wza6+Ha+g2auGJtsu7dzre1BbLJ1BwVUEsdiO3oy8 hkFnkBWD81hqEJSpcCf/Y3FELHW2dvuqNhnVLBXIJhGCPv1tNlPHMLFh/4Oq7n5oDE 9Qou5ArgKmLeqQEbtYU4G2HEZLKNBL2GWvX8TjEQeUkcpHgiHOzRVj5ldEWdQUMjM6 yBVUKNq/3KNbqsbG2n0sayi81o6SuZ+XjpaYKr4yiyrUgA5sFgS3ZogzycHVDT2TpO MSqgqgujgmvJ5yGgz9f4CS6HMJRxRg2z6gtQvBnEkLiOfyjiQdFItvFhgOs+U4O/18 iF95AxOOP6wgA== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 18 Apr 2023 23:47:48 +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 1/2] KVM: arm64: Slightly optimize flush_context() Date: Tue, 18 Apr 2023 23:47:37 +0200 Message-Id: <97bf2743f3a302b3066aced02218b9da60690dd3.1681854412.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230418_144752_636625_343BC04B X-CRM114-Status: UNSURE ( 9.82 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org bitmap_zero() is faster than bitmap_clear(), so use it to save a few cycles. Signed-off-by: Christophe JAILLET --- arch/arm64/kvm/vmid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kvm/vmid.c b/arch/arm64/kvm/vmid.c index 08978d0672e7..bbf0677cfefa 100644 --- a/arch/arm64/kvm/vmid.c +++ b/arch/arm64/kvm/vmid.c @@ -47,7 +47,7 @@ static void flush_context(void) int cpu; u64 vmid; - bitmap_clear(vmid_map, 0, NUM_USER_VMIDS); + bitmap_zero(vmid_map, NUM_USER_VMIDS); for_each_possible_cpu(cpu) { vmid = atomic64_xchg_relaxed(&per_cpu(active_vmids, cpu), 0); 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: 13216168 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 688A8C77B75 for ; Tue, 18 Apr 2023 21:48:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pvM+zir7d3KEiWZDHPyudY/hfMP36f26XuGxPJh7C2E=; b=GN4Wv9zo6Py/q5 w/xOOzpaxBEvE7Cj1EgvIiwmt9zmaot3xwpJst0TJxzPaJqL2JisAYf+PD65+CdzbSDHm58xrJr93 pgPI/ZMgZvKy0j0bSZGe1O4bUaOJ0Ps1RL34cAN6yk9xZ9ILgIg6Z4AXoiALgJZIUezg3H3tuw4Ne xQwhNfrUcERYgamOmEqlovIqrTDy9qhFEWA4/v+cxpOwyxDRmREzquV3LwRTjuvJaMX7GH9/2k7yY DzlZka/WBBX0GTrbILNDdFPSbW1Ws+LF+/dtb0r1wu3MgtZ8OwcEM8t7pcoEE/j0Dm4T/aqkgyFon s33wRKVAgdi5h8/L1PFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1potBB-003R4k-0b; Tue, 18 Apr 2023 21:48:01 +0000 Received: from smtp-15.smtpout.orange.fr ([80.12.242.15] helo=smtp.smtpout.orange.fr) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1potB7-003R45-3D for linux-arm-kernel@lists.infradead.org; Tue, 18 Apr 2023 21:47:59 +0000 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230418_144758_170034_10FCB9C6 X-CRM114-Status: UNSURE ( 9.54 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 --- 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); }