Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp673394ybp; Wed, 9 Oct 2019 02:22:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqy6kbqeq/57uBqLddTzflRUEE8ZK8HrNy6edLIcmU1MBJNiAczSv3EVPGEMQVrh+NhY+gKT X-Received: by 2002:a05:6402:7d2:: with SMTP id u18mr2032033edy.23.1570612962242; Wed, 09 Oct 2019 02:22:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570612962; cv=none; d=google.com; s=arc-20160816; b=cRANAtiU042YlNWyBdZb0UcUejmW9Lf2RcVKdU/HBNMWS0hz+96Ug/EYl6wvoNCPgC gmk0VG+He3ZgAQhMp4kIee4gGy5Pg7uBjJHa1oW1iwl1i9Jf2+fK7T2IAJPSNhs6zNNG x08GsjHCmQ6LwFXfVez0pMdy2B+VZfM1hwpSGbpqRHmFOhP9Io8bIrC7Vm3VGKevogsK UrFtBJwrABBNEAhK6ClMynGV9vgsxq74pJpwThYCPBv+jPVw/NTJV1KgF2so7nVNF8wq oJL5RWlJRKv8tlg0LzOCvvi8GquMdBLgUISDHjgcL90rOcKowLMYx7CP3LdC9b+6wJ0a 1u/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:openpgp:from:references:cc:to:subject; bh=5UOftSR0L2Uy+6rXXf5VN2VI0Ck5ZEnoLKqgZauYpms=; b=iwYro3l03nAZO4eGCBmEPsKUrAeUJumZZ2BJDpULFD2j2aqA5kFSs8Bd7HbvfZdg4D /QVWmBjsRLiCHj39sENpsLIR9u3wsg9QenG/hKeHOgNchX/2OPi9qhAZxAVHnBq0s4Az MSXFwfjlKylAFcisnv5Venyx6cVqlhIJmXXZfYHIDYxpbdhKRyHyJgzw4O3hdgvJdM/P G+r3MakzSBNrc1MLe/lIYvricpKDj8Bh6r5n/fzZ2oqmPyic0uFYCLZYEE3WXYYfLk4A S4C0AyTBeSS4QZF+SiK7RLRYzhRCm/+GN7BBKDfF/UbKvjg1KvmQyOd4gGo7aWpKAA5t gPKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ha16si774190ejb.258.2019.10.09.02.22.19; Wed, 09 Oct 2019 02:22:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730609AbfJIJVt (ORCPT + 99 others); Wed, 9 Oct 2019 05:21:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42962 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730557AbfJIJVt (ORCPT ); Wed, 9 Oct 2019 05:21:49 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C4261C057F2E for ; Wed, 9 Oct 2019 09:21:48 +0000 (UTC) Received: by mail-wr1-f69.google.com with SMTP id w2so828603wrn.4 for ; Wed, 09 Oct 2019 02:21:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=5UOftSR0L2Uy+6rXXf5VN2VI0Ck5ZEnoLKqgZauYpms=; b=qOiV9rjzkx81Qv9wCoXhSR/eI/gniLsc4njacTtp9z1pl0kQVpMee6sVWP9rL+cjOA Kz79BVz/fZq/GUQoI/1dh2QrDsLZXhvliWokmI3WKY6gah+PCizyJLOCkNQRw8ibW4bX 4B4aTyIDO6gtibNqXz1MyuXgifZgBgkVdlPZEGmpSSFdI/LwmVxEEVIz5nvtEcQiLfLN 6+Dvpbx1LhzUIrNLNRuLWHFD2pgDHwJ1JjnK24q07JK9HW3eYsSBKaRT3R4LbmyrTtBG gglKoZDMNadw2Jp5CYwbnWJi7HBltDJYX8+YMm8mX3CS8pNaltXTLgoExYt1Y8VJuCBt S97Q== X-Gm-Message-State: APjAAAWs++0uldFpIlhyii4+38L+Xw9QEO7YCS7jwqHYpYDTqChsSq1j t6IhFk2U6Y2fbXTMGwTgomzAphrstMM9phRxJQkKg9nPh4yGpm9pgaqC/dL61sdtx59UiIbKbb0 x6KsyIsYCDmicEXKzOU8/16Wx X-Received: by 2002:adf:e7c3:: with SMTP id e3mr1925556wrn.218.1570612907378; Wed, 09 Oct 2019 02:21:47 -0700 (PDT) X-Received: by 2002:adf:e7c3:: with SMTP id e3mr1925540wrn.218.1570612907109; Wed, 09 Oct 2019 02:21:47 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:f4b0:55d4:57da:3527? ([2001:b07:6468:f312:f4b0:55d4:57da:3527]) by smtp.gmail.com with ESMTPSA id w9sm3231973wrt.62.2019.10.09.02.21.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Oct 2019 02:21:46 -0700 (PDT) Subject: Re: [PATCH v3 15/16] kvm: x86: ioapic: Lazy update IOAPIC EOI To: "Suthikulpanit, Suravee" , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" Cc: "rkrcmar@redhat.com" , "joro@8bytes.org" , "vkuznets@redhat.com" , "graf@amazon.com" , "jschoenh@amazon.de" , "karahmed@amazon.de" , "rimasluk@amazon.com" , "Grimm, Jon" References: <1568401242-260374-1-git-send-email-suravee.suthikulpanit@amd.com> <1568401242-260374-16-git-send-email-suravee.suthikulpanit@amd.com> From: Paolo Bonzini Openpgp: preference=signencrypt Message-ID: <3771e33d-365b-c214-3d40-bca67c2fa841@redhat.com> Date: Wed, 9 Oct 2019 11:21:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <1568401242-260374-16-git-send-email-suravee.suthikulpanit@amd.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/09/19 21:01, Suthikulpanit, Suravee wrote: > /* > + * In case APICv accelerate EOI write and do not trap, > + * in-kernel IOAPIC will not be able to receive the EOI. > + * In this case, we do lazy update of the pending EOI when > + * trying to set IOAPIC irq. > + */ > + if (kvm_apicv_eoi_accelerate(ioapic->kvm, edge)) > + ioapic_lazy_update_eoi(ioapic, irq); > + This is okay for the RTC, and in fact I suggest that you make it work like this even for Intel. This will get rid of kvm_apicv_eoi_accelerate and be nicer overall. However, it cannot work for the in-kernel PIT, because it is currently checking ps->irq_ack before kvm_set_irq. Unfortunately, the in-kernel PIT is relying on the ack notifier to timely queue the pt->worker work item and reinject the missed tick. Thus, you cannot enable APICv if ps->reinject is true. Perhaps you can make kvm->arch.apicv_state a disabled counter? Then Hyper-V can increment it when enabled, PIT can increment it when ps->reinject becomes true and decrement it when it becomes false; finally, svm.c can increment it when an SVM guest is launched and increment/decrement it around ExtINT handling? (This conflicts with some of the suggestions I made earlier, which implied the existence of apicv_state, but everything should if anything become easier). Paolo