All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Thomas Huth <thuth@redhat.com>, Stefan Weil <sw@weilnetz.de>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	qemu-devel@nongnu.org, qemu-trivial@nongnu.org,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Anthony Perard" <anthony.perard@citrix.com>,
	"Kevin Wolf" <kwolf@redhat.com>, "Max Reitz" <mreitz@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Richard Henderson" <rth@twiddle.net>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"open list:X86" <xen-devel@lists.xenproject.org>,
	"open list:Block layer core" <qemu-block@nongnu.org>
Subject: [Qemu-devel] [PATCH v5 11/46] hw/xen: Use the IEC binary prefix definitions
Date: Mon, 25 Jun 2018 09:42:03 -0300	[thread overview]
Message-ID: <20180625124238.25339-12-f4bug@amsat.org> (raw)
In-Reply-To: <20180625124238.25339-1-f4bug@amsat.org>

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Alan Robinson <Alan.Robinson@ts.fujitsu.com>
---
 hw/block/xen_disk.c        |  3 ++-
 hw/i386/xen/xen-mapcache.c |  3 ++-
 hw/xenpv/xen_domainbuild.c | 13 +++++++------
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
index 9fbc0cdb87..36eff94f84 100644
--- a/hw/block/xen_disk.c
+++ b/hw/block/xen_disk.c
@@ -20,6 +20,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include <sys/ioctl.h>
 #include <sys/uio.h>
 
@@ -814,7 +815,7 @@ static int blk_connect(struct XenDevice *xendev)
     xen_pv_printf(xendev, 1, "type \"%s\", fileproto \"%s\", filename \"%s\","
                   " size %" PRId64 " (%" PRId64 " MB)\n",
                   blkdev->type, blkdev->fileproto, blkdev->filename,
-                  blkdev->file_size, blkdev->file_size >> 20);
+                  blkdev->file_size, blkdev->file_size / MiB);
 
     /* Fill in number of sector size and number of sectors */
     xenstore_write_be_int(xendev, "sector-size", blkdev->file_blk);
diff --git a/hw/i386/xen/xen-mapcache.c b/hw/i386/xen/xen-mapcache.c
index 628b813a11..4e4f069a24 100644
--- a/hw/i386/xen/xen-mapcache.c
+++ b/hw/i386/xen/xen-mapcache.c
@@ -9,6 +9,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu/error-report.h"
 
 #include <sys/resource.h>
@@ -46,7 +47,7 @@
  * From empirical tests I observed that qemu use 75MB more than the
  * max_mcache_size.
  */
