Skip to content

Commit

Permalink
coroutine: reserve 5,000 mappings
Browse files Browse the repository at this point in the history
Daniel P. Berrangé <berrange@redhat.com> pointed out that the coroutine
pool size heuristic is very conservative. Instead of halving
max_map_count, he suggested reserving 5,000 mappings for non-coroutine
users based on observations of guests he has access to.

Fixes: 86a637e ("coroutine: cap per-thread local pool size")
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-id: 20240320181232.1464819-1-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
stefanhaRH committed Mar 21, 2024
1 parent fea445e commit 9352f80
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions util/qemu-coroutine.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,17 @@ static unsigned int get_global_pool_hard_max_size(void)
NULL) &&
qemu_strtoi(contents, NULL, 10, &max_map_count) == 0) {
/*
* This is a conservative upper bound that avoids exceeding
* max_map_count. Leave half for non-coroutine users like library
* dependencies, vhost-user, etc. Each coroutine takes up 2 VMAs so
* halve the amount again.
* This is an upper bound that avoids exceeding max_map_count. Leave a
* fixed amount for non-coroutine users like library dependencies,
* vhost-user, etc. Each coroutine takes up 2 VMAs so halve the
* remaining amount.
*/
return max_map_count / 4;
if (max_map_count > 5000) {
return (max_map_count - 5000) / 2;
} else {
/* Disable the global pool but threads still have local pools */
return 0;
}
}
#endif

Expand Down

0 comments on commit 9352f80

Please sign in to comment.