[CRIU] [PATCH] zdtm: add test maps008 for dedup on unmap vma
Pavel Emelyanov
xemul at parallels.com
Mon Apr 14 04:19:39 PDT 2014
On 04/01/2014 05:18 PM, Andrew Vagin wrote:
Pavel, would you answer on Andrey's questions?
> On Tue, Apr 01, 2014 at 03:10:40PM +0400, Tikhomirov Pavel wrote:
>> this test mmaps 512M area of memory, than sleep to be dumped,
>> than it munmaps 128 odd areas of size 2M of all 256 such areas
>> and in second dump process will have only 256M of memory
>
> Why do we need so big slice of memory? What is a difference between 64
> Mb and 512 Mb for this test? Will it catch more bugs with 512Mb?
>
>>
>> if --auto-dedup option is on, all images in the end must be
>> of size 0
>>
>> use:
>> sudo bash test/zdtm.sh -P -i 2 --auto-dedup transition/maps008
>>
>> to work need "[PATCH] dedup: add dedup on unmap vma, into
>> auto-dedup and dedup"
>>
>> Signed-off-by: Tikhomirov Pavel <snorcht at gmail.com>
>> ---
>> test/zdtm.sh | 1 +
>> test/zdtm/live/transition/Makefile | 1 +
>> test/zdtm/live/transition/maps008.c | 65 +++++++++++++++++++++++++++++++++++++
>> 3 files changed, 67 insertions(+)
>> create mode 100644 test/zdtm/live/transition/maps008.c
>>
>> diff --git a/test/zdtm.sh b/test/zdtm.sh
>> index d7f8fca..e4ed770 100755
>> --- a/test/zdtm.sh
>> +++ b/test/zdtm.sh
>> @@ -103,6 +103,7 @@ static/chroot
>> static/chroot-file
>> static/rtc
>> transition/maps007
>> +transition/maps008
>> "
>> # Duplicate list with ns/ prefix
>> TEST_LIST=$TEST_LIST$(echo $TEST_LIST | tr ' ' '\n' | sed 's#^#ns/#')
>> diff --git a/test/zdtm/live/transition/Makefile b/test/zdtm/live/transition/Makefile
>> index a4d0127..c1f7a7a 100644
>> --- a/test/zdtm/live/transition/Makefile
>> +++ b/test/zdtm/live/transition/Makefile
>> @@ -13,6 +13,7 @@ TST_NOFILE = \
>> fork2 \
>> thread-bomb \
>> maps007 \
>> + maps008 \
>>
>> TST_FILE = \
>> file_read \
>> diff --git a/test/zdtm/live/transition/maps008.c b/test/zdtm/live/transition/maps008.c
>> new file mode 100644
>> index 0000000..04054be
>> --- /dev/null
>> +++ b/test/zdtm/live/transition/maps008.c
>> @@ -0,0 +1,65 @@
>> +#include <unistd.h>
>> +#include <sys/mman.h>
>> +
>> +#include "zdtmtst.h"
>> +
>> +#define MEM_SIZE (1 << 29)
>> +#define PAGE_SIZE 4096
>> +
>> +const char *test_doc = "create big mapping and unmap odd blocks of size 2M";
>> +
>> +int main(int argc, char **argv)
>> +{
>> + void *start, *p;
>> + unsigned long long count = 0;
>> + unsigned long long i;
>> +
>> + test_init(argc, argv);
>> +
>> + /*
>> + * allocate workspace
>> + */
>> + start = mmap(NULL, MEM_SIZE, PROT_READ|PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
>> + if (start == MAP_FAILED)
>> + return -1;
>> +
>> + test_msg("%p-%p\n", start, start + MEM_SIZE);
>> +
>> + /*
>> + * dirty pages to ensure allocation
>> + */
>> + for (i = 0; i < MEM_SIZE/PAGE_SIZE; i++) {
>> + char *t = start + i * PAGE_SIZE;
>> + t[0] = 'o';
>> + }
>> +
>> + test_daemon();
>> +
>> + /*
>> + * Sleep to make 1-st dump get all workspace
>> + */
>> + sleep(1);
>
> test_waitsig()
>
>> +
>> + while (test_go()) {
>
> I don't understand this loop. Pls explain.
>
>> + int ret;
>> + unsigned long size = 512 * PAGE_SIZE;
>> +
>> + if (count * size >= MEM_SIZE)
>> + break;
>> + p = start + ((count) * size);
>> + count+=2;
>> +
>> + /*
>> + * unmap every odd block of size 2M
>> + */
>> + ret = munmap(p, size);
>
> What is an idea to unmap one slice more than once?
>
>> + if (ret == -1) {
>> + err("%p-%p", p, p + size);
>> + return -1;
>> + }
>> + }
>> +
>> + test_waitsig();
>> + pass();
>> + return 0;
>> +}
>> --
>> 1.8.3.2
>>
>> _______________________________________________
>> CRIU mailing list
>> CRIU at openvz.org
>> https://lists.openvz.org/mailman/listinfo/criu
> .
>
More information about the CRIU
mailing list