OSDN Git Service

Add shared memory based buffer metadata
authorCorey Tabaka <eieio@google.com>
Thu, 14 Sep 2017 01:02:48 +0000 (18:02 -0700)
committerJiwen 'Steve' Cai <jwcai@google.com>
Wed, 11 Oct 2017 03:39:56 +0000 (20:39 -0700)
commit52ea25cf06cef250ec73052611b48556b3fce4d5
tree6595f49407fbe45702f943d913a1d34bd1910fb8
parent35b5114be8da71c69fc8a1ff8fb457c912c0992f
Add shared memory based buffer metadata

This CLs reduces BufferHub CPU consumption by adding asynchronous
state transition so that out-of-process VR composition can run on 2016
pixel devices smoothly. In addition, this CL addresses a couple corner
cases in the existing bufferhub logic, which fixes various blackscreen
issues.

1/ Tracks buffer transition states (gained, posted, acquired, released)
   from the client side via atomic shared memory and adds
   PostAsync/AcquireAsync/ReleaseAsync/GainAsync with metadata  and
   fence support.
2/ Adds dequeue order guarantee for buffers enqueued with
   dvrWriteBufferQueuePostBuffer.
3/ Synchronous BuffeHub operations are still supported.
4/ Bump up the bufferhubd's soft limit of open file descriptor.
5/ Handle orphaned consumer in acquired state. This is a corner case
   that consumer process goes aways (most likely due to a crash) leaving
   buffer stuck in acquired state with inconsistent buffer state.
6/ Fixes a race condition for released buffer to be Gain'ed and
   Acquire'd when a new consumer is created in released state.
7/ Improve silent consumer queue efficiency: Silent queues no longer
   import buffers or receive signals about new buffers and they are
   limited to only spawning other consumers and notifications about
   producers hanging up.
8/ Modify PDX/UDS channel event signaling to work around epoll
   behavior. PDX UDS uses a combination of an eventfd and an epoll set
   to simulate the original PDX transport channel events. An odd
   behavior discovered in the kernel implementation of epoll was found
   that causes the epoll fd to "unsignal" itself whenever epoll_wait()
   is called on it, regardless of whether it should still be
   pending. This breaks the edge triggerd behavior in nested epoll sets
   that channel events depend on. Since this is unlikely to ever be
   fixed in the kernel we work around the behavior by using the epoll
   set only as a logical OR of two eventfds and never calling
   epoll_wait() on it. When polling is required we use regluar poll()
   with the eventfds and data fd to avoid the bad behavior in
   epoll_wait().
9/ Keep reading data after PDX hangup signal. UDS will signal hangup
   when the other end of the socket closes. However, data could still be
   in the kerenl buffer and should be consumed. Fix an issue where the
   service misses an impulse sent right before the socket is closed.

Bug: 65455724
Bug: 65458354
Bug: 65458312
Bug: 64027135
Bug: 67424527
Test: libpdx_uds_tests
      bufferhub_tests
      buffer_hub_queue-test
      buffer_hub_queue_producer-test
      dvr_api-test

Change-Id: Id07db1f206ccf4e06f7ee3c671193334408971ca
44 files changed:
libs/vr/libbufferhub/Android.bp
libs/vr/libbufferhub/buffer_hub_client.cpp
libs/vr/libbufferhub/bufferhub_tests.cpp
libs/vr/libbufferhub/include/private/dvr/buffer_hub_client.h
libs/vr/libbufferhub/include/private/dvr/bufferhub_rpc.h
libs/vr/libbufferhubqueue/Android.bp
libs/vr/libbufferhubqueue/buffer_hub_queue_client.cpp
libs/vr/libbufferhubqueue/buffer_hub_queue_producer.cpp
libs/vr/libbufferhubqueue/include/private/dvr/buffer_hub_queue_client.h
libs/vr/libbufferhubqueue/tests/Android.bp
libs/vr/libbufferhubqueue/tests/buffer_hub_queue-test.cpp
libs/vr/libdvr/dvr_buffer_queue.cpp
libs/vr/libdvr/dvr_buffer_queue_internal.h
libs/vr/libdvr/include/dvr/dvr_api.h
libs/vr/libdvr/tests/Android.bp
libs/vr/libdvr/tests/dvr_buffer_queue-test.cpp
libs/vr/libpdx/Android.bp
libs/vr/libpdx/private/pdx/client_channel.h
libs/vr/libpdx/private/pdx/mock_client_channel.h
libs/vr/libpdx/private/pdx/trace.h
libs/vr/libpdx_uds/channel_event_set.cpp
libs/vr/libpdx_uds/channel_manager.cpp
libs/vr/libpdx_uds/client_channel.cpp
libs/vr/libpdx_uds/client_channel_factory.cpp
libs/vr/libpdx_uds/private/uds/channel_event_set.h
libs/vr/libpdx_uds/private/uds/channel_manager.h
libs/vr/libpdx_uds/private/uds/client_channel.h
libs/vr/libpdx_uds/private/uds/ipc_helper.h
libs/vr/libpdx_uds/private/uds/service_endpoint.h
libs/vr/libpdx_uds/service_endpoint.cpp
libs/vr/libpdx_uds/service_framework_tests.cpp
libs/vr/libvrflinger/display_surface.cpp
services/vr/bufferhubd/Android.mk
services/vr/bufferhubd/buffer_hub.cpp
services/vr/bufferhubd/buffer_hub.h
services/vr/bufferhubd/bufferhubd.cpp
services/vr/bufferhubd/consumer_channel.cpp
services/vr/bufferhubd/consumer_channel.h
services/vr/bufferhubd/consumer_queue_channel.cpp
services/vr/bufferhubd/consumer_queue_channel.h
services/vr/bufferhubd/producer_channel.cpp
services/vr/bufferhubd/producer_channel.h
services/vr/bufferhubd/producer_queue_channel.cpp
services/vr/bufferhubd/producer_queue_channel.h