Mir

Merge lp:~kdub/mir/fix-1406725 into lp:mir

Proposed by Kevin DuBois
Status: Merged
Approved by: Kevin DuBois
Approved revision: no longer in the source branch.
Merged at revision: 3109
Proposed branch: lp:~kdub/mir/fix-1406725
Merge into: lp:mir
Diff against target: 69 lines (+34/-3)
3 files modified
include/client/mir_toolkit/mir_buffer_stream.h (+4/-2)
src/client/buffer_stream.cpp (+2/-1)
tests/unit-tests/client/test_client_buffer_stream.cpp (+28/-0)
To merge this branch: bzr merge lp:~kdub/mir/fix-1406725
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alberto Aguirre (community) Approve
Review via email: mp+277826@code.launchpad.net

Commit message

Allow clients to call mir_buffer_stream_get_graphics_region() multiple times between mir_buffer_stream_swap_buffers() without side effects (eg, cache flushing) on android.

This fixes the main corruption that xmir was seeing in lp: #1406725. xmir was using this function to query buffer size, and this would have trashed the android's cpu cache on every size query.

fixes lp: #1406725

Description of the change

Allow clients to call mir_buffer_stream_get_graphics_region() multiple times between mir_buffer_stream_swap_buffers() without side effects (eg, cache flushing) on android.

This fixes the main corruption that xmir was seeing in lp: #1406725. xmir was using this function to query buffer size, and this would have trashed the android's cpu cache on every size query.

fixes lp: #1406725

note: This does not fix the corruption seen with egl_demo_client_flicker (and this corruption is rare, but possible with xmir). Further fixes are coming for lp: #1517205)

To post a comment you must log in.
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

LGTM.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

the errors all look like jenkins just didn't run the jobs.

Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/client/mir_toolkit/mir_buffer_stream.h'
2--- include/client/mir_toolkit/mir_buffer_stream.h 2015-09-15 18:56:59 +0000
3+++ include/client/mir_toolkit/mir_buffer_stream.h 2015-11-18 13:10:34 +0000
4@@ -152,8 +152,10 @@
5 void mir_buffer_stream_swap_buffers_sync(MirBufferStream *buffer_stream);
6
7 /**
8- * Retrieve a buffer stream's graphics region, e.g. map the graphics buffer to main
9- * memory.
10+ * Retrieve a buffer stream's graphics region
11+ * \warning Depending on platform, this can map the graphics buffer each
12+ * time its called. The region remains mapped until
13+ * mir_buffer_stream_swap_buffers().
14 * \pre The buffer stream is valid
15 * \param [in] buffer stream The buffer stream
16 * \param [out] graphics_region Structure to be populated
17
18=== modified file 'src/client/buffer_stream.cpp'
19--- src/client/buffer_stream.cpp 2015-10-26 19:27:50 +0000
20+++ src/client/buffer_stream.cpp 2015-11-18 13:10:34 +0000
21@@ -537,7 +537,8 @@
22 auto buffer = buffer_depository->current_buffer();
23 std::unique_lock<decltype(mutex)> lock(mutex);
24
25- secured_region = buffer->secure_for_cpu_write();
26+ if (!secured_region)
27+ secured_region = buffer->secure_for_cpu_write();
28 return secured_region;
29 }
30
31
32=== modified file 'tests/unit-tests/client/test_client_buffer_stream.cpp'
33--- tests/unit-tests/client/test_client_buffer_stream.cpp 2015-10-21 13:05:45 +0000
34+++ tests/unit-tests/client/test_client_buffer_stream.cpp 2015-11-18 13:10:34 +0000
35@@ -481,6 +481,34 @@
36 EXPECT_EQ(&expected_memory_region, bs.secure_for_cpu_write().get());
37 }
38
39+//lp: #1463873
40+TEST_P(ClientBufferStream, maps_graphics_region_only_once_per_swapbuffers)
41+{
42+ MockClientBuffer mock_client_buffer(size);
43+ ON_CALL(mock_factory, create_buffer(BufferPackageMatches(buffer_package),_,_))
44+ .WillByDefault(Return(mt::fake_shared(mock_client_buffer)));
45+ mcl::BufferStream bs(
46+ nullptr, mock_protobuf_server, mode,
47+ std::make_shared<StubClientPlatform>(mt::fake_shared(mock_factory)),
48+ response, perf_report, "", size, nbuffers);
49+ service_requests_for(bs, 2);
50+
51+ mcl::MemoryRegion first_expected_memory_region;
52+ mcl::MemoryRegion second_expected_memory_region;
53+ EXPECT_CALL(mock_client_buffer, secure_for_cpu_write())
54+ .Times(2)
55+ .WillOnce(Return(mt::fake_shared(first_expected_memory_region)))
56+ .WillOnce(Return(mt::fake_shared(second_expected_memory_region)));
57+ EXPECT_EQ(&first_expected_memory_region, bs.secure_for_cpu_write().get());
58+ bs.secure_for_cpu_write();
59+ bs.secure_for_cpu_write();
60+
61+ bs.request_and_wait_for_next_buffer();
62+ EXPECT_EQ(&second_expected_memory_region, bs.secure_for_cpu_write().get());
63+ bs.secure_for_cpu_write();
64+ bs.secure_for_cpu_write();
65+}
66+
67 TEST_P(ClientBufferStream, passes_name_to_perf_report)
68 {
69 NiceMock<MockPerfReport> mock_perf_report;

Subscribers

People subscribed via source and target branches