[libc-commits] [libc] a6fda58 - [libc] Fix ordering to make sure event_id is written before interrupt (#190705)

via libc-commits libc-commits at lists.llvm.org
Tue Apr 7 04:52:57 PDT 2026


Author: Joseph Huber
Date: 2026-04-07T06:52:52-05:00
New Revision: a6fda587390b6d3bbf00df22a22881561727e9f9

URL: https://github.com/llvm/llvm-project/commit/a6fda587390b6d3bbf00df22a22881561727e9f9
DIFF: https://github.com/llvm/llvm-project/commit/a6fda587390b6d3bbf00df22a22881561727e9f9.diff

LOG: [libc] Fix ordering to make sure event_id is written before interrupt (#190705)

Summary:
Right now this meant we could avoid flushing the event_id write before
firing the interrupt, so it could be unset.

Added: 
    

Modified: 
    libc/shared/rpc.h

Removed: 
    


################################################################################
diff  --git a/libc/shared/rpc.h b/libc/shared/rpc.h
index a27b0676e5957..c4a415f8548e7 100644
--- a/libc/shared/rpc.h
+++ b/libc/shared/rpc.h
@@ -161,10 +161,10 @@ template <bool Invert> struct Process {
     if (rpc::is_first_lane(lane_mask)) {
       if (!__scoped_atomic_fetch_add(doorbell->value, 1UL, __ATOMIC_RELAXED,
                                      __MEMORY_SCOPE_SYSTEM)) {
-        __scoped_atomic_thread_fence(__ATOMIC_RELEASE, __MEMORY_SCOPE_SYSTEM);
         __scoped_atomic_store_n(doorbell->mailbox,
                                 static_cast<uint64_t>(doorbell->event_id),
                                 __ATOMIC_RELAXED, __MEMORY_SCOPE_SYSTEM);
+        __scoped_atomic_thread_fence(__ATOMIC_RELEASE, __MEMORY_SCOPE_SYSTEM);
         signal_interrupt(event_id);
       }
     }


        


More information about the libc-commits mailing list