Pull request
- Add new thread-pool-min/thread-pool-max parameters to control the thread pool used for async I/O. - Fix virtio-scsi IOThread 100% CPU consumption QEMU 7.0 regression. -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAmJ5DqgACgkQnKSrs4Gr c8iAqAf/WEJzEso0Hu3UUYJi2lAXpLxWPjoNBlPdQlKIJ/I0zQIF0P7GeCifF+0l iMjgBv0ofyAuV47gaTJlVrAR75+hJ/IXNDhnu3UuvNWfVOqvksgw6kuHkMo9A2hC 4tIHEU9J8jbQSSdQTaZR8Zj4FX1/zcxMBAXT3YO3De6zo78RatBTuNP4dsZzt8bI Qs1a4A0p2ScNXK8EcF4QwAWfoxu9OPPzN52DBCNxcIcnn0SUab4NbDxzpRV4ZhDP 08WoafI5O+2Kb36QysJN01LqajHrClG/fozrPzBLq5aZUK3xewJGB1hEdGTLkkmz NJNBg5Ldszwj4PDZ1dFU3/03aigb3g== =t5eR -----END PGP SIGNATURE----- Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging Pull request - Add new thread-pool-min/thread-pool-max parameters to control the thread pool used for async I/O. - Fix virtio-scsi IOThread 100% CPU consumption QEMU 7.0 regression. # -----BEGIN PGP SIGNATURE----- # # iQEzBAABCAAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAmJ5DqgACgkQnKSrs4Gr # c8iAqAf/WEJzEso0Hu3UUYJi2lAXpLxWPjoNBlPdQlKIJ/I0zQIF0P7GeCifF+0l # iMjgBv0ofyAuV47gaTJlVrAR75+hJ/IXNDhnu3UuvNWfVOqvksgw6kuHkMo9A2hC # 4tIHEU9J8jbQSSdQTaZR8Zj4FX1/zcxMBAXT3YO3De6zo78RatBTuNP4dsZzt8bI # Qs1a4A0p2ScNXK8EcF4QwAWfoxu9OPPzN52DBCNxcIcnn0SUab4NbDxzpRV4ZhDP # 08WoafI5O+2Kb36QysJN01LqajHrClG/fozrPzBLq5aZUK3xewJGB1hEdGTLkkmz # NJNBg5Ldszwj4PDZ1dFU3/03aigb3g== # =t5eR # -----END PGP SIGNATURE----- # gpg: Signature made Mon 09 May 2022 05:52:56 AM PDT # gpg: using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" [full] # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" [full] * tag 'block-pull-request' of https://gitlab.com/stefanha/qemu: virtio-scsi: move request-related items from .h to .c virtio-scsi: clean up virtio_scsi_handle_cmd_vq() virtio-scsi: clean up virtio_scsi_handle_ctrl_vq() virtio-scsi: clean up virtio_scsi_handle_event_vq() virtio-scsi: don't waste CPU polling the event virtqueue virtio-scsi: fix ctrl and event handler functions in dataplane mode util/event-loop-base: Introduce options to set the thread pool size util/main-loop: Introduce the main loop into QOM Introduce event-loop-base abstract class Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
commit
178bacb66d
18 changed files with 505 additions and 143 deletions
|
|
@ -192,6 +192,8 @@ struct AioContext {
|
|||
QSLIST_HEAD(, Coroutine) scheduled_coroutines;
|
||||
QEMUBH *co_schedule_bh;
|
||||
|
||||
int thread_pool_min;
|
||||
int thread_pool_max;
|
||||
/* Thread pool for performing work and receiving completion callbacks.
|
||||
* Has its own locking.
|
||||
*/
|
||||
|
|
@ -769,4 +771,12 @@ void aio_context_set_poll_params(AioContext *ctx, int64_t max_ns,
|
|||
void aio_context_set_aio_params(AioContext *ctx, int64_t max_batch,
|
||||
Error **errp);
|
||||
|
||||
/**
|
||||
* aio_context_set_thread_pool_params:
|
||||
* @ctx: the aio context
|
||||
* @min: min number of threads to have readily available in the thread pool
|
||||
* @min: max number of threads the thread pool can contain
|
||||
*/
|
||||
void aio_context_set_thread_pool_params(AioContext *ctx, int64_t min,
|
||||
int64_t max, Error **errp);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "block/block.h"
|
||||
|
||||
#define THREAD_POOL_MAX_THREADS_DEFAULT 64
|
||||
|
||||
typedef int ThreadPoolFunc(void *opaque);
|
||||
|
||||
typedef struct ThreadPool ThreadPool;
|
||||
|
|
@ -33,5 +35,6 @@ BlockAIOCB *thread_pool_submit_aio(ThreadPool *pool,
|
|||
int coroutine_fn thread_pool_submit_co(ThreadPool *pool,
|
||||
ThreadPoolFunc *func, void *arg);
|
||||
void thread_pool_submit(ThreadPool *pool, ThreadPoolFunc *func, void *arg);
|
||||
void thread_pool_update_params(ThreadPool *pool, struct AioContext *ctx);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -92,42 +92,6 @@ struct VirtIOSCSI {
|
|||
uint32_t host_features;
|
||||
};
|
||||
|
||||
typedef struct VirtIOSCSIReq {
|
||||
/* Note:
|
||||
* - fields up to resp_iov are initialized by virtio_scsi_init_req;
|
||||
* - fields starting at vring are zeroed by virtio_scsi_init_req.
|
||||
* */
|
||||
VirtQueueElement elem;
|
||||
|
||||
VirtIOSCSI *dev;
|
||||
VirtQueue *vq;
|
||||
QEMUSGList qsgl;
|
||||
QEMUIOVector resp_iov;
|
||||
|
||||
union {
|
||||
/* Used for two-stage request submission */
|
||||
QTAILQ_ENTRY(VirtIOSCSIReq) next;
|
||||
|
||||
/* Used for cancellation of request during TMFs */
|
||||
int remaining;
|
||||
};
|
||||
|
||||
SCSIRequest *sreq;
|
||||
size_t resp_size;
|
||||
enum SCSIXferMode mode;
|
||||
union {
|
||||
VirtIOSCSICmdResp cmd;
|
||||
VirtIOSCSICtrlTMFResp tmf;
|
||||
VirtIOSCSICtrlANResp an;
|
||||
VirtIOSCSIEvent event;
|
||||
} resp;
|
||||
union {
|
||||
VirtIOSCSICmdReq cmd;
|
||||
VirtIOSCSICtrlTMFReq tmf;
|
||||
VirtIOSCSICtrlANReq an;
|
||||
} req;
|
||||
} VirtIOSCSIReq;
|
||||
|
||||
static inline void virtio_scsi_acquire(VirtIOSCSI *s)
|
||||
{
|
||||
if (s->ctx) {
|
||||
|
|
@ -149,13 +113,6 @@ void virtio_scsi_common_realize(DeviceState *dev,
|
|||
Error **errp);
|
||||
|
||||
void virtio_scsi_common_unrealize(DeviceState *dev);
|
||||
bool virtio_scsi_handle_event_vq(VirtIOSCSI *s, VirtQueue *vq);
|
||||
bool virtio_scsi_handle_cmd_vq(VirtIOSCSI *s, VirtQueue *vq);
|
||||
bool virtio_scsi_handle_ctrl_vq(VirtIOSCSI *s, VirtQueue *vq);
|
||||
void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req);
|
||||
void virtio_scsi_free_req(VirtIOSCSIReq *req);
|
||||
void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
|
||||
uint32_t event, uint32_t reason);
|
||||
|
||||
void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error **errp);
|
||||
int virtio_scsi_dataplane_start(VirtIODevice *s);
|
||||
|
|
|
|||
|
|
@ -317,6 +317,7 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq);
|
|||
void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled);
|
||||
void virtio_queue_host_notifier_read(EventNotifier *n);
|
||||
void virtio_queue_aio_attach_host_notifier(VirtQueue *vq, AioContext *ctx);
|
||||
void virtio_queue_aio_attach_host_notifier_no_poll(VirtQueue *vq, AioContext *ctx);
|
||||
void virtio_queue_aio_detach_host_notifier(VirtQueue *vq, AioContext *ctx);
|
||||
VirtQueue *virtio_vector_first_queue(VirtIODevice *vdev, uint16_t vector);
|
||||
VirtQueue *virtio_vector_next_queue(VirtQueue *vq);
|
||||
|
|
|
|||
|
|
@ -26,9 +26,19 @@
|
|||
#define QEMU_MAIN_LOOP_H
|
||||
|
||||
#include "block/aio.h"
|
||||
#include "qom/object.h"
|
||||
#include "sysemu/event-loop-base.h"
|
||||
|
||||
#define SIG_IPI SIGUSR1
|
||||
|
||||
#define TYPE_MAIN_LOOP "main-loop"
|
||||
OBJECT_DECLARE_TYPE(MainLoop, MainLoopClass, MAIN_LOOP)
|
||||
|
||||
struct MainLoop {
|
||||
EventLoopBase parent_obj;
|
||||
};
|
||||
typedef struct MainLoop MainLoop;
|
||||
|
||||
/**
|
||||
* qemu_init_main_loop: Set up the process so that it can run the main loop.
|
||||
*
|
||||
|
|
|
|||
41
include/sysemu/event-loop-base.h
Normal file
41
include/sysemu/event-loop-base.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* QEMU event-loop backend
|
||||
*
|
||||
* Copyright (C) 2022 Red Hat Inc
|
||||
*
|
||||
* Authors:
|
||||
* Nicolas Saenz Julienne <nsaenzju@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 QEMU_EVENT_LOOP_BASE_H
|
||||
#define QEMU_EVENT_LOOP_BASE_H
|
||||
|
||||
#include "qom/object.h"
|
||||
#include "block/aio.h"
|
||||
#include "qemu/typedefs.h"
|
||||
|
||||
#define TYPE_EVENT_LOOP_BASE "event-loop-base"
|
||||
OBJECT_DECLARE_TYPE(EventLoopBase, EventLoopBaseClass,
|
||||
EVENT_LOOP_BASE)
|
||||
|
||||
struct EventLoopBaseClass {
|
||||
ObjectClass parent_class;
|
||||
|
||||
void (*init)(EventLoopBase *base, Error **errp);
|
||||
void (*update_params)(EventLoopBase *base, Error **errp);
|
||||
bool (*can_be_deleted)(EventLoopBase *base);
|
||||
};
|
||||
|
||||
struct EventLoopBase {
|
||||
Object parent;
|
||||
|
||||
/* AioContext AIO engine parameters */
|
||||
int64_t aio_max_batch;
|
||||
|
||||
/* AioContext thread pool parameters */
|
||||
int64_t thread_pool_min;
|
||||
int64_t thread_pool_max;
|
||||
};
|
||||
#endif
|
||||
|
|
@ -17,11 +17,12 @@
|
|||
#include "block/aio.h"
|
||||
#include "qemu/thread.h"
|
||||
#include "qom/object.h"
|
||||
#include "sysemu/event-loop-base.h"
|
||||
|
||||
#define TYPE_IOTHREAD "iothread"
|
||||
|
||||
struct IOThread {
|
||||
Object parent_obj;
|
||||
EventLoopBase parent_obj;
|
||||
|
||||
QemuThread thread;
|
||||
AioContext *ctx;
|
||||
|
|
@ -37,9 +38,6 @@ struct IOThread {
|
|||
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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue