All of lore.kernel.org
 help / color / mirror / Atom feed
* Who uses xc_gnttab_map_grant_refs?
@ 2008-07-16 14:40 Samuel Thibault
  2008-07-16 14:51 ` Derek Murray
  0 siblings, 1 reply; 7+ messages in thread
From: Samuel Thibault @ 2008-07-16 14:40 UTC (permalink / raw)
  To: xen-devel

Hello,

I wanted to map several grants at a time, and I found that
xc_gnttab_map_grant_refs permits that, but it requires you to fill a
domid array with the domids of each page.  Isn't just usually the same?
Or put another way, in which case would you want to contiguously map
pages from different domains?  It looks to me like the interface puts
burden on 99% usage case for little reason...

Samuel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Who uses xc_gnttab_map_grant_refs?
  2008-07-16 14:40 Who uses xc_gnttab_map_grant_refs? Samuel Thibault
@ 2008-07-16 14:51 ` Derek Murray
  2008-07-16 15:08   ` Samuel Thibault
  0 siblings, 1 reply; 7+ messages in thread
From: Derek Murray @ 2008-07-16 14:51 UTC (permalink / raw)
  To: Samuel Thibault, xen-devel

Mea culpa for that bit of API. I think this is a case where the
underlying implementation makes it possible, so I decided to make it
available through the user API. No particular reason for it, so I have
no objection to it being simplified (or wrapped by an additional API
function).

Regards,

Derek Murray.

On Wed, Jul 16, 2008 at 3:40 PM, Samuel Thibault
<samuel.thibault@eu.citrix.com> wrote:
> Hello,
>
> I wanted to map several grants at a time, and I found that
> xc_gnttab_map_grant_refs permits that, but it requires you to fill a
> domid array with the domids of each page.  Isn't just usually the same?
> Or put another way, in which case would you want to contiguously map
> pages from different domains?  It looks to me like the interface puts
> burden on 99% usage case for little reason...
>
> Samuel
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Who uses xc_gnttab_map_grant_refs?
  2008-07-16 14:51 ` Derek Murray
@ 2008-07-16 15:08   ` Samuel Thibault
  2008-07-18 14:21     ` Ian Jackson
  0 siblings, 1 reply; 7+ messages in thread
From: Samuel Thibault @ 2008-07-16 15:08 UTC (permalink / raw)
  To: Derek Murray; +Cc: xen-devel

Derek Murray, le Wed 16 Jul 2008 15:51:18 +0100, a écrit :
> Mea culpa for that bit of API. I think this is a case where the
> underlying implementation makes it possible, so I decided to make it
> available through the user API. No particular reason for it, so I have
> no objection to it being simplified (or wrapped by an additional API
> function).

That's why I asked whether somebody actually use that function :)

Samuel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Who uses xc_gnttab_map_grant_refs?
  2008-07-16 15:08   ` Samuel Thibault
@ 2008-07-18 14:21     ` Ian Jackson
  2008-07-18 14:47       ` Samuel Thibault
  0 siblings, 1 reply; 7+ messages in thread
From: Ian Jackson @ 2008-07-18 14:21 UTC (permalink / raw)
  To: Samuel Thibault; +Cc: Derek Murray, xen-devel

Samuel Thibault writes ("Re: [Xen-devel] Who uses xc_gnttab_map_grant_refs?"):
> Derek Murray, le Wed 16 Jul 2008 15:51:18 +0100, a écrit :
> > Mea culpa for that bit of API. I think this is a case where the
> > underlying implementation makes it possible, so I decided to make it
> > available through the user API. No particular reason for it, so I have
> > no objection to it being simplified (or wrapped by an additional API
> > function).
> 
> That's why I asked whether somebody actually use that function :)

Of course other users of that function may not be reading this list.
If you're suggesting to change the ABI or API, why not give the new
interface a new name ?

Ian.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Who uses xc_gnttab_map_grant_refs?
  2008-07-18 14:21     ` Ian Jackson
@ 2008-07-18 14:47       ` Samuel Thibault
  2008-07-18 14:55         ` Ian Jackson
  0 siblings, 1 reply; 7+ messages in thread
From: Samuel Thibault @ 2008-07-18 14:47 UTC (permalink / raw)
  To: Ian Jackson; +Cc: Derek Murray, xen-devel

