From patchwork Tue Feb 13 09:32:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 200296 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp427002dyb; Tue, 13 Feb 2024 01:43:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFl4ttsobEWgBehXqDeN6kto9UpUicVIvKna+SZbMphAsuWpHqJ5TZCsZmhPWTYRMnX4pWm X-Received: by 2002:a92:d3c1:0:b0:363:cc7d:102c with SMTP id c1-20020a92d3c1000000b00363cc7d102cmr10482028ilh.10.1707817410433; Tue, 13 Feb 2024 01:43:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707817410; cv=pass; d=google.com; s=arc-20160816; b=VWBYGrBBoCtds46M+iD2jFhgoRRJFkvQoMpM3LKZY98b5JObaOlqhGdal5O8C6H+Rr XT9CVfsWycq3AwSAcVwQiNoD92hsC+u0pby3zwK8jp1M5A9gQaQc6TOOgOi7MAeJBijY Vrz+uHg7pIFEnspx/wt4Go5PmEYTl1VeDfy1rlZsBI6yyFTf41bZHB6L782ZyRdWNW0j y2izadPXSs/YTc/Mm7A6YfRA10IuJ253rfeTmQDIQSQ7hKYTNxMA1tQD7dn8mQSK03qV BORmA1e8SH1aRXWxFmOMW3db3gbWz+MbQZI8c96u3lu0+MuPD4yY8i5iu+nKmuFKFERt 2Qkg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=d0pU/1urqxYilVj53Ip1KYtHI35wj+PNtuLJSjy+uYo=; fh=Qu6hlNfzN49lffehpLlumtI2GzgZ0M5+jMg9OoN6y4w=; b=M7faJ3TkXpZtrQ4P2yNqmD8AX4OCPwPTmPsVUqKIFgo2bHCc9zHvD1pyo1EltJicEU 2V2iGj81gDG7Is/NvJkBsMw0IdNlOXDXz9h9LF0GNPyPaw+4VRJHhJuffV6mjf8bCATf 2w4zcxzElk4AAHR3a/23dFtDcTPDhHn5y3/r2chsIzHRZBoQJx8LiQz60bQgOH4vEs4z /4zRDvMIITWWUSNtHNZzxVH57IAqFwXbYF8UNp/t+Q47ODXa+HkmmjCMhghkTyFab4FT YJ4501HOnyxkbrJNROz1Nm+VN7BMqR8iIOBsQvHv9Cc8XIuF+yjoRvKhE01IzK0z77O8 eR4A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=vMfTEbmx; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-63211-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63211-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev X-Forwarded-Encrypted: i=2; AJvYcCWHFs2uXDn8QQ8UWw/jnxh1dleplUL75KsV6u99Lys1nse7BtuRxrj1muDuISNbiMKr5Qxlcmitz2ogfTFzNY7x/XRkgA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id i10-20020a65484a000000b005dc5070efecsi1726265pgs.825.2024.02.13.01.43.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:43:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63211-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=vMfTEbmx; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-63211-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63211-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 1F515B25ECD for ; Tue, 13 Feb 2024 09:36:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E6A4638FB9; Tue, 13 Feb 2024 09:33:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="vMfTEbmx" Received: from out-179.mta1.migadu.com (out-179.mta1.migadu.com [95.215.58.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2CAB62BD00 for ; Tue, 13 Feb 2024 09:33:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707816807; cv=none; b=ax8DMvdfX6WGEJVLqIk0pTHKII6Z1YSQpqONBFMgI4xL6l3dTlVgxIe/k+/ht7wwyf6A3xxnRWMjVB3t9iqRrStbly3NE5ckjzrUww9NEEZHLgI73dBs5/O5thZnjxQ82uQXfxjU1/NSFwmR5Udl5Ftofl7KaG6Wu3NmFLnmWqo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707816807; c=relaxed/simple; bh=x1S98sHSYhxkabprmCbrd2K4IpsVQD88YKDf/wPFgQo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EpSuRjmjLV+rSKzdCJAe1BqmDQX3Ha0fzckhM9rXfdRnPR2ipFN0fulXbD3E2m+LSOpiAtFL7NkTTW6QFkODr/TH/xftfPZ5hrVJEoPGXJk2vm6sd5lwW9DnLXQww+CbgNxUxYVS249YVFM1N3FHdomNkWL2bIzsSlL8pZt929s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=vMfTEbmx; arc=none smtp.client-ip=95.215.58.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1707816803; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d0pU/1urqxYilVj53Ip1KYtHI35wj+PNtuLJSjy+uYo=; b=vMfTEbmx3n8BntxZAxz615n3jMiuLC40HjUl/AUUTd+3ex7zjkcBSO+0xpSIr4MS6fyp6m dsXQMZ5FGNAts1rcmS2qQIZvdQn+8psj5XEPX6TVwyOUjVyx2/eDof6AD+yywnBWA3Gvhd ZtEh0zYClbkXgAGauoANm3irPT7JgbY= From: Oliver Upton To: kvmarm@lists.linux.dev Cc: kvm@vger.kernel.org, Marc Zyngier , James Morse , Suzuki K Poulose , Zenghui Yu , linux-kernel@vger.kernel.org, Oliver Upton Subject: [PATCH v2 06/23] KVM: arm64: vgic: Get rid of the LPI linked-list Date: Tue, 13 Feb 2024 09:32:43 +0000 Message-ID: <20240213093250.3960069-7-oliver.upton@linux.dev> In-Reply-To: <20240213093250.3960069-1-oliver.upton@linux.dev> References: <20240213093250.3960069-1-oliver.upton@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790776348726367631 X-GMAIL-MSGID: 1790776348726367631 All readers of LPI configuration have been transitioned to use the LPI xarray. Get rid of the linked-list altogether. Signed-off-by: Oliver Upton --- arch/arm64/kvm/vgic/vgic-init.c | 1 - arch/arm64/kvm/vgic/vgic-its.c | 8 ++------ arch/arm64/kvm/vgic/vgic.c | 1 - include/kvm/arm_vgic.h | 2 -- 4 files changed, 2 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kvm/vgic/vgic-init.c b/arch/arm64/kvm/vgic/vgic-init.c index 411719053107..e25672d6e846 100644 --- a/arch/arm64/kvm/vgic/vgic-init.c +++ b/arch/arm64/kvm/vgic/vgic-init.c @@ -53,7 +53,6 @@ void kvm_vgic_early_init(struct kvm *kvm) { struct vgic_dist *dist = &kvm->arch.vgic; - INIT_LIST_HEAD(&dist->lpi_list_head); INIT_LIST_HEAD(&dist->lpi_translation_cache); raw_spin_lock_init(&dist->lpi_list_lock); xa_init_flags(&dist->lpi_xa, XA_FLAGS_LOCK_IRQ); diff --git a/arch/arm64/kvm/vgic/vgic-its.c b/arch/arm64/kvm/vgic/vgic-its.c index aefe0794b71c..c68164d6cba0 100644 --- a/arch/arm64/kvm/vgic/vgic-its.c +++ b/arch/arm64/kvm/vgic/vgic-its.c @@ -59,7 +59,6 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid, return ERR_PTR(ret); } - INIT_LIST_HEAD(&irq->lpi_list); INIT_LIST_HEAD(&irq->ap_list); raw_spin_lock_init(&irq->irq_lock); @@ -75,10 +74,8 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid, * There could be a race with another vgic_add_lpi(), so we need to * check that we don't add a second list entry with the same LPI. */ - list_for_each_entry(oldirq, &dist->lpi_list_head, lpi_list) { - if (oldirq->intid != intid) - continue; - + oldirq = xa_load(&dist->lpi_xa, intid); + if (oldirq) { /* Someone was faster with adding this LPI, lets use that. */ kfree(irq); irq = oldirq; @@ -100,7 +97,6 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid, goto out_unlock; } - list_add_tail(&irq->lpi_list, &dist->lpi_list_head); dist->lpi_list_count++; out_unlock: diff --git a/arch/arm64/kvm/vgic/vgic.c b/arch/arm64/kvm/vgic/vgic.c index d90c42ff051d..e58ce68e325c 100644 --- a/arch/arm64/kvm/vgic/vgic.c +++ b/arch/arm64/kvm/vgic/vgic.c @@ -121,7 +121,6 @@ void __vgic_put_lpi_locked(struct kvm *kvm, struct vgic_irq *irq) if (!kref_put(&irq->refcount, vgic_irq_release)) return; - list_del(&irq->lpi_list); xa_erase(&dist->lpi_xa, irq->intid); dist->lpi_list_count--; diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h index 795b35656b54..aeff363e3ba6 100644 --- a/include/kvm/arm_vgic.h +++ b/include/kvm/arm_vgic.h @@ -117,7 +117,6 @@ struct irq_ops { struct vgic_irq { raw_spinlock_t irq_lock; /* Protects the content of the struct */ - struct list_head lpi_list; /* Used to link all LPIs together */ struct list_head ap_list; struct kvm_vcpu *vcpu; /* SGIs and PPIs: The VCPU @@ -277,7 +276,6 @@ struct vgic_dist { /* Protects the lpi_list and the count value below. */ raw_spinlock_t lpi_list_lock; struct xarray lpi_xa; - struct list_head lpi_list_head; int lpi_list_count; /* LPI translation cache */