Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2937942rdb; Tue, 13 Feb 2024 01:37:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXlpHse8yv9ixKw/J7g250QBAQgYX4l/nQCaDDrJoU8rSEF+IR9YmyA1RnITdJgmLm6+wPsnAgmBG01QaAg8lz1SxWermvwZ//4qXKovw== X-Google-Smtp-Source: AGHT+IGGItZTK0KfjLpUyvRMQR/fVbpbC4ZMqpqGQjaBMzWDWB1/sEnyLNIGznPizzbjaZWKkXKY X-Received: by 2002:a17:906:3753:b0:a3d:14ce:5b84 with SMTP id e19-20020a170906375300b00a3d14ce5b84mr372682ejc.7.1707817048025; Tue, 13 Feb 2024 01:37:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707817048; cv=pass; d=google.com; s=arc-20160816; b=zVlXI8R2bNxUAQUBdWefbYPfeGff/Yw5ZR8bFgBiAH9wAI8QqzPMoQDV2/0XtEjrWk NH9FA6lATdRrQXz4tuZbQTH+pBpZzoR93CjZHdWbHDUdSlHk4ppUCcgTT4cnI16bUEL7 cEwt3bqAE1Mq+wRjZ7zuXhlI5SEGuO7TqhNnkjiUtojWXcmqXN8T97hlL3VF6I9zYCwJ 0hMhrbmlzOHKm4gnd80+/Wx64CVgmkNyCQg1zeO5xF1fFkaAjlsioDy1zkz31PMQVmpW iEInjLS6cjONF6KBMcMVzWD+d3fEDeUnqRPO20GsNKIW8sj5Hm3XJuPZ/AvfSPduiAp8 W5og== 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=/NKiyUPOAHZp+4seCuTeFdtHdSqB+Sryj+FB70LZ6SE=; fh=KKaPJOcGFxeDS/OtNP4qbfp1gPJREbPPIKsqop+laBQ=; b=r/wzHUP+Ne45oydejMkNAeUlKngNaZwktxf+gxNQkG0rJx80cMvoHQtMW7gJs2zvzB jOsWtE5yV6PaU0Na0nFy/oWQY6Q+B6I1WHYSGvwtLyM/ed3TFErpNuPgm12uryDVuT+j hp1ZdAIcXLHIQJshVvwEEbg55JlW475CEZMOPJjm5RZ9fhkFMjm6OFeLvOvZmw29HDUw SsACQCB/5Rprhtqq7FE6E9x+mnGyswr8swLALCzpOZOJziNxdF7crBB5bhWUiFFJ1vnX 0E37s+B8Od4f/1FjT+qnL8ILJiCvMUleUnu2oiMYY96EYfAG1qldJ3jZj57Bn1KBiD0c 2Q3A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=m39rFo3b; 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-63216-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63216-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev X-Forwarded-Encrypted: i=2; AJvYcCWX1iUWlhEzibayVHR9hZ6zHUwf+F/nEsxbG0peiA/7K90CaTEMO1DoMSM8BEVxI/Ye+FNS8U3LhgwJSUYyCZi+/tbduruDJF/ZDKaGrw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id y16-20020a170906449000b00a38328246edsi1093831ejo.793.2024.02.13.01.37.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:37:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63216-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=m39rFo3b; 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-63216-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63216-linux.lists.archive=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 am.mirrors.kernel.org (Postfix) with ESMTPS id C441D1F237C5 for ; Tue, 13 Feb 2024 09:37:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3BE812511F; Tue, 13 Feb 2024 09:33:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="m39rFo3b" Received: from out-176.mta1.migadu.com (out-176.mta1.migadu.com [95.215.58.176]) (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 2EA9D487B6 for ; Tue, 13 Feb 2024 09:33:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707816816; cv=none; b=bz854QMqMne67P48FemRx/txDZLmCoLc3rsLD0UM4NEu5Sf3s9S1Y6N3L8hHPLFqRlxRuxR3qq6Chq4mnRXqGq5CXanRENSYQzhP5N8JCugOVexatPMfhaQ0E8Rsg0Zd346xumoSmR/cZG+MonB6p3liI5DgSRhfJAYBbmMvEjM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707816816; c=relaxed/simple; bh=AMfprxM0/ut1EJb/0zCW90BuRmzW+XprxTWpT1Elo/s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=afnPKU/osgFWl03695mo+7B/YxVh9ig/Io4FtlR2ksFxOdKxHJPhrsvnL+vqygBrCK6Druc6xhAmu7VO2zK+kjJw9fpLDuQDucMyRhAFLiqipSyHsVjvBheij9uCs6xGNiz2EHN2ggYKnpoSF6OpJOO5t1tyWxg4xpaE9l/79f8= 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=m39rFo3b; arc=none smtp.client-ip=95.215.58.176 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=1707816812; 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=/NKiyUPOAHZp+4seCuTeFdtHdSqB+Sryj+FB70LZ6SE=; b=m39rFo3bZXhcOOKgVqA1OtqG/2d1pFKH3ESY4PlhbvCQIcBN54j3NLFr67rLVEi8hX3kPX +q0pAZguXIU08yRGInEPzoZMrySX58rpD1cqqK0rjeppMroPaI6tLWSaEP3gEVq7FbS382 U6z1mj8LlFCVXClGb2NJU7VJE0DhZlw= 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 11/23] KVM: arm64: vgic: Don't acquire the lpi_list_lock in vgic_put_irq() Date: Tue, 13 Feb 2024 09:32:48 +0000 Message-ID: <20240213093250.3960069-12-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 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT The LPI xarray's xa_lock is sufficient for synchronizing writers when freeing a given LPI. Furthermore, readers can only take a new reference on an IRQ if it was already nonzero. Stop taking the lpi_list_lock unnecessarily and get rid of __vgic_put_lpi_locked(). Signed-off-by: Oliver Upton --- arch/arm64/kvm/vgic/vgic-its.c | 4 ++-- arch/arm64/kvm/vgic/vgic.c | 21 ++++----------------- arch/arm64/kvm/vgic/vgic.h | 1 - 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/arch/arm64/kvm/vgic/vgic-its.c b/arch/arm64/kvm/vgic/vgic-its.c index 6b9634cec77f..50a9addebeed 100644 --- a/arch/arm64/kvm/vgic/vgic-its.c +++ b/arch/arm64/kvm/vgic/vgic-its.c @@ -650,7 +650,7 @@ static void vgic_its_cache_translation(struct kvm *kvm, struct vgic_its *its, if (cte->irq) { KVM_VM_TRACE_EVENT(kvm, vgic_its_trans_cache_victim, cte->db, cte->devid, cte->eventid, cte->irq->intid); - __vgic_put_lpi_locked(kvm, cte->irq); + vgic_put_irq(kvm, cte->irq); } /* @@ -688,7 +688,7 @@ void vgic_its_invalidate_cache(struct kvm *kvm) if (!cte->irq) break; - __vgic_put_lpi_locked(kvm, cte->irq); + vgic_put_irq(kvm, cte->irq); cte->irq = NULL; } diff --git a/arch/arm64/kvm/vgic/vgic.c b/arch/arm64/kvm/vgic/vgic.c index 2a288d6c0be7..c8208f81fdc8 100644 --- a/arch/arm64/kvm/vgic/vgic.c +++ b/arch/arm64/kvm/vgic/vgic.c @@ -110,13 +110,13 @@ static void vgic_irq_release(struct kref *ref) { } -/* - * Drop the refcount on the LPI. Must be called with lpi_list_lock held. - */ -void __vgic_put_lpi_locked(struct kvm *kvm, struct vgic_irq *irq) +void vgic_put_irq(struct kvm *kvm, struct vgic_irq *irq) { struct vgic_dist *dist = &kvm->arch.vgic; + if (irq->intid < VGIC_MIN_LPI) + return; + if (!kref_put(&irq->refcount, vgic_irq_release)) return; @@ -126,19 +126,6 @@ void __vgic_put_lpi_locked(struct kvm *kvm, struct vgic_irq *irq) kfree_rcu(irq, rcu); } -void vgic_put_irq(struct kvm *kvm, struct vgic_irq *irq) -{ - struct vgic_dist *dist = &kvm->arch.vgic; - unsigned long flags; - - if (irq->intid < VGIC_MIN_LPI) - return; - - raw_spin_lock_irqsave(&dist->lpi_list_lock, flags); - __vgic_put_lpi_locked(kvm, irq); - raw_spin_unlock_irqrestore(&dist->lpi_list_lock, flags); -} - void vgic_flush_pending_lpis(struct kvm_vcpu *vcpu) { struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; diff --git a/arch/arm64/kvm/vgic/vgic.h b/arch/arm64/kvm/vgic/vgic.h index f874b9932c5a..0c2b82de8fa3 100644 --- a/arch/arm64/kvm/vgic/vgic.h +++ b/arch/arm64/kvm/vgic/vgic.h @@ -180,7 +180,6 @@ vgic_get_mmio_region(struct kvm_vcpu *vcpu, struct vgic_io_device *iodev, gpa_t addr, int len); struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu, u32 intid); -void __vgic_put_lpi_locked(struct kvm *kvm, struct vgic_irq *irq); void vgic_put_irq(struct kvm *kvm, struct vgic_irq *irq); bool vgic_get_phys_line_level(struct vgic_irq *irq); void vgic_irq_set_phys_pending(struct vgic_irq *irq, bool pending); -- 2.43.0.687.g38aa6559b0-goog