Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756647AbbLWQmY (ORCPT ); Wed, 23 Dec 2015 11:42:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34105 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751465AbbLWQmW (ORCPT ); Wed, 23 Dec 2015 11:42:22 -0500 Date: Wed, 23 Dec 2015 17:42:17 +0100 From: "rkrcmar@redhat.com" To: "Wu, Feng" Cc: Yang Zhang , "pbonzini@redhat.com" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Jiang Liu (jiang.liu@linux.intel.com)" Subject: Re: [PATCH v2 1/2] KVM: x86: Use vector-hashing to deliver lowest-priority interrupts Message-ID: <20151223164217.GD12725@potion.redhat.com> References: <567759F2.5080809@gmail.com> <56775E9A.5030108@gmail.com> <5678F268.5070801@gmail.com> <5678F81C.5050309@gmail.com> <20151222195259.GC12725@potion.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3306 Lines: 70 2015-12-23 02:12+0000, Wu, Feng: >> From: rkrcmar@redhat.com [mailto:rkrcmar@redhat.com] >> 2015-12-22 07:19+0000, Wu, Feng: >> >> From: Yang Zhang [mailto:yang.zhang.wz@gmail.com] >> >> On 2015/12/22 14:59, Wu, Feng wrote: >> >> >> From: Yang Zhang [mailto:yang.zhang.wz@gmail.com] >> >> >>>>>> On 2015/12/16 9:37, Feng Wu wrote: >> The case is undefined if some targeted LAPICs weren't hardware enabled >> as no interrupts can be delivered to hardware disabled LAPIC, so we can >> check for hardware enabled. >> >> It's not obvious if "enabled to receive the interrupt" means hardware or >> software enabled, but lowest priority cannot deliver NMI/INIT/..., so >> checking for software enabled doesn't restrict any valid uses either. >> >> so ... KVM only musn't blow up when encountering this situation :) >> >> The current code seems correct, but redundant. Just for reference, KVM >> now does: >> - check for software enabled LAPIC since patch aefd18f01ee8 ("KVM: x86: >> In DM_LOWEST, only deliver interrupts to vcpus with enabled LAPIC's") >> - check only for hardware enabled LAPIC in the fast path, since >> 1e08ec4a130e ("KVM: optimize apic interrupt delivery")) > > Software enabled LAPIC is also checked in patch 1e08ec4a130e > ("KVM: optimize apic interrupt delivery"), however, it was removed > in patch 3b5a5ffa928a3f875b0d5dd284eeb7c322e1688a. Right, thanks. (The software check was actually removed in 173beedc1601 ("KVM: x86: Software disabled APIC should still deliver NMIs"), which introduced a two pass mechanism that was later simplified.) > Now I am > a little confused about the policy, when and where should we do > the software/hardware enabled check? It's a mess, I think we'd like both checks to be done early and ideally only in one place. The fast path would like to precompute as much as possible, but only hardware enabled affects all interrupts (like non-present LAPIC); software disabled still needs an extra condition for every interrupt. >> I'd pick whatever results in less code: this time it seems like checking >> for hardware enabled LAPIC in both paths (implicitly in the fast path). >> Maybe it can be done better, I haven't given it much thought. >> >> We should revert aefd18f01ee8 at the same time, so our PI/non-PI slow >> paths won't diverge -- I hope it wasn't fixing a bug :) > > From the change log, It seems to me this patch was fixing a bug. Yeah, I found the original discussion RFC: http://www.spinics.net/lists/kvm/msg36190.html v1: http://www.spinics.net/lists/kvm/msg36395.html v2: http://www.spinics.net/lists/kvm/msg36651.html that led to some explanation in bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=596223 (a clone of https://bugzilla.redhat.com/show_bug.cgi?id=505527) It seems that kexec on VCPU != 0 did something with BSP APIC ID that resulted in a wrong delivery -- I didn't look where the bug was, but the solution we adopted is probably just a lucky workaround. Makes sense to look deeper into it. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/