Skip to contentSkip to conversation

libvchan: replace munmap with correct xc_gntshr_munmap

PATCH In review Marek Marczykowski 4 participants 15 messages May 4, 2013 – Jul 4, 2013

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/2 libvchan: replace munmap with correct xc_gntshr_munmap

On linux it will end up in munmap anyway, but do not assume any particular xc_gntshr_munmap implementation details.

---
 tools/libvchan/io.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tools/libvchan/io.c +4 -2
index 5ec5fb9..3040099 100644
@@ -324,9 +324,11 @@ void libxenvchan_close(struct libxenvchan *ctrl)
 	if (!ctrl)
 		return;
 	if (ctrl->read.order >= PAGE_SHIFT)
-		munmap(ctrl->read.buffer, 1 << ctrl->read.order);
+		xc_gntshr_munmap(ctrl->gntshr, ctrl->read.buffer,
+				1 << (ctrl->read.order - PAGE_SHIFT));
 	if (ctrl->write.order >= PAGE_SHIFT)
-		munmap(ctrl->write.buffer, 1 << ctrl->write.order);
+		xc_gntshr_munmap(ctrl->gntshr, ctrl->write.buffer,
+				1 << (ctrl->write.order - PAGE_SHIFT));
 	if (ctrl->ring) {
 		if (ctrl->is_server) {
 			ctrl->ring->srv_live = 0;
Signature · 1 line
1.8.1.4
#1 lore raw
Quoted 4 lines · Marek Marczykowski

On linux it will end up in munmap anyway, but do not assume any particular xc_gntshr_munmap implementation details.

Hmm, we don't seem to have a maintainer specifically for this code.

Is this fixing an actual bug for you? The commit message doesn't mention anything. If it's just code clean-up, it should probably wait until the 4.4 development window opens.

-George

Quoted 30 lines
---
 tools/libvchan/io.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tools/libvchan/io.c +4 -3
index 5ec5fb9..3040099 100644
@@ -324,9 +324,11 @@ void libxenvchan_close(struct libxenvchan *ctrl)
        if (!ctrl)
                return;
        if (ctrl->read.order >= PAGE_SHIFT)
-               munmap(ctrl->read.buffer, 1 << ctrl->read.order);
+               xc_gntshr_munmap(ctrl->gntshr, ctrl->read.buffer,
+                               1 << (ctrl->read.order - PAGE_SHIFT));
        if (ctrl->write.order >= PAGE_SHIFT)
-               munmap(ctrl->write.buffer, 1 << ctrl->write.order);
+               xc_gntshr_munmap(ctrl->gntshr, ctrl->write.buffer,
+                               1 << (ctrl->write.order - PAGE_SHIFT));
        if (ctrl->ring) {
                if (ctrl->is_server) {
                        ctrl->ring->srv_live = 0;
--

1.8.1.4

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw
Quoted 8 lines · George Dunlap
Quoted 4 lines · Marek Marczykowski

On linux it will end up in munmap anyway, but do not assume any particular xc_gntshr_munmap implementation details.

Hmm, we don't seem to have a maintainer specifically for this code.

Daniel (already CCd) is the de-facto maintainer. I'd be happy for him to propose himself as a maintainer.

Quoted 37 lines

Is this fixing an actual bug for you? The commit message doesn't mention anything. If it's just code clean-up, it should probably wait until the 4.4 development window opens.

-George

Quoted 30 lines
---
 tools/libvchan/io.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tools/libvchan/io.c +4 -3
index 5ec5fb9..3040099 100644
@@ -324,9 +324,11 @@ void libxenvchan_close(struct libxenvchan *ctrl)
        if (!ctrl)
                return;
        if (ctrl->read.order >= PAGE_SHIFT)
-               munmap(ctrl->read.buffer, 1 << ctrl->read.order);
+               xc_gntshr_munmap(ctrl->gntshr, ctrl->read.buffer,
+                               1 << (ctrl->read.order - PAGE_SHIFT));
        if (ctrl->write.order >= PAGE_SHIFT)
-               munmap(ctrl->write.buffer, 1 << ctrl->write.order);
+               xc_gntshr_munmap(ctrl->gntshr, ctrl->write.buffer,
+                               1 << (ctrl->write.order - PAGE_SHIFT));
        if (ctrl->ring) {
                if (ctrl->is_server) {
                        ctrl->ring->srv_live = 0;
--

1.8.1.4

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
In reply to Marek Marczykowski

I can't seem to find the 1/2 patch from this series anywhere?

Quoted 26 lines · Marek Marczykowski

On linux it will end up in munmap anyway, but do not assume any particular xc_gntshr_munmap implementation details.

---
 tools/libvchan/io.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tools/libvchan/io.c +4 -2
index 5ec5fb9..3040099 100644
@@ -324,9 +324,11 @@ void libxenvchan_close(struct libxenvchan *ctrl)
 	if (!ctrl)
 		return;
 	if (ctrl->read.order >= PAGE_SHIFT)
-		munmap(ctrl->read.buffer, 1 << ctrl->read.order);
+		xc_gntshr_munmap(ctrl->gntshr, ctrl->read.buffer,
+				1 << (ctrl->read.order - PAGE_SHIFT));
 	if (ctrl->write.order >= PAGE_SHIFT)
-		munmap(ctrl->write.buffer, 1 << ctrl->write.order);
+		xc_gntshr_munmap(ctrl->gntshr, ctrl->write.buffer,
+				1 << (ctrl->write.order - PAGE_SHIFT));
 	if (ctrl->ring) {
 		if (ctrl->is_server) {
 			ctrl->ring->srv_live = 0;
#4 lore raw
Quoted 1 line · Ian Campbell

I can't seem to find the 1/2 patch from this series anywhere?

Looks like it might be <[email protected]> "[PATCH v2 1/2] libxc: fix xc_gntshr_munmap semantic" but that was sent nearly a week prior to this 2/2 one so I'm not at all sure.

Ian.

#5 lore raw
Quoted 6 lines · Ian Campbell
Quoted 1 line · Ian Campbell

I can't seem to find the 1/2 patch from this series anywhere?

Looks like it might be <[email protected]> "[PATCH v2 1/2] libxc: fix xc_gntshr_munmap semantic" but that was sent nearly a week prior to this 2/2 one so I'm not at all sure.

Yes, this one. I've failed with git format-patch, and the mail date was from my working tree. Sorry...

Signature · 3 lines
Best Regards,
Marek Marczykowski
Invisible Things Lab

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw
In reply to Marek Marczykowski
Quoted 4 lines · Marek Marczykowski

On linux it will end up in munmap anyway, but do not assume any particular xc_gntshr_munmap implementation details.

On a client, this ends up using xc_gntshr_munmap to unmap pages that were mapped with xc_gnttab_map_* instead of using xc_gnttab_unmam

George: unless there is another OS besides Linux that implements the xc_gntshr_* interfaces (I found none from a grep of the source), this is just code clean-up and so could be postponed to 4.4.

Quoted 23 lines
---
  tools/libvchan/io.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
tools/libvchan/io.c +4 -2
index 5ec5fb9..3040099 100644
@@ -324,9 +324,11 @@ void libxenvchan_close(struct libxenvchan *ctrl)
  	if (!ctrl)
  		return;
  	if (ctrl->read.order >= PAGE_SHIFT)
-		munmap(ctrl->read.buffer, 1 << ctrl->read.order);
+		xc_gntshr_munmap(ctrl->gntshr, ctrl->read.buffer,
+				1 << (ctrl->read.order - PAGE_SHIFT));
  	if (ctrl->write.order >= PAGE_SHIFT)
-		munmap(ctrl->write.buffer, 1 << ctrl->write.order);
+		xc_gntshr_munmap(ctrl->gntshr, ctrl->write.buffer,
+				1 << (ctrl->write.order - PAGE_SHIFT));
  	if (ctrl->ring) {
  		if (ctrl->is_server) {
  			ctrl->ring->srv_live = 0;
Signature · 2 lines
Daniel De Graaf
National Security Agency
#7 lore raw
Quoted 4 lines · Daniel De Graaf
Quoted 3 lines · Marek Marczykowski

On linux it will end up in munmap anyway, but do not assume any particular xc_gntshr_munmap implementation details.

Quoted 8 lines
Quoted 1 line

On a client, this ends up using xc_gntshr_munmap to unmap pages that were mapped with xc_gnttab_map_* instead of using xc_gnttab_unmam

George: unless there is another OS besides Linux that implements the xc_gntshr_* interfaces (I found none from a grep of the source), this is just code clean-up and so could be postponed to 4.4.

This is actually prerequirement for libvchan for mini-os (already posted v1, working on v2). But as mini-os libvchan isn't targeted for 4.3, this one also can wait.

Quoted 24 lines
Quoted 24 lines
---
  tools/libvchan/io.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
tools/libvchan/io.c +4 -2
index 5ec5fb9..3040099 100644
@@ -324,9 +324,11 @@ void libxenvchan_close(struct libxenvchan *ctrl)
      if (!ctrl)
          return;
      if (ctrl->read.order >= PAGE_SHIFT)
-        munmap(ctrl->read.buffer, 1 << ctrl->read.order);
+        xc_gntshr_munmap(ctrl->gntshr, ctrl->read.buffer,
+                1 << (ctrl->read.order - PAGE_SHIFT));
      if (ctrl->write.order >= PAGE_SHIFT)
-        munmap(ctrl->write.buffer, 1 << ctrl->write.order);
+        xc_gntshr_munmap(ctrl->gntshr, ctrl->write.buffer,
+                1 << (ctrl->write.order - PAGE_SHIFT));
      if (ctrl->ring) {
          if (ctrl->is_server) {
              ctrl->ring->srv_live = 0;
Signature · 3 lines
Best Regards,
Marek Marczykowski
Invisible Things Lab

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#8 lore raw
Quoted 10 lines · Marek Marczykowski
Quoted 9 lines · Daniel De Graaf
Quoted 4 lines · Marek Marczykowski

On linux it will end up in munmap anyway, but do not assume any particular xc_gntshr_munmap implementation details.

On a client, this ends up using xc_gntshr_munmap to unmap pages that were mapped with xc_gnttab_map_* instead of using xc_gnttab_unmam

Quoted 7 lines
Quoted 3 lines

George: unless there is another OS besides Linux that implements the xc_gntshr_* interfaces (I found none from a grep of the source), this is just code clean-up and so could be postponed to 4.4.

This is actually prerequirement for libvchan for mini-os (already posted v1, working on v2). But as mini-os libvchan isn't targeted for 4.3, this one also can wait.

Is the first patch "libxc: fix xc_gntshr_munmap semantic" also included in this assessment?

Message-Id: <[email protected]>

#9 lore raw
Quoted 15 lines · Ian Campbell
Quoted 14 lines · Marek Marczykowski
Quoted 12 lines · Daniel De Graaf
Quoted 4 lines · Marek Marczykowski

On linux it will end up in munmap anyway, but do not assume any particular xc_gntshr_munmap implementation details.

On a client, this ends up using xc_gntshr_munmap to unmap pages that were mapped with xc_gnttab_map_* instead of using xc_gnttab_unmam

George: unless there is another OS besides Linux that implements the xc_gntshr_* interfaces (I found none from a grep of the source), this is just code clean-up and so could be postponed to 4.4.

Quoted 8 lines
Quoted 3 lines

This is actually prerequirement for libvchan for mini-os (already posted v1, working on v2). But as mini-os libvchan isn't targeted for 4.3, this one also can wait.

Is the first patch "libxc: fix xc_gntshr_munmap semantic" also included in this assessment?

Message-Id: <[email protected]>

As long as libxenvchan is the only (at least I'm aware of) user of xc_gntshr_munmap - probably yes. But IMO it's better to fix xc_gntshr_munmap sooner than later, to minimize changes in code that uses it (if someone will start to use it before 4.4 release).

Signature · 3 lines
Best Regards,
Marek Marczykowski
Invisible Things Lab

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#10 lore raw
Quoted 17 lines · Marek Marczykowski
Quoted 16 lines · Ian Campbell
Quoted 15 lines · Marek Marczykowski
Quoted 11 lines · Daniel De Graaf
Quoted 4 lines · Marek Marczykowski

On linux it will end up in munmap anyway, but do not assume any particular xc_gntshr_munmap implementation details.

On a client, this ends up using xc_gntshr_munmap to unmap pages that were mapped with xc_gnttab_map_* instead of using xc_gnttab_unmam

George: unless there is another OS besides Linux that implements the xc_gntshr_* interfaces (I found none from a grep of the source), this is just code clean-up and so could be postponed to 4.4.

This is actually prerequirement for libvchan for mini-os (already posted v1, working on v2). But as mini-os libvchan isn't targeted for 4.3, this one also can wait.

Quoted 8 lines
Quoted 4 lines

Is the first patch "libxc: fix xc_gntshr_munmap semantic" also included in this assessment?

Message-Id: <[email protected]>

As long as libxenvchan is the only (at least I'm aware of) user of xc_gntshr_munmap - probably yes. But IMO it's better to fix xc_gntshr_munmap sooner than later, to minimize changes in code that uses it (if someone will start to use it before 4.4 release).

I take it from the name that xc_grntshr_munmap() is in libxc? No one externally should be linking against libxc; it's an internal library without a stable interface.

-George

#11 lore raw
In reply to Marek Marczykowski
Quoted 23 lines · Marek Marczykowski
Quoted 22 lines · Ian Campbell
Quoted 10 lines · Marek Marczykowski
Quoted 9 lines · Daniel De Graaf
Quoted 4 lines · Marek Marczykowski

On linux it will end up in munmap anyway, but do not assume any particular xc_gntshr_munmap implementation details.

On a client, this ends up using xc_gntshr_munmap to unmap pages that were mapped with xc_gnttab_map_* instead of using xc_gnttab_unmam

Quoted 7 lines
Quoted 3 lines

George: unless there is another OS besides Linux that implements the xc_gntshr_* interfaces (I found none from a grep of the source), this is just code clean-up and so could be postponed to 4.4.

This is actually prerequirement for libvchan for mini-os (already posted v1, working on v2). But as mini-os libvchan isn't targeted for 4.3, this one also can wait.

Is the first patch "libxc: fix xc_gntshr_munmap semantic" also included in this assessment?

Quoted 6 lines
Quoted 1 line

Message-Id: <[email protected]>

As long as libxenvchan is the only (at least I'm aware of) user of xc_gntshr_munmap - probably yes. But IMO it's better to fix xc_gntshr_munmap sooner than later, to minimize changes in code that uses it (if someone will start to use it before 4.4 release).

I'm not sure if you are arguing for or against putting that fix into 4.3?

Ian.

#12 lore raw
Quoted 21 lines · Ian Campbell
Quoted 20 lines · Marek Marczykowski
Quoted 19 lines · Ian Campbell
Quoted 9 lines · Marek Marczykowski
Quoted 8 lines · Daniel De Graaf
Quoted 4 lines · Marek Marczykowski

On linux it will end up in munmap anyway, but do not assume any particular xc_gntshr_munmap implementation details.

On a client, this ends up using xc_gntshr_munmap to unmap pages that were mapped with xc_gnttab_map_* instead of using xc_gnttab_unmam

Quoted 6 lines
Quoted 3 lines

George: unless there is another OS besides Linux that implements the xc_gntshr_* interfaces (I found none from a grep of the source), this is just code clean-up and so could be postponed to 4.4.

This is actually prerequirement for libvchan for mini-os (already posted v1, working on v2). But as mini-os libvchan isn't targeted for 4.3, this one also can wait.

Is the first patch "libxc: fix xc_gntshr_munmap semantic" also included in this assessment?

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Message-Id: <[email protected]>

As long as libxenvchan is the only (at least I'm aware of) user of xc_gntshr_munmap - probably yes. But IMO it's better to fix xc_gntshr_munmap sooner than later, to minimize changes in code that uses it (if someone will start to use it before 4.4 release).

I'm not sure if you are arguing for or against putting that fix into 4.3?

I read this as, "We should make the interface more useful in case someone decides to use it after 4.3 comes out but before 4.4 comes out." To which my response was, if this is in libxc, people shouldn't be linking against it anyway.

-George

#13 lore raw
Quoted 27 lines · George Dunlap
Quoted 26 lines · Ian Campbell
Quoted 25 lines · Marek Marczykowski
Quoted 13 lines · Ian Campbell
Quoted 12 lines · Marek Marczykowski
Quoted 11 lines · Daniel De Graaf
Quoted 4 lines · Marek Marczykowski

On linux it will end up in munmap anyway, but do not assume any particular xc_gntshr_munmap implementation details.

On a client, this ends up using xc_gntshr_munmap to unmap pages that were mapped with xc_gnttab_map_* instead of using xc_gnttab_unmam

George: unless there is another OS besides Linux that implements the xc_gntshr_* interfaces (I found none from a grep of the source), this is just code clean-up and so could be postponed to 4.4.

Quoted 7 lines
Quoted 3 lines

This is actually prerequirement for libvchan for mini-os (already posted v1, working on v2). But as mini-os libvchan isn't targeted for 4.3, this one also can wait.

Is the first patch "libxc: fix xc_gntshr_munmap semantic" also included in this assessment?

Message-Id: <[email protected]>

As long as libxenvchan is the only (at least I'm aware of) user of xc_gntshr_munmap - probably yes. But IMO it's better to fix xc_gntshr_munmap sooner than later, to minimize changes in code that uses it (if someone will start to use it before 4.4 release).

Quoted 7 lines
Quoted 2 lines

I'm not sure if you are arguing for or against putting that fix into 4.3?

I read this as, "We should make the interface more useful in case someone decides to use it after 4.3 comes out but before 4.4 comes out." To which my response was, if this is in libxc, people shouldn't be linking against it anyway.

OK. Strictly speaking you mean "shouldn't rely on the libxc API not changing", we don't forbid people to link against libxc.

Ian.

#14 lore raw
In reply to Daniel De Graaf
Quoted 8 lines · Daniel De Graaf
Quoted 4 lines · Marek Marczykowski

On linux it will end up in munmap anyway, but do not assume any particular xc_gntshr_munmap implementation details.

On a client, this ends up using xc_gntshr_munmap to unmap pages that were mapped with xc_gnttab_map_* instead of using xc_gnttab_unmam

Did this aspect get resolved?

I suppose I shouldn't apply the 1/2 patch either until this is sorted?

Quoted 28 lines

George: unless there is another OS besides Linux that implements the xc_gntshr_* interfaces (I found none from a grep of the source), this is just code clean-up and so could be postponed to 4.4.

Quoted 23 lines
---
  tools/libvchan/io.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
tools/libvchan/io.c +4 -2
index 5ec5fb9..3040099 100644
@@ -324,9 +324,11 @@ void libxenvchan_close(struct libxenvchan *ctrl)
  	if (!ctrl)
  		return;
  	if (ctrl->read.order >= PAGE_SHIFT)
-		munmap(ctrl->read.buffer, 1 << ctrl->read.order);
+		xc_gntshr_munmap(ctrl->gntshr, ctrl->read.buffer,
+				1 << (ctrl->read.order - PAGE_SHIFT));
  	if (ctrl->write.order >= PAGE_SHIFT)
-		munmap(ctrl->write.buffer, 1 << ctrl->write.order);
+		xc_gntshr_munmap(ctrl->gntshr, ctrl->write.buffer,
+				1 << (ctrl->write.order - PAGE_SHIFT));
  	if (ctrl->ring) {
  		if (ctrl->is_server) {
  			ctrl->ring->srv_live = 0;