ENUM MEMBARRIER_CMD(9)
π enum membarrier_cmd(9) π
okay so this is a page from the Kernel API Manual and it's literally the enum behind the membarrier system call. think of it as the menu of barrier commands you can pass in β each one a different flavor of "hey bestie, please make sure everyone's memory is, like, in order." π§ β¨
πΈ NAME πΈ
enum membarrier_cmd β the command set for the membarrier system call, iykyk π«Ά
β¨ SYNOPSIS β¨
the whole roster, in order, no cap:
enum membarrier_cmd {
MEMBARRIER_CMD_QUERY ,
MEMBARRIER_CMD_GLOBAL ,
MEMBARRIER_CMD_GLOBAL_EXPEDITED ,
MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED ,
MEMBARRIER_CMD_PRIVATE_EXPEDITED ,
MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED ,
MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE ,
MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE ,
MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ ,
MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ ,
MEMBARRIER_CMD_GET_REGISTRATIONS ,
MEMBARRIER_CMD_SHARED
};
π Constants π
MEMBARRIER_CMD_QUERYβ the vibe check π . asks "which commands does this kernel actually support?" and hands you back a bitmask of the valid ones.MEMBARRIER_CMD_GLOBALβ slaps a memory barrier on all running threads. when the syscall returns, the calling thread is guaranteed that every running thread has passed through a state where all memory accesses to user-space addresses match program order between entry to and return from the syscall. as for non-running threads? they're de facto in such a state already, so like, don't worry about them π¦. this covers threads from all processes running on the system. returns0.MEMBARRIER_CMD_GLOBAL_EXPEDITEDβ same barrier energy, but only for all running threads of processes that previously registered withMEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED. when the syscall returns, the calling thread is ensured that all running threads have passed through a state where all memory accesses to user-space addresses match program order between entry to and return from the syscall, and again, non-running threads are de facto in such a state. it only covers threads from processes registered viaMEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED. returns0. and bestie, since registering is about intent to receive the barriers, it is totally valid to invokeMEMBARRIER_CMD_GLOBAL_EXPEDITEDfrom a process that never registered πMEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITEDβ tells the kernel "yes, this process wants to receiveMEMBARRIER_CMD_GLOBAL_EXPEDITEDbarriers". always returns0. no drama πΈMEMBARRIER_CMD_PRIVATE_EXPEDITEDβ runs a memory barrier on every running thread in the same process as the current thread. when the syscall returns, the caller thread is ensured that all its running thread siblings have passed through a state where all memory accesses to user-space addresses match program order between entry to and return from the syscall (non-running threads are de facto in such a state). this only covers threads from the same process as the caller. returns0on success. the "expedited" commands finish faster than the non-expedited ones and they never block, but the tradeoff is extra overhead π. a process has to register its intent to use the private expedited command before using it, otherwise this one returns-EPERM.MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITEDβ registers the process intent to useMEMBARRIER_CMD_PRIVATE_EXPEDITED. always returns0π«ΆMEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_COREβ on top of the memory-ordering guarantees described inMEMBARRIER_CMD_PRIVATE_EXPEDITED, this one ensures the caller thread, upon return from the syscall, that all its running thread siblings have executed a core serializing instruction. (architectures are required to guarantee that non-running threads issue core serializing instructions before they resume user-space execution.) this only covers threads from the same process as the caller thread. returns0on success. expedited commands complete faster than non-expedited ones, never block, but cause extra overhead. if an architecture doesn't implement this command, you get-EINVAL. and a process needs to register its intent to use the private expedited sync core command before using it, otherwise this returns-EPERMπMEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_COREβ registers the process intent to useMEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE. if an architecture doesn't implement this command, it returns-EINVAL. returns0on success β¨MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQβ ensures the caller thread, upon return from the syscall, that all its running thread siblings have any currently running rseq critical sections restarted if the flags parameter is0. if the flags parameter isMEMBARRIER_CMD_FLAG_CPU, then the operation is performed only on the CPU indicated by cpu_id. if an architecture doesn't implement this command, it returns-EINVAL. a process needs to register its intent to use the private expedited rseq command before using it, otherwise this returns-EPERMπ₯MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQβ registers the process intent to useMEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ. if an architecture doesn't implement this command, it returns-EINVAL. returns0on success πMEMBARRIER_CMD_GET_REGISTRATIONSβ returns a bitmask of the registration commands that were previously issued. a little receipt for your registrations π§ΎπMEMBARRIER_CMD_SHAREDβ just an alias toMEMBARRIER_CMD_GLOBAL. it's provided for header backward compatibility, so it's giving legacy-icon behavior π
π¬ Description π¬
okay so this is the command you actually pass into the membarrier system call. here's the crucial detail, bestie: the commands need to be a single bit each β one bit per command, no sharing β except for MEMBARRIER_CMD_QUERY, which is assigned to the value 0. that one's special like that π
π SEE ALSO π
- Kernel file
./include/uapi/linux/membarrier.h
kisses and bye π this page came from ./include/uapi/linux, dated October 2026, and it's enum membarrier_cmd(9) β go forth and barrier responsibly, bestie π§π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms