mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-22 01:51:51 +00:00
test/zdtm/static/maps02: add MAP_DROPPABLE testcase
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
This commit is contained in:
parent
ae9d0d0557
commit
27653caa4c
@ -6,6 +6,10 @@
|
||||
#define MAP_HUGETLB 0x40000
|
||||
#endif
|
||||
|
||||
#ifndef MAP_DROPPABLE
|
||||
#define MAP_DROPPABLE 0x08
|
||||
#endif
|
||||
|
||||
#ifndef MADV_HUGEPAGE
|
||||
#define MADV_HUGEPAGE 14
|
||||
#endif
|
||||
@ -45,6 +49,8 @@ static void parse_vmflags(char *buf, unsigned long *flags, unsigned long *madv)
|
||||
*flags |= MAP_NORESERVE;
|
||||
else if (_vmflag_match(tok, "ht"))
|
||||
*flags |= MAP_HUGETLB;
|
||||
else if (_vmflag_match(tok, "dp"))
|
||||
*flags |= MAP_DROPPABLE;
|
||||
|
||||
/* madvise() block */
|
||||
if (_vmflag_match(tok, "sr"))
|
||||
|
@ -2,6 +2,10 @@
|
||||
#include "zdtmtst.h"
|
||||
#include "get_smaps_bits.h"
|
||||
|
||||
#ifndef MAP_DROPPABLE
|
||||
#define MAP_DROPPABLE 0x08
|
||||
#endif
|
||||
|
||||
#ifndef MADV_DONTDUMP
|
||||
#define MADV_DONTDUMP 16
|
||||
#endif
|
||||
@ -27,8 +31,14 @@ static int alloc_anon_mmap(struct mmap_data *m, int flags, int adv)
|
||||
{
|
||||
m->start = mmap(NULL, MEM_SIZE, PROT_READ | PROT_WRITE, flags, -1, 0);
|
||||
if (m->start == MAP_FAILED) {
|
||||
pr_perror("mmap failed");
|
||||
return -1;
|
||||
if (errno == EINVAL) {
|
||||
test_msg("mmap failed, no kernel support\n");
|
||||
*m = (struct mmap_data){};
|
||||
return 0;
|
||||
} else {
|
||||
pr_perror("mmap failed");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (madvise(m->start, MEM_SIZE, adv)) {
|
||||
@ -47,7 +57,7 @@ static int alloc_anon_mmap(struct mmap_data *m, int flags, int adv)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct mmap_data m[6] = {};
|
||||
struct mmap_data m[7] = {};
|
||||
size_t i;
|
||||
|
||||
test_init(argc, argv);
|
||||
@ -76,6 +86,10 @@ int main(int argc, char **argv)
|
||||
if (alloc_anon_mmap(&m[5], MAP_PRIVATE | MAP_ANONYMOUS, MADV_WIPEONFORK))
|
||||
return -1;
|
||||
|
||||
test_msg("Alloc droppable\n");
|
||||
if (alloc_anon_mmap(&m[6], MAP_DROPPABLE | MAP_ANONYMOUS, MADV_NORMAL))
|
||||
return -1;
|
||||
|
||||
test_msg("Fetch existing flags/adv\n");
|
||||
for (i = 0; i < sizeof(m) / sizeof(m[0]); i++) {
|
||||
if (get_smaps_bits((unsigned long)m[i].start, &m[i].orig_flags, &m[i].orig_madv))
|
||||
|
Loading…
x
Reference in New Issue
Block a user