[PATCHv2,0/9] Large pages support for aarch64/ppc64

Submitted by Mike Rapoport on March 29, 2018, 2:20 p.m.

Details

Message ID 20180329142002.GA30903@rapoport-lnx
State New
Headers show

Patch hide | download patch | download mbox

diff --git a/criu/mem.c b/criu/mem.c
index 9ee5029..14b22b5 100644
--- a/criu/mem.c
+++ b/criu/mem.c
@@ -907,6 +907,7 @@  static int restore_priv_vma_content(struct pstree_item *t, struct page_read *pr)
 	int ret = 0;
 	struct list_head *vmas = &rsti(t)->vmas.h;
 	struct list_head *vma_io = &rsti(t)->vma_io;
+	unsigned char *buf = alloca(PAGE_SIZE);
 
 	unsigned int nr_restored = 0;
 	unsigned int nr_shared = 0;
@@ -948,7 +949,6 @@  static int restore_priv_vma_content(struct pstree_item *t, struct page_read *pr)
 		}
 
 		for (i = 0; i < nr_pages; i++) {
-			unsigned char buf[PAGE_SIZE];
 			void *p;
 
 			/*

Comments

Dmitry Safonov March 29, 2018, 11:51 p.m.
2018-03-29 15:20 GMT+01:00 Mike Rapoport <rppt@linux.vnet.ibm.com>:
> There's one more [PAGE_SIZE] array in mem.c:
>
> From 0a0a1418900677820a5396b9f58352368122a784 Mon Sep 17 00:00:00 2001
> From: Mike Rapoport <rppt@linux.vnet.ibm.com>
> Date: Thu, 29 Mar 2018 17:13:26 +0300
> Subject: [CRIU][PATCH 5.5/9] criu/mem: use alloca() to allocate the buffer for
>  page-read
>
> For variable PAGE_SIZE using alloca() is better than variable length array
> and the actual effect will be the same.
>
> Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
> ---
>  criu/mem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/criu/mem.c b/criu/mem.c
> index 9ee5029..14b22b5 100644
> --- a/criu/mem.c
> +++ b/criu/mem.c
> @@ -907,6 +907,7 @@ static int restore_priv_vma_content(struct pstree_item *t, struct page_read *pr)
>         int ret = 0;
>         struct list_head *vmas = &rsti(t)->vmas.h;
>         struct list_head *vma_io = &rsti(t)->vma_io;
> +       unsigned char *buf = alloca(PAGE_SIZE);
>
>         unsigned int nr_restored = 0;
>         unsigned int nr_shared = 0;
> @@ -948,7 +949,6 @@ static int restore_priv_vma_content(struct pstree_item *t, struct page_read *pr)
>                 }
>
>                 for (i = 0; i < nr_pages; i++) {
> -                       unsigned char buf[PAGE_SIZE];
>                         void *p;
>
>                         /*
> --
> 2.7.4

Oh, good, thank you!
Ugh, but... I wonder, how did that compile with dynamic PAGE_SIZE?
Need to check that..
Dmitry Safonov March 30, 2018, 12:01 a.m.
2018-03-30 0:51 GMT+01:00 Dmitry Safonov <0x7f454c46@gmail.com>:
> 2018-03-29 15:20 GMT+01:00 Mike Rapoport <rppt@linux.vnet.ibm.com>:
>> There's one more [PAGE_SIZE] array in mem.c:
>>
>> From 0a0a1418900677820a5396b9f58352368122a784 Mon Sep 17 00:00:00 2001
>> From: Mike Rapoport <rppt@linux.vnet.ibm.com>
>> Date: Thu, 29 Mar 2018 17:13:26 +0300
>> Subject: [CRIU][PATCH 5.5/9] criu/mem: use alloca() to allocate the buffer for
>>  page-read
>>
>> For variable PAGE_SIZE using alloca() is better than variable length array
>> and the actual effect will be the same.
>>
>> Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
>> ---
>>  criu/mem.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/criu/mem.c b/criu/mem.c
>> index 9ee5029..14b22b5 100644
>> --- a/criu/mem.c
>> +++ b/criu/mem.c
>> @@ -907,6 +907,7 @@ static int restore_priv_vma_content(struct pstree_item *t, struct page_read *pr)
>>         int ret = 0;
>>         struct list_head *vmas = &rsti(t)->vmas.h;
>>         struct list_head *vma_io = &rsti(t)->vma_io;
>> +       unsigned char *buf = alloca(PAGE_SIZE);
>>
>>         unsigned int nr_restored = 0;
>>         unsigned int nr_shared = 0;
>> @@ -948,7 +949,6 @@ static int restore_priv_vma_content(struct pstree_item *t, struct page_read *pr)
>>                 }
>>
>>                 for (i = 0; i < nr_pages; i++) {
>> -                       unsigned char buf[PAGE_SIZE];
>>                         void *p;
>>
>>                         /*
>> --
>> 2.7.4
>
> Oh, good, thank you!
> Ugh, but... I wonder, how did that compile with dynamic PAGE_SIZE?
> Need to check that..

Ok, it looks like, it's:

6.7.5.2 Array declarators

: C99 adds a new array type called a variable length array type.
: The inability to declare arrays whose size is known only at execution
: time was often cited as a primary deterrent to using C as a numerical
: computing language. Adoption of some standard notion of execution time
: arrays was considered crucial for C’s acceptance in the numerical
: computing world.

: The number of elements specified in the declaration of a variable length
: array type is a runtime expression. Before C99, this size expression was
: required to be an integer constant expression.

https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html