[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/2] x86/mem_sharing: Add extra variable to track fork progress


  • To: Tamas K Lengyel <tamas@xxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 15 Feb 2023 12:03:13 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Af/TppUQveJ+dDVFLzwK5u9KrW5Y/LaBTHeydlg9KeM=; b=GbOg2ZGs3sCu30jXLK3uH9uzeWZ212YsxhvUhxTOhHcmKa8Ogk0/4GzFkVZBtJSMosBZzvbJL6r+zxaRH5ZGeVoC3tUzzlIG/MUhqzLWpxMmZalExnvgcbcwXbIWFGFnzfadwnc2xshnEoirj6+HJufizda+ev7GWxtkoXnG6KRCKgGtuG04RiVodON+Ezcw3F10scJ+BBPmOLeuiVPqGZNCqnx/k3KmNejSUonV1/CxUe9z6eUErCwHOCQoJ/cHLMGj4rnt/V/76NJ8FTYEyOFfHlSTTORIRbJ089HH/t76XsN01sBlToRYouL+Yq7ISD2FYNxkwfFV2gD9liE0VA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CFco3KyyQRLQmTi3d6OvU4plBR5V/T2ZtWc9Ssgt24M4rf4yCmIIpLgMOmLKuFq+D0lUmmkTHICb1j0oJF46ZcmHPseXHGPCkoBOcFX+LbDhPkxB0Po6i7zL35keWS8ah0uqJjLqW2O+0+BAm9tslKGwi0PzpstYxcQ5vB+WS5IRkiDPJVLzD0rhbPV5XKkpc6GnZp7V6zd0G+4CfAdflY3XfCVEyhS9bXMhOOvzee49t4Bmz4szxYuNbeoe+kHRlr1ZPI6OJZhkELyIZ27P2vNfDPXOw9mHbIpqB6Yw4kmyYYybXXyQt72U5FcIezzhX7b3AaUi6odxUEHdRIIvzg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 15 Feb 2023 11:04:16 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 14.02.2023 06:07, Tamas K Lengyel wrote:
> When VM forking is initiated a VM is not supposed to try to perform 
> mem_sharing
> yet as the fork process hasn't completed all required steps. However, the vCPU
> bring-up paths trigger guest memory accesses that can lead to such premature
> sharing ops. However, the gating check to see whether a VM is a fork is set
> already (ie. the domain has a parent).

I find this confusing, and I had to read the patch to understand what's
meant. Since there are a total of three VMs involved here (the one
driving the fork, the one being forked, and the new clone), "a VM" is
insufficient. The sentence further reads as if that VM is performing
sharing operations on itself, which according to my understanding is
impossible.

Furthermore "the vCPU bringup paths" is also not specific enough imo.
The forked VM as well as the new clone are both paused if I'm not
mistaken, so neither can be in the process of bringing up any vCPU-s.
I assume you refer to bring_up_vcpus(), but I'm afraid I view this
function as misnamed. vCPU-s are being _created_ there, not brought up.
Furthermore there are no guest memory accesses from underneath
bring_up_vcpus(), so with those accesses you may be referring to
copy_settings() instead? Which in turn - I'm sorry for my ignorance -
raises the question why (implicit) hypervisor side accesses to guest
memory might trigger sharing: So far I was working from the assumption
that it's only control tool requests which do. Otoh you talk of
"sharing ops", which suggests it may indeed be requests coming from
the control tool. Yet that's also what invoked the request to fork,
so shouldn't it coordinate with itself and avoid issuing sharing ops
prematurely?

> --- a/xen/arch/x86/include/asm/hvm/domain.h
> +++ b/xen/arch/x86/include/asm/hvm/domain.h
> @@ -33,6 +33,14 @@ struct mem_sharing_domain
>  {
>      bool enabled, block_interrupts;
>  
> +    /*
> +     * We need to avoid trying to nominate pages for forking until the
> +     * fork operation is completely finished. As parts of fork creation
> +     * is restartable we mark here if the process started to skip the
> +     * non-restartable portion.
> +     */
> +    bool fork_started;

"non-restartable portion" reads incorrect to me: The issue there is with
that portion being one-time initialization. I think this should also be
said this way. Furthermore (nit) it wants to be either "parts" and "are"
or "part" and "is", and I think a comma after "started" would help
readability (or else it can be read as "the process started to skip
<whatever>"). Finally maybe better "... this flag indicates that ..."
(in particular because we definitely do not mark here, but in fork()).

> @@ -1905,7 +1906,7 @@ static int fork(struct domain *cd, struct domain *d)
>          *cd->arch.cpuid = *d->arch.cpuid;
>          *cd->arch.msr = *d->arch.msr;
>          cd->vmtrace_size = d->vmtrace_size;
> -        cd->parent = d;
> +        msd->fork_started = 1;

"true" please (and "false" below).

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.