From 9ca440ac5c1c2bee3fe5eb3ae7549fee2e043c39 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Fri, 6 Sep 2024 16:58:29 +0100 Subject: [PATCH] eio_linux: avoid triggering a TSan warning TSan warns that setting `statx_works` races with users of it. This isn't really a problem, because we always set it to the same value, but it's distracting when looking for other bugs. Reported by Anil Madhavapeddy in #751. --- lib_eio_linux/sched.ml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_eio_linux/sched.ml b/lib_eio_linux/sched.ml index 80fc63f4..ad819245 100644 --- a/lib_eio_linux/sched.ml +++ b/lib_eio_linux/sched.ml @@ -521,7 +521,10 @@ let with_sched ?(fallback=no_fallback) config fn = Uring.exit uring; fallback (`Msg "Linux >= 5.15 is required for io_uring support") ) else ( - statx_works := Uring.op_supported probe Uring.Op.msg_ring; + (* The reason for an if here is to make sure we only set it once, when + the first domain is starting. This is just to avoid a tsan warning. *) + if not !statx_works && Uring.op_supported probe Uring.Op.msg_ring then + statx_works := true; match let mem = let fixed_buf_len = block_size * n_blocks in