* [Qemu-devel] [PATCH qemu] vfio, spapr: Fix levels calculation
@ 2017-09-12 2:53 Alexey Kardashevskiy
2017-09-12 3:59 ` David Gibson
0 siblings, 1 reply; 2+ messages in thread
From: Alexey Kardashevskiy @ 2017-09-12 2:53 UTC (permalink / raw)
To: qemu-devel; +Cc: Alexey Kardashevskiy, qemu-ppc, David Gibson, Alex Williamson
The existing tries to round up the number of pages but @pages is always
calculated as the rounded up value minus one which makes ctz64() always
return 0 and have create.levels always set 1.
This removes wrong "-1" and allows having more than 1 levels. This becomes
handy for >128GB guests with standard 64K pages as this requires blocks
with zone order 9 and the popular limit of CONFIG_FORCE_MAX_ZONEORDER=9
means that only blocks up to order 8 are allowed.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
hw/vfio/spapr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c
index 32fd6a9b54..259397c002 100644
--- a/hw/vfio/spapr.c
+++ b/hw/vfio/spapr.c
@@ -163,7 +163,7 @@ int vfio_spapr_create_window(VFIOContainer *container,
*/
entries = create.window_size >> create.page_shift;
pages = MAX((entries * sizeof(uint64_t)) / getpagesize(), 1);
- pages = MAX(pow2ceil(pages) - 1, 1); /* Round up */
+ pages = MAX(pow2ceil(pages), 1); /* Round up */
create.levels = ctz64(pages) / 6 + 1;
ret = ioctl(container->fd, VFIO_IOMMU_SPAPR_TCE_CREATE, &create);
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH qemu] vfio, spapr: Fix levels calculation
2017-09-12 2:53 [Qemu-devel] [PATCH qemu] vfio, spapr: Fix levels calculation Alexey Kardashevskiy
@ 2017-09-12 3:59 ` David Gibson
0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2017-09-12 3:59 UTC (permalink / raw)
To: Alexey Kardashevskiy; +Cc: qemu-devel, qemu-ppc, Alex Williamson
[-- Attachment #1: Type: text/plain, Size: 1528 bytes --]
On Tue, Sep 12, 2017 at 12:53:07PM +1000, Alexey Kardashevskiy wrote:
> The existing tries to round up the number of pages but @pages is always
> calculated as the rounded up value minus one which makes ctz64() always
> return 0 and have create.levels always set 1.
>
> This removes wrong "-1" and allows having more than 1 levels. This becomes
> handy for >128GB guests with standard 64K pages as this requires blocks
> with zone order 9 and the popular limit of CONFIG_FORCE_MAX_ZONEORDER=9
> means that only blocks up to order 8 are allowed.
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Applied to ppc-for-2.11.
> ---
> hw/vfio/spapr.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c
> index 32fd6a9b54..259397c002 100644
> --- a/hw/vfio/spapr.c
> +++ b/hw/vfio/spapr.c
> @@ -163,7 +163,7 @@ int vfio_spapr_create_window(VFIOContainer *container,
> */
> entries = create.window_size >> create.page_shift;
> pages = MAX((entries * sizeof(uint64_t)) / getpagesize(), 1);
> - pages = MAX(pow2ceil(pages) - 1, 1); /* Round up */
> + pages = MAX(pow2ceil(pages), 1); /* Round up */
> create.levels = ctz64(pages) / 6 + 1;
>
> ret = ioctl(container->fd, VFIO_IOMMU_SPAPR_TCE_CREATE, &create);
--
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] 2+ messages in thread
end of thread, other threads:[~2017-09-12 4:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-12 2:53 [Qemu-devel] [PATCH qemu] vfio, spapr: Fix levels calculation Alexey Kardashevskiy
2017-09-12 3:59 ` David Gibson
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).