From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932735AbbD0MN4 (ORCPT ); Mon, 27 Apr 2015 08:13:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57453 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932353AbbD0MNm (ORCPT ); Mon, 27 Apr 2015 08:13:42 -0400 Message-ID: <553E27EF.4040505@redhat.com> Date: Mon, 27 Apr 2015 14:13:35 +0200 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: "Michael S. Tsirkin" , Julia Lawall CC: zhanghy@sangfor.com, jasowang@redhat.com, x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: KVM: x86: question about kvm_ioapic_destroy References: <20150427120342-mutt-send-email-mst@redhat.com> In-Reply-To: <20150427120342-mutt-send-email-mst@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/04/2015 12:05, Michael S. Tsirkin wrote: > On Sun, Apr 26, 2015 at 07:19:58PM +0200, Julia Lawall wrote: >> The function kvm_ioapic_destroy is defined as follows: >> >> void kvm_ioapic_destroy(struct kvm *kvm) >> { >> struct kvm_ioapic *ioapic = kvm->arch.vioapic; >> >> cancel_delayed_work_sync(&ioapic->eoi_inject); >> if (ioapic) { >> kvm_io_bus_unregister_dev(kvm, KVM_MMIO_BUS, &ioapic->dev); >> kvm->arch.vioapic = NULL; >> kfree(ioapic); >> } >> } >> >> Is there any way that cancel_delayed_work_sync can work if ioapic is NULL? >> Should the call be moved down under the NULL test? Or is the NULL test >> not needed? The NULL test has been there longer than the call to >> cancel_delayed_work_sync, which was introduced in 184564ef. > > I think the NULL test is not needed. > kvm_ioapic_destroy is only called if kvm_ioapic_init > completed successfully, and that sets kvm->arch.vioapic. Agreed. By the way, in that case the cancel_delayed_work_sync is really a nop. Paolo