This is an archive of the discontinued LLVM Phabricator instance.

[libc][rpc] Simplify mailbox state tracking
ClosedPublic

Authored by JonChesterfield on May 3 2023, 2:45 PM.

Details

Summary

Removes the redundant Ack/Data bit manipulation.

Represents the inbox/outbox state with one bit instead of two. This will
be useful if we change to a packed representation and otherwise cuts the
runtime state space from 16 to 4.

Further simplification is possible, this patch is intentionally minimal.

  • can_{send,recv}_data are now in == out
  • {client,server}::try_open can be factored into Process:try_open

This implements the state machine of D148191, modulo differences in atomic
ordering and fences.

Diff Detail

Event Timeline

JonChesterfield created this revision.May 3 2023, 2:45 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMay 3 2023, 2:45 PM
JonChesterfield requested review of this revision.May 3 2023, 2:45 PM
  • update header comment to remove references to ack/data bit
jhuber6 added inline comments.May 3 2023, 3:09 PM
libc/src/__support/OSUtil/gpu/io.cpp
18

I guess since this is a templated type now we can't just have a generic port? Also what happened to the one in Server.h.

libc/src/__support/RPC/rpc.h
105

Can probably just call this can_use_buffer and get rid of the other one. I think keeping send and recv separate is more readable however.

JonChesterfield added inline comments.May 3 2023, 3:18 PM
libc/src/__support/OSUtil/gpu/io.cpp
18

Server.h used auto. I don't know what you have in mind for "generic port", but any user of this has a Client or Server instance available. Moving Port to a member of Process would remove some line noise, as would writing more of the methods on port in the struct,

libc/src/__support/RPC/rpc.h
105

I favour in != out at the call sites but didn't want to disturb them as part of this review. D149788, D149793 are separate to similarly avoid noise in the diff.

jhuber6 accepted this revision.May 3 2023, 3:24 PM

This worked on the unit tests in D149532 when I applied it so it looks good overall, thanks.

libc/src/__support/RPC/rpc.h
89–104

Header comment describing what this does and the inversion scheme please.

105

Yeah that's fair enough. I'll need to rebase those.

217–220

Put these and others in a single template.

This revision is now accepted and ready to land.May 3 2023, 3:24 PM
  • update header comment to remove references to ack/data bit
  • header comment, fold template declarations
  • words instead of symbols as requested
  • back to working template declarations
This revision was landed with ongoing or failed builds.May 3 2023, 4:21 PM
This revision was automatically updated to reflect the committed changes.