domain: Compile with lock_profile=y enabled.
RFC PATCH 1/1 domain: Compile with lock_profile=y enabled.
Our 'struct domain' has when lock profiling is enabled is bigger than one page.
We can't use vmap nor vzalloc as both of those stash the physical address in struct page which makes the assumptions in 'arch_init_memory' trip over ASSERTs.
--- xen/arch/x86/domain.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
xen/arch/x86/domain.c +6 -3
@@ -237,6 +237,7 @@ struct domain *alloc_domain_struct(void)#ifdef CONFIG_BIGMEM const unsigned int bits =0 ;#else +int order =get_order_from_bytes (sizeof (*d));/* * We pack the PDX of the domain structure into a 32-bit field within * the page_info structure. Hence the MEMF_bits() restriction.
@@ -247,10 +248,12 @@ struct domain *alloc_domain_struct(void) bits =_domain_struct_bits ();#endif -BUILD_BUG_ON (sizeof (*d) >PAGE_SIZE ); - d =alloc_xenheap_pages (0 ,MEMF_bits (bits)); + d =alloc_xenheap_pages (order,MEMF_bits (bits));if ( d !=NULL ) -clear_page (d); + { +for ( ; order >=0 ; order-- ) +clear_page ((void *)d +PAGE_SIZE *order); + }return d; }
Signature · 1 line
2.1.0
xen/arch/x86/domain.c struct domain *alloc_domain_struct(void) · line 240
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 02.11.15 at 18:12, <[email protected]> wrote:
xen/arch/x86/domain.c +1
-0@@ -237,6 +237,7 @@ struct domain *alloc_domain_struct(void)#ifdef CONFIG_BIGMEM const unsigned int bits =0 ;#else +int order =get_order_from_bytes (sizeof (*d));
unsigned int
xen/arch/x86/domain.c struct domain *alloc_domain_struct(void) · line 250
Quoted 5 lines
xen/arch/x86/domain.c +0
-1@@ -247,10 +248,12 @@ struct domain *alloc_domain_struct(void) bits =_domain_struct_bits ();#endif -BUILD_BUG_ON (sizeof (*d) >PAGE_SIZE );
Not unconditionally (i.e. at least non-debug builds should continue to have this).
xen/arch/x86/domain.c struct domain *alloc_domain_struct(void) · line 255
Quoted 7 lines
xen/arch/x86/domain.c +4
-2- d =alloc_xenheap_pages (0 ,MEMF_bits (bits)); + d =alloc_xenheap_pages (order,MEMF_bits (bits));if ( d !=NULL ) -clear_page (d); + { +for ( ; order >=0 ; order-- ) +clear_page ((void *)d +PAGE_SIZE *order);
This loop works for orders 0 and 1, but not anything else (not clearing all of the pages).
Jan
Quoted 11 lines · Jan Beulich
xen/arch/x86/domain.c struct domain *alloc_domain_struct(void) · line 240
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 02.11.15 at 18:12, <[email protected]> wrote:
xen/arch/x86/domain.c +1
-0@@ -237,6 +237,7 @@ struct domain *alloc_domain_struct(void)#ifdef CONFIG_BIGMEM const unsigned int bits =0 ;#else +int order =get_order_from_bytes (sizeof (*d));unsigned int
Quoted 8 lines
xen/arch/x86/domain.c struct domain *alloc_domain_struct(void) · line 250
Quoted 5 lines
xen/arch/x86/domain.c +0
-1@@ -247,10 +248,12 @@ struct domain *alloc_domain_struct(void) bits =_domain_struct_bits ();#endif -BUILD_BUG_ON (sizeof (*d) >PAGE_SIZE );Not unconditionally (i.e. at least non-debug builds should continue to have this).
The profile=y does not mandate debug=y?
Meaning if we leave this for non-debug builds with lock_profile=y we will have an compile issue.
Quoted 11 lines
xen/arch/x86/domain.c struct domain *alloc_domain_struct(void) · line 255
Quoted 8 lines
xen/arch/x86/domain.c +4
-2- d =alloc_xenheap_pages (0 ,MEMF_bits (bits)); + d =alloc_xenheap_pages (order,MEMF_bits (bits));if ( d !=NULL ) -clear_page (d); + { +for ( ; order >=0 ; order-- ) +clear_page ((void *)d +PAGE_SIZE *order);This loop works for orders 0 and 1, but not anything else (not clearing all of the pages).
Right. This below should do it:
Quoted 1 line
From
2a611285161fa94ce6a8c2708ac1c141ed6f0830Mon Sep 17 00:00:00 2001
From: Konrad Rzeszutek Wilk <[email protected]>
Date: Fri, 6 Nov 2015 16:05:20 -0500
Subject: [PATCH] domain: Compile with lock_profile=y enabled.
Our 'struct domain' has when lock profiling is enabled is bigger than one page.
We can't use vmap nor vzalloc as both of those stash the physical address in struct page which makes the assumptions in 'arch_init_memory' trip over ASSERTs.
--- xen/arch/x86/domain.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
xen/arch/x86/domain.c +11 -2
@@ -233,6 +233,7 @@ struct domain *alloc_domain_struct(void)#ifdef CONFIG_BIGMEM const unsigned int bits =0 ;#else +unsigned int order =get_order_from_bytes (sizeof (*d));/* * We pack the PDX of the domain structure into a 32-bit field within * the page_info structure. Hence the MEMF_bits() restriction.
@@ -243,10 +244,18 @@ struct domain *alloc_domain_struct(void) bits =_domain_struct_bits ();#endif + +#ifndef LOCK_PROFILE BUILD_BUG_ON (sizeof (*d) >PAGE_SIZE ); - d =alloc_xenheap_pages (0 ,MEMF_bits (bits)); +#endif + d =alloc_xenheap_pages (order,MEMF_bits (bits));if ( d !=NULL ) -clear_page (d); + { +unsigned int sz; + +for ( sz =0 ; sz < (1 << order) *PAGE_SIZE ; sz +=PAGE_SIZE ) +clear_page ((void *)d + sz); + }return d; }
Signature · 1 line
2.1.0
Quoted 3 lines
Jan
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 06.11.15 at 20:39, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
xen/arch/x86/domain.c struct domain *alloc_domain_struct(void) · line 250
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 02.11.15 at 18:12, <[email protected]> wrote:
xen/arch/x86/domain.c +0
-1@@ -247,10 +248,12 @@ struct domain *alloc_domain_struct(void) bits =_domain_struct_bits ();#endif -BUILD_BUG_ON (sizeof (*d) >PAGE_SIZE );Not unconditionally (i.e. at least non-debug builds should continue to have this).
Quoted 4 lines
The profile=y does not mandate debug=y?
Meaning if we leave this for non-debug builds with lock_profile=y we will have an compile issue.
Good point, but still calling for this not to be done unconditionally (even if not a true dependency, I don't expect production builds to enable lock profiling).
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
xen/arch/x86/domain.c +4
-2- d =alloc_xenheap_pages (0 ,MEMF_bits (bits)); + d =alloc_xenheap_pages (order,MEMF_bits (bits));if ( d !=NULL ) -clear_page (d); + { +for ( ; order >=0 ; order-- ) +clear_page ((void *)d +PAGE_SIZE *order);
Quoted 4 lines
Quoted 2 lines
This loop works for orders 0 and 1, but not anything else (not clearing all of the pages).
Right. This below should do it:
Yes, except that ...
Quoted 6 lines
xen/arch/x86/domain.c +2
-0@@ -243,10 +244,18 @@ struct domain *alloc_domain_struct(void) bits =_domain_struct_bits ();#endif + +#ifndef LOCK_PROFILE
xen/arch/x86/domain.c struct domain *alloc_domain_struct(void) · line 256
Quoted 10 lines
xen/arch/x86/domain.c +6
-2BUILD_BUG_ON (sizeof (*d) >PAGE_SIZE ); - d =alloc_xenheap_pages (0 ,MEMF_bits (bits)); +#endif + d =alloc_xenheap_pages (order,MEMF_bits (bits));if ( d !=NULL ) -clear_page (d); + { +unsigned int sz; + +for ( sz =0 ; sz < (1 << order) *PAGE_SIZE ; sz +=PAGE_SIZE )
... this wants to be simplified to PAGE_SIZE << order.
Jan