Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1870224rdb; Tue, 20 Feb 2024 09:16:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXQRN7h/siPlPxsnZmnAhERrlG1HRx5HLeXoLgQBFD3fCKj6+h0ECFsU/igeCR2/cpdytOBGwbWZCy+CUGL8xAoyUXmfqXRkSNj1S6RoA== X-Google-Smtp-Source: AGHT+IFyWqNca6o6tOxGN5rOPSIzTXRR30AtqGPBfoJZlLI9FERjsNkfgeHCcTNAqJKWzaemdKH1 X-Received: by 2002:a05:6358:8aa:b0:176:5c73:393b with SMTP id m42-20020a05635808aa00b001765c73393bmr18305269rwj.18.1708449400153; Tue, 20 Feb 2024 09:16:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708449400; cv=pass; d=google.com; s=arc-20160816; b=u8Yuwd/vMvgC4Cizbjn8BfBzLXkMF+dSARL++NMO4ISnyXe7q0jGF1oz2n1rC0NdGR q3hzek1JEk4WaY2Dr9yue2Ufl4b+iOSctVPMwgJuwR1EM9vKIMVA4MAftVXiwwtnOrOW XA9UvJo/F5Eo//gwY8RYbFv5JUWzH7C21LlVqvRFWXK3AtQ6tw3TtIa/v8aP0qXWZNJo b/Qa6UpRf3j4a99h1jn1csYGxxELCHs/55Qvqc37Mjz33+GBfLvzkhNSK8TmaDrxxlOb 6fijs0pUNwoMgmVZRc1xIvfehhpxzaaes4AJByXtkBcQMVSHK0cDgm6YsKrAJ+csDulI eAcw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:dkim-signature:date; bh=FuuwmqpCQpWAXNTzSXOVhd7IRRo2+InjCoLO7UA0d9k=; fh=blPQ8Vq7qwBDD03Iq2NteBLSSZfMmh90ho5MvMTJktE=; b=jsoIiRcKEVcqAPk/M8SoL9dR5jdqtpTlpkFFa+/OH6l0gcQu4L6DRdQ4J//hFTet4/ R0EPJ5pYEMAZw/wdsHlgE1+IwMW4jtcL1ZrFKL37IZJFIEySVJZ7Ubqv+MJ3RJEAiAmS 4vdbU8HJS6bJk1Ha2XiL5JnIrU8rGGXI3mYYcclI3mKKkXrRa1y/5wmkfKq8HOgW9wAX x+96YbVmf3wuUvSEcD916ToMYyzg+h1CrNnUcXXRddbWQnlJlG4bjWaw5S8xAgIDXePZ TrOvaSszI+RLzGR1sHCHoBZX9MEGlAotoM+2fFOhLHqRGW2iuuUl1H9Y0av/XwZRMtq0 j3Ag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=PhLbGwRx; 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-73413-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73413-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id o3-20020ad45c83000000b0068f8b3d5e83si3009175qvh.372.2024.02.20.09.16.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 09:16:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73413-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=PhLbGwRx; 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-73413-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73413-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 270461C241F1 for ; Tue, 20 Feb 2024 17:16:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2B76776C87; Tue, 20 Feb 2024 17:16:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="PhLbGwRx" Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [95.215.58.178]) (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 D4775768F5 for ; Tue, 20 Feb 2024 17:16:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708449364; cv=none; b=kawTfghfh8aDOsCHTPqjkDHypXsKkzNwGojegLZPcC2UCxH4xQqwRilHIoYChotrXvuMhNFOzMPNaFSBQWXBeatCS5lq1b2BPLg6+yxXlw09WILZJNa/VtezRFhBqLo3YnNAbdKtIaJQw2lcnA42XUIlXehlUEWuLkTtIy31MXA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708449364; c=relaxed/simple; bh=FhliDVkysklF15PfPRnCqEJZYnFpC1xmT61LBc+B6yI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rAXzmzCF9F6XJuIZ1VHT8KXLqEqc8R9CZCCOUISi8XgxkNAlyD9GRQrKsVKeobKdvJ3+rRk8uHOqLIRr0uyDG3I28hpoHw/Snnnfdz7SOBzY08REHDcoYzE3B7jMiJZViml9fmdLSavwwsXrddDX2eBBtoYpGpPv6LUo3MOyGr4= 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=PhLbGwRx; arc=none smtp.client-ip=95.215.58.178 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 Date: Tue, 20 Feb 2024 17:15:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1708449359; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=FuuwmqpCQpWAXNTzSXOVhd7IRRo2+InjCoLO7UA0d9k=; b=PhLbGwRxlT+KuFz6tNw+qZd6Cv2esxSF9tj4+tBVdOBC/t2uIBnFQ32R5S3fpIj9zwDMM4 5EFbyhwJoTMDNouP+8qkoudMbS4tZh82lt0y+8FdzXwuNk4n1Ivu0bT7rH0CElsoD8A/3U SQrrw1LoLkxSGmCEGsLKUs91+vdn6jI= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Zenghui Yu Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, Marc Zyngier , James Morse , Suzuki K Poulose , Zenghui Yu , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 01/10] KVM: arm64: vgic: Store LPIs in an xarray Message-ID: References: <20240216184153.2714504-1-oliver.upton@linux.dev> <20240216184153.2714504-2-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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT Hi Zenghui, On Wed, Feb 21, 2024 at 12:30:24AM +0800, Zenghui Yu wrote: > On 2024/2/17 02:41, Oliver Upton wrote: > > Using a linked-list for LPIs is less than ideal as it of course requires > > iterative searches to find a particular entry. An xarray is a better > > data structure for this use case, as it provides faster searches and can > > still handle a potentially sparse range of INTID allocations. > > > > Start by storing LPIs in an xarray, punting usage of the xarray to a > > subsequent change. > > > > Signed-off-by: Oliver Upton > > [..] > > > diff --git a/arch/arm64/kvm/vgic/vgic.c b/arch/arm64/kvm/vgic/vgic.c > > index db2a95762b1b..c126014f8395 100644 > > --- a/arch/arm64/kvm/vgic/vgic.c > > +++ b/arch/arm64/kvm/vgic/vgic.c > > @@ -131,6 +131,7 @@ void __vgic_put_lpi_locked(struct kvm *kvm, struct vgic_irq *irq) > > return; > > list_del(&irq->lpi_list); > > + xa_erase(&dist->lpi_xa, irq->intid); > > We can get here *after* grabbing the vgic_cpu->ap_list_lock (e.g., > vgic_flush_pending_lpis()/vgic_put_irq()). And as according to vGIC's > "Locking order", we should disable interrupts before taking the xa_lock > in xa_erase() and we would otherwise see bad things like deadlock.. Nice catch! Yeah, the general intention was to disable interrupts outside of the xa_lock, however: > It's not a problem before patch #10, where we drop the lpi_list_lock and > start taking the xa_lock with interrupts enabled. Consider switching to > use xa_erase_irq() instead? I don't think this change is safe until #10, as the implied xa_unlock_irq() would re-enable interrupts before the lpi_list_lock is dropped. Or do I have wires crossed? -- Thanks, Oliver