Skip to contentSkip to conversation

libxl_set_memory_target: only remove videoram from absolute targets

PATCH In review Stefano Stabellini 2 participants 6 messages Jan 26, 2015 – Feb 2, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl_set_memory_target: only remove videoram from absolute targets

If the new target is relative to the current target, do not remove videoram again: it has already been removed from the current target.

---

Changes in v2:
- add videoram when setting maxmem.

---
 tools/libxl/libxl.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
tools/libxl/libxl.c +6 -6
index 82227e8..cd6f42c 100644
@@ -4764,13 +4764,17 @@ retry_transaction:
         goto out;
     }
 
+    videoram_s = libxl__xs_read(gc, t, libxl__sprintf(gc,
+                "%s/memory/videoram", dompath));
+    videoram = videoram_s ? atoi(videoram_s) : 0;
+
     if (relative) {
         if (target_memkb < 0 && abs(target_memkb) > current_target_memkb)
             new_target_memkb = 0;
         else
             new_target_memkb = current_target_memkb + target_memkb;
     } else
-        new_target_memkb = target_memkb;
+        new_target_memkb = target_memkb - videoram;
     if (new_target_memkb > memorykb) {
         LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
                 "memory_dynamic_max must be less than or equal to"
@@ -4786,12 +4790,9 @@ retry_transaction:
         abort_transaction = 1;
         goto out;
     }
-    videoram_s = libxl__xs_read(gc, t, libxl__sprintf(gc,
-                "%s/memory/videoram", dompath));
-    videoram = videoram_s ? atoi(videoram_s) : 0;
 
     if (enforce) {
-        memorykb = new_target_memkb;
+        memorykb = new_target_memkb + videoram;
         rc = xc_domain_setmaxmem(ctx->xch, domid, memorykb +
                 LIBXL_MAXMEM_CONSTANT);
         if (rc != 0) {
@@ -4803,7 +4804,6 @@ retry_transaction:
         }
     }
 
-    new_target_memkb -= videoram;
     rc = xc_domain_set_pod_target(ctx->xch, domid,
             new_target_memkb / 4, NULL, NULL, NULL);
     if (rc != 0) {
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 4 lines · Stefano Stabellini

If the new target is relative to the current target, do not remove videoram again: it has already been removed from the current target.

How does this relate to "libxl_set_memory_target: retain the same maxmem offset on top of the current target"? Doesn't that also achieve the same aim, since maxmem accounts for vram but target doesn't?

Ian.

#2 lore raw
Quoted 9 lines · Ian Campbell
Quoted 4 lines · Stefano Stabellini

If the new target is relative to the current target, do not remove videoram again: it has already been removed from the current target.

How does this relate to "libxl_set_memory_target: retain the same maxmem offset on top of the current target"? Doesn't that also achieve the same aim, since maxmem accounts for vram but target doesn't?

The two patches are different: this one affects the memory target while the other one affects maxmem. The only relationship is that this issue was found out by looking at the other patch.

This patch didn't make it into 4.5 because although it is a bug fix, it doesn't fix a regression compared to 4.4.

#3 lore raw
Quoted 7 lines · Stefano Stabellini
Quoted 6 lines · Ian Campbell
Quoted 4 lines · Stefano Stabellini

If the new target is relative to the current target, do not remove videoram again: it has already been removed from the current target.

Quoted 7 lines
Quoted 3 lines

How does this relate to "libxl_set_memory_target: retain the same maxmem offset on top of the current target"? Doesn't that also achieve the same aim, since maxmem accounts for vram but target doesn't?

The two patches are different: this one affects the memory target while the other one affects maxmem. The only relationship is that this issue was found out by looking at the other patch.

Not even a textual relationship? (i.e. one needs to go first to avoid conflicts)

Quoted 2 lines

This patch didn't make it into 4.5 because although it is a bug fix, it doesn't fix a regression compared to 4.4.

#4 lore raw
Quoted 12 lines · Ian Campbell
Quoted 11 lines · Stefano Stabellini
Quoted 9 lines · Ian Campbell
Quoted 4 lines · Stefano Stabellini

If the new target is relative to the current target, do not remove videoram again: it has already been removed from the current target.

How does this relate to "libxl_set_memory_target: retain the same maxmem offset on top of the current target"? Doesn't that also achieve the same aim, since maxmem accounts for vram but target doesn't?

Quoted 6 lines
Quoted 3 lines

The two patches are different: this one affects the memory target while the other one affects maxmem. The only relationship is that this issue was found out by looking at the other patch.

Not even a textual relationship? (i.e. one needs to go first to avoid conflicts)

Yep, there is a textual relationship. Sorry I failed to mention it.

This one needs to go first.

Quoted 4 lines
Quoted 2 lines

This patch didn't make it into 4.5 because although it is a bug fix, it doesn't fix a regression compared to 4.4.

#5 lore raw
Quoted 17 lines · Stefano Stabellini
Quoted 16 lines · Ian Campbell
Quoted 14 lines · Stefano Stabellini
Quoted 9 lines · Ian Campbell
Quoted 4 lines · Stefano Stabellini

If the new target is relative to the current target, do not remove videoram again: it has already been removed from the current target.

How does this relate to "libxl_set_memory_target: retain the same maxmem offset on top of the current target"? Doesn't that also achieve the same aim, since maxmem accounts for vram but target doesn't?

The two patches are different: this one affects the memory target while the other one affects maxmem. The only relationship is that this issue was found out by looking at the other patch.

Quoted 6 lines
Quoted 2 lines

Not even a textual relationship? (i.e. one needs to go first to avoid conflicts)

Yep, there is a textual relationship. Sorry I failed to mention it.

This one needs to go first.

Acked + applied then, thanks.