Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp150783rdh; Tue, 13 Feb 2024 12:12:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVLGu9P+TDZFgpfCZpOccygbwAGYDK/aquDNPPcAOsp9sHuHSmgbliimDSfSccmH7ziWXu+w/+byhPBPa9BdoUT9XEa7g6stsgDcUXV2A== X-Google-Smtp-Source: AGHT+IEm0w5ON6yCbHBNE8xzL0C72jwu2ajqVvvtBNJ9qGSYNHUR0tMNhiz2a7NPfzhudUfRTm8D X-Received: by 2002:a05:6214:33c4:b0:68c:a0ec:1a39 with SMTP id mw4-20020a05621433c400b0068ca0ec1a39mr6311726qvb.21.1707855160065; Tue, 13 Feb 2024 12:12:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707855160; cv=pass; d=google.com; s=arc-20160816; b=vjzttUsd0uA7Mc/DaDnWKb9cUJAMHjAe2WuWXIK+Zxo0HhksWR2aR97dE+V/eR1ZOH HW3EyDJBgPU5iB/0d1B7ni+VC560YdjobRHGlK15uJlZ+i6Yg9U+DTzVEVTnaUbggQqG y8IkCJb3w1UW0hdnItMLocgnkkHRWyUXKdl2+zXs7gNqWvhx6tBuNeKu10uNJNC2aZeN y5BYqpGNOG81r/uDaQuLZMWr/zk5GBFBdWTh6TK8eZXvZYlJT33v1d7IK99Fz6xYvHaQ ZXTVJrOUGvhQKzChftnSTodYtHmvhKEtz6dKWC9m4agFm2esHEKajcnm4t/AkPj3f1tI +hzQ== 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=3ynvcun4Y8ZFlfFtT4gj87TNcq60Lzv8L5cy3V0DM2g=; fh=OTP2xoPzFwWjPOeBh2nOP2ZPkJChQV3oO2ehSVvpOoA=; b=AUQXRR92qUB2dZdz5wFydo/twUTAKAA5q/lKIFpl2/pNG70BG72XkYvRUlPVWV4Lbj nJyYkkFve/5sf3oJzHGR39q20IiWjbjkbZg+WbP+0BGJqe0pasmrFBCaUI/0Ni8KjFaN THNFCsSRFlHLJ+Eem9N/ikk8g/pgyb9r+5/ZZd4Au7qA1ah3hPxCmRG1zUZi13uelBcK VAJK4b/Ju0VLnrxu02qG398DAJpE5KyZj8VjPSyjvc8XQOn7e12KVRYK5HliZe3/bYDm XHWNOGt+i255/uj/F6pl90WcEKYW9WN/TAO8vurIITrHFNrHoWFdmP2LiwDj21TH6DY1 2ZCg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=gaknWtD7; 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-64218-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64218-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev X-Forwarded-Encrypted: i=2; AJvYcCXe+37gYB8Z3VwqkL+GOTjYNM8omQkxRXtTYG6ceNoDYXyzbTHC79U4SyZuVqjGL1YgoEmaf2sfU04DZwT07VlTSEN4kGWcjj2F4amlzQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i5-20020ad45c65000000b0068ccc9994edsi3859463qvh.163.2024.02.13.12.12.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 12:12:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64218-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=gaknWtD7; 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-64218-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64218-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 CEA3C1C24320 for ; Tue, 13 Feb 2024 20:12:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D88AF60BB7; Tue, 13 Feb 2024 20:12:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="gaknWtD7" Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [95.215.58.172]) (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 DED1760B85 for ; Tue, 13 Feb 2024 20:12:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707855148; cv=none; b=UVwamzV6iP/d5okUp/+UwnhB8ZepvKyemfMpyNaWwBK1PHuCFRRSNelIiV2t2N5E60ymPtsnZZ+VMp8usbBcqrNn3uhlNH4Wl4hHCugXo6Eeuwf01anmEBlAlBSRX9SC+7M9r2GP0QVPdF2X3EkMxh0QERt3cFRD6hvKo1slA54= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707855148; c=relaxed/simple; bh=WzClOifpUCSoYB1Gr9NXXGUfJ+JOmYmKWTDQuwaxiRY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UGx00iQVp0kO4OaIy4+JuK6DVtmK0fQWxZ6QsWfAlO+/l7gqMEKhZjFcrrQ6BgMR4djLiipzlmWWB3v44lZJVvtAuqRXZIeYw1Ju5r2kK5sfAuHmsqHEMjHjKC4/JGPLli2WIE4fyTPf9xXAn5k6znMW1Agj5EKEpSbERID8k6E= 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=gaknWtD7; arc=none smtp.client-ip=95.215.58.172 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, 13 Feb 2024 12:12:17 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1707855143; 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=3ynvcun4Y8ZFlfFtT4gj87TNcq60Lzv8L5cy3V0DM2g=; b=gaknWtD7n6/VN29uhilsWT819EYmFiEjAGhQwHAGgX+2Z4hnXnh/JZQKCHj4890NhvfADc 3SgZMXDJSeCH5W85ySuI8VTgUGytg0q5wQV0W5G1RtEm092yItcmgCZfv4vollSNKJ7vbw bkWKua0XYQmHDvlfRJEjs24ZYMHzQHw= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. 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 Subject: Re: [PATCH v2 00/23] KVM: arm64: Improvements to LPI injection Message-ID: References: <20240213093250.3960069-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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240213093250.3960069-1-oliver.upton@linux.dev> X-Migadu-Flow: FLOW_OUT On Tue, Feb 13, 2024 at 09:32:37AM +0000, Oliver Upton wrote: [...] > Clearly the RCU synchronization is a bounding issue in this case. I > think other scenarios where the cache is overcommitted (16 vCPUs, 16 > devices, 17 events / device) are able to hide effects somewhat, as other > threads can make forward progress while others are stuck waiting on RCU. > > A few ideas on next steps: > > 1) Rework the lpi_list_lock as an rwlock. This would obviate the need > for RCU protection in the LPI cache as well as memory allocations on > the injection path. This is actually what I had in the internal > version of the series, although it was very incomplete. > > I'd expect this to nullify the improvement on the > slightly-overcommitted case and 'fix' the pathological case. > > 2) call_rcu() and move on. This feels somewhat abusive of the API, as > the guest can flood the host with RCU callbacks, but I wasn't able > to make my machine fall over in any mean configuration of the test. > > I haven't studied the degree to which such a malicious VM could > adversely affect neighboring workloads. > > 3) Redo the whole ITS representation with xarrays and allow RCU readers > outside of the ITS lock. I haven't fully thought this out, and if we > pursue this option then we will need a secondary data structure to > track where ITSes have been placed in guest memory to avoid taking > the SRCU lock. We can then stick RCU synchronization in ITS command > processing, which feels right to me, and dump the translation cache > altogether. > > I'd expect slightly worse average case performance in favor of more > consistent performance. Marc and I had an off-list conversation about this and agreed on option 4! It is somewhat similar in spirit to (3), in that KVM will maintain an xarray translation cache per ITS, indexed by (device_id, event_id). This will be a perfect cache that can fit the entire range addressed by the ITS. The memory overheads of the xarray are not anticipated to be consequential, as the ITS memory footprint already scales linearly with the number of entries in the ITS. Separately the DB -> ITS translation will be resolved by walking the ITSes present in the VM. The existing invalidation calls will be scoped to an ITS besides the case where the guest disables LPIs on a redistributor. -- Thanks, Oliver