ENUM MEMBARRIER_CMD(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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. returns 0.
  • MEMBARRIER_CMD_GLOBAL_EXPEDITED β€” same barrier energy, but only for all running threads of processes that previously registered with MEMBARRIER_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 via MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED. returns 0. and bestie, since registering is about intent to receive the barriers, it is totally valid to invoke MEMBARRIER_CMD_GLOBAL_EXPEDITED from a process that never registered πŸ‘‘
  • MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED β€” tells the kernel "yes, this process wants to receive MEMBARRIER_CMD_GLOBAL_EXPEDITED barriers". always returns 0. 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. returns 0 on 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 use MEMBARRIER_CMD_PRIVATE_EXPEDITED. always returns 0 🫢
  • MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE β€” on top of the memory-ordering guarantees described in MEMBARRIER_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. returns 0 on 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 use MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE. if an architecture doesn't implement this command, it returns -EINVAL. returns 0 on 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 is 0. if the flags parameter is MEMBARRIER_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 use MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ. if an architecture doesn't implement this command, it returns -EINVAL. returns 0 on 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 to MEMBARRIER_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