Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7964C433E0 for ; Mon, 8 Jun 2020 09:25:22 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B97D3206A4 for ; Mon, 8 Jun 2020 09:25:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B97D3206A4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jiE1i-0007WI-28; Mon, 08 Jun 2020 09:25:06 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jiE1f-0007WD-Tj for xen-devel@lists.xenproject.org; Mon, 08 Jun 2020 09:25:03 +0000 X-Inumbo-ID: edf8ebc4-a969-11ea-96fb-bc764e2007e4 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id edf8ebc4-a969-11ea-96fb-bc764e2007e4; Mon, 08 Jun 2020 09:25:02 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A1682AE67; Mon, 8 Jun 2020 09:25:04 +0000 (UTC) Subject: Re: handle_pio looping during domain shutdown, with qemu 4.2.0 in stubdom To: paul@xen.org, 'Jan Beulich' , =?UTF-8?Q?=27Marek_Marczykowski-G=c3=b3recki=27?= , 'Ian Jackson' References: <4dcc0092-6f6d-5d63-06cb-15b2fec244db@suse.com> <20200604142542.GC98582@mail-itl> <3b4dbb2f-7a0a-29a8-cca7-0cb641e8338d@suse.com> <000501d63b29$496ce6e0$dc46b4a0$@xen.org> <002001d63b3e$7c268a40$74739ec0$@xen.org> <002e01d63b4f$914b3a90$b3e1afb0$@xen.org> <20200605161804.GJ98582@mail-itl> <002701d63d75$6363a130$2a2ae390$@xen.org> From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Message-ID: <3811b700-7bd7-859a-2c84-a9885acf64a1@suse.com> Date: Mon, 8 Jun 2020 11:24:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <002701d63d75$6363a130$2a2ae390$@xen.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: 'Andrew Cooper' , 'xen-devel' Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On 08.06.20 11:15, Paul Durrant wrote: >> -----Original Message----- >> From: Jan Beulich >> Sent: 08 June 2020 09:14 >> To: 'Marek Marczykowski-Górecki' ; paul@xen.org >> Cc: 'Andrew Cooper' ; 'xen-devel' >> Subject: Re: handle_pio looping during domain shutdown, with qemu 4.2.0 in stubdom >> >> On 05.06.2020 18:18, 'Marek Marczykowski-Górecki' wrote: >>> On Fri, Jun 05, 2020 at 04:39:56PM +0100, Paul Durrant wrote: >>>>> From: Jan Beulich >>>>> Sent: 05 June 2020 14:57 >>>>> >>>>> On 05.06.2020 15:37, Paul Durrant wrote: >>>>>>> From: Jan Beulich >>>>>>> Sent: 05 June 2020 14:32 >>>>>>> >>>>>>> On 05.06.2020 13:05, Paul Durrant wrote: >>>>>>>> That would mean we wouldn't be seeing the "Unexpected PIO" message. From that message this >> clearly >>>>>>> X86EMUL_UNHANDLEABLE which suggests a race with ioreq server teardown, possibly due to selecting >> a >>>>>>> server but then not finding a vcpu match in ioreq_vcpu_list. >>>>>>> >>>>>>> I was suspecting such, but at least the tearing down of all servers >>>>>>> happens only from relinquish-resources, which gets started only >>>>>>> after ->is_shut_down got set (unless the tool stack invoked >>>>>>> XEN_DOMCTL_destroydomain without having observed XEN_DOMINF_shutdown >>>>>>> set for the domain). >>>>>>> >>>>>>> For individually unregistered servers - yes, if qemu did so, this >>>>>>> would be a problem. They need to remain registered until all vCPU-s >>>>>>> in the domain got paused. >>>>>> >>>>>> It shouldn't be a problem should it? Destroying an individual server is only done with the domain >>>>> paused, so no vcpus can be running at the time. >>>>> >>>>> Consider the case of one getting destroyed after it has already >>>>> returned data, but the originating vCPU didn't consume that data >>>>> yet. Once that vCPU gets unpaused, handle_hvm_io_completion() >>>>> won't find the matching server anymore, and hence the chain >>>>> hvm_wait_for_io() -> hvm_io_assist() -> >>>>> vcpu_end_shutdown_deferral() would be skipped. handle_pio() >>>>> would then still correctly consume the result. >>>> >>>> True, and skipping hvm_io_assist() means the vcpu internal ioreq state will be left set to >> IOREQ_READY and *that* explains why we would then exit hvmemul_do_io() with X86EMUL_UNHANDLEABLE (from >> the first switch). >>> >>> I can confirm X86EMUL_UNHANDLEABLE indeed comes from the first switch in >>> hvmemul_do_io(). And it happens shortly after ioreq server is destroyed: >>> >>> (XEN) d12v0 XEN_DMOP_remote_shutdown domain 11 reason 0 >>> (XEN) d12v0 domain 11 domain_shutdown vcpu_id 0 defer_shutdown 1 >>> (XEN) d12v0 XEN_DMOP_remote_shutdown domain 11 done >>> (XEN) d12v0 hvm_destroy_ioreq_server called for 11, id 0 >> >> Can either of you tell why this is? As said before, qemu shouldn't >> start tearing down ioreq servers until the domain has made it out >> of all shutdown deferrals, and all its vCPU-s have been paused. >> For the moment I think the proposed changes, while necessary, will >> mask another issue elsewhere. The @releaseDomain xenstore watch, >> being the trigger I would consider relevant here, will trigger >> only once XEN_DOMINF_shutdown is reported set for a domain, which >> gets derived from d->is_shut_down (i.e. not mistakenly >> d->is_shutting_down). > > I can't find anything that actually calls xendevicemodel_shutdown(). It was added by: destroy_hvm_domain() in qemu does. Juergen