* [Qemu-devel] [PATCH for-2.13] Add host_memory_backend_pagesize() helper
@ 2018-03-29 5:25 David Gibson
2018-03-29 6:37 ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: David Gibson @ 2018-03-29 5:25 UTC (permalink / raw)
To: ehabkost, imammedo; +Cc: pbonzini, qemu-devel, qemu-ppc, david
There are a couple places (one generic, one target specific) where we need
to get the host page size associated with a particular memory backend. I
have some upcoming code which will add another place which wants this. So,
for convenience, add a helper function to calculate this.
host_memory_backend_pagesize() returns the host pagesize for a given
HostMemoryBackend object, or for the default backend (-mem-path) if passed
NULL.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
backends/hostmem.c | 20 ++++++++++++++++++++
exec.c | 21 +++++----------------
include/sysemu/hostmem.h | 2 ++
target/ppc/kvm.c | 10 +---------
4 files changed, 28 insertions(+), 25 deletions(-)
diff --git a/backends/hostmem.c b/backends/hostmem.c
index f61093654e..b6a60cfc5d 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -18,6 +18,7 @@
#include "qapi/visitor.h"
#include "qemu/config-file.h"
#include "qom/object_interfaces.h"
+#include "qemu/mmap-alloc.h"
#ifdef CONFIG_NUMA
#include <numaif.h>
@@ -262,6 +263,25 @@ bool host_memory_backend_is_mapped(HostMemoryBackend *backend)
return backend->is_mapped;
}
+long host_memory_backend_pagesize(HostMemoryBackend *memdev)
+{
+ const char *path = NULL;
+
+#ifdef __linux__
+ if (memdev) {
+ path = object_property_get_str(OBJECT(memdev), "mem-path", NULL);
+ } else {
+ path = mem_path;
+ }
+#endif
+
+ if (path) {
+ return qemu_mempath_getpagesize(path);
+ } else {
+ return getpagesize();
+ }
+}
+
static void
host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
{
diff --git a/exec.c b/exec.c
index c09bd93df3..04856c2402 100644
--- a/exec.c
+++ b/exec.c
@@ -1488,18 +1488,13 @@ void ram_block_dump(Monitor *mon)
*/
static int find_max_supported_pagesize(Object *obj, void *opaque)
{
- char *mem_path;
long *hpsize_min = opaque;
if (object_dynamic_cast(obj, TYPE_MEMORY_BACKEND)) {
- mem_path = object_property_get_str(obj, "mem-path", NULL);
- if (mem_path) {
- long hpsize = qemu_mempath_getpagesize(mem_path);
- if (hpsize < *hpsize_min) {
- *hpsize_min = hpsize;
- }
- } else {
- *hpsize_min = getpagesize();
+ long hpsize = host_memory_backend_pagesize(MEMORY_BACKEND(obj));
+
+ if (hpsize < *hpsize_min) {
+ *hpsize_min = hpsize;
}
}
@@ -1509,15 +1504,9 @@ static int find_max_supported_pagesize(Object *obj, void *opaque)
long qemu_getrampagesize(void)
{
long hpsize = LONG_MAX;
- long mainrampagesize;
+ long mainrampagesize = host_memory_backend_pagesize(NULL);
Object *memdev_root;
- if (mem_path) {
- mainrampagesize = qemu_mempath_getpagesize(mem_path);
- } else {
- mainrampagesize = getpagesize();
- }
-
/* it's possible we have memory-backend objects with
* hugepage-backed RAM. these may get mapped into system
* address space via -numa parameters or memory hotplug
diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h
index 47bc9846ac..f474ef97f6 100644
--- a/include/sysemu/hostmem.h
+++ b/include/sysemu/hostmem.h
@@ -68,4 +68,6 @@ MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend,
void host_memory_backend_set_mapped(HostMemoryBackend *backend, bool mapped);
bool host_memory_backend_is_mapped(HostMemoryBackend *backend);
+long host_memory_backend_pagesize(HostMemoryBackend *memdev);
+
#endif
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index b329cd8173..0adcf18c9f 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -493,15 +493,7 @@ static void kvm_fixup_page_sizes(PowerPCCPU *cpu)
bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path)
{
Object *mem_obj = object_resolve_path(obj_path, NULL);
- char *mempath = object_property_get_str(mem_obj, "mem-path", NULL);
- long pagesize;
-
- if (mempath) {
- pagesize = qemu_mempath_getpagesize(mempath);
- g_free(mempath);
- } else {
- pagesize = getpagesize();
- }
+ long pagesize = host_memory_backend_pagesize(MEMORY_BACKEND(mem_obj));
return pagesize >= max_cpu_page_size;
}
--
2.14.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH for-2.13] Add host_memory_backend_pagesize() helper
2018-03-29 5:25 [Qemu-devel] [PATCH for-2.13] Add host_memory_backend_pagesize() helper David Gibson
@ 2018-03-29 6:37 ` Greg Kurz
2018-03-29 9:56 ` Greg Kurz
2018-04-03 5:31 ` David Gibson
2018-03-31 8:00 ` [Qemu-devel] " no-reply
2018-04-03 2:22 ` Eduardo Habkost
2 siblings, 2 replies; 7+ messages in thread
From: Greg Kurz @ 2018-03-29 6:37 UTC (permalink / raw)
To: David Gibson; +Cc: ehabkost, imammedo, pbonzini, qemu-ppc, qemu-devel
On Thu, 29 Mar 2018 16:25:37 +1100
David Gibson <david@gibson.dropbear.id.au> wrote:
> There are a couple places (one generic, one target specific) where we need
> to get the host page size associated with a particular memory backend. I
> have some upcoming code which will add another place which wants this. So,
> for convenience, add a helper function to calculate this.
>
> host_memory_backend_pagesize() returns the host pagesize for a given
> HostMemoryBackend object, or for the default backend (-mem-path) if passed
> NULL.
>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
The idea is good but there's a small issue. See below.
> backends/hostmem.c | 20 ++++++++++++++++++++
> exec.c | 21 +++++----------------
> include/sysemu/hostmem.h | 2 ++
> target/ppc/kvm.c | 10 +---------
> 4 files changed, 28 insertions(+), 25 deletions(-)
>
> diff --git a/backends/hostmem.c b/backends/hostmem.c
> index f61093654e..b6a60cfc5d 100644
> --- a/backends/hostmem.c
> +++ b/backends/hostmem.c
> @@ -18,6 +18,7 @@
> #include "qapi/visitor.h"
> #include "qemu/config-file.h"
> #include "qom/object_interfaces.h"
> +#include "qemu/mmap-alloc.h"
>
> #ifdef CONFIG_NUMA
> #include <numaif.h>
> @@ -262,6 +263,25 @@ bool host_memory_backend_is_mapped(HostMemoryBackend *backend)
> return backend->is_mapped;
> }
>
> +long host_memory_backend_pagesize(HostMemoryBackend *memdev)
> +{
> + const char *path = NULL;
> +
> +#ifdef __linux__
> + if (memdev) {
> + path = object_property_get_str(OBJECT(memdev), "mem-path", NULL);
object_property_get_str() returns an allocated string. It should be freed
before returning.
> + } else {
> + path = mem_path;
> + }
> +#endif
> +
> + if (path) {
> + return qemu_mempath_getpagesize(path);
> + } else {
> + return getpagesize();
> + }
> +}
> +
> static void
> host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
> {
> diff --git a/exec.c b/exec.c
> index c09bd93df3..04856c2402 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -1488,18 +1488,13 @@ void ram_block_dump(Monitor *mon)
> */
> static int find_max_supported_pagesize(Object *obj, void *opaque)
> {
> - char *mem_path;
> long *hpsize_min = opaque;
>
> if (object_dynamic_cast(obj, TYPE_MEMORY_BACKEND)) {
> - mem_path = object_property_get_str(obj, "mem-path", NULL);
> - if (mem_path) {
> - long hpsize = qemu_mempath_getpagesize(mem_path);
... ie, this code currently leaks mem_path. This should be fixed in 2.12...
> - if (hpsize < *hpsize_min) {
> - *hpsize_min = hpsize;
> - }
> - } else {
> - *hpsize_min = getpagesize();
> + long hpsize = host_memory_backend_pagesize(MEMORY_BACKEND(obj));
> +
> + if (hpsize < *hpsize_min) {
> + *hpsize_min = hpsize;
> }
> }
>
> @@ -1509,15 +1504,9 @@ static int find_max_supported_pagesize(Object *obj, void *opaque)
> long qemu_getrampagesize(void)
> {
> long hpsize = LONG_MAX;
> - long mainrampagesize;
> + long mainrampagesize = host_memory_backend_pagesize(NULL);
> Object *memdev_root;
>
> - if (mem_path) {
> - mainrampagesize = qemu_mempath_getpagesize(mem_path);
> - } else {
> - mainrampagesize = getpagesize();
> - }
> -
> /* it's possible we have memory-backend objects with
> * hugepage-backed RAM. these may get mapped into system
> * address space via -numa parameters or memory hotplug
> diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h
> index 47bc9846ac..f474ef97f6 100644
> --- a/include/sysemu/hostmem.h
> +++ b/include/sysemu/hostmem.h
> @@ -68,4 +68,6 @@ MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend,
>
> void host_memory_backend_set_mapped(HostMemoryBackend *backend, bool mapped);
> bool host_memory_backend_is_mapped(HostMemoryBackend *backend);
> +long host_memory_backend_pagesize(HostMemoryBackend *memdev);
> +
> #endif
> diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
> index b329cd8173..0adcf18c9f 100644
> --- a/target/ppc/kvm.c
> +++ b/target/ppc/kvm.c
> @@ -493,15 +493,7 @@ static void kvm_fixup_page_sizes(PowerPCCPU *cpu)
> bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path)
> {
> Object *mem_obj = object_resolve_path(obj_path, NULL);
> - char *mempath = object_property_get_str(mem_obj, "mem-path", NULL);
> - long pagesize;
> -
> - if (mempath) {
> - pagesize = qemu_mempath_getpagesize(mempath);
> - g_free(mempath);
... but this code is ok. No leak :)
> - } else {
> - pagesize = getpagesize();
> - }
> + long pagesize = host_memory_backend_pagesize(MEMORY_BACKEND(mem_obj));
>
> return pagesize >= max_cpu_page_size;
> }
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH for-2.13] Add host_memory_backend_pagesize() helper
2018-03-29 6:37 ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
@ 2018-03-29 9:56 ` Greg Kurz
2018-04-03 5:31 ` David Gibson
1 sibling, 0 replies; 7+ messages in thread
From: Greg Kurz @ 2018-03-29 9:56 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-devel, imammedo, qemu-ppc, ehabkost, pbonzini
On Thu, 29 Mar 2018 08:37:48 +0200
Greg Kurz <groug@kaod.org> wrote:
> On Thu, 29 Mar 2018 16:25:37 +1100
> David Gibson <david@gibson.dropbear.id.au> wrote:
>
> > There are a couple places (one generic, one target specific) where we need
> > to get the host page size associated with a particular memory backend. I
> > have some upcoming code which will add another place which wants this. So,
> > for convenience, add a helper function to calculate this.
> >
> > host_memory_backend_pagesize() returns the host pagesize for a given
> > HostMemoryBackend object, or for the default backend (-mem-path) if passed
> > NULL.
> >
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> > ---
>
[...]
> > diff --git a/exec.c b/exec.c
> > index c09bd93df3..04856c2402 100644
> > --- a/exec.c
> > +++ b/exec.c
> > @@ -1488,18 +1488,13 @@ void ram_block_dump(Monitor *mon)
> > */
> > static int find_max_supported_pagesize(Object *obj, void *opaque)
> > {
> > - char *mem_path;
> > long *hpsize_min = opaque;
> >
> > if (object_dynamic_cast(obj, TYPE_MEMORY_BACKEND)) {
> > - mem_path = object_property_get_str(obj, "mem-path", NULL);
> > - if (mem_path) {
> > - long hpsize = qemu_mempath_getpagesize(mem_path);
>
> ... ie, this code currently leaks mem_path. This should be fixed in 2.12...
>
FYI, I've sent a series to fix various object_property_get_str()-based
leaks, including this one.
https://lists.nongnu.org/archive/html/qemu-devel/2018-03/msg07266.html
> > - if (hpsize < *hpsize_min) {
> > - *hpsize_min = hpsize;
> > - }
> > - } else {
> > - *hpsize_min = getpagesize();
> > + long hpsize = host_memory_backend_pagesize(MEMORY_BACKEND(obj));
> > +
> > + if (hpsize < *hpsize_min) {
> > + *hpsize_min = hpsize;
> > }
> > }
> >
> > @@ -1509,15 +1504,9 @@ static int find_max_supported_pagesize(Object *obj, void *opaque)
> > long qemu_getrampagesize(void)
> > {
> > long hpsize = LONG_MAX;
> > - long mainrampagesize;
> > + long mainrampagesize = host_memory_backend_pagesize(NULL);
> > Object *memdev_root;
> >
> > - if (mem_path) {
> > - mainrampagesize = qemu_mempath_getpagesize(mem_path);
> > - } else {
> > - mainrampagesize = getpagesize();
> > - }
> > -
> > /* it's possible we have memory-backend objects with
> > * hugepage-backed RAM. these may get mapped into system
> > * address space via -numa parameters or memory hotplug
> > diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h
> > index 47bc9846ac..f474ef97f6 100644
> > --- a/include/sysemu/hostmem.h
> > +++ b/include/sysemu/hostmem.h
> > @@ -68,4 +68,6 @@ MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend,
> >
> > void host_memory_backend_set_mapped(HostMemoryBackend *backend, bool mapped);
> > bool host_memory_backend_is_mapped(HostMemoryBackend *backend);
> > +long host_memory_backend_pagesize(HostMemoryBackend *memdev);
> > +
> > #endif
> > diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
> > index b329cd8173..0adcf18c9f 100644
> > --- a/target/ppc/kvm.c
> > +++ b/target/ppc/kvm.c
> > @@ -493,15 +493,7 @@ static void kvm_fixup_page_sizes(PowerPCCPU *cpu)
> > bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path)
> > {
> > Object *mem_obj = object_resolve_path(obj_path, NULL);
> > - char *mempath = object_property_get_str(mem_obj, "mem-path", NULL);
> > - long pagesize;
> > -
> > - if (mempath) {
> > - pagesize = qemu_mempath_getpagesize(mempath);
> > - g_free(mempath);
>
> ... but this code is ok. No leak :)
>
> > - } else {
> > - pagesize = getpagesize();
> > - }
> > + long pagesize = host_memory_backend_pagesize(MEMORY_BACKEND(mem_obj));
> >
> > return pagesize >= max_cpu_page_size;
> > }
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH for-2.13] Add host_memory_backend_pagesize() helper
2018-03-29 5:25 [Qemu-devel] [PATCH for-2.13] Add host_memory_backend_pagesize() helper David Gibson
2018-03-29 6:37 ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
@ 2018-03-31 8:00 ` no-reply
2018-04-03 2:22 ` Eduardo Habkost
2 siblings, 0 replies; 7+ messages in thread
From: no-reply @ 2018-03-31 8:00 UTC (permalink / raw)
To: david; +Cc: famz, ehabkost, imammedo, pbonzini, qemu-ppc, qemu-devel
Hi,
This series failed docker-build@min-glib build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.
Type: series
Message-id: 20180329052537.32163-1-david@gibson.dropbear.id.au
Subject: [Qemu-devel] [PATCH for-2.13] Add host_memory_backend_pagesize() helper
=== TEST SCRIPT BEGIN ===
#!/bin/bash
set -e
git submodule update --init dtc
# Let docker tests dump environment info
export SHOW_ENV=1
export J=8
time make docker-test-build@min-glib
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
d792ec03e0 Add host_memory_backend_pagesize() helper
=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into '/var/tmp/patchew-tester-tmp-zb9x6tst/src/dtc'...
Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42'
BUILD min-glib
make[1]: Entering directory '/var/tmp/patchew-tester-tmp-zb9x6tst/src'
GEN /var/tmp/patchew-tester-tmp-zb9x6tst/src/docker-src.2018-03-31-03.59.56.9769/qemu.tar
Cloning into '/var/tmp/patchew-tester-tmp-zb9x6tst/src/docker-src.2018-03-31-03.59.56.9769/qemu.tar.vroot'...
done.
Checking out files: 25% (1567/6066)
Checking out files: 26% (1578/6066)
Checking out files: 27% (1638/6066)
Checking out files: 28% (1699/6066)
Checking out files: 29% (1760/6066)
Checking out files: 30% (1820/6066)
Checking out files: 31% (1881/6066)
Checking out files: 31% (1902/6066)
Checking out files: 32% (1942/6066)
Checking out files: 33% (2002/6066)
Checking out files: 34% (2063/6066)
Checking out files: 35% (2124/6066)
Checking out files: 36% (2184/6066)
Checking out files: 37% (2245/6066)
Checking out files: 38% (2306/6066)
Checking out files: 39% (2366/6066)
Checking out files: 40% (2427/6066)
Checking out files: 41% (2488/6066)
Checking out files: 42% (2548/6066)
Checking out files: 43% (2609/6066)
Checking out files: 44% (2670/6066)
Checking out files: 45% (2730/6066)
Checking out files: 46% (2791/6066)
Checking out files: 47% (2852/6066)
Checking out files: 48% (2912/6066)
Checking out files: 49% (2973/6066)
Checking out files: 50% (3033/6066)
Checking out files: 51% (3094/6066)
Checking out files: 52% (3155/6066)
Checking out files: 53% (3215/6066)
Checking out files: 53% (3254/6066)
Checking out files: 54% (3276/6066)
Checking out files: 55% (3337/6066)
Checking out files: 56% (3397/6066)
Checking out files: 57% (3458/6066)
Checking out files: 58% (3519/6066)
Checking out files: 59% (3579/6066)
Checking out files: 60% (3640/6066)
Checking out files: 61% (3701/6066)
Checking out files: 62% (3761/6066)
Checking out files: 63% (3822/6066)
Checking out files: 64% (3883/6066)
Checking out files: 65% (3943/6066)
Checking out files: 66% (4004/6066)
Checking out files: 67% (4065/6066)
Checking out files: 68% (4125/6066)
Checking out files: 69% (4186/6066)
Checking out files: 70% (4247/6066)
Checking out files: 71% (4307/6066)
Checking out files: 72% (4368/6066)
Checking out files: 73% (4429/6066)
Checking out files: 74% (4489/6066)
Checking out files: 75% (4550/6066)
Checking out files: 76% (4611/6066)
Checking out files: 77% (4671/6066)
Checking out files: 78% (4732/6066)
Checking out files: 79% (4793/6066)
Checking out files: 80% (4853/6066)
Checking out files: 81% (4914/6066)
Checking out files: 82% (4975/6066)
Checking out files: 82% (5033/6066)
Checking out files: 83% (5035/6066)
Checking out files: 84% (5096/6066)
Checking out files: 85% (5157/6066)
Checking out files: 86% (5217/6066)
Checking out files: 87% (5278/6066)
Checking out files: 88% (5339/6066)
Checking out files: 89% (5399/6066)
Checking out files: 90% (5460/6066)
Checking out files: 91% (5521/6066)
Checking out files: 92% (5581/6066)
Checking out files: 93% (5642/6066)
Checking out files: 94% (5703/6066)
Checking out files: 95% (5763/6066)
Checking out files: 96% (5824/6066)
Checking out files: 97% (5885/6066)
Checking out files: 98% (5945/6066)
Checking out files: 99% (6006/6066)
Checking out files: 100% (6066/6066)
Checking out files: 100% (6066/6066), done.
Your branch is up-to-date with 'origin/test'.
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into '/var/tmp/patchew-tester-tmp-zb9x6tst/src/docker-src.2018-03-31-03.59.56.9769/qemu.tar.vroot/dtc'...
Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42'
Submodule 'ui/keycodemapdb' (git://git.qemu.org/keycodemapdb.git) registered for path 'ui/keycodemapdb'
Cloning into '/var/tmp/patchew-tester-tmp-zb9x6tst/src/docker-src.2018-03-31-03.59.56.9769/qemu.tar.vroot/ui/keycodemapdb'...
Submodule path 'ui/keycodemapdb': checked out '6b3d716e2b6472eb7189d3220552280ef3d832ce'
tar: /var/tmp/patchew-tester-tmp-zb9x6tst/src/docker-src.2018-03-31-03.59.56.9769/qemu.tar: Wrote only 2048 of 10240 bytes
tar: Error is not recoverable: exiting now
failed to create tar file
COPY RUNNER
RUN test-build in qemu:min-glib
tar: Unexpected EOF in archive
tar: rmtlseek not stopped at a record boundary
tar: Error is not recoverable: exiting now
/var/tmp/qemu/run: line 32: prep_fail: command not found
Environment variables:
HOSTNAME=7f3db3fced08
MAKEFLAGS= -j8
J=8
CCACHE_DIR=/var/tmp/ccache
EXTRA_CONFIGURE_OPTS=
V=
SHOW_ENV=1
PATH=/usr/lib/ccache:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
TARGET_LIST=
SHLVL=1
HOME=/root
TEST_DIR=/tmp/qemu-test
FEATURES= dtc
DEBUG=
_=/usr/bin/env
/var/tmp/qemu/run: line 52: cd: /tmp/qemu-test/src/tests/docker: No such file or directory
/var/tmp/qemu/run: line 57: /test-build: No such file or directory
/var/tmp/qemu/run: line 57: exec: /test-build: cannot execute: No such file or directory
Traceback (most recent call last):
File "./tests/docker/docker.py", line 407, in <module>
sys.exit(main())
File "./tests/docker/docker.py", line 404, in main
return args.cmdobj.run(args, argv)
File "./tests/docker/docker.py", line 261, in run
return Docker().run(argv, args.keep, quiet=args.quiet)
File "./tests/docker/docker.py", line 229, in run
quiet=quiet)
File "./tests/docker/docker.py", line 147, in _do_check
return subprocess.check_call(self._command + cmd, **kwargs)
File "/usr/lib64/python2.7/subprocess.py", line 186, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['docker', 'run', '--label', 'com.qemu.instance.uuid=8e141b9234b911e8a3e452540069c830', '-u', '0', '--security-opt', 'seccomp=unconfined', '--rm', '--net=none', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=8', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/root/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-zb9x6tst/src/docker-src.2018-03-31-03.59.56.9769:/var/tmp/qemu:z,ro', 'qemu:min-glib', '/var/tmp/qemu/run', 'test-build']' returned non-zero exit status 126
make[1]: *** [tests/docker/Makefile.include:129: docker-run] Error 1
make[1]: Leaving directory '/var/tmp/patchew-tester-tmp-zb9x6tst/src'
make: *** [tests/docker/Makefile.include:163: docker-run-test-build@min-glib] Error 2
real 0m36.746s
user 0m9.045s
sys 0m6.498s
=== OUTPUT END ===
Test command exited with code: 2
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH for-2.13] Add host_memory_backend_pagesize() helper
2018-03-29 5:25 [Qemu-devel] [PATCH for-2.13] Add host_memory_backend_pagesize() helper David Gibson
2018-03-29 6:37 ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2018-03-31 8:00 ` [Qemu-devel] " no-reply
@ 2018-04-03 2:22 ` Eduardo Habkost
2018-04-03 5:29 ` David Gibson
2 siblings, 1 reply; 7+ messages in thread
From: Eduardo Habkost @ 2018-04-03 2:22 UTC (permalink / raw)
To: David Gibson; +Cc: imammedo, pbonzini, qemu-devel, qemu-ppc
On Thu, Mar 29, 2018 at 04:25:37PM +1100, David Gibson wrote:
> There are a couple places (one generic, one target specific) where we need
> to get the host page size associated with a particular memory backend. I
> have some upcoming code which will add another place which wants this. So,
> for convenience, add a helper function to calculate this.
>
> host_memory_backend_pagesize() returns the host pagesize for a given
> HostMemoryBackend object, or for the default backend (-mem-path) if passed
> NULL.
>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> backends/hostmem.c | 20 ++++++++++++++++++++
> exec.c | 21 +++++----------------
> include/sysemu/hostmem.h | 2 ++
> target/ppc/kvm.c | 10 +---------
> 4 files changed, 28 insertions(+), 25 deletions(-)
>
> diff --git a/backends/hostmem.c b/backends/hostmem.c
> index f61093654e..b6a60cfc5d 100644
> --- a/backends/hostmem.c
> +++ b/backends/hostmem.c
> @@ -18,6 +18,7 @@
> #include "qapi/visitor.h"
> #include "qemu/config-file.h"
> #include "qom/object_interfaces.h"
> +#include "qemu/mmap-alloc.h"
>
> #ifdef CONFIG_NUMA
> #include <numaif.h>
> @@ -262,6 +263,25 @@ bool host_memory_backend_is_mapped(HostMemoryBackend *backend)
> return backend->is_mapped;
> }
>
> +long host_memory_backend_pagesize(HostMemoryBackend *memdev)
qemu_mempath_getpagesize() returns size_t. Why are you using
long here?
> +{
> + const char *path = NULL;
> +
> +#ifdef __linux__
> + if (memdev) {
> + path = object_property_get_str(OBJECT(memdev), "mem-path", NULL);
> + } else {
> + path = mem_path;
> + }
> +#endif
> +
> + if (path) {
> + return qemu_mempath_getpagesize(path);
> + } else {
> + return getpagesize();
Isn't it simpler to make qemu_mempath_getpagesize() handle
path==NULL?
> + }
> +}
> +
> static void
> host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
> {
> diff --git a/exec.c b/exec.c
> index c09bd93df3..04856c2402 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -1488,18 +1488,13 @@ void ram_block_dump(Monitor *mon)
> */
> static int find_max_supported_pagesize(Object *obj, void *opaque)
> {
> - char *mem_path;
> long *hpsize_min = opaque;
>
> if (object_dynamic_cast(obj, TYPE_MEMORY_BACKEND)) {
> - mem_path = object_property_get_str(obj, "mem-path", NULL);
> - if (mem_path) {
> - long hpsize = qemu_mempath_getpagesize(mem_path);
> - if (hpsize < *hpsize_min) {
> - *hpsize_min = hpsize;
> - }
> - } else {
> - *hpsize_min = getpagesize();
> + long hpsize = host_memory_backend_pagesize(MEMORY_BACKEND(obj));
So in this caller, `backend` is always non-NULL...
> +
> + if (hpsize < *hpsize_min) {
> + *hpsize_min = hpsize;
> }
> }
>
> @@ -1509,15 +1504,9 @@ static int find_max_supported_pagesize(Object *obj, void *opaque)
> long qemu_getrampagesize(void)
> {
> long hpsize = LONG_MAX;
> - long mainrampagesize;
> + long mainrampagesize = host_memory_backend_pagesize(NULL);
...on this caller `backend` is always NULL...
> Object *memdev_root;
>
> - if (mem_path) {
> - mainrampagesize = qemu_mempath_getpagesize(mem_path);
> - } else {
> - mainrampagesize = getpagesize();
> - }
> -
> /* it's possible we have memory-backend objects with
> * hugepage-backed RAM. these may get mapped into system
> * address space via -numa parameters or memory hotplug
[...]
> diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
> index b329cd8173..0adcf18c9f 100644
> --- a/target/ppc/kvm.c
> +++ b/target/ppc/kvm.c
> @@ -493,15 +493,7 @@ static void kvm_fixup_page_sizes(PowerPCCPU *cpu)
> bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path)
> {
> Object *mem_obj = object_resolve_path(obj_path, NULL);
> - char *mempath = object_property_get_str(mem_obj, "mem-path", NULL);
> - long pagesize;
> -
> - if (mempath) {
> - pagesize = qemu_mempath_getpagesize(mempath);
> - g_free(mempath);
> - } else {
> - pagesize = getpagesize();
> - }
> + long pagesize = host_memory_backend_pagesize(MEMORY_BACKEND(mem_obj));
>
...and here `backend` is always non-NULL.
If there's no caller that relies on both code paths, why overload
a single function for two different operations?
I would simply make qemu_mempath_getpagesize() work if path is
NULL, use qemu_mempath_getpagesize(mem_path) at
qemu_getrampagesize(), and make host_memory_backend_pagesize()
assume require a non-NULL `memdev`.
> +long host_memory_backend_pagesize(HostMemoryBackend *memdev)
Why is the code duplicated in target/ppc/kvm.c?
> +{
> + const char *path = NULL;
> +
> +#ifdef __linux__
> + if (memdev) {
> + path = object_property_get_str(OBJECT(memdev), "mem-path", NULL);
> + } else {
> + path = mem_path;
> + }
> +#endif
> +
> + if (path) {
> + return qemu_mempath_getpagesize(path);
> + } else {
> + return getpagesize();
> + }
> +}
> +
> return pagesize >= max_cpu_page_size;
> }
> --
> 2.14.3
>
--
Eduardo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH for-2.13] Add host_memory_backend_pagesize() helper
2018-04-03 2:22 ` Eduardo Habkost
@ 2018-04-03 5:29 ` David Gibson
0 siblings, 0 replies; 7+ messages in thread
From: David Gibson @ 2018-04-03 5:29 UTC (permalink / raw)
To: Eduardo Habkost; +Cc: imammedo, pbonzini, qemu-devel, qemu-ppc
[-- Attachment #1: Type: text/plain, Size: 6395 bytes --]
On Mon, Apr 02, 2018 at 11:22:06PM -0300, Eduardo Habkost wrote:
> On Thu, Mar 29, 2018 at 04:25:37PM +1100, David Gibson wrote:
> > There are a couple places (one generic, one target specific) where we need
> > to get the host page size associated with a particular memory backend. I
> > have some upcoming code which will add another place which wants this. So,
> > for convenience, add a helper function to calculate this.
> >
> > host_memory_backend_pagesize() returns the host pagesize for a given
> > HostMemoryBackend object, or for the default backend (-mem-path) if passed
> > NULL.
> >
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> > ---
> > backends/hostmem.c | 20 ++++++++++++++++++++
> > exec.c | 21 +++++----------------
> > include/sysemu/hostmem.h | 2 ++
> > target/ppc/kvm.c | 10 +---------
> > 4 files changed, 28 insertions(+), 25 deletions(-)
> >
> > diff --git a/backends/hostmem.c b/backends/hostmem.c
> > index f61093654e..b6a60cfc5d 100644
> > --- a/backends/hostmem.c
> > +++ b/backends/hostmem.c
> > @@ -18,6 +18,7 @@
> > #include "qapi/visitor.h"
> > #include "qemu/config-file.h"
> > #include "qom/object_interfaces.h"
> > +#include "qemu/mmap-alloc.h"
> >
> > #ifdef CONFIG_NUMA
> > #include <numaif.h>
> > @@ -262,6 +263,25 @@ bool host_memory_backend_is_mapped(HostMemoryBackend *backend)
> > return backend->is_mapped;
> > }
> >
> > +long host_memory_backend_pagesize(HostMemoryBackend *memdev)
>
> qemu_mempath_getpagesize() returns size_t. Why are you using
> long here?
Because qemu_getrampagesize() returns long. But size_t is better, so
I've changed it.
> > +{
> > + const char *path = NULL;
> > +
> > +#ifdef __linux__
> > + if (memdev) {
> > + path = object_property_get_str(OBJECT(memdev), "mem-path", NULL);
> > + } else {
> > + path = mem_path;
> > + }
> > +#endif
> > +
> > + if (path) {
> > + return qemu_mempath_getpagesize(path);
> > + } else {
> > + return getpagesize();
>
> Isn't it simpler to make qemu_mempath_getpagesize() handle
> path==NULL?
Uh.. possibly not, but things you bring up later kind of make it moot.
> > + }
> > +}
> > +
> > static void
> > host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
> > {
> > diff --git a/exec.c b/exec.c
> > index c09bd93df3..04856c2402 100644
> > --- a/exec.c
> > +++ b/exec.c
> > @@ -1488,18 +1488,13 @@ void ram_block_dump(Monitor *mon)
> > */
> > static int find_max_supported_pagesize(Object *obj, void *opaque)
> > {
> > - char *mem_path;
> > long *hpsize_min = opaque;
> >
> > if (object_dynamic_cast(obj, TYPE_MEMORY_BACKEND)) {
> > - mem_path = object_property_get_str(obj, "mem-path", NULL);
> > - if (mem_path) {
> > - long hpsize = qemu_mempath_getpagesize(mem_path);
> > - if (hpsize < *hpsize_min) {
> > - *hpsize_min = hpsize;
> > - }
> > - } else {
> > - *hpsize_min = getpagesize();
> > + long hpsize = host_memory_backend_pagesize(MEMORY_BACKEND(obj));
>
> So in this caller, `backend` is always non-NULL...
>
> > +
> > + if (hpsize < *hpsize_min) {
> > + *hpsize_min = hpsize;
> > }
> > }
> >
> > @@ -1509,15 +1504,9 @@ static int find_max_supported_pagesize(Object *obj, void *opaque)
> > long qemu_getrampagesize(void)
> > {
> > long hpsize = LONG_MAX;
> > - long mainrampagesize;
> > + long mainrampagesize = host_memory_backend_pagesize(NULL);
>
> ...on this caller `backend` is always NULL...
>
>
> > Object *memdev_root;
> >
> > - if (mem_path) {
> > - mainrampagesize = qemu_mempath_getpagesize(mem_path);
> > - } else {
> > - mainrampagesize = getpagesize();
> > - }
> > -
> > /* it's possible we have memory-backend objects with
> > * hugepage-backed RAM. these may get mapped into system
> > * address space via -numa parameters or memory hotplug
> [...]
> > diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
> > index b329cd8173..0adcf18c9f 100644
> > --- a/target/ppc/kvm.c
> > +++ b/target/ppc/kvm.c
> > @@ -493,15 +493,7 @@ static void kvm_fixup_page_sizes(PowerPCCPU *cpu)
> > bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path)
> > {
> > Object *mem_obj = object_resolve_path(obj_path, NULL);
> > - char *mempath = object_property_get_str(mem_obj, "mem-path", NULL);
> > - long pagesize;
> > -
> > - if (mempath) {
> > - pagesize = qemu_mempath_getpagesize(mempath);
> > - g_free(mempath);
> > - } else {
> > - pagesize = getpagesize();
> > - }
> > + long pagesize = host_memory_backend_pagesize(MEMORY_BACKEND(mem_obj));
> >
>
> ...and here `backend` is always non-NULL.
>
> If there's no caller that relies on both code paths, why overload
> a single function for two different operations?
Good point.
> I would simply make qemu_mempath_getpagesize() work if path is
> NULL, use qemu_mempath_getpagesize(mem_path) at
> qemu_getrampagesize(), and make host_memory_backend_pagesize()
> assume require a non-NULL `memdev`.
Yeah, that makes sense. I thought I might have more need for a
unified entry point in the code I have in the works, but looking at
the latest draft, probably not.
I'll change it as you suggest.
> > +long host_memory_backend_pagesize(HostMemoryBackend *memdev)
>
> Why is the code duplicated in target/ppc/kvm.c?
Leftover from an early version, I think. I'll fix that.
>
>
> > +{
> > + const char *path = NULL;
> > +
> > +#ifdef __linux__
> > + if (memdev) {
> > + path = object_property_get_str(OBJECT(memdev), "mem-path", NULL);
> > + } else {
> > + path = mem_path;
> > + }
> > +#endif
> > +
> > + if (path) {
> > + return qemu_mempath_getpagesize(path);
> > + } else {
> > + return getpagesize();
> > + }
> > +}
> > +
> > return pagesize >= max_cpu_page_size;
> > }
>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH for-2.13] Add host_memory_backend_pagesize() helper
2018-03-29 6:37 ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2018-03-29 9:56 ` Greg Kurz
@ 2018-04-03 5:31 ` David Gibson
1 sibling, 0 replies; 7+ messages in thread
From: David Gibson @ 2018-04-03 5:31 UTC (permalink / raw)
To: Greg Kurz; +Cc: ehabkost, imammedo, pbonzini, qemu-ppc, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 2142 bytes --]
On Thu, Mar 29, 2018 at 08:37:48AM +0200, Greg Kurz wrote:
> On Thu, 29 Mar 2018 16:25:37 +1100
> David Gibson <david@gibson.dropbear.id.au> wrote:
>
> > There are a couple places (one generic, one target specific) where we need
> > to get the host page size associated with a particular memory backend. I
> > have some upcoming code which will add another place which wants this. So,
> > for convenience, add a helper function to calculate this.
> >
> > host_memory_backend_pagesize() returns the host pagesize for a given
> > HostMemoryBackend object, or for the default backend (-mem-path) if passed
> > NULL.
> >
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> > ---
>
> The idea is good but there's a small issue. See below.
>
> > backends/hostmem.c | 20 ++++++++++++++++++++
> > exec.c | 21 +++++----------------
> > include/sysemu/hostmem.h | 2 ++
> > target/ppc/kvm.c | 10 +---------
> > 4 files changed, 28 insertions(+), 25 deletions(-)
> >
> > diff --git a/backends/hostmem.c b/backends/hostmem.c
> > index f61093654e..b6a60cfc5d 100644
> > --- a/backends/hostmem.c
> > +++ b/backends/hostmem.c
> > @@ -18,6 +18,7 @@
> > #include "qapi/visitor.h"
> > #include "qemu/config-file.h"
> > #include "qom/object_interfaces.h"
> > +#include "qemu/mmap-alloc.h"
> >
> > #ifdef CONFIG_NUMA
> > #include <numaif.h>
> > @@ -262,6 +263,25 @@ bool host_memory_backend_is_mapped(HostMemoryBackend *backend)
> > return backend->is_mapped;
> > }
> >
> > +long host_memory_backend_pagesize(HostMemoryBackend *memdev)
> > +{
> > + const char *path = NULL;
> > +
> > +#ifdef __linux__
> > + if (memdev) {
> > + path = object_property_get_str(OBJECT(memdev), "mem-path", NULL);
>
> object_property_get_str() returns an allocated string. It should be freed
> before returning.
Ah, nice catch, I'll correct that.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-04-03 5:32 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-29 5:25 [Qemu-devel] [PATCH for-2.13] Add host_memory_backend_pagesize() helper David Gibson
2018-03-29 6:37 ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2018-03-29 9:56 ` Greg Kurz
2018-04-03 5:31 ` David Gibson
2018-03-31 8:00 ` [Qemu-devel] " no-reply
2018-04-03 2:22 ` Eduardo Habkost
2018-04-03 5:29 ` David Gibson
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.