From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8BF121E4B7; Wed, 14 Feb 2024 20:01:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707940883; cv=none; b=E+m6blLONlBHtKvJXJVVbeQtmEFwwc0ABjP6t5acN+X5u5F8QV7YGSdI2BlVuFwE8qnnhIuH+qfw9PBUaPJPOfLz+O1SUyHNWYwvxS2wpZGC8tect6wnoV7bNp0wEK7cWMYxXjgq+IlCrwx6QXsmEEcDwxTopSi+uUi5k+W55lg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707940883; c=relaxed/simple; bh=5K2WUn7NWr2ouERBIwh/bkIaCWPjJwbZxQ4mhPJU38M=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=CdUcp/APOY72Pf5+OoP6iAhYDRS+opwN7lDnSAppeLmhEFzncZY4zf4iauJ69Os41DdX4ZXXfYl/PXKfT5/KavJDTucIhnAfq0xvMHU14h0ajkv/R3qmj0ixVA9cle/TCuojZzW6PGXS+P3vrWUYPbzchbFfK32YvYAS9nHSpWY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TabFiwUh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TabFiwUh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A529C433F1; Wed, 14 Feb 2024 20:01:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707940883; bh=5K2WUn7NWr2ouERBIwh/bkIaCWPjJwbZxQ4mhPJU38M=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=TabFiwUhrpgZtkQqgIS6buAF5wO7edIU7TzZN7bwb53XohYw2ZyyKROMmVrcCOb+d zPlFl+GCAj0Kg1k8Lc3rnbHbA/7izh8EHK0bcOIoslFyt/j8s0g0cbyIP58dtCfDBp yc11Wbtle+tQ08MjwC+XDB9usxyDR6Z4b6bZ0QmRutoZunwpOALIbHaPno3x+mdh/B /8GxDBlsctQJ1dRarDaVe2frX8y0XeZl5aREMGPa+N084xWR6V98dnf21hk7405ULN VOeGCZwDu0uNEs79kGxqF00BoCs6f5oObRWVH404vEPyaqFrtsuQLvJ049M2Iy4u9q NEVYGbLijFbzA== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1raLRZ-003GBr-15; Wed, 14 Feb 2024 20:01:21 +0000 Date: Wed, 14 Feb 2024 20:01:19 +0000 Message-ID: <86wmr64xyo.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, James Morse , Suzuki K Poulose , Zenghui Yu , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 07/23] KVM: arm64: vgic: Use atomics to count LPIs In-Reply-To: References: <20240213093250.3960069-1-oliver.upton@linux.dev> <20240213093250.3960069-8-oliver.upton@linux.dev> <861q9f56x6.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: oliver.upton@linux.dev, kvmarm@lists.linux.dev, kvm@vger.kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Wed, 14 Feb 2024 18:32:02 +0000, Oliver Upton wrote: > > Hey, > > On Wed, Feb 14, 2024 at 04:47:49PM +0000, Marc Zyngier wrote: > > I'd like to propose an alternative approach here. I've always hated > > this "copy a bunch of INTIDs" thing, > > Agree. > > > and the only purpose of this > > silly counter is to dimension the resulting array. > > Well, we also use it to trivially print the number of LPIs for a > particular vgic in the debug interface. I think we can get survive this... ;-) > > > Could we instead rely on an xarray marking a bunch of entries (the > > ones we want to 'copy'), and get the reader to clear these marks once > > done? > > I think that'd work. I'm trying to convince myself we don't have bugs > lurking in some of the existing usage of vgic_copy_lpi_list()... > > > Of course, we only have 3 marks, so that's a bit restrictive from a > > concurrency perspective, but since most callers hold a lock, it should > > be OK. > > They all hold *a* lock, but maybe not the same one! :) Indeed. But as long as there isn't more than 3 locks (and that the xarray is OK being concurrently updated with marks), we're good! > Maybe we should serialize the use of markers on the LPI list on the > config_lock. A slight misuse, but we need a mutex since we're poking at > guest memory. Then we can go through the whole N-dimensional locking > puzzle and convince ourselves it is still correct. Maybe. This thing is already seeing so many abuses that one more may not matter much. Need to see how it fits in the whole hierarchy of GIC-related locks... Thanks, M. -- Without deviation from the norm, progress is not possible.