From patchwork Thu May 6 16:52:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 12242779 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFBD6C433B4 for ; Thu, 6 May 2021 16:56:48 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1ECCA6109E for ; Thu, 6 May 2021 16:56:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1ECCA6109E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=cM7XBkx8dA0+kx+gFfaQ2Ts3kOiQ13AZQU4zF8Qwm5I=; b=DfSPFKcQ7dG5b1U+ITPMDl8s+o 6V10uTn0gU4f4OyYAFAoCvVa8xEejMMI75oUCqY6/W5DTKJKU3hSampkOQjkwCGhhRETvQ5/b0FMF 5nTIneoW4x+1WnmdSAAhYjCa5FvsAs681teeMjq7dKCTTQR12Md3CPu0rFDy37m1uhjpVg2GpR09C 6PNIOrhb7QlrYNaKh9ydFrQLGcmQLnMElnMD2U/wC+I2otrls2MPd5T2/rE1T4e1tEacl24+BMv2k HmXdE/Mft94/hx6eyj1sXlaQRi9N6ZYjXeaGjXZVPgUlMxKPcHc4xflB5RDS2+2E7BVPKKZ3jpc1N 25xqheIQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lehH8-004s07-3d; Thu, 06 May 2021 16:54:58 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lehGv-004ryS-B8 for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 16:54:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:MIME-Version:Message-ID: Date:Subject:CC:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:In-Reply-To:References; bh=8LBshyB6VXPV5N199sp9Ox3+Ji2uMQYOfaZQ2ILb4uY=; b=E+LbDDNFNZM7seENt5UTY56nkD qwjHC/GEbVJ2m7iGEhh8jJOlsUFu6WyfNCyCkNUlcV6gOKQCXBKcHGIzLKD3SMqDiAfrXp3ImK1l6 UVgRKHVpIZHaB3Lj9gqwXn7VE7pGZU/MJdx/O76j88LAkzIhzKU8CagZUfznAusExFKVw1tpVbrg9 mh39WvYAZvZqOd1Dknqyn0BwEcLTH8YV3Zh51E1NYEqW12ZvqMU5DBkBMDhSkvHCIl9FSVwHZcpUu NOVJ0/TkX9xwGOXlMfzmlw1+X1bMiH/ThyI2TF6bODPF9s02nYmACJdh1NuLGc6GUKDW519HjResc KcJK2/7A==; Received: from szxga04-in.huawei.com ([45.249.212.190]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lehGs-006EV8-FO for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 16:54:44 +0000 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FbfjV3ckdzqSVg; Fri, 7 May 2021 00:51:10 +0800 (CST) Received: from A2006125610.china.huawei.com (10.47.85.115) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.498.0; Fri, 7 May 2021 00:54:16 +0800 From: Shameer Kolothum To: , , CC: , , , , , , , Subject: [RFC PATCH 0/3] kvm/arm: New VMID allocator based on asid(2nd approach) Date: Thu, 6 May 2021 17:52:29 +0100 Message-ID: <20210506165232.1969-1-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.47.85.115] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210506_095442_708212_3F853F62 X-CRM114-Status: GOOD ( 14.50 ) 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 This is based on a suggestion from Will [0] to try out the asid based kvm vmid solution as a separate VMID allocator instead of the shared lib approach attempted in v4[1]. The idea is to compare both the approaches and see whether the shared lib solution with callbacks make sense or not. Though we are not yet using the pinned vmids yet, patch #2 has code for pinned vmid support. This is just to help the comparison. Test Setup/Results ---------------- The measurement was made with maxcpus set to 8 and with the number of VMID limited to 4-bit. The test involves running concurrently 40 guests with 2 vCPUs. Each guest will then execute hackbench 5 times before exiting. The performance difference between the current algo and the new one are(avg. of 10 runs): - 1.9% less entry/exit from the guest - 0.5% faster This is more or less comparable to v4 numbers. For the complete series, please see, https://github.com/hisilicon/kernel-dev/tree/private-v5.12-rc7-vmid-2nd-rfc and for the shared asid lib v4 solution, https://github.com/hisilicon/kernel-dev/tree/private-v5.12-rc7-asid-v4 As you can see there are of course code duplication with this approach but may be this one is more easy to maintain considering the complexity involved. Please take a look and let me know your feedback. Thanks, Shameer [0] https://lore.kernel.org/lkml/20210422160846.GB2214@willie-the-truck/ [1] https://lore.kernel.org/lkml/20210414112312.13704-1-shameerali.kolothum.thodi@huawei.com/ Julien Grall (2): arch/arm64: Introduce a capability to tell whether 16-bit VMID is available kvm/arm: Align the VMID allocation with the arm64 ASID one Shameer Kolothum (1): kvm/arm: Introduce a new vmid allocator for KVM arch/arm64/include/asm/cpucaps.h | 3 +- arch/arm64/include/asm/kvm_asm.h | 4 +- arch/arm64/include/asm/kvm_host.h | 11 +- arch/arm64/include/asm/kvm_mmu.h | 7 +- arch/arm64/kernel/cpufeature.c | 9 + arch/arm64/kvm/Makefile | 2 +- arch/arm64/kvm/arm.c | 115 ++++-------- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 6 +- arch/arm64/kvm/hyp/nvhe/tlb.c | 10 +- arch/arm64/kvm/hyp/vhe/tlb.c | 10 +- arch/arm64/kvm/mmu.c | 1 - arch/arm64/kvm/vmid.c | 285 +++++++++++++++++++++++++++++ 12 files changed, 354 insertions(+), 109 deletions(-) create mode 100644 arch/arm64/kvm/vmid.c