Skip to contentSkip to conversation

xen/arm: Print memory size in decimal in construct_domU

PATCH In review Michal Orzel 4 participants 9 messages Jan 2, 2023 – Jan 4, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm: Print memory size in decimal in construct_domU

Printing domain's memory size in hex without even prepending it with 0x is not very useful and can be misleading. Switch to decimal notation.

---
 xen/arch/arm/domain_build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/domain_build.c +1 -1
index 829cea8de84f..7e204372368c 100644
@@ -3774,7 +3774,7 @@ static int __init construct_domU(struct domain *d,
     if ( rc != 0 )
         return rc;
 
-    printk("*** LOADING DOMU cpus=%u memory=%"PRIx64"KB ***\n", d->max_vcpus, mem);
+    printk("*** LOADING DOMU cpus=%u memory=%"PRIu64"KB ***\n", d->max_vcpus, mem);
 
     kinfo.vpl011 = dt_property_read_bool(node, "vpl011");
 
Signature · 1 line
2.25.1
#1 lore raw

Hi Michal,

Quoted 14 lines · Michal Orzel

Printing domain's memory size in hex without even prepending it with 0x is not very useful and can be misleading. Switch to decimal notation.

---
  xen/arch/arm/domain_build.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/domain_build.c +0 -0
index 829cea8de84f..7e204372368c 100644

xen/arch/arm/domain_build.c static int __init construct_domU(struct domain *d, · line 3777

Quoted 5 lines
xen/arch/arm/domain_build.c +1 -1
@@ -3774,7 +3774,7 @@ static int __init construct_domU(struct domain *d,
      if ( rc != 0 )
          return rc;
 
-    printk("*** LOADING DOMU cpus=%u memory=%"PRIx64"KB ***\n", d->max_vcpus, mem);
+    printk("*** LOADING DOMU cpus=%u memory=%"PRIu64"KB ***\n", d->max_vcpus, mem);

I will prefer it to be printed in hex format with 0x prefixed. The reason being the mem is obtained from device-tree domU's 'memory' prop where the values are in hex.

It will help the user to debug easily without requiring the the person to manually calculate the hex equivalent and then trying to correlate it with what is written in dts.

- Ayan

Quoted 3 lines
xen/arch/arm/domain_build.c +0 -0
      kinfo.vpl011 = dt_property_read_bool(node, "vpl011");
 
#2 lore raw

Hi Ayan,

Quoted 22 lines · Ayan Kumar Halder

Hi Michal,

Quoted 17 lines · Michal Orzel

Printing domain's memory size in hex without even prepending it with 0x is not very useful and can be misleading. Switch to decimal notation.

---
  xen/arch/arm/domain_build.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/domain_build.c +0 -0
index 829cea8de84f..7e204372368c 100644
@@ -3774,7 +3774,7 @@ static int __init construct_domU(struct domain *d,
      if ( rc != 0 )
          return rc;
 
Quoted 6 lines

xen/arch/arm/domain_build.c static int __init construct_domU(struct domain *d, · line 3777

Quoted 2 lines
xen/arch/arm/domain_build.c +1 -1
-    printk("*** LOADING DOMU cpus=%u memory=%"PRIx64"KB ***\n", d->max_vcpus, mem);
+    printk("*** LOADING DOMU cpus=%u memory=%"PRIu64"KB ***\n", d->max_vcpus, mem);

I will prefer it to be printed in hex format with 0x prefixed. The reason being the mem is obtained from device-tree domU's 'memory' prop where the values are in hex.

No, I cannot agree. Refer to booting.txt documentation:
"A 64-bit integer specifying the amount of kilobytes of RAM to allocate to the guest." Also note that in the provided examples, we are using the decimal values.
All in all it does not matter the notation, you can provide e.g. "memory = 131072;" or "memory = 0x20000". I find it a bit odd to print e.g. 0x20000KB and decimal is easier to read.

~Michal

#3 lore raw

Hi Michal,

Quoted 29 lines · Michal Orzel
Quoted 22 lines · Ayan Kumar Halder

Hi Michal,

Quoted 17 lines · Michal Orzel

Printing domain's memory size in hex without even prepending it with 0x is not very useful and can be misleading. Switch to decimal notation.

---
   xen/arch/arm/domain_build.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/domain_build.c +0 -0
index 829cea8de84f..7e204372368c 100644
@@ -3774,7 +3774,7 @@ static int __init construct_domU(struct domain *d,
       if ( rc != 0 )
           return rc;
 
Quoted 6 lines

xen/arch/arm/domain_build.c static int __init construct_domU(struct domain *d, · line 3777

Quoted 2 lines
xen/arch/arm/domain_build.c +1 -1
-    printk("*** LOADING DOMU cpus=%u memory=%"PRIx64"KB ***\n", d->max_vcpus, mem);
+    printk("*** LOADING DOMU cpus=%u memory=%"PRIu64"KB ***\n", d->max_vcpus, mem);

I will prefer it to be printed in hex format with 0x prefixed. The reason being the mem is obtained from device-tree domU's 'memory' prop where the values are in hex.

Quoted 5 lines

No, I cannot agree. Refer to booting.txt documentation:
"A 64-bit integer specifying the amount of kilobytes of RAM to allocate to the guest." Also note that in the provided examples, we are using the decimal values.
All in all it does not matter the notation, you can provide e.g. "memory = 131072;" or "memory = 0x20000". I find it a bit odd to print e.g. 0x20000KB and decimal is easier to read.

By easier, do you mean you can easily figure out how much memory in GB/MB/KB you gave to the guest? If so, then I have to disagree. Without a calculator, I will find quicker the split.

If you want to print in decimal, then I think we should split the amount in GB/MB/KB. Otherwise, we should stick in hexadecimal (so add 0x).

Cheers,

Signature · 1 line
Julien Grall
#4 lore raw

Hi Julien,

Quoted 34 lines · Julien Grall

Hi Michal,

Quoted 29 lines · Michal Orzel
Quoted 28 lines · Ayan Kumar Halder

Hi Michal,

Quoted 14 lines · Michal Orzel

Printing domain's memory size in hex without even prepending it with 0x is not very useful and can be misleading. Switch to decimal notation.

---
   xen/arch/arm/domain_build.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/domain_build.c +0 -0
index 829cea8de84f..7e204372368c 100644

xen/arch/arm/domain_build.c static int __init construct_domU(struct domain *d, · line 3777

Quoted 5 lines
xen/arch/arm/domain_build.c +1 -1
@@ -3774,7 +3774,7 @@ static int __init construct_domU(struct domain *d,
       if ( rc != 0 )
           return rc;
 
-    printk("*** LOADING DOMU cpus=%u memory=%"PRIx64"KB ***\n", d->max_vcpus, mem);
+    printk("*** LOADING DOMU cpus=%u memory=%"PRIu64"KB ***\n", d->max_vcpus, mem);

I will prefer it to be printed in hex format with 0x prefixed. The reason being the mem is obtained from device-tree domU's 'memory' prop where the values are in hex.

Quoted 8 lines
Quoted 5 lines

No, I cannot agree. Refer to booting.txt documentation:
"A 64-bit integer specifying the amount of kilobytes of RAM to allocate to the guest." Also note that in the provided examples, we are using the decimal values.
All in all it does not matter the notation, you can provide e.g. "memory = 131072;" or "memory = 0x20000". I find it a bit odd to print e.g. 0x20000KB and decimal is easier to read.

By easier, do you mean you can easily figure out how much memory in GB/MB/KB you gave to the guest? If so, then I have to disagree. Without a calculator, I will find quicker the split.

I guess it depends on the size but you have a valid point.

Quoted 3 lines

If you want to print in decimal, then I think we should split the amount in GB/MB/KB. Otherwise, we should stick in hexadecimal (so add 0x).

Ok, I will then just add a prefix.

Quoted 5 lines

Cheers,

--
Julien Grall

~Michal

#5 lore raw
In reply to Ayan Kumar Halder

Hi Ayan,

Quoted 10 lines · Ayan Kumar Halder
Quoted 9 lines · Michal Orzel

Printing domain's memory size in hex without even prepending it with 0x is not very useful and can be misleading. Switch to decimal notation.

---
  xen/arch/arm/domain_build.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines

xen/arch/arm/domain_build.c static int __init construct_domU(struct domain *d, · line 3778

Quoted 11 lines
xen/arch/arm/domain_build.c +1 -1
index 829cea8de84f..7e204372368c 100644
@@ -3774,7 +3774,7 @@ static int __init construct_domU(struct domain *d,
       if ( rc != 0 )
           return rc;
-    printk("*** LOADING DOMU cpus=%u memory=%"PRIx64"KB ***\n", 
 d->max_vcpus, mem);
+    printk("*** LOADING DOMU cpus=%u memory=%"PRIu64"KB ***\n", 
 d->max_vcpus, mem);

I will prefer it to be printed in hex format with 0x prefixed. The reason being the mem is obtained from device-tree domU's 'memory' prop where the values are in hex. > It will help the user to debug easily without requiring the the person to manually calculate the hex equivalent and then trying to correlate it with what is written in dts.

I am a bit confused with your reasoning. The value stored in the device-tree is a 64-bit value. This is then up to the consumer to decide whether the output provided is in hexadecimal or decimal.

So are you saying that the tool dumping the device-tree will show the values in hexadecimal?

If so, the argument is the same for the number of CPUs (you could have more than 15 vCPUs). So I think this argument to be used here.

TBH, I am a bit split between using hexadecimal and decimal here. For smaller values, decimal is definitely easier to read but for larger one (i.e. GB), then the hexadecimal would help (it is easier to do the math).

So I would leaning towards using hexadecimal for the memory (so adding the 0x).

Cheers,

Signature · 1 line
Julien Grall
Acked-by on v1 1/1
#6 lore raw
In reply to Michal Orzel
Quoted 5 lines · Michal Orzel

Printing domain's memory size in hex without even prepending it with 0x is not very useful and can be misleading. Switch to decimal notation.

Quoted 20 lines
---
 xen/arch/arm/domain_build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/domain_build.c +1 -1
index 829cea8de84f..7e204372368c 100644
@@ -3774,7 +3774,7 @@ static int __init construct_domU(struct domain *d,
     if ( rc != 0 )
         return rc;
 
-    printk("*** LOADING DOMU cpus=%u memory=%"PRIx64"KB ***\n", d->max_vcpus, mem);
+    printk("*** LOADING DOMU cpus=%u memory=%"PRIu64"KB ***\n", d->max_vcpus, mem);
 
     kinfo.vpl011 = dt_property_read_bool(node, "vpl011");
 
Signature · 1 line
2.25.1
#7 lore raw

Hi Stefano,

Quoted 8 lines · Stefano Stabellini
Quoted 5 lines · Michal Orzel

Printing domain's memory size in hex without even prepending it with 0x is not very useful and can be misleading. Switch to decimal notation.

Was this intended for v2 rather than v1?

Cheers,

Quoted 22 lines
Quoted 22 lines

---
  xen/arch/arm/domain_build.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/domain_build.c +1 -1
index 829cea8de84f..7e204372368c 100644
@@ -3774,7 +3774,7 @@ static int __init construct_domU(struct domain *d,
      if ( rc != 0 )
          return rc;
 
-    printk("*** LOADING DOMU cpus=%u memory=%"PRIx64"KB ***\n", d->max_vcpus, mem);
+    printk("*** LOADING DOMU cpus=%u memory=%"PRIu64"KB ***\n", d->max_vcpus, mem);
 
      kinfo.vpl011 = dt_property_read_bool(node, "vpl011");
 
Signature · 1 line
2.25.1
Signature · 1 line
Julien Grall
#8 lore raw
Quoted 8 lines · Julien Grall

Hi Stefano,

Quoted 5 lines · Stefano Stabellini
Quoted 4 lines · Michal Orzel

Printing domain's memory size in hex without even prepending it with 0x is not very useful and can be misleading. Switch to decimal notation.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Was this intended for v2 rather than v1?

I didn't notice v2 was already out. I did test v2 and made sure it is working so go ahead and pick whichever version you prefer

Quoted 24 lines
Quoted 20 lines
Quoted 20 lines
---
  xen/arch/arm/domain_build.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/domain_build.c +1 -0
index 829cea8de84f..7e204372368c 100644
@@ -3774,7 +3774,7 @@ static int __init construct_domU(struct domain *d,
      if ( rc != 0 )
          return rc;
  -    printk("*** LOADING DOMU cpus=%u memory=%"PRIx64"KB ***\n",
 d->max_vcpus, mem);
+    printk("*** LOADING DOMU cpus=%u memory=%"PRIu64"KB ***\n",
 d->max_vcpus, mem);
        kinfo.vpl011 = dt_property_read_bool(node, "vpl011");
Signature · 2 lines
-- 
2.25.1
Signature · 1 line
Julien Grall