mirror of
https://github.com/xemu-project/xemu.git
synced 2024-12-12 14:05:56 +00:00
1793ad0247
The `aio-max-batch` parameter will be propagated to AIO engines and it will be used to control the maximum number of queued requests. When there are in queue a number of requests equal to `aio-max-batch`, the engine invokes the system call to forward the requests to the kernel. This parameter allows us to control the maximum batch size to reduce the latency that requests might accumulate while queued in the AIO engine queue. If `aio-max-batch` is equal to 0 (default value), the AIO engine will use its default maximum batch size value. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Message-id: 20210721094211.69853-3-sgarzare@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
70 lines
1.7 KiB
C
70 lines
1.7 KiB
C
/*
|
|
* Event loop thread
|
|
*
|
|
* Copyright Red Hat Inc., 2013
|
|
*
|
|
* Authors:
|
|
* Stefan Hajnoczi <stefanha@redhat.com>
|
|
*
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
* See the COPYING file in the top-level directory.
|
|
*
|
|
*/
|
|
|
|
#ifndef IOTHREAD_H
|
|
#define IOTHREAD_H
|
|
|
|
#include "block/aio.h"
|
|
#include "qemu/thread.h"
|
|
#include "qom/object.h"
|
|
|
|
#define TYPE_IOTHREAD "iothread"
|
|
|
|
struct IOThread {
|
|
Object parent_obj;
|
|
|
|
QemuThread thread;
|
|
AioContext *ctx;
|
|
bool run_gcontext; /* whether we should run gcontext */
|
|
GMainContext *worker_context;
|
|
GMainLoop *main_loop;
|
|
QemuSemaphore init_done_sem; /* is thread init done? */
|
|
bool stopping; /* has iothread_stop() been called? */
|
|
bool running; /* should iothread_run() continue? */
|
|
int thread_id;
|
|
|
|
/* AioContext poll parameters */
|
|
int64_t poll_max_ns;
|
|
int64_t poll_grow;
|
|
int64_t poll_shrink;
|
|
|
|
/* AioContext AIO engine parameters */
|
|
int64_t aio_max_batch;
|
|
};
|
|
typedef struct IOThread IOThread;
|
|
|
|
DECLARE_INSTANCE_CHECKER(IOThread, IOTHREAD,
|
|
TYPE_IOTHREAD)
|
|
|
|
char *iothread_get_id(IOThread *iothread);
|
|
IOThread *iothread_by_id(const char *id);
|
|
AioContext *iothread_get_aio_context(IOThread *iothread);
|
|
GMainContext *iothread_get_g_main_context(IOThread *iothread);
|
|
|
|
/*
|
|
* Helpers used to allocate iothreads for internal use. These
|
|
* iothreads will not be seen by monitor clients when query using
|
|
* "query-iothreads".
|
|
*/
|
|
IOThread *iothread_create(const char *id, Error **errp);
|
|
void iothread_stop(IOThread *iothread);
|
|
void iothread_destroy(IOThread *iothread);
|
|
|
|
/*
|
|
* Returns true if executing withing IOThread context,
|
|
* false otherwise.
|
|
*/
|
|
bool qemu_in_iothread(void);
|
|
|
|
#endif /* IOTHREAD_H */
|