Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp58793rdb; Wed, 14 Feb 2024 12:37:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVea4rCUzTZUVB3WzLbAnS/9En0YA7YTpSpVmlqfvpEt5h0qxhh9CDKkbupOKq3pV8iL2Kf2V00/9kw9U5IAu2j8gU5HQCMMPv9se0llg== X-Google-Smtp-Source: AGHT+IGkUXwiJOZaoTJ+eoxbsYWu3VpuDycWQX9L+D4bTPMfX7fzy9yp1Ok1qzoDkzm6zgIZiCSF X-Received: by 2002:a05:6a20:c707:b0:19e:9da6:c73b with SMTP id hi7-20020a056a20c70700b0019e9da6c73bmr5610467pzb.8.1707943051729; Wed, 14 Feb 2024 12:37:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707943051; cv=pass; d=google.com; s=arc-20160816; b=SZJ8f2cnVatX/02FXcFZ3Jji9i70VeOA/uY+gDERZ+ptNZ4MjRTCQZ0QsGDgpmO13y I3IBiUB+fjwbYWbAf0Q5A3o+fQLdi5Q2lLZrOGsJwhF6+Je+8s3aSBwvhaUJeu0vuI5n vFDFfIT/IAv/hTf/VmQdbinhzGxzGMKq3nK8iNf4AHc2J5Zw1LjYJwVaum+KB73FZpcI rxt6BM73Baxkp4q21CMhJFZaXzYlUNpAjeuKNsxhPMab5xDqwYgGS4JqWP/J17U2rlSj 4wJBuG+JbIwJ4FaMOKmwHq1ZlYN1l0WL5Zpy0XFztCtjX3L0n06aaTRQiM8fC6gIlYU0 1AEw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date:dkim-signature; bh=eaa8hhzB8Au6e3m2LbjgFQGSgLGE/RCWcVChQHQIGjc=; fh=GEQfKB8N1yunoFrhqHSjKWjpdVpXs8s06MyjFUor5vs=; b=yPChunpzjTWeR85M2jY8GOVp0eKGhyrMvuLaL5Mkw//ApYjpN16SK5sMcGmiCS/l+E EQTZum1/vCU64hxxzXlpWaTmcWlc8p8HMPuw9eCiLOE6muIUn9k9KkoUH9cjxG9pySXR E0/HMM4VYPi29tD11Ighgncn2y26n0iioJpDV556qW5707wWHrVVEUrSjxSkXzRsNFr4 rkGXscJg74mB9As/EMQghLG/gh16FiY8DofJ80kRRUipGwT4lBCoolPz6B7istDgB81J ToaB4EyvWxCnBx/7jadhurlJF+Naqjm3CCqicY7yKU18vT5U6ImzMi5FvU1Cl+2gDD9g MJBw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TabFiwUh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-65910-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65910-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCXzZtFXBhLaeQRmlG09hl8c6vSUoEIWQHFzFGjWl30WohEM+lZUQUQGBek3Be/Y2/rROOUpwKUHhZ6liu3UsT00YitXeobbqk7efDpmjg== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id x66-20020a636345000000b005dc892da3cfsi2840759pgb.642.2024.02.14.12.37.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 12:37:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65910-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TabFiwUh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-65910-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65910-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 5810AB29B29 for ; Wed, 14 Feb 2024 20:01:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67B7C13DBA2; Wed, 14 Feb 2024 20:01:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TabFiwUh" 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 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: linux-kernel@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.