Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp11249003pxu; Thu, 31 Dec 2020 04:25:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6vCieanS5XKPhG5GR8DzAbxYsPS+E2NjitJ4NHP9p4HfCZkpYFeg4NSuBrsFBwSQtFqKM X-Received: by 2002:aa7:c3cd:: with SMTP id l13mr54224913edr.97.1609417501019; Thu, 31 Dec 2020 04:25:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609417501; cv=none; d=google.com; s=arc-20160816; b=PE3IHQUme6XjKYDCjbohUz6qviY2b4+9rsNunoQCJMYO18XA5zAX7UwXt0nSrRf/Ch Rci355wW//KJwgdx5HdZC/XmLTMgE8KRWQxGCuwUL33UOOjgLT7Uasym2I8FPeo7Y4+F MAs4NJm8NWVW2omESEiIlP5yV7Bh5rPePSJnCD5XmgWdj4ponWa9TMyu/9rP31/V5Ggx wu0rfaUGpkUBTK/foji9mEg/N6Xg8kZp57DfYtAVFFJZtqK1k3YIfBOppwakH2EFzk64 2h1IBHuIM606IDSB0y5Q/kNEqIAgXY+9UfPZQTdsdnlXxfRaRCemL0mUjygtiX9rlu+r +hKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version; bh=u93LHePwNLzGNsRUHiluFVNw3QYeRgkZD8fEes6ODfM=; b=KCTH8TP5u98Zyg2qONlG6D2dGpJRszHHHY5zbQXwddmhfm1YaxQLLjBOHvAKrh9xxa 4sQ05zHUY4Cw6jGCFqjJOlydbghRrPwyEkIZ9ldWYQutT2lWRLL3A2iIOvRr5VkZM/a0 rNTwzFdlBc6sJ3m7m/Vs+upW0U+tq0OLNYI57Mfu6tzv6C7E015HJ8ss/UoVqaFlisVJ ezwHI4yVuGc/jKGF9338D+EeRDdyGU32hYR6r73xnThoEh3jyli77I/YJ/Hv3N/o5K0X ioxXKRIgBqTLEysgvDGcB/HTnJticKSJQTOqbCX9m6R4Bl3dvAoReCKO+1NcEvnd0ATN uYGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w8si23921733ejv.263.2020.12.31.04.24.39; Thu, 31 Dec 2020 04:25:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726329AbgLaMW4 (ORCPT + 99 others); Thu, 31 Dec 2020 07:22:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:33290 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726261AbgLaMW4 (ORCPT ); Thu, 31 Dec 2020 07:22:56 -0500 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0E7FB223DB; Thu, 31 Dec 2020 12:22:15 +0000 (UTC) Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1kuwy4-004iEa-Tk; Thu, 31 Dec 2020 12:22:12 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 31 Dec 2020 12:22:12 +0000 From: Marc Zyngier To: Shenming Lu Cc: Will Deacon , Eric Auger , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, wanghaibin.wang@huawei.com, yuzenghui@huawei.com Subject: Re: [PATCH RFC] KVM: arm64: vgic: Decouple the check of the EnableLPIs bit from the ITS LPI translation In-Reply-To: References: <20201231062813.714-1-lushenming@huawei.com> <683134bdea8a22d3bb784117dcfe17a1@kernel.org> User-Agent: Roundcube Webmail/1.4.9 Message-ID: <85dd45f580eaa7a0b8ec91ac0b7ca066@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: lushenming@huawei.com, will@kernel.org, eric.auger@redhat.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, wanghaibin.wang@huawei.com, yuzenghui@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-12-31 11:58, Shenming Lu wrote: > On 2020/12/31 16:57, Marc Zyngier wrote: >> Hi Shemming, >> >> On 2020-12-31 06:28, Shenming Lu wrote: >>> When the EnableLPIs bit is set to 0, any ITS LPI requests in the >>> Redistributor would be ignored. And this check is independent from >>> the ITS LPI translation. So it might be better to move the check >>> of the EnableLPIs bit out of the LPI resolving, and also add it >>> to the path that uses the translation cache. >> >> But by doing that, you are moving the overhead of checking for >> EnableLPIs from the slow path (translation walk) to the fast >> path (cache hit), which seems counter-productive. > > Oh, I didn't notice the overhead of the checking, I thought it would > be negligible... It probably doesn't show on a modern box, but some of the slower systems might see it. Overall, this is a design decision to keep the translation cache as simple and straightforward as possible: if anything affects the output of the cache, we invalidate it, and that's it. > >> >>> Besides it seems that >>> by this the invalidating of the translation cache caused by the LPI >>> disabling is unnecessary. >>> >>> Not sure if I have missed something... Thanks. >> >> I am certainly missing the purpose of this patch. >> >> The effect of EnableLPIs being zero is to drop the result of any >> translation (a new pending bit) on the floor. Given that, it is >> immaterial whether this causes a new translation or hits in the >> cache, as the result is still to not pend a new interrupt. >> >> I get the feeling that you are trying to optimise for the unusual >> case where EnableLPIs is 0 *and* you have a screaming device >> injecting tons of interrupt. If that is the case, I don't think >> this is worth it. > > In fact, I just found (imagining) that if the EnableLPIs bit is 0, > the kvm_vgic_v4_set_forwarding() would fail when performing the LPI > translation, but indeed we don't try to pend any interrupts there... > > By the way, it seems that the LPI disabling would not affect the > injection of VLPIs... Yes, good point. We could unmap the VPE from all ITS, which would result in all translations to be discarded, but this has the really bad side effect of *also* preventing the delivery of vSGIs, which isn't what you'd expect. Overall, I don't think there is a good way to support this, and maybe we should just prevent EnableLPIs to be turned off when using direct injection. After all, the architecture does allow that for GICv3 implementations, which is what we emulate. Thanks, M. -- Jazz is not dead. It just smells funny...