Ian Jackson, le Fri 18 Jul 2008 15:21:53 +0100, a écrit :
> Samuel Thibault writes ("Re: [Xen-devel] Who uses xc_gnttab_map_grant_refs?"):
> > Derek Murray, le Wed 16 Jul 2008 15:51:18 +0100, a écrit :
> > > Mea culpa for that bit of API. I think this is a case where the
> > > underlying implementation makes it possible, so I decided to make it
> > > available through the user API. No particular reason for it, so I have
> > > no objection to it being simplified (or wrapped by an additional API
> > > function).
> > 
> > That's why I asked whether somebody actually use that function :)
> 
> Of course other users of that function may not be reading this list.

Sure

> If you're suggesting to change the ABI or API, why not give the new
> interface a new name ?

But still kill the old function at least?

I'm asking because not killing the old function would mean either
duplicating the code, or writing a wrapper that merely allocate an array
full of the same value...

Samuel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Who uses xc_gnttab_map_grant_refs?
  2008-07-18 14:47       ` Samuel Thibault
@ 2008-07-18 14:55         ` Ian Jackson
  2008-07-21 10:48           ` [PATCH] " Samuel Thibault
  0 siblings, 1 reply; 7+ messages in thread
From: Ian Jackson @ 2008-07-18 14:55 UTC (permalink / raw)
  To: Samuel Thibault; +Cc: Derek Murray, xen-devel

Samuel Thibault writes ("Re: [Xen-devel] Who uses xc_gnttab_map_grant_refs?"):
> But still kill the old function at least?

Is that a change we want to make at this stage of the release ?  I
don't necessarily have an opinion but it's a question we should be
asking.

Ian.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Re: Who uses xc_gnttab_map_grant_refs?
  2008-07-18 14:55         ` Ian Jackson
