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

Dmitry Safonov 0x7f454c46 at gmail.com
Fri Mar 30 03:01:11 MSK 2018


2018-03-30 0:51 GMT+01:00 Dmitry Safonov <0x7f454c46 at gmail.com>:
> 2018-03-29 15:20 GMT+01:00 Mike Rapoport <rppt at 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 at 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 at 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

-- 
             Dmitry



More information about the CRIU mailing list