[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 26/49] Make qemu_mempath_getpagesize() accept NULL
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 26/49] Make qemu_mempath_getpagesize() accept NULL |
Date: |
Fri, 27 Apr 2018 19:21:03 +1000 |
qemu_mempath_getpagesize() gets the effective (host side) page size for
a block of memory backed by an mmap()ed file on the host. It requires
the mem_path parameter to be non-NULL.
This ends up meaning all the callers need a different case for handling
anonymous memory (for memory-backend-ram or default memory with -mem-path
is not specified).
We can make all those callers a little simpler by having
qemu_mempath_getpagesize() accept NULL, and treat that as the anonymous
memory case.
Signed-off-by: David Gibson <address@hidden>
Reviewed-by: Greg Kurz <address@hidden>
Acked-by: Paolo Bonzini <address@hidden>
---
exec.c | 21 ++++++---------------
target/ppc/kvm.c | 8 ++------
util/mmap-alloc.c | 26 ++++++++++++++------------
3 files changed, 22 insertions(+), 33 deletions(-)
diff --git a/exec.c b/exec.c
index 02b1efebb7..b38b004563 100644
--- a/exec.c
+++ b/exec.c
@@ -1488,19 +1488,14 @@ 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);
- g_free(mem_path);
- if (hpsize < *hpsize_min) {
- *hpsize_min = hpsize;
- }
- } else {
- *hpsize_min = getpagesize();
+ char *mem_path = object_property_get_str(obj, "mem-path", NULL);
+ long hpsize = qemu_mempath_getpagesize(mem_path);
+ g_free(mem_path);
+ if (hpsize < *hpsize_min) {
+ *hpsize_min = hpsize;
}
}
@@ -1513,11 +1508,7 @@ long qemu_getrampagesize(void)
long mainrampagesize;
Object *memdev_root;
- if (mem_path) {
- mainrampagesize = qemu_mempath_getpagesize(mem_path);
- } else {
- mainrampagesize = getpagesize();
- }
+ mainrampagesize = qemu_mempath_getpagesize(mem_path);
/* it's possible we have memory-backend objects with
* hugepage-backed RAM. these may get mapped into system
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index 79a436a384..e24fa50dc9 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -499,12 +499,8 @@ bool kvmppc_is_mem_backend_page_size_ok(const char
*obj_path)
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();
- }
+ pagesize = qemu_mempath_getpagesize(mempath);
+ g_free(mempath);
return pagesize >= max_cpu_page_size;
}
diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c
index 2fd8cbcc6f..fd329eccd8 100644
--- a/util/mmap-alloc.c
+++ b/util/mmap-alloc.c
@@ -50,19 +50,21 @@ size_t qemu_mempath_getpagesize(const char *mem_path)
struct statfs fs;
int ret;
- do {
- ret = statfs(mem_path, &fs);
- } while (ret != 0 && errno == EINTR);
-
- if (ret != 0) {
- fprintf(stderr, "Couldn't statfs() memory path: %s\n",
- strerror(errno));
- exit(1);
- }
+ if (mem_path) {
+ do {
+ ret = statfs(mem_path, &fs);
+ } while (ret != 0 && errno == EINTR);
- if (fs.f_type == HUGETLBFS_MAGIC) {
- /* It's hugepage, return the huge page size */
- return fs.f_bsize;
+ if (ret != 0) {
+ fprintf(stderr, "Couldn't statfs() memory path: %s\n",
+ strerror(errno));
+ exit(1);
+ }
+
+ if (fs.f_type == HUGETLBFS_MAGIC) {
+ /* It's hugepage, return the huge page size */
+ return fs.f_bsize;
+ }
}
#ifdef __sparc__
/* SPARC Linux needs greater alignment than the pagesize */
--
2.14.3
- [Qemu-ppc] [PULL 21/49] uninorth: move PCI IO (ISA) memory region into the uninorth device, (continued)
- [Qemu-ppc] [PULL 21/49] uninorth: move PCI IO (ISA) memory region into the uninorth device, David Gibson, 2018/04/27
- [Qemu-ppc] [PULL 33/49] target/ppc: Pass cpu instead of env to ppc_create_page_sizes_prop(), David Gibson, 2018/04/27
- [Qemu-ppc] [PULL 31/49] target/ppc: Standardize instance_init and realize function names, David Gibson, 2018/04/27
- [Qemu-ppc] [PULL 42/49] target/ppc: Get rid of POWERPC_MMU_VER() macros, David Gibson, 2018/04/27
- [Qemu-ppc] [PULL 23/49] ppc: Fix size of ppc64 xer register, David Gibson, 2018/04/27
- [Qemu-ppc] [PULL 27/49] Add host_memory_backend_pagesize() helper, David Gibson, 2018/04/27
- [Qemu-ppc] [PULL 25/49] spapr: Introduce pseries-2.13 machine type, David Gibson, 2018/04/27
- [Qemu-ppc] [PULL 41/49] target/ppc: Remove unnecessary POWERPC_MMU_V3 flag from mmu_model, David Gibson, 2018/04/27
- [Qemu-ppc] [PULL 47/49] target/ppc: Don't bother with MSR_EP in cpu_ppc_set_papr(), David Gibson, 2018/04/27
- [Qemu-ppc] [PULL 29/49] Revert "spapr: Don't allow memory hotplug to memory less nodes", David Gibson, 2018/04/27
- [Qemu-ppc] [PULL 26/49] Make qemu_mempath_getpagesize() accept NULL,
David Gibson <=
- [Qemu-ppc] [PULL 44/49] spapr: Add ibm, max-associativity-domains property, David Gibson, 2018/04/27
- [Qemu-ppc] [PULL 43/49] target/ppc: Fold slb_nr into PPCHash64Options, David Gibson, 2018/04/27
- [Qemu-ppc] [PULL 45/49] ppc: e500: switch E500 based machines to full machine definition, David Gibson, 2018/04/27
- [Qemu-ppc] [PULL 32/49] target/ppc: Simplify cpu valid check in ppc_cpu_realize, David Gibson, 2018/04/27
- [Qemu-ppc] [PULL 35/49] target/ppc: Remove fallback 64k pagesize information, David Gibson, 2018/04/27
- [Qemu-ppc] [PULL 36/49] target/ppc: Move page size setup to helper function, David Gibson, 2018/04/27
- [Qemu-ppc] [PULL 49/49] Clear mem_path if we fall back to anonymous RAM allocation, David Gibson, 2018/04/27
- [Qemu-ppc] [PULL 46/49] spapr: Support ibm, dynamic-memory-v2 property, David Gibson, 2018/04/27
- [Qemu-ppc] [PULL 48/49] spapr: Set compatibility mode before the rest of spapr_cpu_reset(), David Gibson, 2018/04/27
- Re: [Qemu-ppc] [Qemu-devel] [PULL 00/49] ppc-for-2.13 queue 20180427, no-reply, 2018/04/27