[libc] Fix RPC interface when sending and recieving aribtrary packets
authorJoseph Huber <jhuber6@vols.utk.edu>
Wed, 10 May 2023 23:14:51 +0000 (18:14 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Wed, 10 May 2023 23:51:38 +0000 (18:51 -0500)
commitc8c19e1c31452c93acd3b9c4db5d9ea1c25a4582
tree5a9e93c600f2780210bbca52db69278adc5e445f
parentf9759d0cb6dc19aa67dbe1c3d56404041f8b4c7e
[libc] Fix RPC interface when sending and recieving aribtrary packets

The interface exported by the RPC library allows users to simply send
and recieve fixed sized packets without worrying about the data motion
underneath. However, this was broken in the current implementation. We
can think of the send and recieve implementations in terms of waiting
for ownership of the buffer, using the buffer, and posting ownership to
the other side. Our implementation of `recv` was incorrect in the
following scenarios.

recv -> send // we still own the buffer and should give away ownership
recv -> close // The other side is not waiting for data, this will
                 result in multiple openings of the same port

This patch attempts to fix this with an admittedly hacky fix where we
track if the previous implementation was a recv and post conditionally.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D150327
libc/src/__support/RPC/rpc.h
libc/test/integration/startup/gpu/CMakeLists.txt
libc/test/integration/startup/gpu/rpc_interface_test.cpp [new file with mode: 0644]
libc/utils/gpu/loader/Server.h