[compiler-rt] [scudo] Add ConditionVariable in SizeClassAllocator64 (PR #69031)

Hans Boehm via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 13 16:43:23 PDT 2023


================
@@ -0,0 +1,52 @@
+//===-- condition_variable_linux.cpp ----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "platform.h"
+
+#if SCUDO_LINUX
+
+#include "condition_variable_linux.h"
+
+#include "atomic_helpers.h"
+
+#include <limits.h>
+#include <linux/futex.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+
+namespace scudo {
+
+void ConditionVariableLinux::notifyAllImpl(UNUSED HybridMutex &M) {
+  const u32 V = atomic_load_relaxed(&Counter) + 1;
----------------
hboehm wrote:

I withdraw my earlier comment about repeated WAKE calls. I had misread the code. I don't see any correctness issues.

To me, the code would be a bit clearer if the above line were (modulo style rules):

const u32 PrevCounter = atomic_load_relaxed(&Counter);

without the +1, but all uses of V below adjusted to make the code correct again. The test would just be LastNotifyAll != PrevCounter.

For consistency, I would do the same in waitImpl.

https://github.com/llvm/llvm-project/pull/69031


More information about the llvm-commits mailing list