Date
1 - 3 of 3
[PATCH v5 6/7] 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 | 25 +++++++++++++++++++++ devicemodel/core/vmmapi.c | 19 ++++++++++++++++ devicemodel/include/public/hsm_ioctl_defs.h | 12 ++++++++++ devicemodel/include/vmmapi.h | 1 + 4 files changed, 57 insertions(+) diff --git a/devicemodel/core/main.c b/devicemodel/core/main.c index f2acb0b15..9a77ae853 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; @@ -835,6 +836,23 @@ static struct option long_options[] = { static char optstr[] = "AhYvE:k:r:B:s:m:l:U:G:i:"; +int +setup_asyncio_page(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,13 @@ main(int argc, char *argv[]) goto fail; } + pr_notice("vm setup asyncio page\n"); + error = setup_asyncio_page(ctx, (uint64_t)asyncio_page); + if (error) { + pr_err("failed to setup asyncio page!\n"); + goto fail; + } + 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..43583eafc 100644 --- a/devicemodel/core/vmmapi.c +++ b/devicemodel/core/vmmapi.c @@ -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) { diff --git a/devicemodel/include/public/hsm_ioctl_defs.h b/devicemodel/include/public/hsm_ioctl_defs.h index b68a1e5c5..56b3b7ed7 100644 --- a/devicemodel/include/public/hsm_ioctl_defs.h +++ b/devicemodel/include/public/hsm_ioctl_defs.h @@ -107,6 +107,8 @@ _IOW(ACRN_IOCTL_TYPE, 0x41, struct acrn_vm_memmap) #define ACRN_IOCTL_UNSET_MEMSEG \ _IOW(ACRN_IOCTL_TYPE, 0x42, struct acrn_vm_memmap) +#define ACRN_IOCTL_SETUP_SBUF \ + _IOW(ACRN_IOCTL_TYPE, 0x43, struct acrn_sbuf) /* PCI assignment*/ #define ACRN_IOCTL_SET_PTDEV_INTR \ @@ -246,4 +248,14 @@ struct acrn_irqfd { /** MSI interrupt to be injected */ struct acrn_msi_entry msi; }; + +/** + * struct acrn_sbuf - Data to register a share buffer by ioctl + * @sbuf_id: Type of the sbuf. + * @base: Base address of the sbuf. + */ +struct acrn_sbuf { + uint32_t sbuf_id; + uint64_t base; +}; #endif /* VHM_IOCTL_DEFS_H */ diff --git a/devicemodel/include/vmmapi.h b/devicemodel/include/vmmapi.h index dd848dee9..e9766e5f9 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_sbuf(struct vmctx *ctx, uint32_t sbuf_type, 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 |
|
Yu Wang
On Wed, Sep 21, 2022 at 02:42:32PM +0800, Conghui Chen wrote:
asyncio is a new mechanism in ACRN, which is special for these devicesvm_init_asyncio others are LGTM. Acked-by: Wang, Yu1 <yu1.wang@...> +{ |
|
Conghui Chen
Hi Yu,
toggle quoted message
Show quoted text
-----Original Message-----Will change the name, thanks. Regards, Conghui. |
|