mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 13:28:27 +00:00
proc: Don't use FILE* for reading personality
It turned out, that fdopen (used in fopen_proc) always maps a 4k buffer for reads and this buffer gets unmap-ed later on fclose. Taking into account the amount of proc files we read (~20 per task plus one file per opened file descriptor) this mmap+munmap result in quite a lot of useless CPU time. E.g. for a container of 20 tasks we have 1000 calls taking ~8% of total dump time. So lets first stop doing this for simple cases -- one line proc files. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
d36c4058bc
commit
f3bee6d584
24
cr-dump.c
24
cr-dump.c
@ -579,26 +579,22 @@ err:
|
|||||||
|
|
||||||
static int get_task_personality(pid_t pid, u32 *personality)
|
static int get_task_personality(pid_t pid, u32 *personality)
|
||||||
{
|
{
|
||||||
FILE *file = NULL;
|
int fd, ret = -1;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
pr_info("Obtaining personality ... ");
|
pr_info("Obtaining personality ... ");
|
||||||
|
|
||||||
file = fopen_proc(pid, "personality");
|
fd = open_proc(pid, "personality");
|
||||||
if (!file)
|
if (fd < 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (!fgets(loc_buf, sizeof(loc_buf), file)) {
|
ret = read(fd, loc_buf, sizeof(loc_buf));
|
||||||
pr_perror("Can't read task personality");
|
close(fd);
|
||||||
goto err;
|
|
||||||
|
if (ret >= 0) {
|
||||||
|
loc_buf[ret] = '\0';
|
||||||
|
*personality = atoi(loc_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
*personality = atoi(loc_buf);
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
err:
|
err:
|
||||||
if (file)
|
|
||||||
fclose(file);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -720,7 +716,7 @@ static int dump_task_core_all(struct pstree_item *item,
|
|||||||
pr_info("----------------------------------------\n");
|
pr_info("----------------------------------------\n");
|
||||||
|
|
||||||
ret = get_task_personality(pid, &core->tc->personality);
|
ret = get_task_personality(pid, &core->tc->personality);
|
||||||
if (ret)
|
if (ret < 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
strncpy((char *)core->tc->comm, stat->comm, TASK_COMM_LEN);
|
strncpy((char *)core->tc->comm, stat->comm, TASK_COMM_LEN);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user