From: Ian Campbell <ian.campbell@citrix.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>,
Daniel De Graaf <dgdegra@tycho.nsa.gov>
Cc: wei.liu2@citrix.com, xen-devel@lists.xen.org
Subject: Re: [PATCH XEN v5 07/23] tools: Refactor /dev/xen/gnt{dev, shr} wrappers into libxengnttab.
Date: Fri, 13 Nov 2015 15:02:04 +0000 [thread overview]
Message-ID: <1447426924.18450.171.camel@citrix.com> (raw)
In-Reply-To: <22083.22696.351853.213216@mariner.uk.xensource.com>
On Wed, 2015-11-11 at 15:03 +0000, Ian Jackson wrote:
> Ian Campbell writes ("[PATCH XEN v5 07/23] tools: Refactor
> /dev/xen/gnt{dev,shr} wrappers into libxengnttab."):
> > libxengnttab will provide a stable API and ABI for accessing the
> > grant table devices.
> >
> > The functions are moved into the xengnt{tab,shr} namespace to make a
> > clean break from libxc and avoid ambiguity regarding which interfaces
> > are stable.
>
> I have reviewed the API. Mostly this produced questions...
Yes, thanks this is the sort of feedback I was looking for before we call
this a stable interface.
Some of my answers are of the "yes, we should decide that" variety.
Daniel, I've added you because some of the questions below relate to the
notification mechanism and to gntshr which I don't really understand (not
that I really understand gnttab either).
> > XXX consider combining into a single namespace (i.e. with
> > xengnttab_handle having two open fd's in it on Linux)
>
> Arguments in favour of combining:
> * Some kernel might provide a single thing in /dev, and might even
> have trouble coping with a process which opens it more than once.
> * This is less fiddly for callers.
>
> Arguments against combining:
> * Perhaps some OSes will exist which can do only one and not the
> other. (Tenuous, and a workaround is possible.)
> * Slightly lower performance for a client which uses only one of the
> interfaces. (Barrel-scraping, here.)
> * It is more work.
>
> I conclude it would be better to unify them.
OK, I'm convinced.
> > +/*
> > + * Note:
> > + * After fork a child process must not use any opened xc gnttab
> > + * handle inherited from their parent. They must open a new handle if
> > + * they want to interact with xc.
>
> This should document
> (a) that it is safe to close the handle
> (b) that it is not safe to access grant mapped areas in the child
These two are easy.
> (c) how to reclaim the address space which is otherwise lost
The "obviously going to work, but probably not very useful" answer is you
should reclaim them before forking. That's clearly not practical in any
number of situations.
I really not sure what would happen if the child did a gnttab_close(). I
_think_ the kernel side ought to do the right thing (in that my opinion is
that really it should, and looking at the code it seems like it might).
Making a statement here that gnttab_close() is OK (and the right thing) to
do in the child might make the kernel driver insta-buggy. That might be
tolerable though, no one seems too be bothered by such bugs today and if
someone trips over them we can fix them.
> > +/**
> > + * Memory maps one or more grant references from one or more domains
> > to a
> > + * contiguous local address range. Mappings should be unmapped with
> > + * xengnttab_munmap. Logs errors.
> > + *
> > + * @parm xgt a handle on an open grant table interface
> > + * @parm count the number of grant references to be mapped
> > + * @parm domids an array of @count domain IDs by which the
> > corresponding @refs
> > + * were granted
> > + * @parm refs an array of @count grant references to be mapped
> > + * @parm prot same flag as in mmap()
> > + */
> > +void *xengnttab_map_grant_refs(xengnttab_handle *xgt,
>
> Should explain what happens on partial failure.
>
> > +/**
> > + * Memory maps one or more grant references from one domain to a
> > + * contiguous local address range. Mappings should be unmapped with
> > + * xengnttab_munmap. Logs errors.
> ...
> > +void *xengnttab_map_domain_grant_refs(xengnttab_handle *xgt,
>
> Should say that this is equivalent to a suitable call to
> xengnttab_map_grant_refs. (Assuming that it is.)
I believe so.
Which might argue for not having both, but I think avoiding the common case
of needing to provide an array full of the same domid makes it worthwhile
to have this.
> > +/**
> > + * Memory maps a grant reference from one domain to a local address
> > range.
> > + * Mappings should be unmapped with xengnttab_munmap. If notify_offset
> > or
> > + * notify_port are not -1, this version will attempt to set up an
> > unmap
> > + * notification at the given offset and event channel. When the page
> > is
> > + * unmapped, the byte at the given offset will be zeroed and a wakeup
> > will be
> > + * sent to the given event channel. Logs errors.
>
> What happens if the unmap notification cannot be set up ?
>
> Also "when the page is unmapped" makes it sound like you mean
> xengnttab_munmap but actually I think this is when the grant is
> withdrawn by the grantor ?
>
> If the grant is withdrawn by the grantor, does the page become
> unuseable immediately ? If so, how can anyone ever use this safely ?
Daniel, could you answer these ones please.
>
> > +/*
> > + * Sets the maximum number of grants that may be mapped by the given
> > instance
> > + * to @count. Never logs.
>
> Line wrap.
>
>
> > +int xengnttab_set_max_grants(xengnttab_handle *xgt,
> > + uint32_t count);
>
> Is count in pages or grants or what ?
It was hard to find this out, because the underlying ioctl doesn't exist in
the Linux side. In the end I found it is in grants as the name suggests.
AFAICT this is implemented only by linux-2.6.18-xen.hg and mini-os.git. We
could consider omitting it from the initial API. QEMU calls it but doesn't
care if it didn't work.
> > +/*
> > + * Return an fd onto the grant sharing driver. Logs errors.
>
> It does not return an fd.
Oh yes.
> (See also my comments on gntmap.)
I'm not sure which ones you mean here. If you meant gnttab then I'm still
not sure since you didn't comment on _open() there, but that's the only
commonality in the API.
>
> > +/*
> > + * Creates and shares pages with another domain.
> > + *
> ...
> > +void *xengntshr_share_pages(xengntshr_handle *xgs, uint32_t domid,
> > + int count, uint32_t *refs, int writable);
>
> Can this fail ? Can it partially succeed ?
Daniel?
>
> > +/*
> > + * Creates and shares a page with another domain, with unmap
> > notification.
> > + *
> > + * @parm xgs a handle to an open grant sharing instance
> > + * @parm domid the domain to share memory with
> > + * @parm refs the grant reference of the pages (output)
> > + * @parm writable true if the other domain can write to the page
> > + * @parm notify_offset The byte offset in the page to use for unmap
> > + * notification; -1 for none.
> > + * @parm notify_port The event channel port to use for unmap notify,
> > or -1
> > + * @return local mapping of the page
> > + */
> > +void *xengntshr_share_page_notify(xengntshr_handle *xgs, uint32_t
> > domid,
>
> What is this `unmap notification' ?
Daniel?
>
> > +/*
> > + * Unmaps the @count pages starting at @start_address, which were
> > mapped by a
> > + * call to xengntshr_share_*. Never logs.
>
> Linewrap in the comment.
>
> > + */
> > +int xengntshr_munmap(xengntshr_handle *xgs, void *start_address,
> > uint32_t count);
>
> What effect does this have on the peer ?
Daniel?
>
> Ian.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2015-11-13 15:02 UTC|newest]
Thread overview: 111+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-09 11:59 [Qemu-devel] [Minios-devel] [PATCH v4 0/<VARIOUS>] Begin to disentangle libxenctrl and provide some stable libraries Ian Campbell
2015-11-09 12:00 ` [PATCH XEN v5 00/23] " Ian Campbell
2015-11-09 12:00 ` [PATCH XEN v5 01/23] tools/Rules.mk: Properly handle libraries with recursive dependencies Ian Campbell
2015-11-09 12:00 ` [PATCH XEN v5 02/23] tools: Refactor "xentoollog" into its own library Ian Campbell
2015-11-13 15:05 ` Andrew Cooper
2015-11-13 15:35 ` Ian Campbell
2015-11-09 12:00 ` [PATCH XEN v5 03/23] tools/libxc: Remove osdep indirection for xc_evtchn Ian Campbell
2015-11-09 12:00 ` [PATCH XEN v5 04/23] tools: Refactor /dev/xen/evtchn wrappers into libxenevtchn Ian Campbell
2015-11-11 14:50 ` Ian Jackson
2015-11-09 12:00 ` [PATCH XEN v5 05/23] tools: Arrange to check public headers for ANSI compatiblity Ian Campbell
2015-11-09 12:00 ` [PATCH XEN v5 06/23] tools/libxc: Remove osdep indirection for xc_gnt{shr, tab} Ian Campbell
2015-11-09 12:00 ` [PATCH XEN v5 07/23] tools: Refactor /dev/xen/gnt{dev, shr} wrappers into libxengnttab Ian Campbell
2015-11-11 14:34 ` Wei Liu
2015-11-11 15:03 ` Ian Jackson
2015-11-13 15:02 ` Ian Campbell [this message]
2015-11-13 20:38 ` Daniel De Graaf
2015-11-16 12:30 ` Ian Campbell
2015-11-24 16:32 ` Daniel De Graaf
2015-11-23 17:05 ` Ian Campbell
2015-11-24 9:34 ` Ian Campbell
2015-11-25 15:06 ` Ian Campbell
2015-11-09 12:00 ` [PATCH XEN v5 08/23] tools/libxc: Remove osdep indirection for privcmd Ian Campbell
2015-11-09 12:00 ` [PATCH XEN v5 09/23] tools: Refactor hypercall calling wrappers into libxencall Ian Campbell
2015-11-11 15:08 ` Ian Jackson
2015-11-11 15:31 ` Wei Liu
2015-11-13 15:17 ` Ian Campbell
2015-11-13 15:16 ` Ian Campbell
2015-11-13 16:56 ` Ian Campbell
2015-11-13 16:57 ` Ian Campbell
2015-11-13 17:16 ` Roger Pau Monné
2015-11-13 17:23 ` Ian Campbell
2015-11-13 15:35 ` Andrew Cooper
2015-11-13 15:49 ` Andrew Cooper
2015-12-02 14:55 ` Ian Campbell
2015-11-09 12:00 ` [PATCH XEN v5 10/23] tools/libxc: drop xc_map_foreign_bulk_compat wrappers Ian Campbell
2015-11-09 12:00 ` [PATCH XEN v5 11/23] tools: Remove xc_map_foreign_batch Ian Campbell
2015-11-09 12:00 ` [PATCH XEN v5 12/23] tools: Implement xc_map_foreign_range(s) in terms of common helper Ian Campbell
2015-11-09 12:00 ` [PATCH XEN v5 13/23] tools: Refactor foreign memory mapping into libxenforeignmemory Ian Campbell
2015-11-11 15:13 ` Ian Jackson
2015-11-13 15:21 ` Ian Campbell
2015-11-13 15:27 ` Ian Jackson
2015-11-27 17:18 ` Ian Campbell
2015-11-27 17:48 ` Andrew Cooper
2015-11-29 9:54 ` Paul Durrant
[not found] ` <9AAE0902D5BC7E449B7C8E4E778ABCD02F69D32F@AMSPEX01CL01.citrite.net>
2015-11-30 9:51 ` Ian Campbell
[not found] ` <1448877118.15768.11.camel@citrix.com>
2015-12-01 10:16 ` Paul Durrant
2015-11-27 15:46 ` Ian Campbell
2015-11-09 12:00 ` [PATCH XEN v5 14/23] tools: foreignmemory: provide xenforeignmemory_unmap Ian Campbell
2015-11-11 15:14 ` Ian Jackson
2015-11-27 15:57 ` Ian Campbell
2015-11-13 16:16 ` Andrew Cooper
2015-11-13 16:17 ` Andrew Cooper
2015-11-09 12:00 ` [PATCH XEN v5 15/23] foreignmemory: use size_t for size arguments Ian Campbell
2015-11-11 15:15 ` Ian Jackson
2015-11-09 12:00 ` [PATCH XEN v5 16/23] tools/libs/evtchn: Review and update doc comments Ian Campbell
2015-11-11 15:15 ` Ian Jackson
2015-11-09 12:00 ` [PATCH XEN v5 17/23] tools/libs: Clean up hard tabs Ian Campbell
2015-11-09 12:00 ` [PATCH XEN v5 18/23] tools/libs/gnttab: Review and update doc comments Ian Campbell
2015-11-11 15:17 ` Ian Jackson
2015-11-09 12:00 ` [PATCH XEN v5 19/23] tools/libs/call: Update some log messages to not refer to xc Ian Campbell
2015-11-13 16:20 ` Andrew Cooper
2015-11-23 13:10 ` Ian Campbell
2015-11-09 12:00 ` [PATCH XEN v5 20/23] tools/libs/call: Avoid xc_memalign in netbsd and solaris backends Ian Campbell
2015-11-09 12:00 ` [PATCH XEN v5 21/23] tools/libs/foreignmemory: Mention restrictions on fork in docs Ian Campbell
2015-11-11 15:18 ` Ian Jackson
2015-11-09 12:00 ` [PATCH XEN v5 22/23] tools: Update CFLAGS for qemu-xen to allow it to use new libraries Ian Campbell
2015-11-09 12:00 ` [PATCH XEN v5 23/23] HACK: Update Config.mk to pull all the right bits from my xenbits trees Ian Campbell
2015-11-11 15:20 ` [PATCH XEN v5 00/23] Begin to disentangle libxenctrl and provide some stable libraries Ian Jackson
2015-11-09 12:01 ` [Qemu-devel] [PATCH QEMU-XEN v5 0/9] " Ian Campbell
2015-11-09 12:01 ` Ian Campbell
2015-11-09 12:01 ` [PATCH QEMU-XEN v5 1/9] xen_console: correctly cleanup primary console on teardown Ian Campbell
2015-11-09 12:01 ` [Qemu-devel] " Ian Campbell
2015-11-09 12:01 ` [Qemu-devel] [PATCH QEMU-XEN v5 2/9] xen: Switch to libxenevtchn interface for compat shims Ian Campbell
2015-11-09 12:01 ` Ian Campbell
2015-11-09 12:01 ` [Qemu-devel] [PATCH QEMU-XEN v5 3/9] xen: Switch to libxengnttab " Ian Campbell
2015-11-09 12:01 ` Ian Campbell
2015-11-10 14:02 ` Stefano Stabellini
2015-11-10 14:02 ` [Qemu-devel] " Stefano Stabellini
2015-11-09 12:01 ` [Qemu-devel] [PATCH QEMU-XEN v5 4/9] xen: Switch uses of xc_map_foreign_range into xc_map_foreign_bulk Ian Campbell
2015-11-09 12:01 ` Ian Campbell
2015-11-09 12:01 ` [Qemu-devel] [PATCH QEMU-XEN v5 5/9] xen: Switch uses of xc_map_foreign_pages " Ian Campbell
2015-11-09 12:01 ` Ian Campbell
2015-11-09 12:01 ` [PATCH QEMU-XEN v5 6/9] xen: Switch uses of xc_map_foreign_bulk to use libxenforeignmemory API Ian Campbell
2015-11-09 12:01 ` [Qemu-devel] " Ian Campbell
2015-11-09 12:01 ` [Qemu-devel] [PATCH QEMU-XEN v5 7/9] xen: Use stable library interfaces when they are available Ian Campbell
2015-11-10 14:00 ` Stefano Stabellini
2015-11-10 14:00 ` Stefano Stabellini
2015-11-09 12:01 ` Ian Campbell
2015-11-09 12:01 ` [Qemu-devel] [PATCH QEMU-XEN v5 8/9] xen: domainbuild: reopen libxenctrl interface after forking for domain watcher Ian Campbell
2015-11-09 12:01 ` Ian Campbell
2015-11-09 12:01 ` [Qemu-devel] [PATCH QEMU-XEN v5 9/9] xen: make it possible to build without the Xen PV domain builder Ian Campbell
2015-11-09 12:01 ` Ian Campbell
2015-11-10 12:48 ` [Qemu-devel] " Stefano Stabellini
2015-11-10 12:48 ` Stefano Stabellini
2015-11-09 12:01 ` [PATCH QEMU-XEN-TRADITIONAL v5 0/5] Begin to disentangle libxenctrl and provide some stable libraries Ian Campbell
2015-11-09 12:01 ` [PATCH QEMU-XEN-TRADITIONAL v5 1/5] qemu-xen-traditional: Use xentoollog as a separate library Ian Campbell
2015-11-09 12:01 ` [PATCH QEMU-XEN-TRADITIONAL v5 2/5] qemu-xen-traditional: Use libxenevtchn Ian Campbell
2015-11-11 15:19 ` Ian Jackson
2015-11-09 12:01 ` [PATCH QEMU-XEN-TRADITIONAL v5 3/5] qemu-xen-traditional: Use libxengnttab Ian Campbell
2015-11-11 15:20 ` Ian Jackson
2015-11-09 12:01 ` [PATCH QEMU-XEN-TRADITIONAL v5 4/5] qemu-xen-traditional: Add libxencall to rpath-link Ian Campbell
2015-11-11 15:20 ` Ian Jackson
2015-11-09 12:01 ` [PATCH QEMU-XEN-TRADITIONAL v5 5/5] qemu-xen-traditional: Add libxenforeignmemory " Ian Campbell
2015-11-11 15:21 ` Ian Jackson
2015-11-11 15:23 ` [PATCH QEMU-XEN-TRADITIONAL v5 0/5] Begin to disentangle libxenctrl and provide some stable libraries Ian Jackson
2015-11-09 12:01 ` [PATCH MINI-OS " Ian Campbell
2015-11-09 12:01 ` [PATCH MINI-OS v5 1/5] mini-os: Include libxentoollog with libxc Ian Campbell
2015-11-09 12:01 ` [PATCH MINI-OS v5 2/5] mini-os: Include libxenevtchn " Ian Campbell
2015-11-09 12:01 ` [PATCH MINI-OS v5 3/5] mini-os: Include libxengnttab " Ian Campbell
2015-11-09 12:01 ` [PATCH MINI-OS v5 4/5] mini-os: Include libxencall " Ian Campbell
2015-11-09 12:01 ` [PATCH MINI-OS v5 5/5] mini-os: Include libxenforeignmemory " Ian Campbell
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=1447426924.18450.171.camel@citrix.com \
--to=ian.campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=dgdegra@tycho.nsa.gov \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.