* [Qemu-devel] [PATCH v3 0/2] spapr: Enable huge pages again
@ 2014-07-10 15:03 Alexey Kardashevskiy
2014-07-10 15:03 ` [Qemu-devel] [PATCH v3 1/2] spapr: Move RMA memory region registration code Alexey Kardashevskiy
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Alexey Kardashevskiy @ 2014-07-10 15:03 UTC (permalink / raw)
To: qemu-devel; +Cc: Alexey Kardashevskiy, Paolo Bonzini, qemu-ppc, Alexander Graf
This does small RMA allocation rework and enables huge pages.
Please comment, especially commit logs. Thanks!
Changes:
v3:
* split to 2 patches, one mechanical
* tested on PPC970
v2:
* moved RMA memory region out of KVM code
Alexey Kardashevskiy (2):
spapr: Move RMA memory region registration code
spapr: Enable use of huge pages
hw/ppc/spapr.c | 19 ++++++++++++-------
target-ppc/kvm.c | 13 +++----------
target-ppc/kvm_ppc.h | 2 +-
3 files changed, 16 insertions(+), 18 deletions(-)
--
2.0.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v3 1/2] spapr: Move RMA memory region registration code
2014-07-10 15:03 [Qemu-devel] [PATCH v3 0/2] spapr: Enable huge pages again Alexey Kardashevskiy
@ 2014-07-10 15:03 ` Alexey Kardashevskiy
2014-07-10 15:03 ` [Qemu-devel] [PATCH v3 2/2] spapr: Enable use of huge pages Alexey Kardashevskiy
2014-07-14 13:13 ` [Qemu-devel] [PATCH v3 0/2] spapr: Enable huge pages again Alexey Kardashevskiy
2 siblings, 0 replies; 7+ messages in thread
From: Alexey Kardashevskiy @ 2014-07-10 15:03 UTC (permalink / raw)
To: qemu-devel; +Cc: Alexey Kardashevskiy, Paolo Bonzini, qemu-ppc, Alexander Graf
PPC970 does not support VRMA (virtual RMA) so real memory required
for SLOF to execute must be allocated by the KVM_ALLOCATE_RMA ioctl.
Later this memory is used as a part of the guest RAM area.
The RMA allocating code also registers a memory region for this piece
of RAM.
We are going to simplify memory regions layout: RMA memory region
will be a subregion in the RAM memory region, both starting from zero.
This way we will not have to take care of start address alignment for
the piece of RAM next to the RMA.
This moves memory region business closer to the RAM memory region
creation/allocation code.
As this is a mechanical patch, no change in behaviour is expected.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
hw/ppc/spapr.c | 12 +++++++++++-
target-ppc/kvm.c | 13 +++----------
target-ppc/kvm_ppc.h | 2 +-
3 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 10cbf4d..e182bd5 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1260,6 +1260,8 @@ static void ppc_spapr_init(MachineState *machine)
int i;
MemoryRegion *sysmem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
+ MemoryRegion *rma_region;
+ void *rma = NULL;
hwaddr rma_alloc_size;
hwaddr node0_size = (nb_numa_nodes > 1) ? numa_info[0].node_mem : ram_size;
uint32_t initrd_base = 0;
@@ -1276,7 +1278,7 @@ static void ppc_spapr_init(MachineState *machine)
cpu_ppc_hypercall = emulate_spapr_hypercall;
/* Allocate RMA if necessary */
- rma_alloc_size = kvmppc_alloc_rma("ppc_spapr.rma", sysmem);
+ rma_alloc_size = kvmppc_alloc_rma(&rma);
if (rma_alloc_size == -1) {
hw_error("qemu: Unable to create RMA\n");
@@ -1379,6 +1381,14 @@ static void ppc_spapr_init(MachineState *machine)
memory_region_add_subregion(sysmem, nonrma_base, ram);
}
+ if (rma_alloc_size && rma) {
+ rma_region = g_new(MemoryRegion, 1);
+ memory_region_init_ram_ptr(rma_region, NULL, "ppc_spapr.rma",
+ rma_alloc_size, rma);
+ vmstate_register_ram_global(rma_region);
+ memory_region_add_subregion(sysmem, 0, rma_region);
+ }
+
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "spapr-rtas.bin");
spapr->rtas_size = load_image_targphys(filename, spapr->rtas_addr,
rtas_limit - spapr->rtas_addr);
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index afc7963..8c9e79c 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -1591,13 +1591,11 @@ int kvmppc_smt_threads(void)
}
#ifdef TARGET_PPC64
-off_t kvmppc_alloc_rma(const char *name, MemoryRegion *sysmem)
+off_t kvmppc_alloc_rma(void **rma)
{
- void *rma;
off_t size;
int fd;
struct kvm_allocate_rma ret;
- MemoryRegion *rma_region;
/* If cap_ppc_rma == 0, contiguous RMA allocation is not supported
* if cap_ppc_rma == 1, contiguous RMA allocation is supported, but
@@ -1620,17 +1618,12 @@ off_t kvmppc_alloc_rma(const char *name, MemoryRegion *sysmem)
size = MIN(ret.rma_size, 256ul << 20);
- rma = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
- if (rma == MAP_FAILED) {
+ *rma = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+ if (*rma == MAP_FAILED) {
fprintf(stderr, "KVM: Error mapping RMA: %s\n", strerror(errno));
return -1;
};
- rma_region = g_new(MemoryRegion, 1);
- memory_region_init_ram_ptr(rma_region, NULL, name, size, rma);
- vmstate_register_ram_global(rma_region);
- memory_region_add_subregion(sysmem, 0, rma_region);
-
return size;
}
diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h
index fad2b8c..5b397cb 100644
--- a/target-ppc/kvm_ppc.h
+++ b/target-ppc/kvm_ppc.h
@@ -33,7 +33,7 @@ int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
int kvmppc_set_tcr(PowerPCCPU *cpu);
int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu);
#ifndef CONFIG_USER_ONLY
-off_t kvmppc_alloc_rma(const char *name, MemoryRegion *sysmem);
+off_t kvmppc_alloc_rma(void **rma);
bool kvmppc_spapr_use_multitce(void);
void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t window_size, int *pfd,
bool vfio_accel);
--
2.0.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v3 2/2] spapr: Enable use of huge pages
2014-07-10 15:03 [Qemu-devel] [PATCH v3 0/2] spapr: Enable huge pages again Alexey Kardashevskiy
2014-07-10 15:03 ` [Qemu-devel] [PATCH v3 1/2] spapr: Move RMA memory region registration code Alexey Kardashevskiy
@ 2014-07-10 15:03 ` Alexey Kardashevskiy
2014-07-14 13:13 ` [Qemu-devel] [PATCH v3 0/2] spapr: Enable huge pages again Alexey Kardashevskiy
2 siblings, 0 replies; 7+ messages in thread
From: Alexey Kardashevskiy @ 2014-07-10 15:03 UTC (permalink / raw)
To: qemu-devel; +Cc: Alexey Kardashevskiy, Paolo Bonzini, qemu-ppc, Alexander Graf
0b183fc87 "memory: move mem_path handling to
memory_region_allocate_system_memory" disabled -mempath use for all
machines that do not use memory_region_allocate_system_memory() to
register RAM. Since SPAPR uses memory_region_init_ram(), the huge pages
support was disabled for it.
This replaces memory_region_init_ram()+vmstate_register_ram_global() with
memory_region_allocate_system_memory() to get huge pages back.
This changes RAM size from (ram_limit - rma_alloc_size) to ram_limit as
the previous patch moved RMA memory region allocation after RAM allocation
and therefore this change does not have immediate effect but simplifies
the code.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
hw/ppc/spapr.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index e182bd5..6b48a26 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1372,14 +1372,9 @@ static void ppc_spapr_init(MachineState *machine)
/* allocate RAM */
spapr->ram_limit = ram_size;
- if (spapr->ram_limit > rma_alloc_size) {
- ram_addr_t nonrma_base = rma_alloc_size;
- ram_addr_t nonrma_size = spapr->ram_limit - rma_alloc_size;
-
- memory_region_init_ram(ram, NULL, "ppc_spapr.ram", nonrma_size);
- vmstate_register_ram_global(ram);
- memory_region_add_subregion(sysmem, nonrma_base, ram);
- }
+ memory_region_allocate_system_memory(ram, NULL, "ppc_spapr.ram",
+ spapr->ram_limit);
+ memory_region_add_subregion(sysmem, 0, ram);
if (rma_alloc_size && rma) {
rma_region = g_new(MemoryRegion, 1);
--
2.0.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v3 0/2] spapr: Enable huge pages again
2014-07-10 15:03 [Qemu-devel] [PATCH v3 0/2] spapr: Enable huge pages again Alexey Kardashevskiy
2014-07-10 15:03 ` [Qemu-devel] [PATCH v3 1/2] spapr: Move RMA memory region registration code Alexey Kardashevskiy
2014-07-10 15:03 ` [Qemu-devel] [PATCH v3 2/2] spapr: Enable use of huge pages Alexey Kardashevskiy
@ 2014-07-14 13:13 ` Alexey Kardashevskiy
2014-07-14 13:30 ` Paolo Bonzini
2 siblings, 1 reply; 7+ messages in thread
From: Alexey Kardashevskiy @ 2014-07-14 13:13 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini, qemu-ppc, Alexander Graf
On 07/11/2014 01:03 AM, Alexey Kardashevskiy wrote:
> This does small RMA allocation rework and enables huge pages.
>
> Please comment, especially commit logs. Thanks!
>
> Changes:
> v3:
> * split to 2 patches, one mechanical
> * tested on PPC970
>
> v2:
> * moved RMA memory region out of KVM code
This is 2.2 stuff, right? :)
>
>
> Alexey Kardashevskiy (2):
> spapr: Move RMA memory region registration code
> spapr: Enable use of huge pages
>
> hw/ppc/spapr.c | 19 ++++++++++++-------
> target-ppc/kvm.c | 13 +++----------
> target-ppc/kvm_ppc.h | 2 +-
> 3 files changed, 16 insertions(+), 18 deletions(-)
>
--
Alexey
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v3 0/2] spapr: Enable huge pages again
2014-07-14 13:13 ` [Qemu-devel] [PATCH v3 0/2] spapr: Enable huge pages again Alexey Kardashevskiy
@ 2014-07-14 13:30 ` Paolo Bonzini
2014-07-14 17:24 ` Alexander Graf
0 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2014-07-14 13:30 UTC (permalink / raw)
To: Alexey Kardashevskiy, qemu-devel; +Cc: qemu-ppc, Alexander Graf
Il 14/07/2014 15:13, Alexey Kardashevskiy ha scritto:
> On 07/11/2014 01:03 AM, Alexey Kardashevskiy wrote:
>> This does small RMA allocation rework and enables huge pages.
>>
>> Please comment, especially commit logs. Thanks!
>>
>> Changes:
>> v3:
>> * split to 2 patches, one mechanical
>> * tested on PPC970
>>
>> v2:
>> * moved RMA memory region out of KVM code
>
>
> This is 2.2 stuff, right? :)
For me it would be okay for 2.1, but Alex may disagree.
Paolo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v3 0/2] spapr: Enable huge pages again
2014-07-14 13:30 ` Paolo Bonzini
@ 2014-07-14 17:24 ` Alexander Graf
2014-07-14 20:59 ` [Qemu-devel] [Qemu-ppc] " Alexander Graf
0 siblings, 1 reply; 7+ messages in thread
From: Alexander Graf @ 2014-07-14 17:24 UTC (permalink / raw)
To: Paolo Bonzini, Alexey Kardashevskiy, qemu-devel; +Cc: qemu-ppc
On 14.07.14 15:30, Paolo Bonzini wrote:
> Il 14/07/2014 15:13, Alexey Kardashevskiy ha scritto:
>> On 07/11/2014 01:03 AM, Alexey Kardashevskiy wrote:
>>> This does small RMA allocation rework and enables huge pages.
>>>
>>> Please comment, especially commit logs. Thanks!
>>>
>>> Changes:
>>> v3:
>>> * split to 2 patches, one mechanical
>>> * tested on PPC970
>>>
>>> v2:
>>> * moved RMA memory region out of KVM code
>>
>>
>> This is 2.2 stuff, right? :)
>
> For me it would be okay for 2.1, but Alex may disagree.
No, I agree. Missing huge page support is a regression over 2.0.
Thanks, applied to for-2.1.
Alex
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH v3 0/2] spapr: Enable huge pages again
2014-07-14 17:24 ` Alexander Graf
@ 2014-07-14 20:59 ` Alexander Graf
0 siblings, 0 replies; 7+ messages in thread
From: Alexander Graf @ 2014-07-14 20:59 UTC (permalink / raw)
To: Paolo Bonzini, Alexey Kardashevskiy, qemu-devel; +Cc: qemu-ppc
On 14.07.14 19:24, Alexander Graf wrote:
>
> On 14.07.14 15:30, Paolo Bonzini wrote:
>> Il 14/07/2014 15:13, Alexey Kardashevskiy ha scritto:
>>> On 07/11/2014 01:03 AM, Alexey Kardashevskiy wrote:
>>>> This does small RMA allocation rework and enables huge pages.
>>>>
>>>> Please comment, especially commit logs. Thanks!
>>>>
>>>> Changes:
>>>> v3:
>>>> * split to 2 patches, one mechanical
>>>> * tested on PPC970
>>>>
>>>> v2:
>>>> * moved RMA memory region out of KVM code
>>>
>>>
>>> This is 2.2 stuff, right? :)
>>
>> For me it would be okay for 2.1, but Alex may disagree.
>
> No, I agree. Missing huge page support is a regression over 2.0.
>
> Thanks, applied to for-2.1.
ppc-next of course.
I had to add this patch on top to make compilation work on non-PPC hosts:
diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h
index ac16a47..d9516e7 100644
--- a/target-ppc/kvm_ppc.h
+++ b/target-ppc/kvm_ppc.h
@@ -134,7 +134,7 @@ static inline int
kvmppc_booke_watchdog_enable(PowerPCCPU *cpu)
}
#ifndef CONFIG_USER_ONLY
-static inline off_t kvmppc_alloc_rma(const char *name, MemoryRegion
*sysmem)
+static inline off_t kvmppc_alloc_rma(void **rma)
{
return 0;
}
Alex
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-07-14 21:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-10 15:03 [Qemu-devel] [PATCH v3 0/2] spapr: Enable huge pages again Alexey Kardashevskiy
2014-07-10 15:03 ` [Qemu-devel] [PATCH v3 1/2] spapr: Move RMA memory region registration code Alexey Kardashevskiy
2014-07-10 15:03 ` [Qemu-devel] [PATCH v3 2/2] spapr: Enable use of huge pages Alexey Kardashevskiy
2014-07-14 13:13 ` [Qemu-devel] [PATCH v3 0/2] spapr: Enable huge pages again Alexey Kardashevskiy
2014-07-14 13:30 ` Paolo Bonzini
2014-07-14 17:24 ` Alexander Graf
2014-07-14 20:59 ` [Qemu-devel] [Qemu-ppc] " Alexander Graf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).