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 85732C3815B for ; Mon, 20 Apr 2020 15:51:51 +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 5EA87206DD for ; Mon, 20 Apr 2020 15:51:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5EA87206DD 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.89) (envelope-from ) id 1jQYhv-0006E9-Ea; Mon, 20 Apr 2020 15:51:39 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jQYhu-0006E4-DV for xen-devel@lists.xenproject.org; Mon, 20 Apr 2020 15:51:38 +0000 X-Inumbo-ID: d140ef0c-831e-11ea-b4f4-bc764e2007e4 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d140ef0c-831e-11ea-b4f4-bc764e2007e4; Mon, 20 Apr 2020 15:51:37 +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 BA58EAD49; Mon, 20 Apr 2020 15:51:35 +0000 (UTC) Subject: Re: [PATCH v15 1/3] mem_sharing: don't reset vCPU info page during fork reset To: Tamas K Lengyel References: <20200420074516.GQ28601@Air-de-Roger> <686dafe9-54f6-3224-d2ff-8cfb99734b2c@suse.com> From: Jan Beulich Message-ID: Date: Mon, 20 Apr 2020 17:51:34 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Tamas K Lengyel , Wei Liu , Andrew Cooper , George Dunlap , Xen-devel , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On 20.04.2020 16:27, Tamas K Lengyel wrote: > On Mon, Apr 20, 2020 at 8:19 AM Jan Beulich wrote: >> >> On 20.04.2020 16:15, Tamas K Lengyel wrote: >>> On Mon, Apr 20, 2020 at 1:45 AM Roger Pau Monné wrote: >>>> >>>> On Fri, Apr 17, 2020 at 10:06:31AM -0700, Tamas K Lengyel wrote: >>>>> When a forked VM is being reset while having vm_events active, re-copying the >>>>> vCPU info page can lead to events being lost. This seems to only affect a >>>>> subset of events (interrupts), while not others (cpuid, MTF, EPT) thus it was >>>> >>>> I'm slightly lost by the sentence, is the guest or the hypervisor >>>> the one losing events? >>>> >>>> Ie: interrupts are events from a guest PoV, but cpuid or EPT is not >>>> something that triggers events that are injected to the guest. I think >>>> the commit message needs clarification. >>> >>> Sorry, what I meant was software interrupts are not triggered anymore, >>> ie. int3 and it's associated event is not sent to the monitor >>> application (VM_EVENT_REASON_SOFTWARE_BREAKPOINT). >>> >>>> >>>>> not discovered beforehand. Only copying vCPU info page contents during initial >>>>> fork fixes the problem. >>>> >>>> Hm, I'm not sure I understand why this is causing issues. When you >>>> reset a fork you should reset the vcpu info page, or else event masks would >>>> be in a wrong state? >>> >>> When we reset a fork we only want to 1) discard any memory allocated >>> for it 2) reset the vCPU registers. We don't want to reset event >>> channels or anything else. We have active vm_events on the domain and >>> the whole point of doing a fork reset is to avoid having to >>> reinitialize all that as it's quite slow. >> >> So for an arbitrary piece of state, what are the criteria to establish >> whether to copy or re-init them during a fork? Is it really now and >> forever only memory that wants resetting? I have to admit I'm confused >> by you also mentioning CPU registers - aren't they to be copied rather >> than reset? > > Registers are being reset by copying them from the parent. Allocated > memory is discarded as the memory that's needed for the new execution > will get copied when EPT faults happen as it's executing. The goal is > to put the domain back to its initial execution state without having > to reinitialize vm_events. In our experiments when the forks are > executed only for a very short period (fuzzing), having to > reinitialize the vm_event interfaces mean going from ~100 execution/s > to ~2 executions/s. Unfortunately in the current state the fork > doesn't generate the required vm_events after the first execution and > for some reason it only happens for int3 generated events. Thanks, but I'm afraid this doesn't answer my question regarding the criteria for what should be put back to the fork's initial state vs what should be left as is. In fact _anything_ not getting reset to initial state would seem to need special justification (beyond performance considerations). Jan