-#define NON_MCACHE_MEMORY_SIZE (80 * 1024 * 1024)
+#define NON_MCACHE_MEMORY_SIZE (80 * MiB)
 
 typedef struct MapCacheEntry {
     hwaddr paddr_index;
diff --git a/hw/xenpv/xen_domainbuild.c b/hw/xenpv/xen_domainbuild.c
index 027f76fad1..188acaca16 100644
--- a/hw/xenpv/xen_domainbuild.c
+++ b/hw/xenpv/xen_domainbuild.c
@@ -1,4 +1,5 @@
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/xen/xen_backend.h"
 #include "xen_domainbuild.h"
 #include "qemu/timer.h"
@@ -75,9 +76,9 @@ int xenstore_domain_init1(const char *kernel, const char *ramdisk,
     xenstore_write_str(dom, "vm",     vm);
 
     /* memory */
-    xenstore_write_int(dom, "memory/target", ram_size >> 10);  // kB
-    xenstore_write_int(vm, "memory",         ram_size >> 20);  // MB
-    xenstore_write_int(vm, "maxmem",         ram_size >> 20);  // MB
+    xenstore_write_int(dom, "memory/target", ram_size / KiB);
+    xenstore_write_int(vm, "memory",         ram_size / MiB);
+    xenstore_write_int(vm, "maxmem",         ram_size / MiB);
 
     /* cpus */
     for (i = 0; i < smp_cpus; i++) {
@@ -113,7 +114,7 @@ int xenstore_domain_init2(int xenstore_port, int xenstore_mfn,
 
     /* console */
     xenstore_write_str(dom, "console/type",     "ioemu");
-    xenstore_write_int(dom, "console/limit",    128 * 1024);
+    xenstore_write_int(dom, "console/limit",    128 * KiB);
     xenstore_write_int(dom, "console/ring-ref", console_mfn);
     xenstore_write_int(dom, "console/port",     console_port);
     xen_config_dev_console(0);
@@ -260,7 +261,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
     }
 #endif
 
-    rc = xc_domain_setmaxmem(xen_xc, xen_domid, ram_size >> 10);
+    rc = xc_domain_setmaxmem(xen_xc, xen_domid, ram_size / KiB);
     if (rc < 0) {
         fprintf(stderr, "xen: xc_domain_setmaxmem() failed\n");
         goto err;
@@ -269,7 +270,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
     xenstore_port = xc_evtchn_alloc_unbound(xen_xc, xen_domid, 0);
     console_port = xc_evtchn_alloc_unbound(xen_xc, xen_domid, 0);
 
-    rc = xc_linux_build(xen_xc, xen_domid, ram_size >> 20,
+    rc = xc_linux_build(xen_xc, xen_domid, ram_size / MiB,
                         kernel, ramdisk, cmdline,
                         0, flags,
                         xenstore_port, &xenstore_mfn,
-- 
2.18.0

WARNING: multiple messages have this Message-ID (diff)
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Thomas Huth <thuth@redhat.com>, Stefan Weil <sw@weilnetz.de>
Cc: "Kevin Wolf" <kwolf@redhat.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"open list:Block layer core" <qemu-block@nongnu.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	qemu-trivial@nongnu.org,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	qemu-devel@nongnu.org,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"open list:X86" <xen-devel@lists.xenproject.org>,
	"Anthony Perard" <anthony.perard@citrix.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Max Reitz" <mreitz@redhat.com>,
	"Richard Henderson" <rth@twiddle.net>
Subject: [PATCH v5 11/46] hw/xen: Use the IEC binary prefix definitions
Date: Mon, 25 Jun 2018 09:42:03 -0300	[thread overview]
Message-ID: <20180625124238.25339-12-f4bug@amsat.org> (raw)
In-Reply-To: <20180625124238.25339-1-f4bug@amsat.org>

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/

and modified manually.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Alan Robinson <Alan.Robinson@ts.fujitsu.com>
---
 hw/block/xen_disk.c        |  3 ++-
 hw/i386/xen/xen-mapcache.c |  3 ++-
 hw/xenpv/xen_domainbuild.c | 13 +++++++------
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
index 9fbc0cdb87..36eff94f84 100644
--- a/hw/block/xen_disk.c
+++ b/hw/block/xen_disk.c
@@ -20,6 +20,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include <sys/ioctl.h>
 #include <sys/uio.h>
 
@@ -814,7 +815,7 @@ static int blk_connect(struct XenDevice *xendev)
     xen_pv_printf(xendev, 1, "type \"%s\", fileproto \"%s\", filename \"%s\","
                   " size %" PRId64 " (%" PRId64 " MB)\n",
                   blkdev->type, blkdev->fileproto, blkdev->filename,
-                  blkdev->file_size, blkdev->file_size >> 20);
+                  blkdev->file_size, blkdev->file_size / MiB);
 
     /* Fill in number of sector size and number of sectors */
     xenstore_write_be_int(xendev, "sector-size", blkdev->file_blk);
diff --git a/hw/i386/xen/xen-mapcache.c b/hw/i386/xen/xen-mapcache.c
index 628b813a11..4e4f069a24 100644
--- a/hw/i386/xen/xen-mapcache.c
+++ b/hw/i386/xen/xen-mapcache.c
@@ -9,6 +9,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu/error-report.h"
 
 #include <sys/resource.h>
@@ -46,7 +47,7 @@
  * From empirical tests I observed that qemu use 75MB more than the
  * max_mcache_size.
  */
-#define NON_MCACHE_MEMORY_SIZE (80 * 1024 * 1024)
+#define NON_MCACHE_MEMORY_SIZE (80 * MiB)
 
 typedef struct MapCacheEntry {
     hwaddr paddr_index;
diff --git a/hw/xenpv/xen_domainbuild.c b/hw/xenpv/xen_domainbuild.c
index 027f76fad1..188acaca16 100644
--- a/hw/xenpv/xen_domainbuild.c
+++ b/hw/xenpv/xen_domainbuild.c
@@ -1,4 +1,5 @@
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/xen/xen_backend.h"
 #include "xen_domainbuild.h"
 #include "qemu/timer.h"
@@ -75,9 +76,9 @@ int xenstore_domain_init1(const char *kernel, const char *ramdisk,
     xenstore_write_str(dom, "vm",     vm);
 
     /* memory */
-    xenstore_write_int(dom, "memory/target", ram_size >> 10);  // kB
-    xenstore_write_int(vm, "memory",         ram_size >> 20);  // MB
-    xenstore_write_int(vm, "maxmem",         ram_size >> 20);  // MB
+    xenstore_write_int(dom, "memory/target", ram_size / KiB);
+    xenstore_write_int(vm, "memory",         ram_size / MiB);
+    xenstore_write_int(vm, "maxmem",         ram_size / MiB);
 
     /* cpus */
     for (i = 0; i < smp_cpus; i++) {
@@ -113,7 +114,7 @@ int xenstore_domain_init2(int xenstore_port, int xenstore_mfn,
 
     /* console */
     xenstore_write_str(dom, "console/type",     "ioemu");
-    xenstore_write_int(dom, "console/limit",    128 * 1024);
+    xenstore_write_int(dom, "console/limit",    128 * KiB);
     xenstore_write_int(dom, "console/ring-ref", console_mfn);
     xenstore_write_int(dom, "console/port",     console_port);
     xen_config_dev_console(0);
@@ -260,7 +261,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
     }
 #endif
 
-    rc = xc_domain_setmaxmem(xen_xc, xen_domid, ram_size >> 10);
+    rc = xc_domain_setmaxmem(xen_xc, xen_domid, ram_size / KiB);
     if (rc < 0) {
         fprintf(stderr, "xen: xc_domain_setmaxmem() failed\n");
         goto err;
@@ -269,7 +270,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
     xenstore_port = xc_evtchn_alloc_unbound(xen_xc, xen_domid, 0);
     console_port = xc_evtchn_alloc_unbound(xen_xc, xen_domid, 0);
 
-    rc = xc_linux_build(xen_xc, xen_domid, ram_size >> 20,
+    rc = xc_linux_build(xen_xc, xen_domid, ram_size / MiB,
                         kernel, ramdisk, cmdline,
                         0, flags,
                         xenstore_port, &xenstore_mfn,
-- 
2.18.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2018-06-25 12:43 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-25 12:41 [Qemu-devel] [PATCH v5 00/46] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
2018-06-25 12:41 ` [Qemu-devel] [PATCH v5 01/46] include: Add IEC binary prefixes in "qemu/units.h" Philippe Mathieu-Daudé
2018-06-27  5:48   ` Richard Henderson
2018-06-27 11:27   ` Igor Mammedov
2018-06-27 12:26     ` Eric Blake
2018-06-28 22:53       ` Philippe Mathieu-Daudé
2018-06-29 12:19         ` Eric Blake
2018-06-29 14:49           ` Philippe Mathieu-Daudé
2018-06-29 15:02             ` Daniel P. Berrangé
2018-06-29 17:03               ` Eric Blake
2018-06-25 12:41 ` [Qemu-devel] [PATCH v5 02/46] vdi: Use definitions from "qemu/units.h" Philippe Mathieu-Daudé
2018-06-27  5:48   ` Richard Henderson
2018-06-25 12:41 ` [Qemu-devel] [PATCH v5 03/46] x86/cpu: " Philippe Mathieu-Daudé
2018-06-27  5:49   ` Richard Henderson
2018-06-25 12:41 ` [Qemu-devel] [PATCH v5 04/46] checkpatch: Recognize IEC binary prefix definitions Philippe Mathieu-Daudé
2018-06-29 20:41   ` Eric Blake
2018-06-29 21:46     ` Joe Perches
2018-07-02 12:37       ` Paolo Bonzini
2018-07-02 14:45         ` Joe Perches
2018-06-25 12:41 ` [Qemu-devel] [PATCH v5 05/46] hw: Use IEC binary prefix definitions from "qemu/units.h" Philippe Mathieu-Daudé
2018-06-27  5:57   ` Richard Henderson
2018-06-25 12:41 ` [Qemu-devel] [PATCH v5 06/46] hw: Directly use "qemu/units.h" instead of "qemu/cutils.h" Philippe Mathieu-Daudé
2018-06-27  6:04   ` Richard Henderson
2018-06-25 12:41 ` [Qemu-devel] [PATCH v5 07/46] hw/ivshmem: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 08/46] hw/ipack: " Philippe Mathieu-Daudé
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 09/46] hw/scsi: " Philippe Mathieu-Daudé
2018-06-27  6:05   ` Richard Henderson
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 10/46] hw/smbios: " Philippe Mathieu-Daudé
2018-06-27  6:09   ` Richard Henderson
2018-06-27 14:03   ` Igor Mammedov
2018-06-25 12:42 ` Philippe Mathieu-Daudé [this message]
2018-06-25 12:42   ` [PATCH v5 11/46] hw/xen: " Philippe Mathieu-Daudé
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 12/46] hw/tpm: " Philippe Mathieu-Daudé
2018-06-27 11:24   ` Igor Mammedov
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 13/46] hw/block: " Philippe Mathieu-Daudé
2018-06-27  6:12   ` Richard Henderson
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 14/46] hw/display: " Philippe Mathieu-Daudé
2018-06-25 12:42   ` Philippe Mathieu-Daudé
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 15/46] hw/misc: " Philippe Mathieu-Daudé
2018-06-27  6:13   ` Richard Henderson
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 16/46] hw/riscv: " Philippe Mathieu-Daudé
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 17/46] hw/m68k: " Philippe Mathieu-Daudé
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 18/46] hw/sparc: " Philippe Mathieu-Daudé
2018-06-27  6:14   ` Richard Henderson
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 19/46] hw/s390x: " Philippe Mathieu-Daudé
2018-06-25 13:07   ` Cornelia Huck
2018-06-25 13:16     ` David Hildenbrand
2018-06-25 14:21       ` Cornelia Huck
2018-06-25 13:19     ` Philippe Mathieu-Daudé
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 21/46] hw/xtensa: " Philippe Mathieu-Daudé
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 22/46] hw/alpha: " Philippe Mathieu-Daudé
2018-06-27  6:18   ` Richard Henderson
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 23/46] hw/tricore: " Philippe Mathieu-Daudé
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 24/46] hw/microblaze: " Philippe Mathieu-Daudé
2018-06-27  6:19   ` Richard Henderson
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 25/46] hw/nios2: " Philippe Mathieu-Daudé
2018-06-27  6:59   ` Richard Henderson
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 26/46] hw/cris: " Philippe Mathieu-Daudé
2018-06-27  6:59   ` Richard Henderson
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 27/46] hw/lm32: " Philippe Mathieu-Daudé
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 28/46] hw/sh4: " Philippe Mathieu-Daudé
2018-06-27  7:00   ` Richard Henderson
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 29/46] hw/mips/r4k: Constify params_size Philippe Mathieu-Daudé
2018-06-27 13:48   ` Thomas Huth
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 30/46] hw/mips: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 32/46] hw/ppc: " Philippe Mathieu-Daudé
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 34/46] hw/net: " Philippe Mathieu-Daudé
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 35/46] hw/usb: " Philippe Mathieu-Daudé
2018-06-27  7:04   ` Richard Henderson
2018-06-27 13:03     ` Philippe Mathieu-Daudé
2018-06-27 13:47       ` Richard Henderson
2018-06-27 14:43         ` Philippe Mathieu-Daudé
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 36/46] hw/sd: " Philippe Mathieu-Daudé
2018-06-27  7:19   ` Richard Henderson
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 37/46] hw/vfio: " Philippe Mathieu-Daudé
2018-06-27  7:26   ` Richard Henderson
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 38/46] hw/virtio: " Philippe Mathieu-Daudé
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 39/46] hw/rdma: " Philippe Mathieu-Daudé
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 40/46] cutils: Do not include "qemu/units.h" directly Philippe Mathieu-Daudé
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 41/46] hw/ppc: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
2018-06-26  0:48   ` David Gibson
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 42/46] monitor: " Philippe Mathieu-Daudé
2018-06-27 14:39   ` Richard Henderson
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 43/46] vl: " Philippe Mathieu-Daudé
2018-06-27 14:40   ` Richard Henderson
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 44/46] tests/crypto: " Philippe Mathieu-Daudé
2018-06-27 14:41   ` Richard Henderson
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 45/46] linux-user: " Philippe Mathieu-Daudé
2018-06-27 14:42   ` Richard Henderson
2018-06-27 18:50   ` Laurent Vivier
2018-06-25 12:42 ` [Qemu-devel] [PATCH v5 46/46] bsd-user: " Philippe Mathieu-Daudé
2018-06-27 14:42   ` Richard Henderson
2018-06-26  1:08 ` [Qemu-devel] [PATCH v5 00/46] " Michael S. Tsirkin
     [not found] ` <20180625124238.25339-34-f4bug@amsat.org>
2018-06-27 14:01   ` [Qemu-devel] [PATCH v5 33/46] hw/i386: " Igor Mammedov
2018-06-29 14:08 ` [Qemu-devel] [Qemu-block] [PATCH v5 00/46] " Paolo Bonzini

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=20180625124238.25339-12-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=anthony.perard@citrix.com \
    --cc=ehabkost@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=sstabellini@kernel.org \
    --cc=sw@weilnetz.de \
    --cc=thuth@redhat.com \
    --cc=xen-devel@lists.xenproject.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.