Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2168384rdb; Tue, 20 Feb 2024 21:44:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUF9c6hrPcQXK2wYyp3UyXkgNOY23FieqWtKfFXRWuB/ri52bO7ZN0ujZT78PMUD6+DEfEX2qxNxAugJZCIH8GT2zW8eODqXKp+BkERSA== X-Google-Smtp-Source: AGHT+IHWkiwthZJxAHfBcyyDtycwXlXG2JNQAmoJU79INCIBaYQpwzkzXwp4dq1LLeTKR1aOERvE X-Received: by 2002:a17:906:2b88:b0:a3e:34b2:a2fc with SMTP id m8-20020a1709062b8800b00a3e34b2a2fcmr6364813ejg.1.1708494262763; Tue, 20 Feb 2024 21:44:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708494262; cv=pass; d=google.com; s=arc-20160816; b=TqFJr4X4xR1PFlx303DGmihMFSBwZ6v04HqHJhiKbAw6Vl2yLkR2+LCDDbVdH0AJpX lEx+Ht24/4uHSxjQB+qxzny29JkAqERmAnZYWdK11TVR7VHYFhCV44+cy/VRLaMYTJjA jAvYs1+v4topUGlWr2HRzTbwlK07eFtM8mEc33O0DbWmX7h/Pb+CCVYuT8Omq/41D/1c hvVSq0syzrlnO6uFgtsoCykNhht5W/cZ2iFL9snVAX0mM23Xs7M2L6v1JJMGD0hvZ2t+ o+8M+4VZkZim+Eb5zHjpsLv17klKGy7H8WenHq4BFGPjjtimYsR837rig3pAmpoxcFcA 2xgQ== 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=mj321azO2g3V6z75I7i/wkEQoxgT4KRGdjlI33lsjxQ=; fh=kCIhDCwfhVa+1moYcBlLNuY7yX/BfELZCoRk1wSf3jY=; b=R8j0Ml4+FE2Ae2y4/zpbhynmqoIhErqLm98dfo/VxMKKd+8XgCYsf58u1YNBEpwTbV vsFCoj160BaMhASHxXnoS8UlVBU0febdNuFfxXrA21LWbq0XVJC8ymeB3+sKGopAgpo9 tvi5jdGG9e7QwF0HdgT1jJ/mdRTo7PVlwbsxUo3rSL8JOPZTXqHiPNcVZj1/8ltPmf+2 t14Ykh/m5gY7DiiE4qoj/q3BoRLHcKidF+MUMb7nazzMEYUJJAHOvs79PDZdaONQzMAv RUa9ZP+AEz7FtE2pL83BWDEysa2zUUfJKrvLUgFd7ZyJDFAnx2d/Y4A8Zj1cmbZgw7dN 1kyA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=mbz+iDp+; 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-74100-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74100-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id he41-20020a1709073da900b00a3f161d3bd9si936654ejc.497.2024.02.20.21.44.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 21:44:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74100-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=mbz+iDp+; 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-74100-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74100-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 7DFF71F24F16 for ; Wed, 21 Feb 2024 05:44:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D07803B295; Wed, 21 Feb 2024 05:43:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="mbz+iDp+" Received: from out-188.mta0.migadu.com (out-188.mta0.migadu.com [91.218.175.188]) (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 309B13A8E5 for ; Wed, 21 Feb 2024 05:43:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708494205; cv=none; b=IeOEdz1BPKJNez76JfVC+kfLZSRE0tsnhM6fdepxHP2EG5k7T9XlfHMKr13iorHrLTzNvK8gWTPf0jqJBX/YCqjuPFEulUgnZNoVz2K96vVuzBltiAWb1WH5GxUu0CyBxh6yDQSAwVu53eD0/q9CTdxsNpoZ8cbhJ4GHfPedfjo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708494205; c=relaxed/simple; bh=PdEyg5rDXT1t31oqeD150AOaybowNPAh6qErSbtdqXs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u2eIgXgj0pew8GYGXYsi+0DSSjpSK83x/ZFm9tH3GAnt0TSbqtTd0C3YVKRBXoRWVk3cMpV6TcgFIba+mj+AbI9z5CiWouuvvQAUi/COdU+8bis85RA1SIGYF2bHM9ahvdBcerkI1+dPS2ZYZ874bqHBp2i/quz7nvKDso8Vj0Y= 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=mbz+iDp+; arc=none smtp.client-ip=91.218.175.188 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=1708494202; 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=mj321azO2g3V6z75I7i/wkEQoxgT4KRGdjlI33lsjxQ=; b=mbz+iDp+sw32XYqQJv3DxB3aud7oUieMyg8J1rhMwXBs5ROt8iTNNC8UxSHnazQzP+3+B0 twdyKRXR7PasSyIRSD+4uYe2Gx9jg4AdcRBXUONHgEXY4DGuz5EnLw/Za+daWMM7sKgN9V KaOcci7KlpsTEBdUrUkbceIT/gbzOPE= 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, Eric Auger , Oliver Upton Subject: [PATCH v4 02/10] KVM: arm64: vgic: Use xarray to find LPI in vgic_get_lpi() Date: Wed, 21 Feb 2024 05:42:45 +0000 Message-ID: <20240221054253.3848076-3-oliver.upton@linux.dev> In-Reply-To: <20240221054253.3848076-1-oliver.upton@linux.dev> References: <20240221054253.3848076-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 92e4d2fea365..7d17dbc8f5dc 100644 --- a/arch/arm64/kvm/vgic/vgic.c +++ b/arch/arm64/kvm/vgic/vgic.c @@ -55,8 +55,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) { @@ -66,20 +67,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.44.0.rc0.258.g7320e95886-goog