Skip to content

Commit

Permalink
kerndat: check support for PAGE_IS_SOFT_DIRTY
Browse files Browse the repository at this point in the history
The commit introducing PAGE_IS_SOFT_DIRTY has not been merged
in kernel v6.7.x.

fs/proc/task_mmu: report SOFT_DIRTY bits through the PAGEMAP_SCAN ioctl
torvalds/linux@e6a9a2cbc13bf

As a result, CRIU fails with the following error:

Error (criu/pagemap-cache.c:199): pagemap-cache: PAGEMAP_SCAN: Invalid argument'
Error (criu/pagemap-cache.c:225): pagemap-cache: Failed to fill cache for 63 (400000-402000)'

This patch updates check_pagemap() in kerndat to check if PAGE_IS_SOFT_DIRTY is supported.
Fixes: checkpoint-restore#2334

Signed-off-by: Radostin Stoyanov <[email protected]>
  • Loading branch information
rst0git authored and avagin committed Aug 16, 2024
1 parent 248a5b6 commit 6ea7c95
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions criu/kerndat.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ static int check_pagemap(void)
{
int ret, fd, retry;
u64 pfn = 0;
struct pm_scan_arg args = {
.size = sizeof(struct pm_scan_arg),
.flags = 0,
.category_inverted = PAGE_IS_PFNZERO | PAGE_IS_FILE,
.category_mask = PAGE_IS_PFNZERO | PAGE_IS_FILE,
.category_anyof_mask = PAGE_IS_PRESENT | PAGE_IS_SWAPPED,
.return_mask = PAGE_IS_PRESENT | PAGE_IS_SWAPPED | PAGE_IS_SOFT_DIRTY,
};

fd = __open_proc(PROC_SELF, EPERM, O_RDONLY, "pagemap");
if (fd < 0) {
Expand All @@ -75,15 +83,11 @@ static int check_pagemap(void)
return -1;
}

if (ioctl(fd, PAGEMAP_SCAN, NULL) == 0) {
pr_err("PAGEMAP_SCAN succeeded unexpectedly\n");
return -1;
if (ioctl(fd, PAGEMAP_SCAN, &args) == 0) {
pr_debug("PAGEMAP_SCAN is supported\n");
kdat.has_pagemap_scan = true;
} else {
switch (errno) {
case EFAULT:
pr_debug("PAGEMAP_SCAN is supported\n");
kdat.has_pagemap_scan = true;
break;
case EINVAL:
case ENOTTY:
pr_debug("PAGEMAP_SCAN isn't supported\n");
Expand Down

0 comments on commit 6ea7c95

Please sign in to comment.