Commit 94c6d773 authored by Pavel Emelyanov's avatar Pavel Emelyanov

shmem: Split shmem dumping code into two

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 9486946b
...@@ -291,21 +291,14 @@ int add_shmem_area(pid_t pid, VmaEntry *vma) ...@@ -291,21 +291,14 @@ int add_shmem_area(pid_t pid, VmaEntry *vma)
return 0; return 0;
} }
#define for_each_shmem_dump(_i, _si) \ static int dump_one_shmem(struct shmem_info_dump *si)
for (i = 0; i < SHMEM_HASH_SIZE; i++) \
for (si = shmems_hash[i]; si; si = si->next)
int cr_dump_shmem(void)
{ {
int i, err, fd, fd_pg; PagemapEntry pe = PAGEMAP_ENTRY__INIT;
int err, fd, fd_pg;
unsigned char *map = NULL; unsigned char *map = NULL;
void *addr = NULL; void *addr = NULL;
struct shmem_info_dump *si;
unsigned long pfn, nrpages; unsigned long pfn, nrpages;
for_each_shmem_dump (i, si) {
PagemapEntry pe = PAGEMAP_ENTRY__INIT;
pr_info("Dumping shared memory 0x%lx\n", si->shmid); pr_info("Dumping shared memory 0x%lx\n", si->shmid);
nrpages = (si->size + PAGE_SIZE - 1) / PAGE_SIZE; nrpages = (si->size + PAGE_SIZE - 1) / PAGE_SIZE;
...@@ -375,8 +368,6 @@ int cr_dump_shmem(void) ...@@ -375,8 +368,6 @@ int cr_dump_shmem(void)
close(fd); close(fd);
munmap(addr, si->size); munmap(addr, si->size);
xfree(map); xfree(map);
}
return 0; return 0;
err_close2: err_close2:
...@@ -389,3 +380,21 @@ err: ...@@ -389,3 +380,21 @@ err:
xfree(map); xfree(map);
return -1; return -1;
} }
#define for_each_shmem_dump(_i, _si) \
for (i = 0; i < SHMEM_HASH_SIZE; i++) \
for (si = shmems_hash[i]; si; si = si->next)
int cr_dump_shmem(void)
{
int ret = 0, i;
struct shmem_info_dump *si;
for_each_shmem_dump (i, si) {
ret = dump_one_shmem(si);
if (ret)
break;
}
return ret;
}
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