xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Zhongze Liu <blackskygg@gmail.com>
To: Wei Liu <wei.liu2@citrix.com>
Cc: Tim Deegan <tim@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	xen-devel@lists.xen.org, Julien Grall <julien.grall@arm.com>,
	Jan Beulich <jbeulich@suse.com>
Subject: Re: [PATCH v2 5/6] libxl: support mapping static shared memory areas during domain creation
Date: Sat, 2 Sep 2017 01:49:32 +0800	[thread overview]
Message-ID: <CAHrd_jqaAhdSQtH7zHfopz1u=cEB2_VmMr4W5ax5SGRoy37RGQ@mail.gmail.com> (raw)
In-Reply-To: <20170901162307.jcyegg72xqg5bke3@citrix.com>

Hi Wei,

Thanks for reviewing.

2017-09-02 0:23 GMT+08:00 Wei Liu <wei.liu2@citrix.com>:
> On Sun, Aug 27, 2017 at 04:36:14PM +0800, Zhongze Liu wrote:
>> Add libxl__sshm_add to map shared pages from one DomU to another, The mapping
>> process involves the follwing steps:
>>
>>   * Set defaults and check for further errors in the static_shm configs:
>>     overlapping areas, invalid ranges, duplicated master domain,
>>     no master domain etc.
>>   * Write infomation of static shared memory areas into the appropriate
>>     xenstore paths.
>>   * Use xc_domain_add_to_physmap_batch to do the page sharing.
>>   * Set the refcount of the shared region accordingly
>>
>> Temporarily mark this as unsupported on x86 because calling p2m_add_foregin on
>> two domU's is currently not allowd on x86 (see the comments in
>> x86/mm/p2m.c:p2m_add_foregin for more details).
>>
>> This is for the proposal "Allow setting up shared memory areas between VMs
>> from xl config file" (see [1]).
>>
>> [1] https://lists.xen.org/archives/html/xen-devel/2017-08/msg03242.html
>>
>> Signed-off-by: Zhongze Liu <blackskygg@gmail.com>
> [...]
>> +
>> +        rc = libxl__xs_read_checked(gc, xt,
>> +                                    GCSPRINTF("%s/master", sshm_path),
>> +                                    &xs_value);
>> +        if (rc) goto out;
>> +        master_domid = strtoull(xs_value, NULL, 16);
>> +
>> +        if (sshm->prot == LIBXL_SSHM_PROT_UNKNOWN) {
>> +            sshm->prot = master_sshm.prot;
>> +        }
>> +        /* check if the slave is asking too much permission */
>> +        if (master_sshm.prot < sshm->prot) {
>> +            SSHM_ERROR(domid, sshm->id, "slave is asking too much permission.");
>> +            rc = ERROR_INVAL;
>> +            goto out;
>> +        }
>> +
>> +        /* all checks passed, do the job */
>> +        if (!isretry) {
>> +            rc = libxl__sshm_do_map(gc, master_domid, domid, sshm,
>> +                                    master_sshm.begin, master_sshm.end);
>> +            if (rc) goto out;
>
> You probably need to roll back the mapping should the transaction gets
> aborted in this loop.

OK. I'll move the rollback code to the abort path.

>
>> +        }
>> +
>> +        /* write the result to xenstore and commit */
>> +        rc = libxl__xs_write_checked(gc, xt, dom_role_path, "slave");
>> +        if (rc) goto out;
>> +        rc = libxl__xs_writev(gc, xt, slave_path, ents);
>> +        if (rc) goto out;
>> +        rc = libxl__sshm_incref(gc, xt, sshm_path);
>> +        if (rc) goto out;
>> +
>> +        rc = libxl__xs_transaction_commit(gc, &xt);
>> +        if (!rc) break;
>> +        if (rc < 0) goto out;
>> +        isretry = true;
>> +    }
>> +
>> +    rc = 0;
>> +out:
>> +    libxl__xs_transaction_abort(gc, &xt);
>> +    return rc;
>> +}
>> +
>> +static int libxl__sshm_add_master(libxl__gc *gc, uint32_t domid,
>> +                                  libxl_static_shm *sshm)
>> +{
>> +
>
> No refcount increment here?

For every sshm ID, this will be called only once. And in the xenstore
ents array, I've  already
set "users = 1", so there's no need to call libxl__sshm_incref().


Cheers,

Zhongze Liu

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2017-09-01 17:49 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-27  8:36 [PATCH v2 0/6] Allow setting up shared memory areas between VMs from xl config files Zhongze Liu
2017-08-27  8:36 ` [PATCH v2 1/6] libxc: add xc_domain_remove_from_physmap to wrap XENMEM_remove_from_physmap Zhongze Liu
2017-08-27  8:36 ` [PATCH v2 2/6] libxl: introduce a new structure to represent static shared memory regions Zhongze Liu
2017-08-27  8:36 ` [PATCH v2 3/6] libxl:xl: add parsing code to parse "libxl_static_sshm" from xl config files Zhongze Liu
2017-09-01 16:03   ` Wei Liu
2017-09-01 17:56     ` Zhongze Liu
2017-09-05 13:10       ` Wei Liu
2017-09-01 16:25   ` Wei Liu
2017-08-27  8:36 ` [PATCH v2 4/6] xsm: flask: change the dummy xsm policy and flask hook for map_gmfn_foregin Zhongze Liu
2017-08-28  8:29   ` Jan Beulich
2017-08-28 11:01     ` Zhongze Liu
2017-08-28 11:18       ` Jan Beulich
2017-08-28 14:24     ` George Dunlap
2017-08-28 14:53       ` Jan Beulich
2017-08-27  8:36 ` [PATCH v2 5/6] libxl: support mapping static shared memory areas during domain creation Zhongze Liu
2017-09-01 16:23   ` Wei Liu
2017-09-01 17:49     ` Zhongze Liu [this message]
2017-08-27  8:36 ` [PATCH v2 6/6] libxl: support unmapping static shared memory areas during domain destruction Zhongze Liu
2017-10-10 23:55 ` [PATCH v2 0/6] Allow setting up shared memory areas between VMs from xl config files Stefano Stabellini
2017-10-11  8:26   ` Zhongze Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHrd_jqaAhdSQtH7zHfopz1u=cEB2_VmMr4W5ax5SGRoy37RGQ@mail.gmail.com' \
    --to=blackskygg@gmail.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).