Skip to content

Commit f9c2fb3

Browse files
pvts-matbmastbergen
authored andcommitted
ktests wiki: sync: basic description
1 parent d4135b1 commit f9c2fb3

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

kselftests/sync/README.rst

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
About
2+
=====
3+
4+
The ``sync`` collection contains a single test ``sync:sync_test``. At
5+
its core it tests the "Sync File" functionality enabled by
6+
``CONFIG_SYNC_FILE``.
7+
8+
The *sync* mechanism in the context of this test is a solution to a
9+
problem of different devices working asynchronously with shared memory
10+
buffers. One device (the producer) fills the buffer while other devices
11+
(the consumers - possibly many) read it. The buffer should not be read
12+
by any consumer until the producer finished filling it. Conversely, the
13+
producer should not try to re-use a buffer for other tasks before the
14+
last consumer finished reading it. The *sync* framework allows producers
15+
to signal to consumers (and vice versa) when the data is ready to be
16+
read (or the buffer to be written). [1]_
17+
18+
This process is first and mainly used for rendering graphics, with a GPU
19+
or V4L driver in the role of a producer and a DRM (Direct Rendering
20+
Manager) driver in the role of a consumer. [2]_
21+
22+
The *sync* framework was born in Android and was later (2016) ported to
23+
Linux. [3]_ It's now part of the ``driver/dma-buf``, which was
24+
previously using a similar mechanism - dma-buf fences [4]_ - albeit
25+
lower-level and more primitve [5]_. It didn't replace dma-buf fences but
26+
acts as an alternative [6]_
27+
28+
Applicability
29+
=============
30+
31+
Some confusion may arise around which module ``sync:sync_test`` actually
32+
tests: is it ``sw_sync.ko``, provided by ``CONFIG_SW_SYNC`` option
33+
(*disabled* in all Rocky versions) or ``sync_file.ko``, provided by
34+
``CONFIG_SYNC_FILE`` (*enabled* in all Rocky versions)?
35+
36+
The ``sw_sync.ko`` is presented in different (and even the same)
37+
contexts as either
38+
39+
#. a module made specifically for testing ``sync_file.ko`` (like the
40+
"Sync File Validation Framework" title in ``CONFIG_SW_SYNC``'s
41+
`documentation <https://www.kernelconfig.io/CONFIG_SW_SYNC?q=CONFIG_SW_SYNC&kernelversion=5.15.183&arch=x86>`__),
42+
or
43+
#. a module providing a separate functionality deserving of its own
44+
testing (like the "Useful when there is no hardware primitive backing
45+
the synchronization" characterization in the very same doc).
46+
47+
Current understanding is that ``sync:sync_test`` tests ``sw_sync.ko``
48+
directly and ``sync_file.ko`` indirectly and while, theoretically,
49+
``sw_sync.ko`` provides functionality usable beyond just testing
50+
``sync_file.ko``, in practice that is its only purpose and using it for
51+
any other is discouraged in the module's own documentation ("WARNING:
52+
improper use of this can result in deadlocking kernel drivers from
53+
userspace. Intended for test and debug only." [7]_). At the same time
54+
there are no tests testing ``sync_file.ko`` by other means than with the
55+
use of ``sw_sync.ko``. The ``sw_sync.ko`` should therefore be treated as
56+
a de facto testing module for ``sync_file.ko``.
57+
58+
The ``sync`` test suite therefore applies to all Rocky versions LTS 8.6,
59+
8.8, 9.2, 9.4 (enabled ``CONFIG_SYNC_FILE``), but requires modified
60+
configuration to actually run the tests (disabled ``CONFIG_SW_SYNC``).
61+
Otherwise it will always ``# SKIP`` and can be omitted.
62+
63+
.. [1]
64+
https://blog.linuxplumbersconf.org/2014/ocw/system/presentations/2355/original/03%20-%20sync%20%26%20dma-fence.pdf
65+
66+
.. [2]
67+
https://www.kernelconfig.io/CONFIG_SYNC_FILE?q=CONFIG_SYNC_FILE&kernelversion=5.15.183&arch=x86
68+
69+
.. [3]
70+
https://lwn.net/Articles/672094/
71+
72+
.. [4]
73+
https://www.kernel.org/doc/html/v4.10/driver-api/dma-buf.html
74+
75+
.. [5]
76+
https://blog.linuxplumbersconf.org/2014/ocw/system/presentations/2355/original/03%20-%20sync%20%26%20dma-fence.pdf
77+
78+
.. [6]
79+
https://www.phoronix.com/news/Linux-4.9-To-De-Stage-SW_SYNC
80+
81+
.. [7]
82+
https://www.kernelconfig.io/CONFIG_SW_SYNC?q=CONFIG_SW_SYNC&kernelversion=5.15.183&arch=x86

0 commit comments

Comments
 (0)