From: Ian Campbell <ian.campbell@citrix.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov>,
wei.liu2@citrix.com, xen-devel@lists.xen.org
Subject: Re: [PATCH XEN v6 25/32] tools/libs/gnttab: Extensive updates to API documentation.
Date: Fri, 11 Dec 2015 17:14:06 +0000 [thread overview]
Message-ID: <1449854046.30975.78.camel@citrix.com> (raw)
In-Reply-To: <1449680885.9759.34.camel@citrix.com>
On Wed, 2015-12-09 at 17:08 +0000, Ian Campbell wrote:
> On Wed, 2015-12-09 at 16:28 +0000, Ian Jackson wrote:
> > Ian Campbell writes ("Re: [PATCH XEN v6 25/32] tools/libs/gnttab:
> > Extensive updates to API documentation."):
> > > On Wed, 2015-12-09 at 16:09 +0000, Ian Jackson wrote:
> > > > Is this actually true ? Normally close() on an fd does not munmap
> > > > anything mmapped from the fd.
> > >
> > > Uh yes, I was talking rubbish here, unless the drivers are more magic
> > > than
> > > I think they are.
> > >
> > > So what is the answer? That such memory is wasted and irrecovable
> > > until
> > > exec?
> >
> > I don't know. What would happen if you munmapped it ?
>
> We discussed all this IRL and concluded after much back and forth that
> there is nothing we can do here other than require a call to each relevant
> library's _close() method by callers of fork() who do not exec but who care
> about the (usually modest) resources consumed by these sorts of mappings.
>
> The _close call after fork should be documented as potentially not actually
> achieving anything and we decided to treat this as a future bug if/when it
> has a real world impact by fixing.
Here is what I cam up with.
/*
* Returns a handle onto the grant table driver. Logs errors.
*
* Note: After fork(2) a child process must not use any opened gnttab
* handle inherited from their parent, nor access any grant mapped
* areas associated with that handle.
*
* The child must open a new handle if they want to interact with
* gnttab.
*
* Calling exec(2) in a child will safely (and reliably) reclaim any
* allocated resources via a xengnttab_handle in the parent.
*
* A child which does not call exec(2) may safely call
* xengnttab_close() on a xengnttab_handle inherited from their
* parent. This will attempt to reclaim any resources associated with
* that handle. Note that in some implementations this reclamation may
* not be completely effective, in this case any affected resources
* remain allocated.
*
* Calling xengnttab_close() is the only safe operation on a
* xengnttab_handle which has been inherited.
*/
I'm currently intending to write something very similar for each of the
xen*_open (gntshr, gnttab, foreignmemory, evtchn and probably call too)
functions. I don't really like repeating the same thing like this, but I
also don't really like API documentation which makes you play follow the
piece of string to the docs of other libraries to find out what is going
on.
I'm also considering whether on the _close function I should write
something to the effect that in non-forked contexts the application should
call the associated _unmap() on any active mappings before calling _close()
in order to ensure all resources have been freed. And reiterate that
calling _unmap after fork() is not safe.
Ian.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2015-12-11 17:14 UTC|newest]
Thread overview: 134+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-03 11:21 [Qemu-devel] [Minios-devel] [PATCH v6 0/<VARIOUS>] Begin to disentangle libxenctrl and provide some stable libraries Ian Campbell
2015-12-03 11:21 ` [PATCH XEN v6 00/32] " Ian Campbell
2015-12-03 11:21 ` [PATCH XEN v6 01/32] x86/libxc: add an arch domain config parameter to xc_domain_create Ian Campbell
2015-12-09 12:21 ` Wei Liu
2015-12-03 11:21 ` [PATCH XEN v6 02/32] mce-test: do not include libxenguest internal headers Ian Campbell
2015-12-03 12:48 ` Andrew Cooper
2015-12-09 12:22 ` Wei Liu
2015-12-03 11:22 ` [PATCH XEN v6 03/32] tools/ocaml: simplify compile/link of test apps Ian Campbell
2015-12-03 11:59 ` David Scott
2015-12-09 12:22 ` Wei Liu
2015-12-03 11:22 ` [PATCH XEN v6 04/32] tools/Rules.mk: Properly handle libraries with recursive dependencies Ian Campbell
2015-12-03 11:22 ` [PATCH XEN v6 05/32] tools: Refactor "xentoollog" into its own library Ian Campbell
2015-12-03 11:22 ` [PATCH XEN v6 06/32] tools/libxc: Remove osdep indirection for xc_evtchn Ian Campbell
2015-12-03 11:22 ` [PATCH XEN v6 07/32] tools: Refactor /dev/xen/evtchn wrappers into libxenevtchn Ian Campbell
2015-12-03 11:22 ` [PATCH XEN v6 08/32] tools: Arrange to check public headers for ANSI compatiblity Ian Campbell
2015-12-03 11:22 ` [PATCH XEN v6 09/32] tools/libxc: Remove osdep indirection for xc_gnt{shr, tab} Ian Campbell
2015-12-03 11:22 ` [PATCH XEN v6 10/32] tools: Refactor /dev/xen/gnt{dev, shr} wrappers into libxengnttab Ian Campbell
2015-12-14 14:07 ` Ian Campbell
2015-12-03 11:22 ` [PATCH XEN v6 11/32] tools/libxc: Remove osdep indirection for privcmd Ian Campbell
2015-12-03 11:22 ` [PATCH XEN v6 12/32] tools: Refactor hypercall calling wrappers into libxencall Ian Campbell
2015-12-03 11:22 ` [PATCH XEN v6 13/32] tools/libxc: drop xc_map_foreign_bulk_compat wrappers Ian Campbell
2015-12-03 11:22 ` [PATCH XEN v6 14/32] tools: Remove xc_map_foreign_batch Ian Campbell
2015-12-09 12:22 ` Wei Liu
2015-12-10 15:21 ` George Dunlap
2015-12-11 15:42 ` Ian Campbell
2015-12-11 16:04 ` George Dunlap
2015-12-03 11:22 ` [PATCH XEN v6 15/32] tools: Implement xc_map_foreign_range(s) in terms of common helper Ian Campbell
2015-12-03 11:22 ` [PATCH XEN v6 16/32] tools: Refactor foreign memory mapping into libxenforeignmemory Ian Campbell
2015-12-09 15:38 ` Ian Jackson
2015-12-03 11:22 ` [PATCH XEN v6 17/32] tools/libs/foreignmemory: provide xenforeignmemory_unmap Ian Campbell
2015-12-09 15:38 ` Ian Jackson
2015-12-03 11:22 ` [PATCH XEN v6 18/32] tools/libs/foreignmemory: use size_t for size arguments Ian Campbell
2015-12-03 11:22 ` [PATCH XEN v6 19/32] tools/libs/foreignmemory: Mention restrictions on fork in docs Ian Campbell
2015-12-03 11:22 ` [PATCH XEN v6 20/32] tools/libs/foreignmemory: Support err == NULL to map Ian Campbell
2015-12-09 12:22 ` Wei Liu
2015-12-09 12:31 ` Egger, Christoph
2015-12-09 12:45 ` Ian Campbell
2015-12-09 12:41 ` Ian Campbell
2015-12-09 12:56 ` Wei Liu
2015-12-09 13:15 ` Ian Campbell
2015-12-09 16:16 ` Wei Liu
2015-12-09 15:40 ` Ian Jackson
2015-12-03 11:22 ` [PATCH XEN v6 21/32] tools/libs/foreignmemory: pull array length argument to map forward Ian Campbell
2015-12-09 12:22 ` Wei Liu
2015-12-09 15:41 ` Ian Jackson
2015-12-03 11:22 ` [PATCH XEN v6 22/32] tools/libs/foreignmemory: optimise map(num==1, err==NULL) case Ian Campbell
2015-12-09 15:42 ` Ian Jackson
2015-12-11 15:56 ` Ian Campbell
2015-12-03 11:22 ` [PATCH XEN v6 23/32] tools/libs/evtchn: Review and update doc comments Ian Campbell
2015-12-03 11:22 ` [PATCH XEN v6 24/32] tools/libs: Clean up hard tabs Ian Campbell
2015-12-03 11:22 ` [PATCH XEN v6 25/32] tools/libs/gnttab: Extensive updates to API documentation Ian Campbell
2015-12-03 18:08 ` Daniel De Graaf
2015-12-04 10:06 ` Ian Campbell
2015-12-09 12:41 ` Wei Liu
2015-12-09 13:00 ` Ian Campbell
2015-12-09 13:37 ` Wei Liu
2015-12-09 13:50 ` Andrew Cooper
2015-12-09 14:03 ` Ian Campbell
2015-12-09 16:14 ` Ian Jackson
2015-12-09 16:09 ` Ian Jackson
2015-12-09 16:25 ` Ian Campbell
2015-12-09 16:28 ` Ian Jackson
2015-12-09 17:08 ` Ian Campbell
2015-12-11 17:14 ` Ian Campbell [this message]
2015-12-11 17:19 ` Ian Jackson
2015-12-11 17:35 ` Ian Campbell
2015-12-14 11:29 ` Ian Campbell
2015-12-14 11:55 ` Ian Jackson
2015-12-03 11:22 ` [PATCH XEN v6 26/32] tools/libs/call: Update some log messages to not refer to xc Ian Campbell
2015-12-03 11:22 ` [PATCH XEN v6 27/32] tools/libs/call: Describe return values and error semantics for xencall* Ian Campbell
2015-12-09 12:22 ` Wei Liu
2015-12-09 16:15 ` Ian Jackson
2015-12-03 11:22 ` [PATCH XEN v6 28/32] tools/libs/call: Avoid xc_memalign in netbsd and solaris backends Ian Campbell
2015-12-03 11:22 ` [PATCH XEN v6 29/32] tools/libs/call: Use O_CLOEXEC when opening /dev/xen/privcmd on Linux Ian Campbell
2015-12-09 12:22 ` Wei Liu
2015-12-09 16:17 ` Ian Jackson
2015-12-11 17:22 ` Ian Campbell
2015-12-12 10:55 ` Roger Pau Monné
2015-12-03 11:22 ` [PATCH XEN v6 30/32] tools/libs/call: linux: avoid forking between mmap and madvise Ian Campbell
2015-12-09 12:22 ` Wei Liu
2015-12-09 16:18 ` Ian Jackson
2015-12-11 17:16 ` Ian Campbell
2015-12-03 11:22 ` [PATCH XEN v6 31/32] tools: Update CFLAGS for qemu-xen to allow it to use new libraries Ian Campbell
2015-12-03 11:22 ` [PATCH XEN v6 32/32] HACK: Update Config.mk to pull all the right bits from my xenbits trees Ian Campbell
2015-12-03 11:23 ` [PATCH QEMU-XEN v6 0/8] Begin to disentangle libxenctrl and provide some stable libraries Ian Campbell
2015-12-03 11:23 ` [Qemu-devel] " Ian Campbell
2015-12-03 11:23 ` [Qemu-devel] [PATCH QEMU-XEN v6 1/8] xen_console: correctly cleanup primary console on teardown Ian Campbell
2015-12-03 11:23 ` Ian Campbell
2015-12-03 11:23 ` [Qemu-devel] [PATCH QEMU-XEN v6 2/8] xen: Switch to libxenevtchn interface for compat shims Ian Campbell
2015-12-03 11:23 ` Ian Campbell
2015-12-03 11:23 ` [Qemu-devel] [PATCH QEMU-XEN v6 3/8] xen: Switch to libxengnttab " Ian Campbell
2015-12-03 11:23 ` Ian Campbell
2015-12-03 11:23 ` [Qemu-devel] [PATCH QEMU-XEN v6 4/8] xen: Switch uses of xc_map_foreign_range into xc_map_foreign_pages Ian Campbell
2015-12-03 11:23 ` Ian Campbell
2015-12-04 15:26 ` Stefano Stabellini
2015-12-04 15:26 ` [Qemu-devel] " Stefano Stabellini
2015-12-09 13:41 ` Ian Campbell
2015-12-09 13:56 ` [Qemu-devel] [Xen-devel] " Andrew Cooper
2015-12-09 14:05 ` Ian Campbell
2015-12-09 14:05 ` Ian Campbell
2015-12-09 13:56 ` Andrew Cooper
2015-12-11 14:26 ` Stefano Stabellini
2015-12-11 14:26 ` [Qemu-devel] " Stefano Stabellini
2015-12-11 15:23 ` Ian Campbell
2015-12-11 15:23 ` Ian Campbell
2015-12-11 16:42 ` [Qemu-devel] " Stefano Stabellini
2015-12-11 16:42 ` Stefano Stabellini
2015-12-09 13:41 ` Ian Campbell
2015-12-03 11:23 ` [Qemu-devel] [PATCH QEMU-XEN v6 5/8] xen: Switch uses of xc_map_foreign_{pages, bulk} to use libxenforeignmemory API Ian Campbell
2015-12-03 11:23 ` Ian Campbell
2015-12-04 15:26 ` Stefano Stabellini
2015-12-04 15:26 ` [Qemu-devel] " Stefano Stabellini
2015-12-03 11:23 ` [Qemu-devel] [PATCH QEMU-XEN v6 6/8] xen: Use stable library interfaces when they are available Ian Campbell
2015-12-04 15:31 ` Stefano Stabellini
2015-12-04 15:31 ` [Qemu-devel] " Stefano Stabellini
2015-12-03 11:23 ` Ian Campbell
2015-12-03 11:23 ` [Qemu-devel] [PATCH QEMU-XEN v6 7/8] xen: domainbuild: reopen libxenctrl interface after forking for domain watcher Ian Campbell
2015-12-03 11:23 ` Ian Campbell
2015-12-03 11:23 ` [Qemu-devel] [PATCH QEMU-XEN v6 8/8] xen: make it possible to build without the Xen PV domain builder Ian Campbell
2015-12-03 11:23 ` Ian Campbell
2015-12-03 11:23 ` [PATCH QEMU-XEN-TRADITIONAL v6 0/5] Begin to disentangle libxenctrl and provide some stable libraries Ian Campbell
2015-12-03 11:23 ` [PATCH QEMU-XEN-TRADITIONAL v6 1/5] qemu-xen-traditional: Use xentoollog as a separate library Ian Campbell
2015-12-03 11:23 ` [PATCH QEMU-XEN-TRADITIONAL v6 2/5] qemu-xen-traditional: Use libxenevtchn Ian Campbell
2015-12-03 11:23 ` [PATCH QEMU-XEN-TRADITIONAL v6 3/5] qemu-xen-traditional: Use libxengnttab Ian Campbell
2015-12-03 11:23 ` [PATCH QEMU-XEN-TRADITIONAL v6 4/5] qemu-xen-traditional: Add libxencall to rpath-link Ian Campbell
2015-12-03 11:23 ` [PATCH QEMU-XEN-TRADITIONAL v6 5/5] qemu-xen-traditional: Add libxenforeignmemory " Ian Campbell
2015-12-03 11:23 ` [PATCH MINI-OS v6 0/5] Begin to disentangle libxenctrl and provide some stable libraries Ian Campbell
2015-12-03 11:23 ` [PATCH MINI-OS v6 1/5] mini-os: Include libxentoollog with libxc Ian Campbell
2015-12-03 11:23 ` [PATCH MINI-OS v6 2/5] mini-os: Include libxenevtchn " Ian Campbell
2015-12-03 11:23 ` [PATCH MINI-OS v6 3/5] mini-os: Include libxengnttab " Ian Campbell
2015-12-03 11:23 ` [PATCH MINI-OS v6 4/5] mini-os: Include libxencall " Ian Campbell
2015-12-03 11:23 ` [PATCH MINI-OS v6 5/5] mini-os: Include libxenforeignmemory " Ian Campbell
2015-12-09 12:37 ` [Qemu-devel] [Minios-devel] [PATCH v6 0/<VARIOUS>] Begin to disentangle libxenctrl and provide some stable libraries Ian Campbell
2015-12-09 12:37 ` 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=1449854046.30975.78.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.