Skip to content

Commit ad38520

Browse files
committed
Merge remote-tracking branch 'remotes/stefanha-gitlab/tags/block-pull-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 <[email protected]>" [full] # gpg: aka "Stefan Hajnoczi <[email protected]>" [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 <[email protected]>
2 parents cc6721e + 4c41c69 commit ad38520

File tree

5 files changed

+51
-4
lines changed

5 files changed

+51
-4
lines changed

docs/about/deprecated.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,3 +447,20 @@ nanoMIPS ISA
447447

448448
The ``nanoMIPS`` ISA has never been upstreamed to any compiler toolchain.
449449
As it is hard to generate binaries for it, declare it deprecated.
450+
451+
Tools
452+
-----
453+
454+
virtiofsd
455+
'''''''''
456+
457+
There is a new Rust implementation of ``virtiofsd`` at
458+
``https://gitlab.com/virtio-fs/virtiofsd``;
459+
since this is now marked stable, new development should be done on that
460+
rather than the existing C version in the QEMU tree.
461+
The C version will still accept fixes and patches that
462+
are already in development for the moment, but will eventually
463+
be deleted from this tree.
464+
New deployments should use the Rust version, and existing systems
465+
should consider moving to it. The command line and feature set
466+
is very close and moving should be simple.

hw/block/virtio-blk.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "hw/virtio/virtio-bus.h"
3333
#include "migration/qemu-file-types.h"
3434
#include "hw/virtio/virtio-access.h"
35+
#include "qemu/coroutine.h"
3536

3637
/* Config size before the discard support (hide associated config fields) */
3738
#define VIRTIO_BLK_CFG_SIZE offsetof(struct virtio_blk_config, \
@@ -1214,6 +1215,8 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
12141215
for (i = 0; i < conf->num_queues; i++) {
12151216
virtio_add_queue(vdev, conf->queue_size, virtio_blk_handle_output);
12161217
}
1218+
qemu_coroutine_increase_pool_batch_size(conf->num_queues * conf->queue_size
1219+
/ 2);
12171220
virtio_blk_data_plane_create(vdev, conf, &s->dataplane, &err);
12181221
if (err != NULL) {
12191222
error_propagate(errp, err);
@@ -1250,6 +1253,8 @@ static void virtio_blk_device_unrealize(DeviceState *dev)
12501253
for (i = 0; i < conf->num_queues; i++) {
12511254
virtio_del_queue(vdev, i);
12521255
}
1256+
qemu_coroutine_decrease_pool_batch_size(conf->num_queues * conf->queue_size
1257+
/ 2);
12531258
qemu_del_vm_change_state_handler(s->change);
12541259
blockdev_mark_auto_del(s->blk);
12551260
virtio_cleanup(vdev);

include/qemu/coroutine.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,16 @@ void qemu_co_sleep_wake(QemuCoSleep *w);
331331
*/
332332
void coroutine_fn yield_until_fd_readable(int fd);
333333

334+
/**
335+
* Increase coroutine pool size
336+
*/
337+
void qemu_coroutine_increase_pool_batch_size(unsigned int additional_pool_size);
338+
339+
/**
340+
* Devcrease coroutine pool size
341+
*/
342+
void qemu_coroutine_decrease_pool_batch_size(unsigned int additional_pool_size);
343+
334344
#include "qemu/lockable.h"
335345

336346
#endif /* QEMU_COROUTINE_H */

tools/virtiofsd/passthrough_seccomp.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ static const int syscall_allowlist[] = {
9191
SCMP_SYS(renameat2),
9292
SCMP_SYS(removexattr),
9393
SCMP_SYS(restart_syscall),
94+
#ifdef __NR_rseq
95+
SCMP_SYS(rseq), /* required since glibc 2.35 */
96+
#endif
9497
SCMP_SYS(rt_sigaction),
9598
SCMP_SYS(rt_sigprocmask),
9699
SCMP_SYS(rt_sigreturn),

util/qemu-coroutine.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
#include "qemu/coroutine_int.h"
2121
#include "block/aio.h"
2222

23+
/** Initial batch size is 64, and is increased on demand */
2324
enum {
24-
POOL_BATCH_SIZE = 64,
25+
POOL_INITIAL_BATCH_SIZE = 64,
2526
};
2627

2728
/** Free list to speed up creation */
2829
static QSLIST_HEAD(, Coroutine) release_pool = QSLIST_HEAD_INITIALIZER(pool);
30+
static unsigned int pool_batch_size = POOL_INITIAL_BATCH_SIZE;
2931
static unsigned int release_pool_size;
3032
static __thread QSLIST_HEAD(, Coroutine) alloc_pool = QSLIST_HEAD_INITIALIZER(pool);
3133
static __thread unsigned int alloc_pool_size;
@@ -49,7 +51,7 @@ Coroutine *qemu_coroutine_create(CoroutineEntry *entry, void *opaque)
4951
if (CONFIG_COROUTINE_POOL) {
5052
co = QSLIST_FIRST(&alloc_pool);
5153
if (!co) {
52-
if (release_pool_size > POOL_BATCH_SIZE) {
54+
if (release_pool_size > qatomic_read(&pool_batch_size)) {
5355
/* Slow path; a good place to register the destructor, too. */
5456
if (!coroutine_pool_cleanup_notifier.notify) {
5557
coroutine_pool_cleanup_notifier.notify = coroutine_pool_cleanup;
@@ -86,12 +88,12 @@ static void coroutine_delete(Coroutine *co)
8688
co->caller = NULL;
8789

8890
if (CONFIG_COROUTINE_POOL) {
89-
if (release_pool_size < POOL_BATCH_SIZE * 2) {
91+
if (release_pool_size < qatomic_read(&pool_batch_size) * 2) {
9092
QSLIST_INSERT_HEAD_ATOMIC(&release_pool, co, pool_next);
9193
qatomic_inc(&release_pool_size);
9294
return;
9395
}
94-
if (alloc_pool_size < POOL_BATCH_SIZE) {
96+
if (alloc_pool_size < qatomic_read(&pool_batch_size)) {
9597
QSLIST_INSERT_HEAD(&alloc_pool, co, pool_next);
9698
alloc_pool_size++;
9799
return;
@@ -202,3 +204,13 @@ AioContext *coroutine_fn qemu_coroutine_get_aio_context(Coroutine *co)
202204
{
203205
return co->ctx;
204206
}
207+
208+
void qemu_coroutine_increase_pool_batch_size(unsigned int additional_pool_size)
209+
{
210+
qatomic_add(&pool_batch_size, additional_pool_size);
211+
}
212+
213+
void qemu_coroutine_decrease_pool_batch_size(unsigned int removing_pool_size)
214+
{
215+
qatomic_sub(&pool_batch_size, removing_pool_size);
216+
}

0 commit comments

Comments
 (0)