mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-08-03 07:12:48 +00:00
pagemap: Use pread to read pagemap entries
When reading pagemaps, we read it from specific position. To do it, we called lseek, then read. Fortunetely, there's a syscall that does both things in one call -- pread. Since we don't need to keep pagemap's position for further reads, it perfectly suits our needs. This removes 75% of lseek calls when dumping basic container. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
608db864a3
commit
593cb59a63
1 changed files with 4 additions and 9 deletions
13
mem.c
13
mem.c
|
|
@ -105,17 +105,12 @@ static int generate_iovs(struct vma_area *vma, int pagemap, struct page_pipe *pp
|
|||
{
|
||||
unsigned long pfn, nr_to_scan;
|
||||
unsigned long pages[2] = {};
|
||||
u64 aux;
|
||||
|
||||
aux = vma->vma.start / PAGE_SIZE * sizeof(*map);
|
||||
if (lseek(pagemap, aux, SEEK_SET) != aux) {
|
||||
pr_perror("Can't rewind pagemap file");
|
||||
return -1;
|
||||
}
|
||||
u64 from, len;
|
||||
|
||||
nr_to_scan = vma_area_len(vma) / PAGE_SIZE;
|
||||
aux = nr_to_scan * sizeof(*map);
|
||||
if (read(pagemap, map, aux) != aux) {
|
||||
from = vma->vma.start / PAGE_SIZE * sizeof(*map);
|
||||
len = nr_to_scan * sizeof(*map);
|
||||
if (pread(pagemap, map, len, from) != len) {
|
||||
pr_perror("Can't read pagemap file");
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue