mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-28 20:42:49 +00:00
aio: Refactor nr_req calculation
nr_req always depends on ring size and we even check for that. Kill parasite_aio::max_reqs,vma_nr_reqs and vma_area::aio_nr_req, because they are not need and excess. Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
parent
9dd414c2de
commit
51ff6240e4
6 changed files with 13 additions and 19 deletions
25
criu/aio.c
25
criu/aio.c
|
|
@ -8,6 +8,8 @@
|
|||
#include "parasite-syscall.h"
|
||||
#include "images/mm.pb-c.h"
|
||||
|
||||
#define NR_IOEVENTS_IN_NPAGES(npages) ((PAGE_SIZE * npages - sizeof(struct aio_ring)) / sizeof(struct io_event))
|
||||
|
||||
int dump_aio_ring(MmEntry *mme, struct vma_area *vma)
|
||||
{
|
||||
int nr = mme->n_aios;
|
||||
|
|
@ -23,8 +25,10 @@ int dump_aio_ring(MmEntry *mme, struct vma_area *vma)
|
|||
|
||||
aio_ring_entry__init(re);
|
||||
re->id = vma->e->start;
|
||||
re->nr_req = vma->aio_nr_req;
|
||||
re->ring_len = vma->e->end - vma->e->start;
|
||||
re->nr_req = aio_estimate_nr_reqs(re->ring_len);
|
||||
if (!re->nr_req)
|
||||
return -1;
|
||||
mme->aios[nr] = re;
|
||||
mme->n_aios = nr + 1;
|
||||
pr_info("Dumping AIO ring @%"PRIx64"-%"PRIx64"\n",
|
||||
|
|
@ -43,8 +47,14 @@ void free_aios(MmEntry *mme)
|
|||
}
|
||||
}
|
||||
|
||||
static unsigned int aio_estimate_nr_reqs(unsigned int k_max_reqs)
|
||||
unsigned int aio_estimate_nr_reqs(unsigned int size)
|
||||
{
|
||||
unsigned int k_max_reqs = NR_IOEVENTS_IN_NPAGES(size/PAGE_SIZE);
|
||||
|
||||
if (size & ~PAGE_MASK) {
|
||||
pr_err("Ring size is not aligned\n");
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Kernel does
|
||||
*
|
||||
|
|
@ -74,7 +84,6 @@ int parasite_collect_aios(struct parasite_ctl *ctl, struct vm_area_list *vmas)
|
|||
struct vma_area *vma;
|
||||
struct parasite_check_aios_args *aa;
|
||||
struct parasite_aio *pa;
|
||||
int i;
|
||||
|
||||
if (!vmas->nr_aios)
|
||||
return 0;
|
||||
|
|
@ -99,8 +108,6 @@ int parasite_collect_aios(struct parasite_ctl *ctl, struct vm_area_list *vmas)
|
|||
(long)(pa - &aa->ring[0]), vma->e->start);
|
||||
pa->ctx = vma->e->start;
|
||||
pa->size = vma->e->end - vma->e->start;
|
||||
pa->max_reqs = 0;
|
||||
pa->vma_nr_reqs = &vma->aio_nr_req;
|
||||
pa++;
|
||||
}
|
||||
aa->nr_rings = vmas->nr_aios;
|
||||
|
|
@ -108,13 +115,5 @@ int parasite_collect_aios(struct parasite_ctl *ctl, struct vm_area_list *vmas)
|
|||
if (parasite_execute_daemon(PARASITE_CMD_CHECK_AIOS, ctl))
|
||||
return -1;
|
||||
|
||||
pa = &aa->ring[0];
|
||||
for (i = 0; i < vmas->nr_aios; i++) {
|
||||
pa = &aa->ring[i];
|
||||
*pa->vma_nr_reqs = aio_estimate_nr_reqs(pa->max_reqs);
|
||||
pr_debug(" `- Ring #%d has %u reqs, estimated to %u\n", i,
|
||||
pa->max_reqs, *pa->vma_nr_reqs);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <linux/aio_abi.h>
|
||||
#include "images/mm.pb-c.h"
|
||||
unsigned int aio_estimate_nr_reqs(unsigned int size);
|
||||
int dump_aio_ring(MmEntry *mme, struct vma_area *vma);
|
||||
void free_aios(MmEntry *mme);
|
||||
struct parasite_ctl;
|
||||
|
|
|
|||
|
|
@ -140,8 +140,6 @@ struct parasite_dump_posix_timers_args {
|
|||
struct parasite_aio {
|
||||
unsigned long ctx;
|
||||
unsigned int size;
|
||||
unsigned int max_reqs;
|
||||
unsigned int *vma_nr_reqs;
|
||||
};
|
||||
|
||||
struct parasite_check_aios_args {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ struct vma_area {
|
|||
* The aio_nr_req is only for aio rings.
|
||||
*/
|
||||
int vm_socket_id;
|
||||
unsigned int aio_nr_req;
|
||||
};
|
||||
|
||||
char *aufs_rpath; /* path from aufs root */
|
||||
|
|
|
|||
|
|
@ -418,8 +418,6 @@ static int parasite_check_aios(struct parasite_check_aios_args *args)
|
|||
}
|
||||
|
||||
/* XXX: wait aio completion */
|
||||
|
||||
args->ring[i].max_reqs = ring->nr;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -252,7 +252,6 @@ static int vma_get_mapfile(char *fname, struct vma_area *vma, DIR *mfd,
|
|||
if ((buf.st_mode & S_IFMT) == 0 && !strncmp(fname, AIO_FNAME, sizeof(AIO_FNAME) - 1)) {
|
||||
/* AIO ring, let's try */
|
||||
close_safe(vm_file_fd);
|
||||
vma->aio_nr_req = -1;
|
||||
vma->e->status = VMA_AREA_AIORING;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue