util/oslib-posix: Support concurrent os_mem_prealloc() invocation
commita960d6642d39f7d255b7b2b8bda3c2ae4e4e649b
authorDavid Hildenbrand <david@redhat.com>
Fri, 17 Dec 2021 13:46:09 +0000 (17 14:46 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 7 Jan 2022 10:19:55 +0000 (7 05:19 -0500)
treee96bff148489aac1d0420f57311fabc5e22d6b02
parentac86e5c37df4963846d1a2e999696bb5031a99cd
util/oslib-posix: Support concurrent os_mem_prealloc() invocation

Add a mutex to protect the SIGBUS case, as we cannot mess concurrently
with the sigbus handler and we have to manage the global variable
sigbus_memset_context. The MADV_POPULATE_WRITE path can run
concurrently.

Note that page_mutex and page_cond are shared between concurrent
invocations, which shouldn't be a problem.

This is a preparation for future virtio-mem prealloc code, which will call
os_mem_prealloc() asynchronously from an iothread when handling guest
requests.

Reviewed-by: Pankaj Gupta <pankaj.gupta@ionos.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20211217134611.31172-7-david@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
util/oslib-posix.c