Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1842731rdb; Tue, 20 Feb 2024 08:31:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUC9Bei1Ei9sdmMHkULZlNi5cHKu6+czlBBKOl8CNichrAMrR3STxrG1C3/hq1SzkQpSh0p59BO6c0G8J/W/W64iZAfF8geAbbBuwlepQ== X-Google-Smtp-Source: AGHT+IEQO0iIVsSSLcpN9SvBjf1DV3AKxo7YWKe4fQJ55ifwxm5U4b1RUrx66YlVxhH+hfSv2pmq X-Received: by 2002:a05:6102:368:b0:470:5379:21f with SMTP id f8-20020a056102036800b004705379021fmr6689147vsa.2.1708446672694; Tue, 20 Feb 2024 08:31:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708446672; cv=pass; d=google.com; s=arc-20160816; b=SU0nmW+hunABYfMiWfdDKlAp+2DpVPPTmK5eVp4jm8yvUuOsocXW5Ac8bDzX2/H28v HOLKSiyq15hRerZREcrnuvk0lb8AfJavJa/jqn0fH2Hbw4sVKgfaA9hO15jBXuhDp+yo kzcECj96gKnEsLq/cBI3k4LWFRLZA0i88pA9zeOGwgHX5b0iZnp/E8QxmrUHmsE4VR+w D4kIL1VfE24j+uLExTKABZZY0Fs4LHkq2zlvAYXAqrsdTLXyQjAqU+Kh9IC0u7SxdlAn Yx5j29rBLBr9lNfxQPBE8TclMHbsfM3mYmPjE6bld7vd/Dhbzqp/Xj7q9sQAlkqyneQS PSRA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=q36kWA/MC7EF1Sh3We0UtEcn1Ana4Gh6S3w6HUOZ5xw=; fh=3nSOjcYu0xjOKS5AnQqMEDdK4waEu/vPZqfD0rX3+yM=; b=0G1k5cAGyMZtm0C8jWGq52PiixcOt7CJGSE0+lWDppkBbdqW5g5JdZNXjbYQvVxGs+ NKnnrx7um8ebeZG5/DL2IlnQkq/rAdV9T3YkL52qPVz6dT7ktPcOzGoJjf7vhD3XvEZh KWHibwMA+8YLgWowVlFTVfPwwruXThbE4+ngUedtY0VMb/c21cUwDzb3NiWsZduVTHVq 5RSQZC7vbpJAR5BuqCZxNdMoqRnYzzLE0Ts26Nc8lhevWiySSwLqFqii+mM4m1IUiN8m 1ea/vgHShM+2JgIS9xfsBwxYqwP4JO3SN0GvXzp1gaZe/q6YVU3bxkAGwYF641GC09mz +Zqg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=i54KhuKP; 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-73359-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73359-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. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id q1-20020a056102204100b0046ebcb9242bsi502880vsr.408.2024.02.20.08.31.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 08:31:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73359-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=i54KhuKP; 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-73359-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73359-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 6AE381C237F7 for ; Tue, 20 Feb 2024 16:31:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E33A768E0; Tue, 20 Feb 2024 16:31:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="i54KhuKP" Received: from out-174.mta0.migadu.com (out-174.mta0.migadu.com [91.218.175.174]) (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 CC7DD692EB; Tue, 20 Feb 2024 16:30:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708446661; cv=none; b=lQvOSfENeR0Bg0gJkh7zPhS/JRBGU5yoD1sTIVz1owx/N51qYkTa9P1GOeHdDqXI3/WI9ujtFBjPz/r98o4NHznOJ7OidVjcCnlhW6bjdOdgh+xCdjZuAcQEI4jbt3fmonBAUXUUtGJ9Ya8ED9TiMRYoRQZpXnU+b/qhR6m8VX4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708446661; c=relaxed/simple; bh=1+/RA9pWeDwmtnkvb1unZWEhB64IvThTUVkVaz20I0Q=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Tl6f8zzXdO3qWma6hXoUnMbbRohlFcDCzTtWj0J9OfdNXJqcweUmz0uqQrP14wwOe6PnKgbc/PCfygwtsjGvio4G2HgCFnyM5bsCznHw8NAeOV3tvIJoVHoc7cPK20juZxzRORFDcAJI28x3YZ6NNiGb4jEovGxo4TI2vLdImCY= 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=i54KhuKP; arc=none smtp.client-ip=91.218.175.174 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 Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1708446656; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q36kWA/MC7EF1Sh3We0UtEcn1Ana4Gh6S3w6HUOZ5xw=; b=i54KhuKP0AuNirJ0AqIJGXRMIbcP+ZxJwNOenJcEtrLHcMEcOyccJ9w4qD1teOQNwhPjR2 zq1poH3ELpJwXyyPVMs5m8G7vUjLw4Fhy81Cj+Mud9D69K7H7ZBoqE3Lfg3s4C5oiqZgpW uGQnio/fuyhObOC46oRKYCEGK1GrnA0= Date: Wed, 21 Feb 2024 00:30:24 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH v3 01/10] KVM: arm64: vgic: Store LPIs in an xarray Content-Language: en-US To: Oliver Upton , kvmarm@lists.linux.dev Cc: kvm@vger.kernel.org, Marc Zyngier , James Morse , Suzuki K Poulose , Zenghui Yu , linux-kernel@vger.kernel.org References: <20240216184153.2714504-1-oliver.upton@linux.dev> <20240216184153.2714504-2-oliver.upton@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Zenghui Yu In-Reply-To: <20240216184153.2714504-2-oliver.upton@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT 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.. 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? > dist->lpi_list_count--; > > kfree(irq); Thanks, Zenghui