[CRIU] Fwd: [PATCH] zdtm: add test maps008 for dedup on unmap vma

Pavel Tikhomirov snorcht at gmail.com
Mon Apr 14 04:27:37 PDT 2014


Sorry, missed mailing list

Best Regards, Tikhomirov Pavel.


---------- Forwarded message ----------
From: Pavel Tikhomirov <snorcht at gmail.com>
Date: 2014-04-01 18:21 GMT+04:00
Subject: Re: [CRIU] [PATCH] zdtm: add test maps008 for dedup on unmap vma
To: Andrew Vagin <avagin at parallels.com>


2014-04-01 17:36 GMT+04:00 Pavel Tikhomirov <snorcht at gmail.com>:


> 2014-04-01 17:18 GMT+04:00 Andrew Vagin <avagin at parallels.com>:
>
> 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?
>
>
> For this test it doesn't matter, yes, we can do even less than 64Mb.
>
>
>>  >
>> > 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()
>
>
> Oh, now I understand. Thanks!
>

some how then I use test_waitsig in that place, all 2 dumps appear to take
place here
before the loop, I need one before loop and another at the end.


>
>
>>
>>
>  > +
>> > +     while (test_go()) {
>>
>> I don't understand this loop. Pls explain.
>>
>
> OK. and may be i need to simplify it.
>
>
>>
>>
> > +             int ret;
>> > +             unsigned long size = 512 * PAGE_SIZE;
>> > +
>> > +             if (count * size >= MEM_SIZE)
>> > +                     break;
>>
>
> count til the end of memory, than break.
>
>
>>  > +             p = start + ((count) * size);
>> > +             count+=2;
>>
>
> counts step is 2, because I want unmap odd blocks: 1-st,3-rd, etc.
>
>
>>  > +
>> > +             /*
>> > +              * unmap every odd block of size 2M
>> > +              */
>> > +             ret = munmap(p, size);
>>
>> What is an idea to unmap one slice more than once?
>
> I unmap one slice only one time resulting memory will look like:
>     |maped|unmaped|maped|unmaped|....
>
>>  > +             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
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20140414/8a6ab6d6/attachment-0001.html>


More information about the CRIU mailing list