mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 14:25:49 +00:00
restore: shmem -- Don't poll, use wait helpers instead
Signed-off-by: Andrey Vagin <avagin@openvz.org> [gorcunov: A few tuneups] Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This commit is contained in:
committed by
Cyrill Gorcunov
parent
bd8b2b0f11
commit
aeb638f845
30
cr-restore.c
30
cr-restore.c
@@ -144,33 +144,27 @@ static void shmem_update_real_pid(int vpid, int rpid)
|
||||
|
||||
static int shmem_wait_and_open(struct shmem_info *si)
|
||||
{
|
||||
unsigned long time = 1000;
|
||||
unsigned long time = 1;
|
||||
char path[128];
|
||||
int ret;
|
||||
|
||||
sleep(1);
|
||||
|
||||
while (si->real_pid == 0)
|
||||
usleep(time);
|
||||
cr_wait_until(&si->lock, 1);
|
||||
|
||||
sprintf(path, "/proc/%d/map_files/%lx-%lx",
|
||||
si->real_pid, si->start, si->end);
|
||||
|
||||
while (1) {
|
||||
int ret = open(path, O_RDWR);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
pr_info("Waiting for [%s] to appear\n", path);
|
||||
|
||||
if (ret < 0 && errno != ENOENT) {
|
||||
pr_perror(" %d: Can't stat shmem at %s\n",
|
||||
si->real_pid, path);
|
||||
return -1;
|
||||
}
|
||||
ret = open(path, O_RDWR);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
|
||||
pr_info("Waiting for [%s] to appear\n", path);
|
||||
if (time < 20000000)
|
||||
time <<= 1;
|
||||
usleep(time);
|
||||
if (ret < 0) {
|
||||
pr_perror(" %d: Can't stat shmem at %s\n",
|
||||
si->real_pid, path);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int collect_shmem(int pid, struct shmem_entry *e)
|
||||
|
@@ -296,6 +296,7 @@ struct shmem_info {
|
||||
unsigned long shmid;
|
||||
int pid;
|
||||
int real_pid;
|
||||
u32 lock; /* futex */
|
||||
};
|
||||
|
||||
struct shmems {
|
||||
|
17
restorer.c
17
restorer.c
@@ -277,6 +277,23 @@ self_len_end:
|
||||
|
||||
if (vma_entry->fd != -1UL)
|
||||
sys_close(vma_entry->fd);
|
||||
|
||||
if (vma_entry_is(vma_entry, VMA_ANON_SHARED) &&
|
||||
vma_entry->fd == -1UL) {
|
||||
struct shmem_info *entry;
|
||||
|
||||
entry = find_shmem_by_pid(args->shmems,
|
||||
vma_entry->start,
|
||||
sys_getpid());
|
||||
if (!entry) {
|
||||
write_num_n(__LINE__);
|
||||
write_hex_n(vma_entry->start);
|
||||
goto core_restore_end;
|
||||
}
|
||||
|
||||
cr_wait_set(&entry->lock, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user