[PATCH v3 1/2] dm: add a new page for asyncio


Conghui Chen
 

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.

Signed-off-by: Conghui <conghui.chen@...>
---
devicemodel/core/main.c | 11 +++++++++++
devicemodel/core/vmmapi.c | 14 ++++++++++++++
devicemodel/include/public/hsm_ioctl_defs.h | 2 ++
devicemodel/include/vmmapi.h | 1 +
4 files changed, 28 insertions(+)

diff --git a/devicemodel/core/main.c b/devicemodel/core/main.c
index f2acb0b15..1de1ee98e 100644
--- a/devicemodel/core/main.c
+++ b/devicemodel/core/main.c
@@ -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;
@@ -1093,6 +1094,16 @@ main(int argc, char *argv[])
goto fail;
}

+ pr_notice("vm setup asyncio page\n");
+ error = vm_setup_asyncio_page(ctx, (uint64_t)asyncio_page);
+ if (error) {
+ pr_err("failed to setup asyncio page!\n");
+ ctx->asyncio_enabled = false;
+ goto fail;
+ } else {
+ ctx->asyncio_enabled = true;
+ }
+
pr_notice("vm_setup_memory: size=0x%lx\n", memsize);
error = vm_setup_memory(ctx, memsize);
if (error) {
diff --git a/devicemodel/core/vmmapi.c b/devicemodel/core/vmmapi.c
index 336aee01f..569ece32e 100644
--- a/devicemodel/core/vmmapi.c
+++ b/devicemodel/core/vmmapi.c
@@ -294,6 +294,20 @@ vm_destroy(struct vmctx *ctx)
devfd = -1;
}

+int
+vm_setup_asyncio_page(struct vmctx *ctx, uint64_t base)
+{
+ int error;
+
+ error = ioctl(ctx->fd, ACRN_IOCTL_SETUP_ASYNCIO_PAGE, &base);
+
+ if (error) {
+ pr_err("ACRN_IOCTL_FASTIO_PAGE ioctl() returned an error: %s\n", errormsg(errno));
+ }
+
+ return error;
+}
+
int
vm_parse_memsize(const char *optarg, size_t *ret_memsize)
{
diff --git a/devicemodel/include/public/hsm_ioctl_defs.h b/devicemodel/include/public/hsm_ioctl_defs.h
index b68a1e5c5..6741f039a 100644
--- a/devicemodel/include/public/hsm_ioctl_defs.h
+++ b/devicemodel/include/public/hsm_ioctl_defs.h
@@ -135,6 +135,8 @@
_IOW(ACRN_IOCTL_TYPE, 0x70, struct acrn_ioeventfd)
#define ACRN_IOCTL_IRQFD \
_IOW(ACRN_IOCTL_TYPE, 0x71, struct acrn_irqfd)
+#define ACRN_IOCTL_SETUP_ASYNCIO_PAGE \
+ _IOW(ACRN_IOCTL_TYPE, 0x72, __u64)


#define ACRN_MEM_ACCESS_RIGHT_MASK 0x00000007U
diff --git a/devicemodel/include/vmmapi.h b/devicemodel/include/vmmapi.h
index dd848dee9..46ae49388 100644
--- a/devicemodel/include/vmmapi.h
+++ b/devicemodel/include/vmmapi.h
@@ -107,6 +107,7 @@ int vm_create_ioreq_client(struct vmctx *ctx);
int vm_destroy_ioreq_client(struct vmctx *ctx);
int vm_attach_ioreq_client(struct vmctx *ctx);
int vm_notify_request_done(struct vmctx *ctx, int vcpu);
+int vm_setup_asyncio_page(struct vmctx *ctx, uint64_t base);
void vm_clear_ioreq(struct vmctx *ctx);
const char *vm_state_to_str(enum vm_suspend_how idx);
void vm_set_suspend_mode(enum vm_suspend_how how);
--
2.25.1