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 9DE26EE7FF4 for ; Mon, 11 Sep 2023 15:02:00 +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:In-Reply-To:References: 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=JhSFC2nFzEpTmvvOj1QmAA4mBW3SlAZu0SkzpPCCUAc=; b=ejyJjrkKwBsqfj unmLNCZOPe0mT+l498DWXLt7nQGmA0wvaG+u2A9tQSzrC4aFJXMat6lRNUbzUO+U7Vc2l8xROIo6b OlSbB5aTVKOGWe7adIVhMFxe2vlXd8/tz/Mcuzf+xQSyh1M6YWAA+qMknpcdU6L1yUb8AWulYUDRN SZBDtriMMZttFS0zsLJhdSCsVw0ZoZf7lrWcI8i3k6OAH3v8VVBvFLDm13XNlPK+N+3QaxN2fAZvq ahvh8BfXKtxVSA61ddyXG250J22FhivjPaAC0iMuy2sJyu7hS571GOcn1UYF/UalY3cnQ+N1Bz8mp PfiUEzwDc8TFfyIQyCHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qfiPk-000njY-0f; Mon, 11 Sep 2023 15:01:24 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qfiPf-000ngl-0u for linux-arm-kernel@lists.infradead.org; Mon, 11 Sep 2023 15:01:22 +0000 Received: from kwepemm600007.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RkqYr5q77ztQSJ; Mon, 11 Sep 2023 22:57:04 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by kwepemm600007.china.huawei.com (7.193.23.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Mon, 11 Sep 2023 23:01:08 +0800 Received: from lhrpeml500005.china.huawei.com ([7.191.163.240]) by lhrpeml500005.china.huawei.com ([7.191.163.240]) with mapi id 15.01.2507.031; Mon, 11 Sep 2023 16:01:06 +0100 From: Shameerali Kolothum Thodi To: Marc Zyngier , "kvmarm@lists.linux.dev" , "linux-arm-kernel@lists.infradead.org" , "kvm@vger.kernel.org" CC: James Morse , Suzuki K Poulose , Oliver Upton , yuzenghui , Xu Zhao Subject: RE: [PATCH 0/5] KVM: arm64: Accelerate lookup of vcpus by MPIDR values Thread-Topic: [PATCH 0/5] KVM: arm64: Accelerate lookup of vcpus by MPIDR values Thread-Index: AQHZ4XN765G1jppQP0y0NbhsgeOcJrAVu9Iw Date: Mon, 11 Sep 2023 15:01:06 +0000 Message-ID: References: <20230907100931.1186690-1-maz@kernel.org> In-Reply-To: <20230907100931.1186690-1-maz@kernel.org> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.227.178] MIME-Version: 1.0 X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230911_080119_816434_26AA7C4C X-CRM114-Status: GOOD ( 19.21 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org > -----Original Message----- > From: Marc Zyngier [mailto:maz@kernel.org] > Sent: 07 September 2023 11:09 > To: kvmarm@lists.linux.dev; linux-arm-kernel@lists.infradead.org; > kvm@vger.kernel.org > Cc: James Morse ; Suzuki K Poulose > ; Oliver Upton ; > yuzenghui ; Xu Zhao > Subject: [PATCH 0/5] KVM: arm64: Accelerate lookup of vcpus by MPIDR > values > > Xu Zhao recently reported[1] that sending SGIs on large VMs was slower > than expected, specially if targeting vcpus that have a high vcpu > index. They root-caused it to the way we walk the vcpu xarray in the > search of the correct MPIDR, one vcpu at a time, which is of course > grossly inefficient. > > The solution they proposed was, unfortunately, less than ideal, but I > was "nerd snipped" into doing something about it. > > The main idea is to build a small hash table of MPIDR to vcpu > mappings, using the fact that most of the time, the MPIDR values only > use a small number of significant bits and that we can easily compute > a compact index from it. Once we have that, accelerating vcpu lookup > becomes pretty cheap, and we can in turn make SGIs great again. > > It must be noted that since the MPIDR values are controlled by > userspace, it isn't always possible to allocate the hash table > (userspace could build a 32 vcpu VM and allocate one bit of affinity > to each of them, making all the bits significant). We thus always have > an iterative fallback -- if it hurts, don't do that. > > Performance wise, this is very significant: using the KUT micro-bench > test with the following patch (always IPI-ing the last vcpu of the VM) > and running it with large number of vcpus shows a large improvement > (from 3832ns to 2593ns for a 64 vcpu VM, a 32% reduction, measured on > an Ampere Altra). I expect that IPI-happy workloads could benefit from > this. Hi Marc, Tested on a HiSilicon D06 test board using KUT micro-bench(+ the changes) with a 64 vCPU VM. From an avg. of 5 runs, observed around ~54% improvement for IPI (from 5309ns to 2413ns). FWIW, Tested-by: Shameer Kolothum Thanks, Shameer _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel