dm: add a new page for asyncio

asyncio is a new mechanism in ACRN, which is special for these devices
which need high IO performance. ACRN hypervisor would process the IO
request from User VM in an async mode.

Just like the original IOReq shared page, the devicemodel also create a
page for fastio requests. As the asyncio use the ioeventfd, so the
reuqests are handled in kernel, devicemodel only need to provide the
page.

Tracked-On: #8209
Signed-off-by: Conghui <conghui.chen@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
This commit is contained in:
Conghui
2022-08-17 09:16:52 +08:00
committed by acrnsi-robot
parent 17f94605f0
commit 0f599e8d56
4 changed files with 56 additions and 0 deletions

View File

@@ -116,6 +116,7 @@ static cpuset_t cpumask;
static void vm_loop(struct vmctx *ctx);
static char io_request_page[4096] __aligned(4096);
static char asyncio_page[4096] __aligned(4096);
static struct acrn_io_request *ioreq_buf =
(struct acrn_io_request *)&io_request_page;
@@ -835,6 +836,23 @@ static struct option long_options[] = {
static char optstr[] = "AhYvE:k:r:B:s:m:l:U:G:i:";
int
vm_init_asyncio(struct vmctx *ctx, uint64_t base)
{
struct shared_buf *sbuf = (struct shared_buf *)base;
sbuf->magic = SBUF_MAGIC;
sbuf->ele_size = sizeof(uint64_t);
sbuf->ele_num = (4096 - SBUF_HEAD_SIZE) / sbuf->ele_size;
sbuf->size = sbuf->ele_size * sbuf->ele_num;
/* set flag to 0 to make sure not overrun! */
sbuf->flags = 0;
sbuf->overrun_cnt = 0;
sbuf->head = 0;
sbuf->tail = 0;
return vm_setup_sbuf(ctx, ACRN_ASYNCIO, base);
}
int
main(int argc, char *argv[])
{
@@ -1093,6 +1111,12 @@ main(int argc, char *argv[])
goto fail;
}
pr_notice("vm setup asyncio page\n");
error = vm_init_asyncio(ctx, (uint64_t)asyncio_page);
if (error) {
pr_warn("ASYNIO capability is not supported by kernel or hyperviosr!\n");
}
pr_notice("vm_setup_memory: size=0x%lx\n", memsize);
error = vm_setup_memory(ctx, memsize);
if (error) {

View File

@@ -294,6 +294,25 @@ vm_destroy(struct vmctx *ctx)
devfd = -1;
}
int
vm_setup_sbuf(struct vmctx *ctx, uint32_t sbuf_id, uint64_t base)
{
int error;
struct acrn_sbuf sbuf_param;
bzero(&sbuf_param, sizeof(sbuf_param));
sbuf_param.sbuf_id = sbuf_id;
sbuf_param.base = base;
error = ioctl(ctx->fd, ACRN_IOCTL_SETUP_SBUF, &sbuf_param);
if (error) {
pr_err("ACRN_IOCTL_SBUF_PAGE ioctl() returned an error: %s\n", errormsg(errno));
}
return error;
}
int
vm_parse_memsize(const char *optarg, size_t *ret_memsize)
{