Commit aeb638f8 authored by Andrey Vagin's avatar Andrey Vagin Committed by Cyrill Gorcunov

restore: shmem -- Don't poll, use wait helpers instead

Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
[gorcunov: A few tuneups]
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent bd8b2b0f
......@@ -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);
pr_info("Waiting for [%s] to appear\n", path);
ret = open(path, O_RDWR);
if (ret >= 0)
return ret;
if (ret < 0 && errno != ENOENT) {
if (ret < 0) {
pr_perror(" %d: Can't stat shmem at %s\n",
si->real_pid, path);
return -1;
}
pr_info("Waiting for [%s] to appear\n", path);
if (time < 20000000)
time <<= 1;
usleep(time);
}
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 {
......
......@@ -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);
}
}
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment