mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-22 09:58:09 +00:00
Use run-time page size where it matters
In AArch64, pages may be 4K or 64K depending on kernel configuration. The GNU C Library documentation suggests [1], "the correct interface to query about the page size is sysconf". Introduce one new architecture-specific function-like macro, page_size(), that on x86 and AArch32 remains a constant so as to minimally affect performance, but on AArch64 is sysconf(_SC_PAGESIZE) for correctness. 1. https://www.gnu.org/software/libc/manual/html_node/Query-Memory-Parameters.html To minimize churn, the PAGE_SIZE macro is left as a build-time estimation of what the run-time page size might be. This fixes the following errors for CRIU on AArch64 kernels with CONFIG_ARM64_64K_PAGES=y, allowing dump of `setsid sleep < /dev/null &> /dev/null` to succeed. Error (kerndat.c:48): Can't stat self map_files: No such file or directory Error (util.c:668): Can't read pme for pid 90: No such file or directory Error (parasite-syscall.c:1135): Can't open 89/map_files/0x3ffb7da0000-0x3ffb7dac000 on procfs: No such file or directory Signed-off-by: Christopher Covington <cov@codeaurora.org> Acked-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
208fe10565
commit
cefe22bdac
19
arch/aarch64/include/asm/page.h
Normal file
19
arch/aarch64/include/asm/page.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#ifndef __CR_ASM_PAGE_H__
|
||||||
|
#define __CR_ASM_PAGE_H__
|
||||||
|
|
||||||
|
#ifndef PAGE_SHIFT
|
||||||
|
# define PAGE_SHIFT 12
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PAGE_SIZE
|
||||||
|
# define PAGE_SIZE (1UL << PAGE_SHIFT)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PAGE_MASK
|
||||||
|
# define PAGE_MASK (~(PAGE_SIZE - 1))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define PAGE_PFN(addr) ((addr) / PAGE_SIZE)
|
||||||
|
#define page_size() sysconf(_SC_PAGESIZE)
|
||||||
|
|
||||||
|
#endif /* __CR_ASM_PAGE_H__ */
|
@ -6,7 +6,7 @@
|
|||||||
#include <asm/ptrace.h>
|
#include <asm/ptrace.h>
|
||||||
#include "protobuf/core.pb-c.h"
|
#include "protobuf/core.pb-c.h"
|
||||||
|
|
||||||
#include "asm-generic/page.h"
|
#include "asm/page.h"
|
||||||
#include "asm/bitops.h"
|
#include "asm/bitops.h"
|
||||||
#include "asm/int.h"
|
#include "asm/int.h"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef __CR_ASM_GENERIC_PAGE_H__
|
#ifndef __CR_ASM_PAGE_H__
|
||||||
#define __CR_ASM_GENERIC_PAGE_H__
|
#define __CR_ASM_PAGE_H__
|
||||||
|
|
||||||
#ifndef PAGE_SHIFT
|
#ifndef PAGE_SHIFT
|
||||||
# define PAGE_SHIFT 12
|
# define PAGE_SHIFT 12
|
||||||
@ -14,5 +14,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PAGE_PFN(addr) ((addr) / PAGE_SIZE)
|
#define PAGE_PFN(addr) ((addr) / PAGE_SIZE)
|
||||||
|
#define page_size() PAGE_SIZE
|
||||||
|
|
||||||
#endif /* __CR_ASM_GENERIC_PAGE_H__ */
|
#endif /* __CR_ASM_PAGE_H__ */
|
@ -5,7 +5,7 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include "protobuf/core.pb-c.h"
|
#include "protobuf/core.pb-c.h"
|
||||||
|
|
||||||
#include "asm-generic/page.h"
|
#include "asm/page.h"
|
||||||
#include "asm/bitops.h"
|
#include "asm/bitops.h"
|
||||||
#include "asm/int.h"
|
#include "asm/int.h"
|
||||||
|
|
||||||
|
19
arch/x86/include/asm/page.h
Normal file
19
arch/x86/include/asm/page.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#ifndef __CR_ASM_PAGE_H__
|
||||||
|
#define __CR_ASM_PAGE_H__
|
||||||
|
|
||||||
|
#ifndef PAGE_SHIFT
|
||||||
|
# define PAGE_SHIFT 12
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PAGE_SIZE
|
||||||
|
# define PAGE_SIZE (1UL << PAGE_SHIFT)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PAGE_MASK
|
||||||
|
# define PAGE_MASK (~(PAGE_SIZE - 1))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define PAGE_PFN(addr) ((addr) / PAGE_SIZE)
|
||||||
|
#define page_size() PAGE_SIZE
|
||||||
|
|
||||||
|
#endif /* __CR_ASM_PAGE_H__ */
|
@ -4,7 +4,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "asm-generic/page.h"
|
#include "asm/page.h"
|
||||||
#include "asm/bitops.h"
|
#include "asm/bitops.h"
|
||||||
#include "asm/int.h"
|
#include "asm/int.h"
|
||||||
#include "asm/prlimit.h"
|
#include "asm/prlimit.h"
|
||||||
|
2
bfd.c
2
bfd.c
@ -13,7 +13,7 @@
|
|||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
#include "asm-generic/page.h"
|
#include "asm/page.h"
|
||||||
|
|
||||||
#undef LOG_PREFIX
|
#undef LOG_PREFIX
|
||||||
#define LOG_PREFIX "bfd: "
|
#define LOG_PREFIX "bfd: "
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define __CR_PAGEMAP_H__
|
#define __CR_PAGEMAP_H__
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include "asm-generic/page.h"
|
#include "asm/page.h"
|
||||||
#include "asm/int.h"
|
#include "asm/int.h"
|
||||||
|
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
@ -42,7 +42,7 @@ static int kerndat_get_shmemdev(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sprintf(maps, "/proc/self/map_files/%lx-%lx",
|
sprintf(maps, "/proc/self/map_files/%lx-%lx",
|
||||||
(unsigned long)map, (unsigned long)map + PAGE_SIZE);
|
(unsigned long)map, (unsigned long)map + page_size());
|
||||||
if (stat(maps, &buf) < 0) {
|
if (stat(maps, &buf) < 0) {
|
||||||
munmap(map, PAGE_SIZE);
|
munmap(map, PAGE_SIZE);
|
||||||
pr_perror("Can't stat self map_files");
|
pr_perror("Can't stat self map_files");
|
||||||
|
@ -1129,7 +1129,7 @@ int parasite_map_exchange(struct parasite_ctl *ctl, unsigned long size)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctl->map_length = round_up(size, PAGE_SIZE);
|
ctl->map_length = round_up(size, page_size());
|
||||||
|
|
||||||
fd = open_proc_rw(ctl->pid.real, "map_files/%p-%p",
|
fd = open_proc_rw(ctl->pid.real, "map_files/%p-%p",
|
||||||
ctl->remote_map, ctl->remote_map + ctl->map_length);
|
ctl->remote_map, ctl->remote_map + ctl->map_length);
|
||||||
|
2
util.c
2
util.c
@ -657,7 +657,7 @@ int vaddr_to_pfn(unsigned long vaddr, u64 *pfn)
|
|||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
off = (vaddr / PAGE_SIZE) * sizeof(u64);
|
off = (vaddr / page_size()) * sizeof(u64);
|
||||||
if (lseek(fd, off, SEEK_SET) != off) {
|
if (lseek(fd, off, SEEK_SET) != off) {
|
||||||
pr_perror("Failed to seek address %lx", vaddr);
|
pr_perror("Failed to seek address %lx", vaddr);
|
||||||
goto out;
|
goto out;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user