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, ...@@ -408,13 +408,16 @@ static int dump_task_mm(pid_t pid, const struct proc_pid_stat *stat,
{ {
MmEntry mme = MM_ENTRY__INIT; MmEntry mme = MM_ENTRY__INIT;
struct vma_area *vma_area; struct vma_area *vma_area;
int ret = -1, fd; int ret = -1, i = 0;
pr_info("\n"); pr_info("\n");
pr_info("Dumping mm (pid: %d)\n", pid); pr_info("Dumping mm (pid: %d)\n", pid);
pr_info("----------------------------------------\n"); 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) { list_for_each_entry(vma_area, &vma_area_list->h, list) {
VmaEntry *vma = vma_area->e; VmaEntry *vma = vma_area->e;
...@@ -434,11 +437,10 @@ static int dump_task_mm(pid_t pid, const struct proc_pid_stat *stat, ...@@ -434,11 +437,10 @@ static int dump_task_mm(pid_t pid, const struct proc_pid_stat *stat,
ret = dump_socket_map(vma_area); ret = dump_socket_map(vma_area);
else else
ret = 0; ret = 0;
if (!ret)
ret = pb_write_one(fd, vma, PB_VMA);
if (ret) if (ret)
goto err; goto err;
mme.vmas[i++] = vma;
} }
mme.mm_start_code = stat->start_code; mme.mm_start_code = stat->start_code;
......
...@@ -15,7 +15,6 @@ enum { ...@@ -15,7 +15,6 @@ enum {
CR_FD_CORE, CR_FD_CORE,
CR_FD_IDS, CR_FD_IDS,
CR_FD_MM, CR_FD_MM,
CR_FD_VMAS,
CR_FD_SIGACT, CR_FD_SIGACT,
CR_FD_ITIMERS, CR_FD_ITIMERS,
CR_FD_POSIX_TIMERS, CR_FD_POSIX_TIMERS,
...@@ -84,6 +83,7 @@ enum { ...@@ -84,6 +83,7 @@ enum {
CR_FD_PAGES, CR_FD_PAGES,
CR_FD_PSIGNAL, CR_FD_PSIGNAL,
CR_FD_VMAS,
CR_FD_PAGES_OLD, CR_FD_PAGES_OLD,
CR_FD_SHM_PAGES_OLD, CR_FD_SHM_PAGES_OLD,
......
...@@ -344,7 +344,7 @@ int parasite_dump_pages_seized(struct parasite_ctl *ctl, ...@@ -344,7 +344,7 @@ int parasite_dump_pages_seized(struct parasite_ctl *ctl,
int prepare_mm_pid(struct pstree_item *i) int prepare_mm_pid(struct pstree_item *i)
{ {
pid_t pid = i->pid.virt; pid_t pid = i->pid.virt;
int fd, ret = -1; int fd, ret = -1, vn = 0;
struct rst_info *ri = i->rst; struct rst_info *ri = i->rst;
fd = open_image(CR_FD_MM, O_RSTR, pid); fd = open_image(CR_FD_MM, O_RSTR, pid);
...@@ -359,27 +359,17 @@ int prepare_mm_pid(struct pstree_item *i) ...@@ -359,27 +359,17 @@ int prepare_mm_pid(struct pstree_item *i)
if (ret < 0) if (ret < 0)
return -1; return -1;
fd = open_image(CR_FD_VMAS, O_RSTR, pid); while (vn < ri->mm->n_vmas) {
if (fd < 0)
return -1;
while (1) {
struct vma_area *vma; struct vma_area *vma;
VmaEntry *vi;
ret = -1; ret = -1;
vma = alloc_vma_area(); vma = alloc_vma_area();
if (!vma) if (!vma)
break; break;
ret = pb_read_one_eof(fd, &vi, PB_VMA); ret = 0;
if (ret <= 0) {
xfree(vma);
break;
}
ri->vmas.nr++; ri->vmas.nr++;
vma->e = vi; vma->e = ri->mm->vmas[vn++];
list_add_tail(&vma->list, &ri->vmas.h); list_add_tail(&vma->list, &ri->vmas.h);
if (vma_priv(vma->e)) { if (vma_priv(vma->e)) {
...@@ -399,7 +389,6 @@ int prepare_mm_pid(struct pstree_item *i) ...@@ -399,7 +389,6 @@ int prepare_mm_pid(struct pstree_item *i)
break; break;
} }
close(fd);
return ret; return ret;
} }
import "vma.proto";
message mm_entry { message mm_entry {
required uint64 mm_start_code = 1; required uint64 mm_start_code = 1;
required uint64 mm_end_code = 2; required uint64 mm_end_code = 2;
...@@ -13,4 +15,6 @@ message mm_entry { ...@@ -13,4 +15,6 @@ message mm_entry {
required uint32 exe_file_id = 12; required uint32 exe_file_id = 12;
repeated uint64 mm_saved_auxv = 13; 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