Commit 54f4f889 authored by Pavel Emelyanov's avatar Pavel Emelyanov

mm: Move VmaEntries from separate image into Mm one

When writing VMAs we perform too many small writes into vma-.img files.
This can be easily fixed by moving the vma-s into mm-s, all the more
so they cannot be splitted from each other.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 72e462ad
......@@ -408,13 +408,16 @@ static int dump_task_mm(pid_t pid, const struct proc_pid_stat *stat,
{
MmEntry mme = MM_ENTRY__INIT;
struct vma_area *vma_area;
int ret = -1, fd;
int ret = -1, i = 0;
pr_info("\n");
pr_info("Dumping mm (pid: %d)\n", pid);
pr_info("----------------------------------------\n");
fd = fdset_fd(fdset, CR_FD_VMAS);
mme.n_vmas = vma_area_list->nr;
mme.vmas = xmalloc(mme.n_vmas * sizeof(VmaEntry *));
if (!mme.vmas)
goto err;
list_for_each_entry(vma_area, &vma_area_list->h, list) {
VmaEntry *vma = vma_area->e;
......@@ -434,11 +437,10 @@ static int dump_task_mm(pid_t pid, const struct proc_pid_stat *stat,
ret = dump_socket_map(vma_area);
else
ret = 0;
if (!ret)
ret = pb_write_one(fd, vma, PB_VMA);
if (ret)
goto err;
mme.vmas[i++] = vma;
}
mme.mm_start_code = stat->start_code;
......
......@@ -15,7 +15,6 @@ enum {
CR_FD_CORE,
CR_FD_IDS,
CR_FD_MM,
CR_FD_VMAS,
CR_FD_SIGACT,
CR_FD_ITIMERS,
CR_FD_POSIX_TIMERS,
......@@ -84,6 +83,7 @@ enum {
CR_FD_PAGES,
CR_FD_PSIGNAL,
CR_FD_VMAS,
CR_FD_PAGES_OLD,
CR_FD_SHM_PAGES_OLD,
......
......@@ -344,7 +344,7 @@ int parasite_dump_pages_seized(struct parasite_ctl *ctl,
int prepare_mm_pid(struct pstree_item *i)
{
pid_t pid = i->pid.virt;
int fd, ret = -1;
int fd, ret = -1, vn = 0;
struct rst_info *ri = i->rst;
fd = open_image(CR_FD_MM, O_RSTR, pid);
......@@ -359,27 +359,17 @@ int prepare_mm_pid(struct pstree_item *i)
if (ret < 0)
return -1;
fd = open_image(CR_FD_VMAS, O_RSTR, pid);
if (fd < 0)
return -1;
while (1) {
while (vn < ri->mm->n_vmas) {
struct vma_area *vma;
VmaEntry *vi;
ret = -1;
vma = alloc_vma_area();
if (!vma)
break;
ret = pb_read_one_eof(fd, &vi, PB_VMA);
if (ret <= 0) {
xfree(vma);
break;
}
ret = 0;
ri->vmas.nr++;
vma->e = vi;
vma->e = ri->mm->vmas[vn++];
list_add_tail(&vma->list, &ri->vmas.h);
if (vma_priv(vma->e)) {
......@@ -399,7 +389,6 @@ int prepare_mm_pid(struct pstree_item *i)
break;
}
close(fd);
return ret;
}
import "vma.proto";
message mm_entry {
required uint64 mm_start_code = 1;
required uint64 mm_end_code = 2;
......@@ -13,4 +15,6 @@ message mm_entry {
required uint32 exe_file_id = 12;
repeated uint64 mm_saved_auxv = 13;
repeated vma_entry vmas = 14;
}
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