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=-3.3 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS 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 AB30AC433DF for ; Mon, 8 Jun 2020 09:16:15 +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 77BAD206C3 for ; Mon, 8 Jun 2020 09:16:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U64EY8SK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 77BAD206C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.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 1jiDsi-0006dJ-7q; Mon, 08 Jun 2020 09:15:48 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jiDsh-0006dE-3I for xen-devel@lists.xenproject.org; Mon, 08 Jun 2020 09:15:47 +0000 X-Inumbo-ID: a28d304c-a968-11ea-9b55-bc764e2007e4 Received: from mail-wr1-x441.google.com (unknown [2a00:1450:4864:20::441]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id a28d304c-a968-11ea-9b55-bc764e2007e4; Mon, 08 Jun 2020 09:15:46 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id l11so16561539wru.0 for ; Mon, 08 Jun 2020 02:15:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:reply-to:to:cc:references:in-reply-to:subject:date:message-id :mime-version:content-transfer-encoding:content-language :thread-index; bh=t0yGidRJi7/PMf3lJefQZDlXr8CiQRn2DBjcPbG5Uz8=; b=U64EY8SKDU0M564SnMzFq8+T7uSBdQEMiDHTUxNiFdlfJTQ9aQOL8tFQHtMsALNjsH FuFi/tLQ+j7eGQH1LDSgwe4iVnRbdgXzzhnt8ZdOZ74pZX+IFsrSidAa2nOllXrDULiq OZNtFVjEiQCtBcRD2RhgjgQM5Om6CVQqig2sIfIbJhUqy1Eva/QzCxl+d8PUeGszFg+X rrK/HW5go6yqjSq0qRko9lfxBEU1DHl60x1GQcVs2jobFB5IQ/5Zs/LRHhxrNzCKG9lm uVzMR9/bBzJVh1Lj9gsLcSFUjYM2CFcSpbwVKJsm1sFvc4Wgn/BfBB45UECp73lCcLcL 4lVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:reply-to:to:cc:references:in-reply-to :subject:date:message-id:mime-version:content-transfer-encoding :content-language:thread-index; bh=t0yGidRJi7/PMf3lJefQZDlXr8CiQRn2DBjcPbG5Uz8=; b=Z3zBJKcwR3fqjRwVPQ4r/dqH1GDoPHvbF0CCk/p87oHdN9L8oYaGrTNzjYpQKDk5uG UuNY6tzp70r177dzdYwfhWA/zBOdPbtK13ckijLjz2ip0l6lps5qAT7TJevJhrRj1Znh UMc0wrtY63dN73zGtyRKeuGJHvz8TasVy2R42c4pA/U/5riszYq8zpbBnI9uL6kg8NsU oXUfEbLZRZX1GU8LUOg+vmAKkbnFctmvFAQWD4nlIq+TbyNsSpW4p1avljKYaWktsDRk KotKe7dw69IlgCl81llp1Uu0UbyQH32iHm9xk5NvgDeddmnO58rkWbRHwHsDsJ4sDwyQ 33tw== X-Gm-Message-State: AOAM532HtuYddCncstks4ZKfqi2SBacKbLAnTjEYfuFA1YQWZJN6jIVB HGCL31yaO0XlfFgxIhmCPyI= X-Google-Smtp-Source: ABdhPJwJqWLBywfxEES/B2CSTA6qmuaT2CDgLb/Uj11bGStuMlWi2wUvHInWgB7D7rqP2R9CvYD2vw== X-Received: by 2002:a05:6000:100e:: with SMTP id a14mr22184134wrx.349.1591607745252; Mon, 08 Jun 2020 02:15:45 -0700 (PDT) Received: from CBGR90WXYV0 ([54.239.6.187]) by smtp.gmail.com with ESMTPSA id p1sm22082382wrx.44.2020.06.08.02.15.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Jun 2020 02:15:44 -0700 (PDT) From: Paul Durrant X-Google-Original-From: "Paul Durrant" To: "'Jan Beulich'" , =?utf-8?Q?'Marek_Marczykowski-G=C3=B3recki'?= , "'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> In-Reply-To: Subject: RE: handle_pio looping during domain shutdown, with qemu 4.2.0 in stubdom Date: Mon, 8 Jun 2020 10:15:42 +0100 Message-ID: <002701d63d75$6363a130$2a2ae390$@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Content-Language: en-gb Thread-Index: AQCJ30jDNcpaWIG0GDXmJ4sF0URUNgF7hKHXArBYEOQB4r0ScAFGccUAApWxmk4BPtBDbAHi/U0vAkOVa4cCoqFkNAIjoGbrAeOG1z+qt1tb0A== 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: , Reply-To: paul@xen.org Cc: 'Andrew Cooper' , 'xen-devel' Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" > -----Original Message----- > From: Jan Beulich > Sent: 08 June 2020 09:14 > To: 'Marek Marczykowski-G=C3=B3recki' = ; paul@xen.org > Cc: 'Andrew Cooper' ; 'xen-devel' = > Subject: Re: handle_pio looping during domain shutdown, with qemu = 4.2.0 in stubdom >=20 > On 05.06.2020 18:18, 'Marek Marczykowski-G=C3=B3recki' 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 >=20 > 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: commit 1462f9ea8f4219d520a530787b80c986e050aa98 Author: Ian Jackson Date: Fri Sep 15 17:21:14 2017 +0100 tools: libxendevicemodel: Provide xendevicemodel_shutdown Signed-off-by: Ian Jackson Acked-by: Wei Liu Perhaps Ian can shed more light on it? Paul >=20 > Jan