Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2937191rdb; Tue, 13 Feb 2024 01:35:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IHgJZElt9nhQ5HT+FHudgeCx+mEzY09b7Zx56hsKQxuU1dPpqwDpd46F1gXaUFMnMUlpOa/ X-Received: by 2002:aa7:8381:0:b0:6e0:9e95:b3f8 with SMTP id u1-20020aa78381000000b006e09e95b3f8mr8165284pfm.9.1707816914541; Tue, 13 Feb 2024 01:35:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707816914; cv=pass; d=google.com; s=arc-20160816; b=iYxPev4FZEBEqlEgWWYPK1VnaYqpXbKgvE/T63w6hpMErwsMym1IkKyFid7Y9oVPBA 4rh1jNe6Z2VSo+1n1xDAnds/vC0MqDNXpcyaGQDqXwoiiAO9akvpNly+241tFa94raDF 0MnG3YzVYSSbyVi7XBxBaOm3ns8GtVxLz8/jhA8TwReU+hOyourZnfrNFg3MHBinHeMl lzI/Tm20ZVuveXhVfO8P9TnloKa8rdZfd7TgiH+YJOSaermzlrPaLWP63gTJA9wopbTy 9mKGd4e/Pawis3mNucCD1DlYjmRcyGw+ZVYXh1+hz7nVXrF7tMvuRojwXmnjVTvCRd24 VfSg== 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=MN4YT9WjubbgV9vwymCrG2zbA0P41iVcrtZBfJr5OD0=; fh=2aw/g8KalaFojXrxRfLK+Yqo8nNpUcf6nWa6H+OkUEU=; b=V2fR3ltsbhDD2jGfhn3BtOu1fbJnBU4Ag2fP/OTbxMUa9Z3oQuintfmACmV7egokjv 1K2eSP+V+H58MS76SOfXSA8oCFlRdmQdtHHy5REWQYXOIKjuEfMLzBSRfxuadwD4+8VJ vRGVQymrGvd6fooVsB9g+ISLzFo7TRIWPQclZ3ZyZ66aH2gkFi1mPzukDGqnGiehgFLk ZiyO+9ZokrDxwCLmys1BLjs7e/n4s2GKEhYJFzg4cojiF+oHq59n1oLD9153DyEGsPaO f3FJLQ9AnrtYIJEFHRw1oGg3PIMcnyG7f5arihhVVidSbQrT4OQSfPuvgI6HNpOHUCoy deJg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=C7HSnkXR; 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-63208-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63208-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; AJvYcCU+3ekP7jbxuT4rZc0Plya9vjZcFrTAcIcQp2i5A/Q5kDjY5TW3uuB+2zpXHyCdppnAW6WDlbwZF7SRamUxYKvz9jBzGJSuJiWNWuStng== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t24-20020a63b258000000b005cdfd4aa8b3si1691547pgo.193.2024.02.13.01.35.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:35:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63208-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=C7HSnkXR; 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-63208-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63208-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 3CDAC2863BD for ; Tue, 13 Feb 2024 09:34:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9CD162BB0E; Tue, 13 Feb 2024 09:33:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="C7HSnkXR" Received: from out-183.mta1.migadu.com (out-183.mta1.migadu.com [95.215.58.183]) (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 1DC85225D7 for ; Tue, 13 Feb 2024 09:33:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.183 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707816803; cv=none; b=kTneMpRHw8jja/y4W4rZeaSVY0nF5qk1miMMwi4sPsE4XQOJTrMEpN4vRh05mPJ+dalxPxbFfFV+qrnw0DoaZVrVl8WRICw0LsVwrr6RcXWui3XxKA0GMs3HypR0vLQ2bLZyVDr9WrQMW5PkXdrV5EcBJ7scxQR9yPIIaIOX6SE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707816803; c=relaxed/simple; bh=4brcHvDAVkgAUVv+EhHLpJGf3bgOIUhxLJMTpEy7pkA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q8sLUztp2/o2s22TI83H0hxi8J0aoF2kOsJhiiqjdVYJOdK97c/2MnKqAr9GtbDYMvNp2kVZws/wW1h/vMMThu3v5jKEPIRKlnSf2Hkpu/guB1OBrYSZ9NZ+phi6xb6DXiMTCaFJ8t0KiEKAc7vv1Zq58IoLx5rTVAJP9JgGV0g= 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=C7HSnkXR; arc=none smtp.client-ip=95.215.58.183 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=1707816798; 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=MN4YT9WjubbgV9vwymCrG2zbA0P41iVcrtZBfJr5OD0=; b=C7HSnkXROz1+UoFZtjeg4W2NSgOZRroDA00Cdsa98sNQuumqq4yrXfLeNfcXS5vMpujcKT OmC+dNgbyNxY5y311yrx0WTver+2ok75zp+yixGCV9iajwZaZBpvbGmw7RTG9c6dzlLqgO 71HwURum7tLyeuMsoVyAtjOEU1Opz+Y= 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 03/23] KVM: arm64: vgic: Use xarray to find LPI in vgic_get_lpi() Date: Tue, 13 Feb 2024 09:32:40 +0000 Message-ID: <20240213093250.3960069-4-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 Iterating over the LPI linked-list is less than ideal when the desired index is already known. Use the INTID to index the LPI xarray instead. Signed-off-by: Oliver Upton --- arch/arm64/kvm/vgic/vgic.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/arch/arm64/kvm/vgic/vgic.c b/arch/arm64/kvm/vgic/vgic.c index c126014f8395..d90c42ff051d 100644 --- a/arch/arm64/kvm/vgic/vgic.c +++ b/arch/arm64/kvm/vgic/vgic.c @@ -54,8 +54,9 @@ struct vgic_global kvm_vgic_global_state __ro_after_init = { */ /* - * Iterate over the VM's list of mapped LPIs to find the one with a - * matching interrupt ID and return a reference to the IRQ structure. + * Index the VM's xarray of mapped LPIs and return a reference to the IRQ + * structure. The caller is expected to call vgic_put_irq() later once it's + * finished with the IRQ. */ static struct vgic_irq *vgic_get_lpi(struct kvm *kvm, u32 intid) { @@ -65,20 +66,10 @@ static struct vgic_irq *vgic_get_lpi(struct kvm *kvm, u32 intid) raw_spin_lock_irqsave(&dist->lpi_list_lock, flags); - list_for_each_entry(irq, &dist->lpi_list_head, lpi_list) { - if (irq->intid != intid) - continue; - - /* - * This increases the refcount, the caller is expected to - * call vgic_put_irq() later once it's finished with the IRQ. - */ + irq = xa_load(&dist->lpi_xa, intid); + if (irq) vgic_get_irq_kref(irq); - goto out_unlock; - } - irq = NULL; -out_unlock: raw_spin_unlock_irqrestore(&dist->lpi_list_lock, flags); return irq; -- 2.43.0.687.g38aa6559b0-goog