Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/stefanha-gitlab/tags/block-pull…
Browse files Browse the repository at this point in the history
…-request' into staging

Pull request

This contains coroutine poll size scaling, virtiofsd rseq seccomp for new glibc
versions, and the QEMU C virtiofsd deprecation notice.

# gpg: Signature made Mon 14 Feb 2022 17:14:21 GMT
# gpg:                using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" [full]
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>" [full]
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* remotes/stefanha-gitlab/tags/block-pull-request:
  util: adjust coroutine pool size to virtio block queue
  Deprecate C virtiofsd
  tools/virtiofsd: Add rseq syscall to the seccomp allowlist

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Feb 15, 2022
2 parents cc6721e + 4c41c69 commit ad38520
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 4 deletions.
17 changes: 17 additions & 0 deletions docs/about/deprecated.rst
Expand Up @@ -447,3 +447,20 @@ nanoMIPS ISA

The ``nanoMIPS`` ISA has never been upstreamed to any compiler toolchain.
As it is hard to generate binaries for it, declare it deprecated.

Tools
-----

virtiofsd
'''''''''

There is a new Rust implementation of ``virtiofsd`` at
``https://gitlab.com/virtio-fs/virtiofsd``;
since this is now marked stable, new development should be done on that
rather than the existing C version in the QEMU tree.
The C version will still accept fixes and patches that
are already in development for the moment, but will eventually
be deleted from this tree.
New deployments should use the Rust version, and existing systems
should consider moving to it. The command line and feature set
is very close and moving should be simple.
5 changes: 5 additions & 0 deletions hw/block/virtio-blk.c
Expand Up @@ -32,6 +32,7 @@
#include "hw/virtio/virtio-bus.h"
#include "migration/qemu-file-types.h"
#include "hw/virtio/virtio-access.h"
#include "qemu/coroutine.h"

/* Config size before the discard support (hide associated config fields) */
#define VIRTIO_BLK_CFG_SIZE offsetof(struct virtio_blk_config, \
Expand Down Expand Up @@ -1214,6 +1215,8 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
for (i = 0; i < conf->num_queues; i++) {
virtio_add_queue(vdev, conf->queue_size, virtio_blk_handle_output);
}
qemu_coroutine_increase_pool_batch_size(conf->num_queues * conf->queue_size
/ 2);
virtio_blk_data_plane_create(vdev, conf, &s->dataplane, &err);
if (err != NULL) {
error_propagate(errp, err);
Expand Down Expand Up @@ -1250,6 +1253,8 @@ static void virtio_blk_device_unrealize(DeviceState *dev)
for (i = 0; i < conf->num_queues; i++) {
virtio_del_queue(vdev, i);
}
qemu_coroutine_decrease_pool_batch_size(conf->num_queues * conf->queue_size
/ 2);
qemu_del_vm_change_state_handler(s->change);
blockdev_mark_auto_del(s->blk);
virtio_cleanup(vdev);
Expand Down
10 changes: 10 additions & 0 deletions include/qemu/coroutine.h
Expand Up @@ -331,6 +331,16 @@ void qemu_co_sleep_wake(QemuCoSleep *w);
*/
void coroutine_fn yield_until_fd_readable(int fd);

/**
* Increase coroutine pool size
*/
void qemu_coroutine_increase_pool_batch_size(unsigned int additional_pool_size);

/**
* Devcrease coroutine pool size
*/
void qemu_coroutine_decrease_pool_batch_size(unsigned int additional_pool_size);

#include "qemu/lockable.h"

#endif /* QEMU_COROUTINE_H */
3 changes: 3 additions & 0 deletions tools/virtiofsd/passthrough_seccomp.c
Expand Up @@ -91,6 +91,9 @@ static const int syscall_allowlist[] = {
SCMP_SYS(renameat2),
SCMP_SYS(removexattr),
SCMP_SYS(restart_syscall),
#ifdef __NR_rseq
SCMP_SYS(rseq), /* required since glibc 2.35 */
#endif
SCMP_SYS(rt_sigaction),
SCMP_SYS(rt_sigprocmask),
SCMP_SYS(rt_sigreturn),
Expand Down
20 changes: 16 additions & 4 deletions util/qemu-coroutine.c
Expand Up @@ -20,12 +20,14 @@
#include "qemu/coroutine_int.h"
#include "block/aio.h"

/** Initial batch size is 64, and is increased on demand */
enum {
POOL_BATCH_SIZE = 64,
POOL_INITIAL_BATCH_SIZE = 64,
};

/** Free list to speed up creation */
static QSLIST_HEAD(, Coroutine) release_pool = QSLIST_HEAD_INITIALIZER(pool);
static unsigned int pool_batch_size = POOL_INITIAL_BATCH_SIZE;
static unsigned int release_pool_size;
static __thread QSLIST_HEAD(, Coroutine) alloc_pool = QSLIST_HEAD_INITIALIZER(pool);
static __thread unsigned int alloc_pool_size;
Expand All @@ -49,7 +51,7 @@ Coroutine *qemu_coroutine_create(CoroutineEntry *entry, void *opaque)
if (CONFIG_COROUTINE_POOL) {
co = QSLIST_FIRST(&alloc_pool);
if (!co) {
if (release_pool_size > POOL_BATCH_SIZE) {
if (release_pool_size > qatomic_read(&pool_batch_size)) {
/* Slow path; a good place to register the destructor, too. */
if (!coroutine_pool_cleanup_notifier.notify) {
coroutine_pool_cleanup_notifier.notify = coroutine_pool_cleanup;
Expand Down Expand Up @@ -86,12 +88,12 @@ static void coroutine_delete(Coroutine *co)
co->caller = NULL;

if (CONFIG_COROUTINE_POOL) {
if (release_pool_size < POOL_BATCH_SIZE * 2) {
if (release_pool_size < qatomic_read(&pool_batch_size) * 2) {
QSLIST_INSERT_HEAD_ATOMIC(&release_pool, co, pool_next);
qatomic_inc(&release_pool_size);
return;
}
if (alloc_pool_size < POOL_BATCH_SIZE) {
if (alloc_pool_size < qatomic_read(&pool_batch_size)) {
QSLIST_INSERT_HEAD(&alloc_pool, co, pool_next);
alloc_pool_size++;
return;
Expand Down Expand Up @@ -202,3 +204,13 @@ AioContext *coroutine_fn qemu_coroutine_get_aio_context(Coroutine *co)
{
return co->ctx;
}

void qemu_coroutine_increase_pool_batch_size(unsigned int additional_pool_size)
{
qatomic_add(&pool_batch_size, additional_pool_size);
}

void qemu_coroutine_decrease_pool_batch_size(unsigned int removing_pool_size)
{
qatomic_sub(&pool_batch_size, removing_pool_size);
}

0 comments on commit ad38520

Please sign in to comment.