2
0
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:
Andrey Vagin
2011-12-26 23:50:45 +04:00
committed by Cyrill Gorcunov
parent bd8b2b0f11
commit aeb638f845
3 changed files with 30 additions and 18 deletions

View File

@@ -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)

View File

@@ -296,6 +296,7 @@ struct shmem_info {
unsigned long shmid;
int pid;
int real_pid;
u32 lock; /* futex */
};
struct shmems {

View File

@@ -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);
}
}
/*