diff mbox series

[kvm-unit-tests] s390x: Initialize the physical allocator on mem init

Message ID 20190110103424.166061-1-frankja@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series [kvm-unit-tests] s390x: Initialize the physical allocator on mem init | expand

Commit Message

Janosch Frank Jan. 10, 2019, 10:34 a.m. UTC
The physical and virtual allocators can coexist, so we can initialize
the former and allocate pages without breaking VM alloc.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 lib/s390x/sclp.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

David Hildenbrand Jan. 10, 2019, 12:10 p.m. UTC | #1
On 10.01.19 11:34, Janosch Frank wrote:
> The physical and virtual allocators can coexist, so we can initialize
> the former and allocate pages without breaking VM alloc.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> ---
>  lib/s390x/sclp.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c
> index e14f25d..52be655 100644
> --- a/lib/s390x/sclp.c
> +++ b/lib/s390x/sclp.c
> @@ -18,6 +18,7 @@
>  #include <asm/spinlock.h>
>  #include "sclp.h"
>  #include <alloc_phys.h>
> +#include <alloc_page.h>
>  
>  extern unsigned long stacktop;
>  
> @@ -31,9 +32,17 @@ static struct spinlock sclp_lock;
>  
>  static void mem_init(phys_addr_t mem_end)
>  {
> +	phys_addr_t base, top;

nit: move this one line down

>  	phys_addr_t freemem_start = (phys_addr_t)&stacktop;
>  
>  	phys_alloc_init(freemem_start, mem_end - freemem_start);
> +	phys_alloc_get_unused(&base, &top);
> +	base = (base + PAGE_SIZE - 1) & -PAGE_SIZE;
> +	top = top & -PAGE_SIZE;
> +
> +	/* Make the pages available to the physical allocator */
> +	free_pages((void *)(unsigned long)base, top - base);
> +	page_alloc_ops_enable();
>  }
>  
>  static void sclp_setup_int(void)
> 

This does not apply upstream. (sclp_setup_int) I guess this is based on
your other series.

Tests still run fine

Acked-by: David Hildenbrand <david@redhat.com>
Janosch Frank Jan. 10, 2019, 12:19 p.m. UTC | #2
On 10.01.19 13:10, David Hildenbrand wrote:
> On 10.01.19 11:34, Janosch Frank wrote:
>> The physical and virtual allocators can coexist, so we can initialize
>> the former and allocate pages without breaking VM alloc.
>>
>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>> ---
>>  lib/s390x/sclp.c | 9 +++++++++
>>  1 file changed, 9 insertions(+)
>>
>> diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c
>> index e14f25d..52be655 100644
>> --- a/lib/s390x/sclp.c
>> +++ b/lib/s390x/sclp.c
>> @@ -18,6 +18,7 @@
>>  #include <asm/spinlock.h>
>>  #include "sclp.h"
>>  #include <alloc_phys.h>
>> +#include <alloc_page.h>
>>  
>>  extern unsigned long stacktop;
>>  
>> @@ -31,9 +32,17 @@ static struct spinlock sclp_lock;
>>  
>>  static void mem_init(phys_addr_t mem_end)
>>  {
>> +	phys_addr_t base, top;
> 
> nit: move this one line down

Will do

> 
>>  	phys_addr_t freemem_start = (phys_addr_t)&stacktop;
>>  
>>  	phys_alloc_init(freemem_start, mem_end - freemem_start);
>> +	phys_alloc_get_unused(&base, &top);
>> +	base = (base + PAGE_SIZE - 1) & -PAGE_SIZE;
>> +	top = top & -PAGE_SIZE;
>> +
>> +	/* Make the pages available to the physical allocator */
>> +	free_pages((void *)(unsigned long)base, top - base);
>> +	page_alloc_ops_enable();
>>  }
>>  
>>  static void sclp_setup_int(void)
>>
> 
> This does not apply upstream. (sclp_setup_int) I guess this is based on
> your other series.

Yup
I'll add it to the series.

> 
> Tests still run fine
> 
> Acked-by: David Hildenbrand <david@redhat.com>

Thanks

>
diff mbox series

Patch

diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c
index e14f25d..52be655 100644
--- a/lib/s390x/sclp.c
+++ b/lib/s390x/sclp.c
@@ -18,6 +18,7 @@ 
 #include <asm/spinlock.h>
 #include "sclp.h"
 #include <alloc_phys.h>
+#include <alloc_page.h>
 
 extern unsigned long stacktop;
 
@@ -31,9 +32,17 @@  static struct spinlock sclp_lock;
 
 static void mem_init(phys_addr_t mem_end)
 {
+	phys_addr_t base, top;
 	phys_addr_t freemem_start = (phys_addr_t)&stacktop;
 
 	phys_alloc_init(freemem_start, mem_end - freemem_start);
+	phys_alloc_get_unused(&base, &top);
+	base = (base + PAGE_SIZE - 1) & -PAGE_SIZE;
+	top = top & -PAGE_SIZE;
+
+	/* Make the pages available to the physical allocator */
+	free_pages((void *)(unsigned long)base, top - base);
+	page_alloc_ops_enable();
 }
 
 static void sclp_setup_int(void)