@ 2008-07-21 10:48           ` Samuel Thibault
  0 siblings, 0 replies; 7+ messages in thread
From: Samuel Thibault @ 2008-07-21 10:48 UTC (permalink / raw)
  To: Ian Jackson; +Cc: Derek Murray, xen-devel

[-- Attachment #1: Type: text/plain, Size: 3519 bytes --]

Ian Jackson, le Fri 18 Jul 2008 15:55:58 +0100, a écrit :
> Samuel Thibault writes ("Re: [Xen-devel] Who uses xc_gnttab_map_grant_refs?"):
> > But still kill the old function at least?
> 
> Is that a change we want to make at this stage of the release ?  I
> don't necessarily have an opinion but it's a question we should be
> asking.

Ok, well, here is a patch that keeps the old function, just making its
implementation an internal with an additional domids_stride parameter in
order to also both efficiency.

Samuel



libxc: add xc_gnttab_map_domain_grant_refs.

xc_gnttab_map_domain_grant_refs permits to simply map several pages from
the same domain.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>

diff -r 3139383b36a0 tools/libxc/xc_linux.c
--- a/tools/libxc/xc_linux.c	Fri Jul 18 18:13:53 2008 +0100
+++ b/tools/libxc/xc_linux.c	Mon Jul 21 11:44:43 2008 +0100
@@ -418,9 +418,10 @@
     return addr;
 }
 
-void *xc_gnttab_map_grant_refs(int xcg_handle,
+static void *do_gnttab_map_grant_refs(int xcg_handle,
                                uint32_t count,
                                uint32_t *domids,
+                               int domids_stride,
                                uint32_t *refs,
                                int prot)
 {
@@ -435,7 +436,7 @@
 
     for ( i = 0; i < count; i++ )
     {
-        map->refs[i].domid = domids[i];
+        map->refs[i].domid = domids[i * domids_stride];
         map->refs[i].ref   = refs[i];
     }
 
@@ -462,6 +463,24 @@
  out:
     free(map);
     return addr;
+}
+
+void *xc_gnttab_map_grant_refs(int xcg_handle,
+                               uint32_t count,
+                               uint32_t *domids,
+                               uint32_t *refs,
+                               int prot)
+{
+    return do_gnttab_map_grant_refs(xcg_handle, count, domids, 1, refs, prot);
+}
+
+void *xc_gnttab_map_domain_grant_refs(int xcg_handle,
+                               uint32_t count,
+                               uint32_t domid,
+                               uint32_t *refs,
+                               int prot)
+{
+    return do_gnttab_map_grant_refs(xcg_handle, count, &domid, 0, refs, prot);
 }
 
 int xc_gnttab_munmap(int xcg_handle,
diff -r 3139383b36a0 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h	Fri Jul 18 18:13:53 2008 +0100
+++ b/tools/libxc/xenctrl.h	Mon Jul 21 11:44:43 2008 +0100
@@ -865,6 +865,23 @@
                                uint32_t *refs,
                                int prot);
 
+/**
+ * Memory maps one or more grant references from one domain to a
+ * contiguous local address range. Mappings should be unmapped with
+ * xc_gnttab_munmap.  Returns NULL on failure.
+ *
+ * @parm xcg_handle a handle on an open grant table interface
+ * @parm count the number of grant references to be mapped
+ * @parm domid the domain to map memory from
+ * @parm refs an array of @count grant references to be mapped
+ * @parm prot same flag as in mmap()
+ */
+void *xc_gnttab_map_domain_grant_refs(int xcg_handle,
+                                      uint32_t count,
+                                      uint32_t domid,
+                                      uint32_t *refs,
+                                      int prot);
+
 /*
  * Unmaps the @count pages starting at @start_address, which were mapped by a
  * call to xc_gnttab_map_grant_ref or xc_gnttab_map_grant_refs. Returns zero

[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 2697 bytes --]

diff -r 3139383b36a0 tools/libxc/xc_linux.c
--- a/tools/libxc/xc_linux.c	Fri Jul 18 18:13:53 2008 +0100
+++ b/tools/libxc/xc_linux.c	Mon Jul 21 11:44:43 2008 +0100
@@ -418,9 +418,10 @@
     return addr;
 }
 
-void *xc_gnttab_map_grant_refs(int xcg_handle,
+static void *do_gnttab_map_grant_refs(int xcg_handle,
                                uint32_t count,
                                uint32_t *domids,
+                               int domids_stride,
                                uint32_t *refs,
                                int prot)
 {
@@ -435,7 +436,7 @@
 
     for ( i = 0; i < count; i++ )
     {
-        map->refs[i].domid = domids[i];
+        map->refs[i].domid = domids[i * domids_stride];
         map->refs[i].ref   = refs[i];
     }
 
@@ -462,6 +463,24 @@
  out:
     free(map);
     return addr;
+}
+
+void *xc_gnttab_map_grant_refs(int xcg_handle,
+                               uint32_t count,
+                               uint32_t *domids,
+                               uint32_t *refs,
+                               int prot)
+{
+    return do_gnttab_map_grant_refs(xcg_handle, count, domids, 1, refs, prot);
+}
+
+void *xc_gnttab_map_domain_grant_refs(int xcg_handle,
+                               uint32_t count,
+                               uint32_t domid,
+                               uint32_t *refs,
+                               int prot)
+{
+    return do_gnttab_map_grant_refs(xcg_handle, count, &domid, 0, refs, prot);
 }
 
 int xc_gnttab_munmap(int xcg_handle,
diff -r 3139383b36a0 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h	Fri Jul 18 18:13:53 2008 +0100
+++ b/tools/libxc/xenctrl.h	Mon Jul 21 11:44:43 2008 +0100
@@ -865,6 +865,23 @@
                                uint32_t *refs,
                                int prot);
 
+/**
+ * Memory maps one or more grant references from one domain to a
+ * contiguous local address range. Mappings should be unmapped with
+ * xc_gnttab_munmap.  Returns NULL on failure.
+ *
+ * @parm xcg_handle a handle on an open grant table interface
+ * @parm count the number of grant references to be mapped
+ * @parm domid the domain to map memory from
+ * @parm refs an array of @count grant references to be mapped
+ * @parm prot same flag as in mmap()
+ */
+void *xc_gnttab_map_domain_grant_refs(int xcg_handle,
+                                      uint32_t count,
+                                      uint32_t domid,
+                                      uint32_t *refs,
+                                      int prot);
+
 /*
  * Unmaps the @count pages starting at @start_address, which were mapped by a
  * call to xc_gnttab_map_grant_ref or xc_gnttab_map_grant_refs. Returns zero

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-07-21 10:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-16 14:40 Who uses xc_gnttab_map_grant_refs? Samuel Thibault
2008-07-16 14:51 ` Derek Murray
2008-07-16 15:08   ` Samuel Thibault
2008-07-18 14:21     ` Ian Jackson
2008-07-18 14:47       ` Samuel Thibault
2008-07-18 14:55         ` Ian Jackson
2008-07-21 10:48           ` [PATCH] " Samuel Thibault

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.