arm/domain: allocate pages according to the order of struct domain size
PATCH 1/1 arm/domain: allocate pages according to the order of struct domain size
As the number of CPUs supported on the system grows, number of GIC redistributors and mmio handlers increase. We need to increase MAX_RDIST_COUNT and MAX_IO_HANDLER which makes size of struct domain bigger than one page.
Remove the BUILD_BUG_ON check for if size of struct domain is greater than PAGE_SIZE. And allocate xenheap pages according to the order of the size of struct domain.
--- xen/arch/arm/domain.c | 5 +++-- xen/include/asm-arm/gic.h | 2 +- xen/include/asm-arm/mmio.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-)
xen/arch/arm/domain.c +3 -2
@@ -438,8 +438,9 @@ void startup_cpu_idle_loop(void)struct domain *alloc_domain_struct (void ) {struct domain *d; -BUILD_BUG_ON (sizeof (*d) >PAGE_SIZE ); - d =alloc_xenheap_pages (0 ,0 ); +unsigned int order =get_order_from_bytes (sizeof (*d)); + + d =alloc_xenheap_pages (order,0 );if ( d ==NULL )return NULL ;
xen/include/asm-arm/gic.h +1 -1
@@ -20,7 +20,7 @@#define NR_GIC_LOCAL_IRQS NR_LOCAL_IRQS#define NR_GIC_SGI 16 -#define MAX_RDIST_COUNT 4 +#define MAX_RDIST_COUNT 64#define GICD_CTLR (0x000)#define GICD_TYPER (0x004)
xen/include/asm-arm/mmio.h +1 -1
@@ -23,7 +23,7 @@#include <asm/processor.h> #include <asm/regs.h> -#define MAX_IO_HANDLER 16 +#define MAX_IO_HANDLER 32 typedef struct {
Signature · 9 lines
Jiandi An Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Hello Jiandi,
Quoted 4 lines · Jiandi An
As the number of CPUs supported on the system grows, number of GIC redistributors and mmio handlers increase. We need to increase
MAX_RDIST_COUNTandMAX_IO_HANDLERwhich makes size of struct domain bigger than one page.
With this change, the memory footprint of a domain will increase by 4KB even if they don't use GICv3.
What is the size of the domain structure with your patch?
I would much prefer to allocate separate memory for the vGIC redistributors if it takes too much space.
Quoted 33 lines
Remove the
BUILD_BUG_ONcheck for if size of struct domain is greater thanPAGE_SIZE. And allocate xenheap pages according to the order of the size of struct domain.Signed-off-by Jiandi An <[email protected]>--- xen/arch/arm/domain.c | 5 +++-- xen/include/asm-arm/gic.h | 2 +- xen/include/asm-arm/mmio.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-)xen/arch/arm/domain.c +3
-2@@ -438,8 +438,9 @@ void startup_cpu_idle_loop(void)struct domain *alloc_domain_struct (void ) {struct domain *d; -BUILD_BUG_ON (sizeof (*d) >PAGE_SIZE ); - d =alloc_xenheap_pages (0 ,0 ); +unsigned int order =get_order_from_bytes (sizeof (*d)); + + d =alloc_xenheap_pages (order,0 );if ( d ==NULL )return NULL ;xen/include/asm-arm/gic.h +0
-0
xen/include/asm-arm/gic.h line 23
Quoted 5 lines
xen/include/asm-arm/gic.h +1
-1@@ -20,7 +20,7 @@#define NR_GIC_LOCAL_IRQS NR_LOCAL_IRQS#define NR_GIC_SGI 16 -#define MAX_RDIST_COUNT 4 +#define MAX_RDIST_COUNT 64
How many re-distributor regions does your platform have?
xen/include/asm-arm/mmio.h line 26
Quoted 13 lines
xen/include/asm-arm/gic.h +0
-0#define GICD_CTLR (0x000)#define GICD_TYPER (0x004)xen/include/asm-arm/mmio.h +1
-1@@ -23,7 +23,7 @@#include <asm/processor.h> #include <asm/regs.h> -#define MAX_IO_HANDLER 16 +#define MAX_IO_HANDLER 32
The vGICv3 driver is allocating one I/O handler per redistributor region. So if you bump MAX_RDIST_COUNT to 64, you at least need to bump MAX_IO_HANDLER to 80.
However, I am bit concerned of the performance impact in long-term because the lookup is linear.
Regards,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 8 lines · Julien Grall
Hello Jiandi,
Quoted 4 lines · Jiandi An
As the number of CPUs supported on the system grows, number of GIC redistributors and mmio handlers increase. We need to increase
MAX_RDIST_COUNTandMAX_IO_HANDLERwhich makes size of struct domain bigger than one page.
Quoted 6 lines
With this change, the memory footprint of a domain will increase by 4KB even if they don't use GICv3.
What is the size of the domain structure with your patch?
I would much prefer to allocate separate memory for the vGIC redistributors if it takes too much space.
Hi Julien, the intent of this patch is in preparation for introducing the patch to support redistributor parsing from GICC subtable, which is tied to number of CPUs on the system. Current MAX_RDIST_COUNT and MAX_IO_HANDLER are not enough and it drives the domain struct size bigger.
I do see the better way is to leave the domain struct alone and allocate memory for vGIC redistributors separately and dynamically based on number of CPU interfaces from GICC subtable.
Thanks for your sugguestion. We'll bundle the dynanmic memory allocation for redistributors and io handlers in the patch that's coming in for supporting redistributor parsing from GICC subtable.
Quoted 34 lines
Quoted 34 lines
Remove the
BUILD_BUG_ONcheck for if size of struct domain is greater thanPAGE_SIZE. And allocate xenheap pages according to the order of the size of struct domain.Signed-off-by Jiandi An <[email protected]>--- xen/arch/arm/domain.c | 5 +++-- xen/include/asm-arm/gic.h | 2 +- xen/include/asm-arm/mmio.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-)xen/arch/arm/domain.c +3
-2@@ -438,8 +438,9 @@ void startup_cpu_idle_loop(void)struct domain *alloc_domain_struct (void ) {struct domain *d; -BUILD_BUG_ON (sizeof (*d) >PAGE_SIZE ); - d =alloc_xenheap_pages (0 ,0 ); +unsigned int order =get_order_from_bytes (sizeof (*d)); + + d =alloc_xenheap_pages (order,0 );if ( d ==NULL )return NULL ;xen/include/asm-arm/gic.h +0
-0@@ -20,7 +20,7 @@
Quoted 6 lines
xen/include/asm-arm/gic.h line 23
Quoted 4 lines
xen/include/asm-arm/gic.h +1
-1#define NR_GIC_LOCAL_IRQS NR_LOCAL_IRQS#define NR_GIC_SGI 16 -#define MAX_RDIST_COUNT 4 +#define MAX_RDIST_COUNT 64How many re-distributor regions does your platform have?
It's more than the current cap of 4.
Quoted 12 lines
Quoted 12 lines
xen/include/asm-arm/gic.h +0
-0#define GICD_CTLR (0x000)#define GICD_TYPER (0x004)xen/include/asm-arm/mmio.h +0
-0@@ -23,7 +23,7 @@#include <asm/processor.h> #include <asm/regs.h>
Quoted 6 lines
xen/include/asm-arm/mmio.h line 26
Quoted 2 lines
xen/include/asm-arm/mmio.h +1
-1-#define MAX_IO_HANDLER 16 +#define MAX_IO_HANDLER 32The vGICv3 driver is allocating one I/O handler per redistributor region. So if you bump
MAX_RDIST_COUNTto 64, you at least need to bumpMAX_IO_HANDLERto 80.However, I am bit concerned of the performance impact in long-term because the lookup is linear.
Agreed that this also needs to be figured out and allocated dynamically.
Quoted 3 lines
Regards,
Signature · 8 lines
Jiandi An Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel