[all-commits] [llvm/llvm-project] f15279: [libc][rpc] Fix the memory ordering in lock.

Jon Chesterfield via All-commits all-commits at lists.llvm.org
Wed May 3 15:24:09 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f152796fd3e028d22dbe59e8157549bb98852800
      https://github.com/llvm/llvm-project/commit/f152796fd3e028d22dbe59e8157549bb98852800
  Author: Jon Chesterfield <jonathanchesterfield at gmail.com>
  Date:   2023-05-03 (Wed, 03 May 2023)

  Changed paths:
    M libc/src/__support/RPC/rpc.h

  Log Message:
  -----------
  [libc][rpc] Fix the memory ordering in lock.

Prevent operation reordering with fence instead of a comment.

The mailboxes are in shared memory and the locks structure in device memory.
If the mailboxes are read and then the lock taken, the lock says nothing
about the current or future state of those mail boxes. The relaxed atomic
fetch_or can be reordered before the relaxed atomic loads of unrelated
variables unless there is a fence preventing this.

Patches both Client::try_open and Server::try_open, one of which is missing
an optimisation and the other is missing the comment, but which otherwise
could be Process::try_open followed by buffer->opcode = opcode in Client.

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D149790




More information about the All-commits mailing list