From 84d839e4998bf3845a2e16ea482a3da3d1598346 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Mon, 1 May 2023 13:34:43 -0400 Subject: block: compile out assert_bdrv_graph_readable() by default reader_count() is a performance bottleneck because the global aio_context_list_lock mutex causes thread contention. Put this debugging assertion behind a new ./configure --enable-debug-graph-lock option and disable it by default. The --enable-debug-graph-lock option is also enabled by the more general --enable-debug option. Signed-off-by: Stefan Hajnoczi Message-Id: <20230501173443.153062-1-stefanha@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf (cherry picked from commit 58a2e3f5c37be02dac3086b81bdda9414b931edf) Signed-off-by: Michael Tokarev (Mjt: pick this one up so the next patch which disables this applies cleanly) --- block/graph-lock.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'block') diff --git a/block/graph-lock.c b/block/graph-lock.c index 454c31e691..259a7a0bde 100644 --- a/block/graph-lock.c +++ b/block/graph-lock.c @@ -265,7 +265,10 @@ void bdrv_graph_rdunlock_main_loop(void) void assert_bdrv_graph_readable(void) { + /* reader_count() is slow due to aio_context_list_lock lock contention */ +#ifdef CONFIG_DEBUG_GRAPH_LOCK assert(qemu_in_main_thread() || reader_count()); +#endif } void assert_bdrv_graph_writable(void) -- cgit v1.2.3