€•?Œsphinx.addnodes”Œdocument”“”)�”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)�”}”(hhh]”(hŒ pending_xref”“”)�”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…”�”}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ#/translations/zh_CN/dev-tools/kcsan”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)�”}”(hhh]”hŒChinese (Traditional)”…”�”}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ#/translations/zh_TW/dev-tools/kcsan”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒItalian”…”�”}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ#/translations/it_IT/dev-tools/kcsan”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒJapanese”…”�”}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ#/translations/ja_JP/dev-tools/kcsan”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒKorean”…”�”}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ#/translations/ko_KR/dev-tools/kcsan”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒPortuguese (Brazilian)”…”�”}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ#/translations/pt_BR/dev-tools/kcsan”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒSpanish”…”�”}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ#/translations/sp_SP/dev-tools/kcsan”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒcomment”“”)�”}”(hŒ SPDX-License-Identifier: GPL-2.0”h]”hŒ SPDX-License-Identifier: GPL-2.0”…”�”}”hh·sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1hµhhh²hh³Œ=/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan.rst”h´Kubh¶)�”}”(hŒCopyright (C) 2019, Google LLC.”h]”hŒCopyright (C) 2019, Google LLC.”…”�”}”hhÈsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1hµhhh²hh³hÇh´KubhŒsection”“”)�”}”(hhh]”(hŒtitle”“”)�”}”(hŒ$Kernel Concurrency Sanitizer (KCSAN)”h]”hŒ$Kernel Concurrency Sanitizer (KCSAN)”…”�”}”(hhÝh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhhØh²hh³hÇh´KubhŒ paragraph”“”)�”}”(hŒåThe Kernel Concurrency Sanitizer (KCSAN) is a dynamic race detector, which relies on compile-time instrumentation, and uses a watchpoint-based sampling approach to detect races. KCSAN's primary purpose is to detect `data races`_.”h]”(hŒÙThe Kernel Concurrency Sanitizer (KCSAN) is a dynamic race detector, which relies on compile-time instrumentation, and uses a watchpoint-based sampling approach to detect races. KCSAN’s primary purpose is to detect ”…”�”}”(hhíh²hh³Nh´NubhŒ reference”“”)�”}”(hŒ `data races`_”h]”hŒ data races”…”�”}”(hh÷h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”Œ data races”Œrefid”Œ data-races”uh1hõhhíŒresolved”KubhŒ.”…”�”}”(hhíh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´KhhØh²hubh×)�”}”(hhh]”(hÜ)�”}”(hŒUsage”h]”hŒUsage”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjh²hh³hÇh´K ubhì)�”}”(hŒƒKCSAN is supported by both GCC and Clang. With GCC we require version 11 or later, and with Clang also require version 11 or later.”h]”hŒƒKCSAN is supported by both GCC and Clang. With GCC we require version 11 or later, and with Clang also require version 11 or later.”…”�”}”(hj%h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´Khjh²hubhì)�”}”(hŒ+To enable KCSAN configure the kernel with::”h]”hŒ*To enable KCSAN configure the kernel with:”…”�”}”(hj3h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´Khjh²hubhŒ literal_block”“”)�”}”(hŒCONFIG_KCSAN = y”h]”hŒCONFIG_KCSAN = y”…”�”}”hjCsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jAh³hÇh´Khjh²hubhì)�”}”(hŒ�KCSAN provides several other configuration options to customize behaviour (see the respective help text in ``lib/Kconfig.kcsan`` for more info).”h]”(hŒkKCSAN provides several other configuration options to customize behaviour (see the respective help text in ”…”�”}”(hjQh²hh³Nh´NubhŒliteral”“”)�”}”(hŒ``lib/Kconfig.kcsan``”h]”hŒlib/Kconfig.kcsan”…”�”}”(hj[h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjQubhŒ for more info).”…”�”}”(hjQh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´Khjh²hubh×)�”}”(hhh]”(hÜ)�”}”(hŒ Error reports”h]”hŒ Error reports”…”�”}”(hjvh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjsh²hh³hÇh´Kubhì)�”}”(hŒ,A typical data race report looks like this::”h]”hŒ+A typical data race report looks like this:”…”�”}”(hj„h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´Khjsh²hubjB)�”}”(hXû================================================================== BUG: KCSAN: data-race in test_kernel_read / test_kernel_write write to 0xffffffffc009a628 of 8 bytes by task 487 on cpu 0: test_kernel_write+0x1d/0x30 access_thread+0x89/0xd0 kthread+0x23e/0x260 ret_from_fork+0x22/0x30 read to 0xffffffffc009a628 of 8 bytes by task 488 on cpu 6: test_kernel_read+0x10/0x20 access_thread+0x89/0xd0 kthread+0x23e/0x260 ret_from_fork+0x22/0x30 value changed: 0x00000000000009a6 -> 0x00000000000009b2 Reported by Kernel Concurrency Sanitizer on: CPU: 6 PID: 488 Comm: access_thread Not tainted 5.12.0-rc2+ #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014 ==================================================================”h]”hXû================================================================== BUG: KCSAN: data-race in test_kernel_read / test_kernel_write write to 0xffffffffc009a628 of 8 bytes by task 487 on cpu 0: test_kernel_write+0x1d/0x30 access_thread+0x89/0xd0 kthread+0x23e/0x260 ret_from_fork+0x22/0x30 read to 0xffffffffc009a628 of 8 bytes by task 488 on cpu 6: test_kernel_read+0x10/0x20 access_thread+0x89/0xd0 kthread+0x23e/0x260 ret_from_fork+0x22/0x30 value changed: 0x00000000000009a6 -> 0x00000000000009b2 Reported by Kernel Concurrency Sanitizer on: CPU: 6 PID: 488 Comm: access_thread Not tainted 5.12.0-rc2+ #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014 ==================================================================”…”�”}”hj’sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jAh³hÇh´Khjsh²hubhì)�”}”(hX8The header of the report provides a short summary of the functions involved in the race. It is followed by the access types and stack traces of the 2 threads involved in the data race. If KCSAN also observed a value change, the observed old value and new value are shown on the "value changed" line respectively.”h]”hX<The header of the report provides a short summary of the functions involved in the race. It is followed by the access types and stack traces of the 2 threads involved in the data race. If KCSAN also observed a value change, the observed old value and new value are shown on the “value changedâ€� line respectively.”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´K3hjsh²hubhì)�”}”(hŒ@The other less common type of data race report looks like this::”h]”hŒ?The other less common type of data race report looks like this:”…”�”}”(hj®h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´K8hjsh²hubjB)�”}”(hXv================================================================== BUG: KCSAN: data-race in test_kernel_rmw_array+0x71/0xd0 race at unknown origin, with read to 0xffffffffc009bdb0 of 8 bytes by task 515 on cpu 2: test_kernel_rmw_array+0x71/0xd0 access_thread+0x89/0xd0 kthread+0x23e/0x260 ret_from_fork+0x22/0x30 value changed: 0x0000000000002328 -> 0x0000000000002329 Reported by Kernel Concurrency Sanitizer on: CPU: 2 PID: 515 Comm: access_thread Not tainted 5.12.0-rc2+ #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014 ==================================================================”h]”hXv================================================================== BUG: KCSAN: data-race in test_kernel_rmw_array+0x71/0xd0 race at unknown origin, with read to 0xffffffffc009bdb0 of 8 bytes by task 515 on cpu 2: test_kernel_rmw_array+0x71/0xd0 access_thread+0x89/0xd0 kthread+0x23e/0x260 ret_from_fork+0x22/0x30 value changed: 0x0000000000002328 -> 0x0000000000002329 Reported by Kernel Concurrency Sanitizer on: CPU: 2 PID: 515 Comm: access_thread Not tainted 5.12.0-rc2+ #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014 ==================================================================”…”�”}”hj¼sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jAh³hÇh´K:hjsh²hubhì)�”}”(hXÜThis report is generated where it was not possible to determine the other racing thread, but a race was inferred due to the data value of the watched memory location having changed. These reports always show a "value changed" line. A common reason for reports of this type are missing instrumentation in the racing thread, but could also occur due to e.g. DMA accesses. Such reports are shown only if ``CONFIG_KCSAN_REPORT_RACE_UNKNOWN_ORIGIN=y``, which is enabled by default.”h]”(hX•This report is generated where it was not possible to determine the other racing thread, but a race was inferred due to the data value of the watched memory location having changed. These reports always show a “value changedâ€� line. A common reason for reports of this type are missing instrumentation in the racing thread, but could also occur due to e.g. DMA accesses. Such reports are shown only if ”…”�”}”(hjÊh²hh³Nh´NubjZ)�”}”(hŒ-``CONFIG_KCSAN_REPORT_RACE_UNKNOWN_ORIGIN=y``”h]”hŒ)CONFIG_KCSAN_REPORT_RACE_UNKNOWN_ORIGIN=y”…”�”}”(hjÒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjÊubhŒ, which is enabled by default.”…”�”}”(hjÊh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´KJhjsh²hubeh}”(h]”Œ error-reports”ah ]”h"]”Œ error reports”ah$]”h&]”uh1hÖhjh²hh³hÇh´Kubh×)�”}”(hhh]”(hÜ)�”}”(hŒSelective analysis”h]”hŒSelective analysis”…”�”}”(hjõh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjòh²hh³hÇh´KSubhì)�”}”(hŒ¸It may be desirable to disable data race detection for specific accesses, functions, compilation units, or entire subsystems. For static blacklisting, the below options are available:”h]”hŒ¸It may be desirable to disable data race detection for specific accesses, functions, compilation units, or entire subsystems. For static blacklisting, the below options are available:”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´KUhjòh²hubhŒ bullet_list”“”)�”}”(hhh]”(hŒ list_item”“”)�”}”(hX"KCSAN understands the ``data_race(expr)`` annotation, which tells KCSAN that any data races due to accesses in ``expr`` should be ignored and resulting behaviour when encountering a data race is deemed safe. Please see `"Marking Shared-Memory Accesses" in the LKMM`_ for more information. ”h]”hì)�”}”(hX!KCSAN understands the ``data_race(expr)`` annotation, which tells KCSAN that any data races due to accesses in ``expr`` should be ignored and resulting behaviour when encountering a data race is deemed safe. Please see `"Marking Shared-Memory Accesses" in the LKMM`_ for more information.”h]”(hŒKCSAN understands the ”…”�”}”(hjh²hh³Nh´NubjZ)�”}”(hŒ``data_race(expr)``”h]”hŒdata_race(expr)”…”�”}”(hj$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjubhŒF annotation, which tells KCSAN that any data races due to accesses in ”…”�”}”(hjh²hh³Nh´NubjZ)�”}”(hŒ``expr``”h]”hŒexpr”…”�”}”(hj6h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjubhŒe should be ignored and resulting behaviour when encountering a data race is deemed safe. Please see ”…”�”}”(hjh²hh³Nh´Nubhö)�”}”(hŒ/`"Marking Shared-Memory Accesses" in the LKMM`_”h]”hŒ0“Marking Shared-Memory Accessesâ€� in the LKMM”…”�”}”(hjHh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”Œ,"Marking Shared-Memory Accesses" in the LKMM”Œrefuri”Œ{https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/memory-model/Documentation/access-marking.txt”uh1hõhjj KubhŒ for more information.”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´KYhjubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjh²hh³hÇh´Nubj)�”}”(hXSimilar to ``data_race(...)``, the type qualifier ``__data_racy`` can be used to document that all data races due to accesses to a variable are intended and should be ignored by KCSAN:: struct foo { ... int __data_racy stats_counter; ... }; ”h]”(hì)�”}”(hŒ¹Similar to ``data_race(...)``, the type qualifier ``__data_racy`` can be used to document that all data races due to accesses to a variable are intended and should be ignored by KCSAN::”h]”(hŒ Similar to ”…”�”}”(hjnh²hh³Nh´NubjZ)�”}”(hŒ``data_race(...)``”h]”hŒdata_race(...)”…”�”}”(hjvh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjnubhŒ, the type qualifier ”…”�”}”(hjnh²hh³Nh´NubjZ)�”}”(hŒ``__data_racy``”h]”hŒ __data_racy”…”�”}”(hjˆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjnubhŒw can be used to document that all data races due to accesses to a variable are intended and should be ignored by KCSAN:”…”�”}”(hjnh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´K^hjjubjB)�”}”(hŒBstruct foo { ... int __data_racy stats_counter; ... };”h]”hŒBstruct foo { ... int __data_racy stats_counter; ... };”…”�”}”hj sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jAh³hÇh´Kbhjjubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhjh²hh³hÇh´Nubj)�”}”(hXDisabling data race detection for entire functions can be accomplished by using the function attribute ``__no_kcsan``:: __no_kcsan void foo(void) { ... To dynamically limit for which functions to generate reports, see the `DebugFS interface`_ blacklist/whitelist feature. ”h]”(hì)�”}”(hŒwDisabling data race detection for entire functions can be accomplished by using the function attribute ``__no_kcsan``::”h]”(hŒgDisabling data race detection for entire functions can be accomplished by using the function attribute ”…”�”}”(hj¸h²hh³Nh´NubjZ)�”}”(hŒ``__no_kcsan``”h]”hŒ __no_kcsan”…”�”}”(hjÀh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj¸ubhŒ:”…”�”}”(hj¸h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´Khhj´ubjB)�”}”(hŒ#__no_kcsan void foo(void) { ...”h]”hŒ#__no_kcsan void foo(void) { ...”…”�”}”hjØsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jAh³hÇh´Kkhj´ubhì)�”}”(hŒwTo dynamically limit for which functions to generate reports, see the `DebugFS interface`_ blacklist/whitelist feature.”h]”(hŒFTo dynamically limit for which functions to generate reports, see the ”…”�”}”(hjæh²hh³Nh´Nubhö)�”}”(hŒ`DebugFS interface`_”h]”hŒDebugFS interface”…”�”}”(hjîh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”ŒDebugFS interface”jŒdebugfs-interface”uh1hõhjæj KubhŒ blacklist/whitelist feature.”…”�”}”(hjæh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´Kohj´ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhjh²hh³hÇh´Nubj)�”}”(hŒzTo disable data race detection for a particular compilation unit, add to the ``Makefile``:: KCSAN_SANITIZE_file.o := n ”h]”(hì)�”}”(hŒ[To disable data race detection for a particular compilation unit, add to the ``Makefile``::”h]”(hŒMTo disable data race detection for a particular compilation unit, add to the ”…”�”}”(hjh²hh³Nh´NubjZ)�”}”(hŒ ``Makefile``”h]”hŒMakefile”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjubhŒ:”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´KrhjubjB)�”}”(hŒKCSAN_SANITIZE_file.o := n”h]”hŒKCSAN_SANITIZE_file.o := n”…”�”}”hj3sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jAh³hÇh´Kuhjubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhjh²hh³hÇh´Nubj)�”}”(hŒ�To disable data race detection for all compilation units listed in a ``Makefile``, add to the respective ``Makefile``:: KCSAN_SANITIZE := n ”h]”(hì)�”}”(hŒwTo disable data race detection for all compilation units listed in a ``Makefile``, add to the respective ``Makefile``::”h]”(hŒETo disable data race detection for all compilation units listed in a ”…”�”}”(hjKh²hh³Nh´NubjZ)�”}”(hŒ ``Makefile``”h]”hŒMakefile”…”�”}”(hjSh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjKubhŒ, add to the respective ”…”�”}”(hjKh²hh³Nh´NubjZ)�”}”(hŒ ``Makefile``”h]”hŒMakefile”…”�”}”(hjeh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjKubhŒ:”…”�”}”(hjKh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´KwhjGubjB)�”}”(hŒKCSAN_SANITIZE := n”h]”hŒKCSAN_SANITIZE := n”…”�”}”hj}sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jAh³hÇh´KzhjGubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhjh²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ*”uh1jh³hÇh´KYhjòh²hubhŒtarget”“”)�”}”(hŒ­.. _"Marking Shared-Memory Accesses" in the LKMM: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/memory-model/Documentation/access-marking.txt”h]”h}”(h]”Œ*marking-shared-memory-accesses-in-the-lkmm”ah ]”h"]”Œ,"marking shared-memory accesses" in the lkmm”ah$]”h&]”jXjYuh1j™h´K|hjòh²hh³hÇŒ referenced”Kubhì)�”}”(hŒ©Furthermore, it is possible to tell KCSAN to show or hide entire classes of data races, depending on preferences. These can be changed via the following Kconfig options:”h]”hŒ©Furthermore, it is possible to tell KCSAN to show or hide entire classes of data races, depending on preferences. These can be changed via the following Kconfig options:”…”�”}”(hj¨h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´K~hjòh²hubj)�”}”(hhh]”(j)�”}”(hŒÕ``CONFIG_KCSAN_REPORT_VALUE_CHANGE_ONLY``: If enabled and a conflicting write is observed via a watchpoint, but the data value of the memory location was observed to remain unchanged, do not report the data race. ”h]”hì)�”}”(hŒÔ``CONFIG_KCSAN_REPORT_VALUE_CHANGE_ONLY``: If enabled and a conflicting write is observed via a watchpoint, but the data value of the memory location was observed to remain unchanged, do not report the data race.”h]”(jZ)�”}”(hŒ)``CONFIG_KCSAN_REPORT_VALUE_CHANGE_ONLY``”h]”hŒ%CONFIG_KCSAN_REPORT_VALUE_CHANGE_ONLY”…”�”}”(hjÁh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj½ubhŒ«: If enabled and a conflicting write is observed via a watchpoint, but the data value of the memory location was observed to remain unchanged, do not report the data race.”…”�”}”(hj½h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´K‚hj¹ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj¶h²hh³hÇh´Nubj)�”}”(hX\``CONFIG_KCSAN_ASSUME_PLAIN_WRITES_ATOMIC``: Assume that plain aligned writes up to word size are atomic by default. Assumes that such writes are not subject to unsafe compiler optimizations resulting in data races. The option causes KCSAN to not report data races due to conflicts where the only plain accesses are aligned writes up to word size. ”h]”hì)�”}”(hX[``CONFIG_KCSAN_ASSUME_PLAIN_WRITES_ATOMIC``: Assume that plain aligned writes up to word size are atomic by default. Assumes that such writes are not subject to unsafe compiler optimizations resulting in data races. The option causes KCSAN to not report data races due to conflicts where the only plain accesses are aligned writes up to word size.”h]”(jZ)�”}”(hŒ+``CONFIG_KCSAN_ASSUME_PLAIN_WRITES_ATOMIC``”h]”hŒ'CONFIG_KCSAN_ASSUME_PLAIN_WRITES_ATOMIC”…”�”}”(hjçh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjãubhX0: Assume that plain aligned writes up to word size are atomic by default. Assumes that such writes are not subject to unsafe compiler optimizations resulting in data races. The option causes KCSAN to not report data races due to conflicts where the only plain accesses are aligned writes up to word size.”…”�”}”(hjãh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´K†hjßubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj¶h²hh³hÇh´Nubj)�”}”(hXã``CONFIG_KCSAN_PERMISSIVE``: Enable additional permissive rules to ignore certain classes of common data races. Unlike the above, the rules are more complex involving value-change patterns, access type, and address. This option depends on ``CONFIG_KCSAN_REPORT_VALUE_CHANGE_ONLY=y``. For details please see the ``kernel/kcsan/permissive.h``. Testers and maintainers that only focus on reports from specific subsystems and not the whole kernel are recommended to disable this option. ”h]”hì)�”}”(hXâ``CONFIG_KCSAN_PERMISSIVE``: Enable additional permissive rules to ignore certain classes of common data races. Unlike the above, the rules are more complex involving value-change patterns, access type, and address. This option depends on ``CONFIG_KCSAN_REPORT_VALUE_CHANGE_ONLY=y``. For details please see the ``kernel/kcsan/permissive.h``. Testers and maintainers that only focus on reports from specific subsystems and not the whole kernel are recommended to disable this option.”h]”(jZ)�”}”(hŒ``CONFIG_KCSAN_PERMISSIVE``”h]”hŒCONFIG_KCSAN_PERMISSIVE”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj ubhŒÔ: Enable additional permissive rules to ignore certain classes of common data races. Unlike the above, the rules are more complex involving value-change patterns, access type, and address. This option depends on ”…”�”}”(hj h²hh³Nh´NubjZ)�”}”(hŒ+``CONFIG_KCSAN_REPORT_VALUE_CHANGE_ONLY=y``”h]”hŒ'CONFIG_KCSAN_REPORT_VALUE_CHANGE_ONLY=y”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj ubhŒ. For details please see the ”…”�”}”(hj h²hh³Nh´NubjZ)�”}”(hŒ``kernel/kcsan/permissive.h``”h]”hŒkernel/kcsan/permissive.h”…”�”}”(hj1h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj ubhŒŽ. Testers and maintainers that only focus on reports from specific subsystems and not the whole kernel are recommended to disable this option.”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´KŒhjubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj¶h²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”j—j˜uh1jh³hÇh´K‚hjòh²hubhì)�”}”(hŒ°To use the strictest possible rules, select ``CONFIG_KCSAN_STRICT=y``, which configures KCSAN to follow the Linux-kernel memory consistency model (LKMM) as closely as possible.”h]”(hŒ,To use the strictest possible rules, select ”…”�”}”(hjUh²hh³Nh´NubjZ)�”}”(hŒ``CONFIG_KCSAN_STRICT=y``”h]”hŒCONFIG_KCSAN_STRICT=y”…”�”}”(hj]h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjUubhŒk, which configures KCSAN to follow the Linux-kernel memory consistency model (LKMM) as closely as possible.”…”�”}”(hjUh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´K”hjòh²hubeh}”(h]”Œselective-analysis”ah ]”h"]”Œselective analysis”ah$]”h&]”uh1hÖhjh²hh³hÇh´KSubh×)�”}”(hhh]”(hÜ)�”}”(hŒDebugFS interface”h]”hŒDebugFS interface”…”�”}”(hj€h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhj}h²hh³hÇh´K™ubhì)�”}”(hŒFThe file ``/sys/kernel/debug/kcsan`` provides the following interface:”h]”(hŒ The file ”…”�”}”(hjŽh²hh³Nh´NubjZ)�”}”(hŒ``/sys/kernel/debug/kcsan``”h]”hŒ/sys/kernel/debug/kcsan”…”�”}”(hj–h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjŽubhŒ" provides the following interface:”…”�”}”(hjŽh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´K›hj}h²hubj)�”}”(hhh]”(j)�”}”(hŒHReading ``/sys/kernel/debug/kcsan`` returns various runtime statistics. ”h]”hì)�”}”(hŒGReading ``/sys/kernel/debug/kcsan`` returns various runtime statistics.”h]”(hŒReading ”…”�”}”(hjµh²hh³Nh´NubjZ)�”}”(hŒ``/sys/kernel/debug/kcsan``”h]”hŒ/sys/kernel/debug/kcsan”…”�”}”(hj½h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjµubhŒ$ returns various runtime statistics.”…”�”}”(hjµh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´K�hj±ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj®h²hh³hÇh´Nubj)�”}”(hŒgWriting ``on`` or ``off`` to ``/sys/kernel/debug/kcsan`` allows turning KCSAN on or off, respectively. ”h]”hì)�”}”(hŒfWriting ``on`` or ``off`` to ``/sys/kernel/debug/kcsan`` allows turning KCSAN on or off, respectively.”h]”(hŒWriting ”…”�”}”(hjßh²hh³Nh´NubjZ)�”}”(hŒ``on``”h]”hŒon”…”�”}”(hjçh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjßubhŒ or ”…”�”}”(hjßh²hh³Nh´NubjZ)�”}”(hŒ``off``”h]”hŒoff”…”�”}”(hjùh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjßubhŒ to ”…”�”}”(hjßh²hh³Nh´NubjZ)�”}”(hŒ``/sys/kernel/debug/kcsan``”h]”hŒ/sys/kernel/debug/kcsan”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjßubhŒ. allows turning KCSAN on or off, respectively.”…”�”}”(hjßh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´KŸhjÛubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj®h²hh³hÇh´Nubj)�”}”(hŒåWriting ``!some_func_name`` to ``/sys/kernel/debug/kcsan`` adds ``some_func_name`` to the report filter list, which (by default) blacklists reporting data races where either one of the top stackframes are a function in the list. ”h]”hì)�”}”(hŒäWriting ``!some_func_name`` to ``/sys/kernel/debug/kcsan`` adds ``some_func_name`` to the report filter list, which (by default) blacklists reporting data races where either one of the top stackframes are a function in the list.”h]”(hŒWriting ”…”�”}”(hj-h²hh³Nh´NubjZ)�”}”(hŒ``!some_func_name``”h]”hŒ!some_func_name”…”�”}”(hj5h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj-ubhŒ to ”…”�”}”(hj-h²hh³Nh´NubjZ)�”}”(hŒ``/sys/kernel/debug/kcsan``”h]”hŒ/sys/kernel/debug/kcsan”…”�”}”(hjGh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj-ubhŒ adds ”…”�”}”(hj-h²hh³Nh´NubjZ)�”}”(hŒ``some_func_name``”h]”hŒsome_func_name”…”�”}”(hjYh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj-ubhŒ’ to the report filter list, which (by default) blacklists reporting data races where either one of the top stackframes are a function in the list.”…”�”}”(hj-h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´K¢hj)ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj®h²hh³hÇh´Nubj)�”}”(hXWriting either ``blacklist`` or ``whitelist`` to ``/sys/kernel/debug/kcsan`` changes the report filtering behaviour. For example, the blacklist feature can be used to silence frequently occurring data races; the whitelist feature can help with reproduction and testing of fixes. ”h]”hì)�”}”(hXWriting either ``blacklist`` or ``whitelist`` to ``/sys/kernel/debug/kcsan`` changes the report filtering behaviour. For example, the blacklist feature can be used to silence frequently occurring data races; the whitelist feature can help with reproduction and testing of fixes.”h]”(hŒWriting either ”…”�”}”(hj{h²hh³Nh´NubjZ)�”}”(hŒ ``blacklist``”h]”hŒ blacklist”…”�”}”(hjƒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj{ubhŒ or ”…”�”}”(hj{h²hh³Nh´NubjZ)�”}”(hŒ ``whitelist``”h]”hŒ whitelist”…”�”}”(hj•h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj{ubhŒ to ”…”�”}”(hj{h²hh³Nh´NubjZ)�”}”(hŒ``/sys/kernel/debug/kcsan``”h]”hŒ/sys/kernel/debug/kcsan”…”�”}”(hj§h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj{ubhŒÊ changes the report filtering behaviour. For example, the blacklist feature can be used to silence frequently occurring data races; the whitelist feature can help with reproduction and testing of fixes.”…”�”}”(hj{h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´K§hjwubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj®h²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”j—j˜uh1jh³hÇh´K�hj}h²hubeh}”(h]”jþah ]”h"]”Œdebugfs interface”ah$]”h&]”uh1hÖhjh²hh³hÇh´K™j§Kubh×)�”}”(hhh]”(hÜ)�”}”(hŒTuning performance”h]”hŒTuning performance”…”�”}”(hjÕh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjÒh²hh³hÇh´K­ubhì)�”}”(hŒÈCore parameters that affect KCSAN's overall performance and bug detection ability are exposed as kernel command-line arguments whose defaults can also be changed via the corresponding Kconfig options.”h]”hŒÊCore parameters that affect KCSAN’s overall performance and bug detection ability are exposed as kernel command-line arguments whose defaults can also be changed via the corresponding Kconfig options.”…”�”}”(hjãh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´K¯hjÒh²hubj)�”}”(hhh]”(j)�”}”(hXY``kcsan.skip_watch`` (``CONFIG_KCSAN_SKIP_WATCH``): Number of per-CPU memory operations to skip, before another watchpoint is set up. Setting up watchpoints more frequently will result in the likelihood of races to be observed to increase. This parameter has the most significant impact on overall system performance and race detection ability. ”h]”hì)�”}”(hXX``kcsan.skip_watch`` (``CONFIG_KCSAN_SKIP_WATCH``): Number of per-CPU memory operations to skip, before another watchpoint is set up. Setting up watchpoints more frequently will result in the likelihood of races to be observed to increase. This parameter has the most significant impact on overall system performance and race detection ability.”h]”(jZ)�”}”(hŒ``kcsan.skip_watch``”h]”hŒkcsan.skip_watch”…”�”}”(hjüh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjøubhŒ (”…”�”}”(hjøh²hh³Nh´NubjZ)�”}”(hŒ``CONFIG_KCSAN_SKIP_WATCH``”h]”hŒCONFIG_KCSAN_SKIP_WATCH”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjøubhX'): Number of per-CPU memory operations to skip, before another watchpoint is set up. Setting up watchpoints more frequently will result in the likelihood of races to be observed to increase. This parameter has the most significant impact on overall system performance and race detection ability.”…”�”}”(hjøh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´K³hjôubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjñh²hh³hÇh´Nubj)�”}”(hŒÝ``kcsan.udelay_task`` (``CONFIG_KCSAN_UDELAY_TASK``): For tasks, the microsecond delay to stall execution after a watchpoint has been set up. Larger values result in the window in which we may observe a race to increase. ”h]”hì)�”}”(hŒÜ``kcsan.udelay_task`` (``CONFIG_KCSAN_UDELAY_TASK``): For tasks, the microsecond delay to stall execution after a watchpoint has been set up. Larger values result in the window in which we may observe a race to increase.”h]”(jZ)�”}”(hŒ``kcsan.udelay_task``”h]”hŒkcsan.udelay_task”…”�”}”(hj4h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj0ubhŒ (”…”�”}”(hj0h²hh³Nh´NubjZ)�”}”(hŒ``CONFIG_KCSAN_UDELAY_TASK``”h]”hŒCONFIG_KCSAN_UDELAY_TASK”…”�”}”(hjFh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj0ubhŒ©): For tasks, the microsecond delay to stall execution after a watchpoint has been set up. Larger values result in the window in which we may observe a race to increase.”…”�”}”(hj0h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´K¹hj,ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjñh²hh³hÇh´Nubj)�”}”(hX``kcsan.udelay_interrupt`` (``CONFIG_KCSAN_UDELAY_INTERRUPT``): For interrupts, the microsecond delay to stall execution after a watchpoint has been set up. Interrupts have tighter latency requirements, and their delay should generally be smaller than the one chosen for tasks. ”h]”hì)�”}”(hX``kcsan.udelay_interrupt`` (``CONFIG_KCSAN_UDELAY_INTERRUPT``): For interrupts, the microsecond delay to stall execution after a watchpoint has been set up. Interrupts have tighter latency requirements, and their delay should generally be smaller than the one chosen for tasks.”h]”(jZ)�”}”(hŒ``kcsan.udelay_interrupt``”h]”hŒkcsan.udelay_interrupt”…”�”}”(hjlh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjhubhŒ (”…”�”}”(hjhh²hh³Nh´NubjZ)�”}”(hŒ!``CONFIG_KCSAN_UDELAY_INTERRUPT``”h]”hŒCONFIG_KCSAN_UDELAY_INTERRUPT”…”�”}”(hj~h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjhubhŒØ): For interrupts, the microsecond delay to stall execution after a watchpoint has been set up. Interrupts have tighter latency requirements, and their delay should generally be smaller than the one chosen for tasks.”…”�”}”(hjhh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´K¾hjdubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjñh²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”j—j˜uh1jh³hÇh´K³hjÒh²hubhì)�”}”(hŒEThey may be tweaked at runtime via ``/sys/module/kcsan/parameters/``.”h]”(hŒ#They may be tweaked at runtime via ”…”�”}”(hj¢h²hh³Nh´NubjZ)�”}”(hŒ!``/sys/module/kcsan/parameters/``”h]”hŒ/sys/module/kcsan/parameters/”…”�”}”(hjªh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj¢ubhŒ.”…”�”}”(hj¢h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´KÃhjÒh²hubeh}”(h]”Œtuning-performance”ah ]”h"]”Œtuning performance”ah$]”h&]”uh1hÖhjh²hh³hÇh´K­ubeh}”(h]”Œusage”ah ]”h"]”Œusage”ah$]”h&]”uh1hÖhhØh²hh³hÇh´K ubh×)�”}”(hhh]”(hÜ)�”}”(hŒ Data Races”h]”hŒ Data Races”…”�”}”(hjÕh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjÒh²hh³hÇh´KÆubhì)�”}”(hXaIn an execution, two memory accesses form a *data race* if they *conflict*, they happen concurrently in different threads, and at least one of them is a *plain access*; they *conflict* if both access the same memory location, and at least one is a write. For a more thorough discussion and definition, see `"Plain Accesses and Data Races" in the LKMM`_.”h]”(hŒ,In an execution, two memory accesses form a ”…”�”}”(hjãh²hh³Nh´NubhŒemphasis”“”)�”}”(hŒ *data race*”h]”hŒ data race”…”�”}”(hjíh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jëhjãubhŒ if they ”…”�”}”(hjãh²hh³Nh´Nubjì)�”}”(hŒ *conflict*”h]”hŒconflict”…”�”}”(hjÿh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jëhjãubhŒO, they happen concurrently in different threads, and at least one of them is a ”…”�”}”(hjãh²hh³Nh´Nubjì)�”}”(hŒ*plain access*”h]”hŒ plain access”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jëhjãubhŒ; they ”…”�”}”(hjãh²hh³Nh´Nubjì)�”}”(hŒ *conflict*”h]”hŒconflict”…”�”}”(hj#h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jëhjãubhŒz if both access the same memory location, and at least one is a write. For a more thorough discussion and definition, see ”…”�”}”(hjãh²hh³Nh´Nubhö)�”}”(hŒ.`"Plain Accesses and Data Races" in the LKMM`_”h]”hŒ/“Plain Accesses and Data Racesâ€� in the LKMM”…”�”}”(hj5h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”Œ+"Plain Accesses and Data Races" in the LKMM”jXŒªhttps://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/memory-model/Documentation/explanation.txt?id=8f6629c004b193d23612641c3607e785819e97ab#n2164”uh1hõhjãj KubhŒ.”…”�”}”(hjãh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´KÈhjÒh²hubjš)�”}”(hŒÛ.. _"Plain Accesses and Data Races" in the LKMM: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/memory-model/Documentation/explanation.txt?id=8f6629c004b193d23612641c3607e785819e97ab#n2164”h]”h}”(h]”Œ)plain-accesses-and-data-races-in-the-lkmm”ah ]”h"]”Œ+"plain accesses and data races" in the lkmm”ah$]”h&]”jXjEuh1j™h´KÎhjÒh²hh³hÇj§Kubh×)�”}”(hhh]”(hÜ)�”}”(hŒBRelationship with the Linux-Kernel Memory Consistency Model (LKMM)”h]”hŒBRelationship with the Linux-Kernel Memory Consistency Model (LKMM)”…”�”}”(hj_h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhj\h²hh³hÇh´KÑubhì)�”}”(hXThe LKMM defines the propagation and ordering rules of various memory operations, which gives developers the ability to reason about concurrent code. Ultimately this allows to determine the possible executions of concurrent code, and if that code is free from data races.”h]”hXThe LKMM defines the propagation and ordering rules of various memory operations, which gives developers the ability to reason about concurrent code. Ultimately this allows to determine the possible executions of concurrent code, and if that code is free from data races.”…”�”}”(hjmh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´KÓhj\h²hubhì)�”}”(hXŠKCSAN is aware of *marked atomic operations* (``READ_ONCE``, ``WRITE_ONCE``, ``atomic_*``, etc.), and a subset of ordering guarantees implied by memory barriers. With ``CONFIG_KCSAN_WEAK_MEMORY=y``, KCSAN models load or store buffering, and can detect missing ``smp_mb()``, ``smp_wmb()``, ``smp_rmb()``, ``smp_store_release()``, and all ``atomic_*`` operations with equivalent implied barriers.”h]”(hŒKCSAN is aware of ”…”�”}”(hj{h²hh³Nh´Nubjì)�”}”(hŒ*marked atomic operations*”h]”hŒmarked atomic operations”…”�”}”(hjƒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jëhj{ubhŒ (”…”�”}”(hj{h²hh³Nh´NubjZ)�”}”(hŒ ``READ_ONCE``”h]”hŒ READ_ONCE”…”�”}”(hj•h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj{ubhŒ, ”…”�”}”(hj{h²hh³Nh´NubjZ)�”}”(hŒ``WRITE_ONCE``”h]”hŒ WRITE_ONCE”…”�”}”(hj§h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj{ubhŒ, ”…”�”}”(hj{h²hh³Nh´NubjZ)�”}”(hŒ ``atomic_*``”h]”hŒatomic_*”…”�”}”(hj¹h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj{ubhŒN, etc.), and a subset of ordering guarantees implied by memory barriers. With ”…”�”}”(hj{h²hh³Nh´NubjZ)�”}”(hŒ``CONFIG_KCSAN_WEAK_MEMORY=y``”h]”hŒCONFIG_KCSAN_WEAK_MEMORY=y”…”�”}”(hjËh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj{ubhŒ?, KCSAN models load or store buffering, and can detect missing ”…”�”}”(hj{h²hh³Nh´NubjZ)�”}”(hŒ ``smp_mb()``”h]”hŒsmp_mb()”…”�”}”(hjÝh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj{ubhŒ, ”…”�”}”hj{sbjZ)�”}”(hŒ ``smp_wmb()``”h]”hŒ smp_wmb()”…”�”}”(hjïh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj{ubhŒ, ”…”�”}”hj{sbjZ)�”}”(hŒ ``smp_rmb()``”h]”hŒ smp_rmb()”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj{ubhŒ, ”…”�”}”hj{sbjZ)�”}”(hŒ``smp_store_release()``”h]”hŒsmp_store_release()”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj{ubhŒ , and all ”…”�”}”(hj{h²hh³Nh´NubjZ)�”}”(hŒ ``atomic_*``”h]”hŒatomic_*”…”�”}”(hj%h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj{ubhŒ- operations with equivalent implied barriers.”…”�”}”(hj{h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´KØhj\h²hubhì)�”}”(hX<Note, KCSAN will not report all data races due to missing memory ordering, specifically where a memory barrier would be required to prohibit subsequent memory operation from reordering before the barrier. Developers should therefore carefully consider the required memory ordering requirements that remain unchecked.”h]”hX<Note, KCSAN will not report all data races due to missing memory ordering, specifically where a memory barrier would be required to prohibit subsequent memory operation from reordering before the barrier. Developers should therefore carefully consider the required memory ordering requirements that remain unchecked.”…”�”}”(hj=h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´Kßhj\h²hubeh}”(h]”Œ@relationship-with-the-linux-kernel-memory-consistency-model-lkmm”ah ]”h"]”ŒBrelationship with the linux-kernel memory consistency model (lkmm)”ah$]”h&]”uh1hÖhjÒh²hh³hÇh´KÑubeh}”(h]”jah ]”h"]”Œ data races”ah$]”h&]”uh1hÖhhØh²hh³hÇh´KÆj§Kubh×)�”}”(hhh]”(hÜ)�”}”(hŒ Race Detection Beyond Data Races”h]”hŒ Race Detection Beyond Data Races”…”�”}”(hj]h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjZh²hh³hÇh´Kæubhì)�”}”(hX~For code with complex concurrency design, race-condition bugs may not always manifest as data races. Race conditions occur if concurrently executing operations result in unexpected system behaviour. On the other hand, data races are defined at the C-language level. The following macros can be used to check properties of concurrent code where bugs would not manifest as data races.”h]”hX~For code with complex concurrency design, race-condition bugs may not always manifest as data races. Race conditions occur if concurrently executing operations result in unexpected system behaviour. On the other hand, data races are defined at the C-language level. The following macros can be used to check properties of concurrent code where bugs would not manifest as data races.”…”�”}”(hjkh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´KèhjZh²hubhŒindex”“”)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œentries”]”(Œsingle”Œ!ASSERT_EXCLUSIVE_WRITER (C macro)”Œc.ASSERT_EXCLUSIVE_WRITER”hNt”auh1jyhjZh²hh³Nh´NubhŒdesc”“”)�”}”(hhh]”(hŒdesc_signature”“”)�”}”(hŒASSERT_EXCLUSIVE_WRITER”h]”hŒdesc_signature_line”“”)�”}”(hŒASSERT_EXCLUSIVE_WRITER”h]”hŒ desc_name”“”)�”}”(hŒASSERT_EXCLUSIVE_WRITER”h]”hŒ desc_sig_name”“”)�”}”(hj“h]”hŒASSERT_EXCLUSIVE_WRITER”…”�”}”(hj£h²hh³Nh´Nubah}”(h]”h ]”Œn”ah"]”h$]”h&]”uh1j¡hj�ubah}”(h]”h ]”(Œsig-name”Œdescname”eh"]”h$]”h&]”hÅhÆuh1j›hj—h²hh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MTubah}”(h]”h ]”h"]”h$]”h&]”hÅhÆŒ add_permalink”ˆuh1j•Œsphinx_line_type”Œ declarator”hj‘h²hh³j¹h´MTubah}”(h]”jˆah ]”(Œsig”Œ sig-object”eh"]”h$]”h&]”Œ is_multiline”ˆŒ _toc_parts”)Œ _toc_name”huh1j�h³j¹h´MThjŒh²hubhŒ desc_content”“”)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”uh1jÎhjŒh²hh³j¹h´MTubeh}”(h]”h ]”(Œc”Œmacro”eh"]”h$]”h&]”Œdomain”jÜŒobjtype”jÝŒdesctype”jÝŒnoindex”‰Œ noindexentry”‰Œnocontentsentry”‰uh1jŠh²hhjZh³Nh´Nubhì)�”}”(hŒ!``ASSERT_EXCLUSIVE_WRITER (var)``”h]”jZ)�”}”(hjéh]”hŒASSERT_EXCLUSIVE_WRITER (var)”…”�”}”(hjëh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjçubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MVhjZh²hubhŒ block_quote”“”)�”}”(hŒ'assert no concurrent writes to **var** ”h]”hì)�”}”(hŒ&assert no concurrent writes to **var**”h]”(hŒassert no concurrent writes to ”…”�”}”(hj h²hh³Nh´NubhŒstrong”“”)�”}”(hŒ**var**”h]”hŒvar”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hj ubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MThj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÿh³j# h´MThjZh²hubhŒ container”“”)�”}”(hXa**Parameters** ``var`` variable to assert on **Description** Assert that there are no concurrent writes to **var**; other readers are allowed. This assertion can be used to specify properties of concurrent code, where violation cannot be detected as a normal data race. For example, if we only have a single writer, but multiple concurrent readers, to avoid data races, all these accesses must be marked; even concurrent marked writes racing with the single writer are bugs. Unfortunately, due to being marked, they are no longer data races. For cases like these, we can use the macro as follows: .. code-block:: c void writer(void) { spin_lock(&update_foo_lock); ASSERT_EXCLUSIVE_WRITER(shared_foo); WRITE_ONCE(shared_foo, ...); spin_unlock(&update_foo_lock); } void reader(void) { // update_foo_lock does not need to be held! ... = READ_ONCE(shared_foo); } **Note** ASSERT_EXCLUSIVE_WRITER_SCOPED(), if applicable, performs more thorough checking if a clear scope where no concurrent writes are expected exists.”h]”(hì)�”}”(hŒ**Parameters**”h]”j )�”}”(hj2 h]”hŒ Parameters”…”�”}”(hj4 h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hj0 ubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MXhj, ubhŒdefinition_list”“”)�”}”(hhh]”hŒdefinition_list_item”“”)�”}”(hŒ``var`` variable to assert on ”h]”(hŒterm”“”)�”}”(hŒ``var``”h]”jZ)�”}”(hjW h]”hŒvar”…”�”}”(hjY h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjU ubah}”(h]”h ]”h"]”h$]”h&]”uh1jS h³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MphjO ubhŒ definition”“”)�”}”(hhh]”hì)�”}”(hŒvariable to assert on”h]”hŒvariable to assert on”…”�”}”(hjr h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³jl h´Mphjo ubah}”(h]”h ]”h"]”h$]”h&]”uh1jm hjO ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jM h³jl h´MphjJ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jH hj, ubhì)�”}”(hŒ**Description**”h]”j )�”}”(hj” h]”hŒ Description”…”�”}”(hj– h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hj’ ubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´Mrhj, ubhì)�”}”(hŒÐAssert that there are no concurrent writes to **var**; other readers are allowed. This assertion can be used to specify properties of concurrent code, where violation cannot be detected as a normal data race.”h]”(hŒ.Assert that there are no concurrent writes to ”…”�”}”(hjª h²hh³Nh´Nubj )�”}”(hŒ**var**”h]”hŒvar”…”�”}”(hj² h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjª ubhŒ›; other readers are allowed. This assertion can be used to specify properties of concurrent code, where violation cannot be detected as a normal data race.”…”�”}”(hjª h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MUhj, ubhì)�”}”(hXFFor example, if we only have a single writer, but multiple concurrent readers, to avoid data races, all these accesses must be marked; even concurrent marked writes racing with the single writer are bugs. Unfortunately, due to being marked, they are no longer data races. For cases like these, we can use the macro as follows:”h]”hXFFor example, if we only have a single writer, but multiple concurrent readers, to avoid data races, all these accesses must be marked; even concurrent marked writes racing with the single writer are bugs. Unfortunately, due to being marked, they are no longer data races. For cases like these, we can use the macro as follows:”…”�”}”(hjË h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MYhj, ubjB)�”}”(hX#void writer(void) { spin_lock(&update_foo_lock); ASSERT_EXCLUSIVE_WRITER(shared_foo); WRITE_ONCE(shared_foo, ...); spin_unlock(&update_foo_lock); } void reader(void) { // update_foo_lock does not need to be held! ... = READ_ONCE(shared_foo); }”h]”hX#void writer(void) { spin_lock(&update_foo_lock); ASSERT_EXCLUSIVE_WRITER(shared_foo); WRITE_ONCE(shared_foo, ...); spin_unlock(&update_foo_lock); } void reader(void) { // update_foo_lock does not need to be held! ... = READ_ONCE(shared_foo); }”…”�”}”hjÚ sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆŒforce”‰Œlanguage”jÜŒhighlight_args”}”uh1jAh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M_hj, ubhì)�”}”(hŒ**Note**”h]”j )�”}”(hjï h]”hŒNote”…”�”}”(hjñ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjí ubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´Mlhj, ubhì)�”}”(hŒ‘ASSERT_EXCLUSIVE_WRITER_SCOPED(), if applicable, performs more thorough checking if a clear scope where no concurrent writes are expected exists.”h]”hŒ‘ASSERT_EXCLUSIVE_WRITER_SCOPED(), if applicable, performs more thorough checking if a clear scope where no concurrent writes are expected exists.”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´Mmhj, ubeh}”(h]”h ]”Œ kernelindent”ah"]”h$]”h&]”uh1j* hjZh²hh³Nh´Nubjz)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œentries”]”(j†Œ(ASSERT_EXCLUSIVE_WRITER_SCOPED (C macro)”Œ c.ASSERT_EXCLUSIVE_WRITER_SCOPED”hNt”auh1jyhjZh²hh³Nh´Nubj‹)�”}”(hhh]”(j�)�”}”(hŒASSERT_EXCLUSIVE_WRITER_SCOPED”h]”j–)�”}”(hŒASSERT_EXCLUSIVE_WRITER_SCOPED”h]”jœ)�”}”(hŒASSERT_EXCLUSIVE_WRITER_SCOPED”h]”j¢)�”}”(hj. h]”hŒASSERT_EXCLUSIVE_WRITER_SCOPED”…”�”}”(hj8 h²hh³Nh´Nubah}”(h]”h ]”j­ah"]”h$]”h&]”uh1j¡hj4 ubah}”(h]”h ]”(j´jµeh"]”h$]”h&]”hÅhÆuh1j›hj0 h²hh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M„ubah}”(h]”h ]”h"]”h$]”h&]”hÅhÆjÀˆuh1j•jÁjÂhj, h²hh³jK h´M„ubah}”(h]”j' ah ]”(jÆjÇeh"]”h$]”h&]”jˈjÌ)jÍhuh1j�h³jK h´M„hj) h²hubjÏ)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”uh1jÎhj) h²hh³jK h´M„ubeh}”(h]”h ]”(jÜŒmacro”eh"]”h$]”h&]”jájÜjâjd jãjd jä‰jå‰jæ‰uh1jŠh²hhjZh³Nh´Nubhì)�”}”(hŒ(``ASSERT_EXCLUSIVE_WRITER_SCOPED (var)``”h]”jZ)�”}”(hjj h]”hŒ$ASSERT_EXCLUSIVE_WRITER_SCOPED (var)”…”�”}”(hjl h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjh ubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M†hjZh²hubj )�”}”(hŒ0assert no concurrent writes to **var** in scope ”h]”hì)�”}”(hŒ/assert no concurrent writes to **var** in scope”h]”(hŒassert no concurrent writes to ”…”�”}”(hj„ h²hh³Nh´Nubj )�”}”(hŒ**var**”h]”hŒvar”…”�”}”(hjŒ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hj„ ubhŒ in scope”…”�”}”(hj„ h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M„hj€ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÿh³j¤ h´M„hjZh²hubj+ )�”}”(hXõ**Parameters** ``var`` variable to assert on **Description** Scoped variant of ASSERT_EXCLUSIVE_WRITER(). Assert that there are no concurrent writes to **var** for the duration of the scope in which it is introduced. This provides a better way to fully cover the enclosing scope, compared to multiple ASSERT_EXCLUSIVE_WRITER(), and increases the likelihood for KCSAN to detect racing accesses. For example, it allows finding race-condition bugs that only occur due to state changes within the scope itself: .. code-block:: c void writer(void) { spin_lock(&update_foo_lock); { ASSERT_EXCLUSIVE_WRITER_SCOPED(shared_foo); WRITE_ONCE(shared_foo, 42); ... // shared_foo should still be 42 here! } spin_unlock(&update_foo_lock); } void buggy(void) { if (READ_ONCE(shared_foo) == 42) WRITE_ONCE(shared_foo, 1); // bug! }”h]”(hì)�”}”(hŒ**Parameters**”h]”j )�”}”(hj± h]”hŒ Parameters”…”�”}”(hj³ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hj¯ ubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´Mˆhj« ubjI )�”}”(hhh]”jN )�”}”(hŒ``var`` variable to assert on ”h]”(jT )�”}”(hŒ``var``”h]”jZ)�”}”(hjÐ h]”hŒvar”…”�”}”(hjÒ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjÎ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jS h³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M¡hjÊ ubjn )�”}”(hhh]”hì)�”}”(hŒvariable to assert on”h]”hŒvariable to assert on”…”�”}”(hjé h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³jå h´M¡hjæ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jm hjÊ ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jM h³jå h´M¡hjÇ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jH hj« ubhì)�”}”(hŒ**Description**”h]”j )�”}”(hj h]”hŒ Description”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hj ubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M£hj« ubhì)�”}”(hŒ,Scoped variant of ASSERT_EXCLUSIVE_WRITER().”h]”hŒ,Scoped variant of ASSERT_EXCLUSIVE_WRITER().”…”�”}”(hj! h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M…hj« ubhì)�”}”(hXAssert that there are no concurrent writes to **var** for the duration of the scope in which it is introduced. This provides a better way to fully cover the enclosing scope, compared to multiple ASSERT_EXCLUSIVE_WRITER(), and increases the likelihood for KCSAN to detect racing accesses.”h]”(hŒ.Assert that there are no concurrent writes to ”…”�”}”(hj0 h²hh³Nh´Nubj )�”}”(hŒ**var**”h]”hŒvar”…”�”}”(hj8 h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hj0 ubhŒê for the duration of the scope in which it is introduced. This provides a better way to fully cover the enclosing scope, compared to multiple ASSERT_EXCLUSIVE_WRITER(), and increases the likelihood for KCSAN to detect racing accesses.”…”�”}”(hj0 h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M‡hj« ubhì)�”}”(hŒpFor example, it allows finding race-condition bugs that only occur due to state changes within the scope itself:”h]”hŒpFor example, it allows finding race-condition bugs that only occur due to state changes within the scope itself:”…”�”}”(hjQ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MŒhj« ubjB)�”}”(hX™void writer(void) { spin_lock(&update_foo_lock); { ASSERT_EXCLUSIVE_WRITER_SCOPED(shared_foo); WRITE_ONCE(shared_foo, 42); ... // shared_foo should still be 42 here! } spin_unlock(&update_foo_lock); } void buggy(void) { if (READ_ONCE(shared_foo) == 42) WRITE_ONCE(shared_foo, 1); // bug! }”h]”hX™void writer(void) { spin_lock(&update_foo_lock); { ASSERT_EXCLUSIVE_WRITER_SCOPED(shared_foo); WRITE_ONCE(shared_foo, 42); ... // shared_foo should still be 42 here! } spin_unlock(&update_foo_lock); } void buggy(void) { if (READ_ONCE(shared_foo) == 42) WRITE_ONCE(shared_foo, 1); // bug! }”…”�”}”hj` sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆjè ‰jé jÜjê }”uh1jAh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M�hj« ubeh}”(h]”h ]”Œ kernelindent”ah"]”h$]”h&]”uh1j* hjZh²hh³Nh´Nubjz)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œentries”]”(j†Œ!ASSERT_EXCLUSIVE_ACCESS (C macro)”Œc.ASSERT_EXCLUSIVE_ACCESS”hNt”auh1jyhjZh²hh³Nh´Nubj‹)�”}”(hhh]”(j�)�”}”(hŒASSERT_EXCLUSIVE_ACCESS”h]”j–)�”}”(hŒASSERT_EXCLUSIVE_ACCESS”h]”jœ)�”}”(hŒASSERT_EXCLUSIVE_ACCESS”h]”j¢)�”}”(hjŠ h]”hŒASSERT_EXCLUSIVE_ACCESS”…”�”}”(hj” h²hh³Nh´Nubah}”(h]”h ]”j­ah"]”h$]”h&]”uh1j¡hj� ubah}”(h]”h ]”(j´jµeh"]”h$]”h&]”hÅhÆuh1j›hjŒ h²hh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M§ubah}”(h]”h ]”h"]”h$]”h&]”hÅhÆjÀˆuh1j•jÁjÂhjˆ h²hh³j§ h´M§ubah}”(h]”jƒ ah ]”(jÆjÇeh"]”h$]”h&]”jˈjÌ)jÍhuh1j�h³j§ h´M§hj… h²hubjÏ)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”uh1jÎhj… h²hh³j§ h´M§ubeh}”(h]”h ]”(jÜŒmacro”eh"]”h$]”h&]”jájÜjâjÀ jãjÀ jä‰jå‰jæ‰uh1jŠh²hhjZh³Nh´Nubhì)�”}”(hŒ!``ASSERT_EXCLUSIVE_ACCESS (var)``”h]”jZ)�”}”(hjÆ h]”hŒASSERT_EXCLUSIVE_ACCESS (var)”…”�”}”(hjÈ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjÄ ubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M©hjZh²hubj )�”}”(hŒ)assert no concurrent accesses to **var** ”h]”hì)�”}”(hŒ(assert no concurrent accesses to **var**”h]”(hŒ!assert no concurrent accesses to ”…”�”}”(hjà h²hh³Nh´Nubj )�”}”(hŒ**var**”h]”hŒvar”…”�”}”(hjè h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjà ubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M§hjÜ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÿh³jü h´M§hjZh²hubj+ )�”}”(hX±**Parameters** ``var`` variable to assert on **Description** Assert that there are no concurrent accesses to **var** (no readers nor writers). This assertion can be used to specify properties of concurrent code, where violation cannot be detected as a normal data race. For example, where exclusive access is expected after determining no other users of an object are left, but the object is not actually freed. We can check that this property actually holds as follows: .. code-block:: c if (refcount_dec_and_test(&obj->refcnt)) { ASSERT_EXCLUSIVE_ACCESS(*obj); do_some_cleanup(obj); release_for_reuse(obj); } **Note** 1. ASSERT_EXCLUSIVE_ACCESS_SCOPED(), if applicable, performs more thorough checking if a clear scope where no concurrent accesses are expected exists. 2. For cases where the object is freed, `KASAN `_ is a better fit to detect use-after-free bugs.”h]”(hì)�”}”(hŒ**Parameters**”h]”j )�”}”(hj h]”hŒ Parameters”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hj ubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M«hj ubjI )�”}”(hhh]”jN )�”}”(hŒ``var`` variable to assert on ”h]”(jT )�”}”(hŒ``var``”h]”jZ)�”}”(hj( h]”hŒvar”…”�”}”(hj* h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj& ubah}”(h]”h ]”h"]”h$]”h&]”uh1jS h³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MÁhj" ubjn )�”}”(hhh]”hì)�”}”(hŒvariable to assert on”h]”hŒvariable to assert on”…”�”}”(hjA h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³j= h´MÁhj> ubah}”(h]”h ]”h"]”h$]”h&]”uh1jm hj" ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jM h³j= h´MÁhj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jH hj ubhì)�”}”(hŒ**Description**”h]”j )�”}”(hjc h]”hŒ Description”…”�”}”(hje h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hja ubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MÃhj ubhì)�”}”(hŒÐAssert that there are no concurrent accesses to **var** (no readers nor writers). This assertion can be used to specify properties of concurrent code, where violation cannot be detected as a normal data race.”h]”(hŒ0Assert that there are no concurrent accesses to ”…”�”}”(hjy h²hh³Nh´Nubj )�”}”(hŒ**var**”h]”hŒvar”…”�”}”(hj� h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjy ubhŒ™ (no readers nor writers). This assertion can be used to specify properties of concurrent code, where violation cannot be detected as a normal data race.”…”�”}”(hjy h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M¨hj ubhì)�”}”(hŒÈFor example, where exclusive access is expected after determining no other users of an object are left, but the object is not actually freed. We can check that this property actually holds as follows:”h]”hŒÈFor example, where exclusive access is expected after determining no other users of an object are left, but the object is not actually freed. We can check that this property actually holds as follows:”…”�”}”(hjš h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M¬hj ubjB)�”}”(hŒ‘if (refcount_dec_and_test(&obj->refcnt)) { ASSERT_EXCLUSIVE_ACCESS(*obj); do_some_cleanup(obj); release_for_reuse(obj); }”h]”hŒ‘if (refcount_dec_and_test(&obj->refcnt)) { ASSERT_EXCLUSIVE_ACCESS(*obj); do_some_cleanup(obj); release_for_reuse(obj); }”…”�”}”hj© sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆjè ‰jé jÜjê }”uh1jAh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M°hj ubhì)�”}”(hŒ**Note**”h]”j )�”}”(hj» h]”hŒNote”…”�”}”(hj½ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hj¹ ubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M¸hj ubhŒenumerated_list”“”)�”}”(hhh]”(j)�”}”(hŒ”ASSERT_EXCLUSIVE_ACCESS_SCOPED(), if applicable, performs more thorough checking if a clear scope where no concurrent accesses are expected exists. ”h]”hì)�”}”(hŒ“ASSERT_EXCLUSIVE_ACCESS_SCOPED(), if applicable, performs more thorough checking if a clear scope where no concurrent accesses are expected exists.”h]”hŒ“ASSERT_EXCLUSIVE_ACCESS_SCOPED(), if applicable, performs more thorough checking if a clear scope where no concurrent accesses are expected exists.”…”�”}”(hjÚ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M¹hjÖ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÓ ubj)�”}”(hŒiFor cases where the object is freed, `KASAN `_ is a better fit to detect use-after-free bugs.”h]”hì)�”}”(hŒiFor cases where the object is freed, `KASAN `_ is a better fit to detect use-after-free bugs.”h]”(hŒ%For cases where the object is freed, ”…”�”}”(hjó h²hh³Nh´Nubhö)�”}”(hŒ`KASAN `_”h]”hŒKASAN”…”�”}”(hjû h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”ŒKASAN”jXŒ kasan.html”uh1hõhjó ubjš)�”}”(hŒ ”h]”h}”(h]”Œkasan”ah ]”h"]”Œkasan”ah$]”h&]”Œrefuri”j uh1j™j§Khjó ubhŒ/ is a better fit to detect use-after-free bugs.”…”�”}”(hjó h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M¼hjï ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÓ ubeh}”(h]”h ]”h"]”h$]”h&]”Œenumtype”Œarabic”Œprefix”hŒsuffix”Œ.”uh1jÑ hj ubeh}”(h]”h ]”Œ kernelindent”ah"]”h$]”h&]”uh1j* hjZh²hh³Nh´Nubjz)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œentries”]”(j†Œ(ASSERT_EXCLUSIVE_ACCESS_SCOPED (C macro)”Œ c.ASSERT_EXCLUSIVE_ACCESS_SCOPED”hNt”auh1jyhjZh²hh³Nh´Nubj‹)�”}”(hhh]”(j�)�”}”(hŒASSERT_EXCLUSIVE_ACCESS_SCOPED”h]”j–)�”}”(hŒASSERT_EXCLUSIVE_ACCESS_SCOPED”h]”jœ)�”}”(hŒASSERT_EXCLUSIVE_ACCESS_SCOPED”h]”j¢)�”}”(hjO h]”hŒASSERT_EXCLUSIVE_ACCESS_SCOPED”…”�”}”(hjY h²hh³Nh´Nubah}”(h]”h ]”j­ah"]”h$]”h&]”uh1j¡hjU ubah}”(h]”h ]”(j´jµeh"]”h$]”h&]”hÅhÆuh1j›hjQ h²hh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MÇubah}”(h]”h ]”h"]”h$]”h&]”hÅhÆjÀˆuh1j•jÁjÂhjM h²hh³jl h´MÇubah}”(h]”jH ah ]”(jÆjÇeh"]”h$]”h&]”jˈjÌ)jÍhuh1j�h³jl h´MÇhjJ h²hubjÏ)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”uh1jÎhjJ h²hh³jl h´MÇubeh}”(h]”h ]”(jÜŒmacro”eh"]”h$]”h&]”jájÜjâj… jãj… jä‰jå‰jæ‰uh1jŠh²hhjZh³Nh´Nubhì)�”}”(hŒ(``ASSERT_EXCLUSIVE_ACCESS_SCOPED (var)``”h]”jZ)�”}”(hj‹ h]”hŒ$ASSERT_EXCLUSIVE_ACCESS_SCOPED (var)”…”�”}”(hj� h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj‰ ubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MÉhjZh²hubj )�”}”(hŒ2assert no concurrent accesses to **var** in scope ”h]”hì)�”}”(hŒ1assert no concurrent accesses to **var** in scope”h]”(hŒ!assert no concurrent accesses to ”…”�”}”(hj¥ h²hh³Nh´Nubj )�”}”(hŒ**var**”h]”hŒvar”…”�”}”(hj­ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hj¥ ubhŒ in scope”…”�”}”(hj¥ h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MÇhj¡ ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÿh³jÅ h´MÇhjZh²hubj+ )�”}”(hX±**Parameters** ``var`` variable to assert on **Description** Scoped variant of ASSERT_EXCLUSIVE_ACCESS(). Assert that there are no concurrent accesses to **var** (no readers nor writers) for the entire duration of the scope in which it is introduced. This provides a better way to fully cover the enclosing scope, compared to multiple ASSERT_EXCLUSIVE_ACCESS(), and increases the likelihood for KCSAN to detect racing accesses.”h]”(hì)�”}”(hŒ**Parameters**”h]”j )�”}”(hjÒ h]”hŒ Parameters”…”�”}”(hjÔ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjÐ ubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MËhjÌ ubjI )�”}”(hhh]”jN )�”}”(hŒ``var`` variable to assert on ”h]”(jT )�”}”(hŒ``var``”h]”jZ)�”}”(hjñ h]”hŒvar”…”�”}”(hjó h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjï ubah}”(h]”h ]”h"]”h$]”h&]”uh1jS h³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”•8šh´MÑhjë ubjn )�”}”(hhh]”hì)�”}”(hŒvariable to assert on”h]”hŒvariable to assert on”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³jh´MÑhjubah}”(h]”h ]”h"]”h$]”h&]”uh1jm hjë ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jM h³jh´MÑhjè ubah}”(h]”h ]”h"]”h$]”h&]”uh1jH hjÌ ubhì)�”}”(hŒ**Description**”h]”j )�”}”(hj,h]”hŒ Description”…”�”}”(hj.h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hj*ubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MÓhjÌ ubhì)�”}”(hŒ,Scoped variant of ASSERT_EXCLUSIVE_ACCESS().”h]”hŒ,Scoped variant of ASSERT_EXCLUSIVE_ACCESS().”…”�”}”(hjBh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MÈhjÌ ubhì)�”}”(hXAAssert that there are no concurrent accesses to **var** (no readers nor writers) for the entire duration of the scope in which it is introduced. This provides a better way to fully cover the enclosing scope, compared to multiple ASSERT_EXCLUSIVE_ACCESS(), and increases the likelihood for KCSAN to detect racing accesses.”h]”(hŒ0Assert that there are no concurrent accesses to ”…”�”}”(hjQh²hh³Nh´Nubj )�”}”(hŒ**var**”h]”hŒvar”…”�”}”(hjYh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjQubhX  (no readers nor writers) for the entire duration of the scope in which it is introduced. This provides a better way to fully cover the enclosing scope, compared to multiple ASSERT_EXCLUSIVE_ACCESS(), and increases the likelihood for KCSAN to detect racing accesses.”…”�”}”(hjQh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MÊhjÌ ubeh}”(h]”h ]”Œ kernelindent”ah"]”h$]”h&]”uh1j* hjZh²hh³Nh´Nubjz)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œentries”]”(j†ŒASSERT_EXCLUSIVE_BITS (C macro)”Œc.ASSERT_EXCLUSIVE_BITS”hNt”auh1jyhjZh²hh³Nh´Nubj‹)�”}”(hhh]”(j�)�”}”(hŒASSERT_EXCLUSIVE_BITS”h]”j–)�”}”(hŒASSERT_EXCLUSIVE_BITS”h]”jœ)�”}”(hŒASSERT_EXCLUSIVE_BITS”h]”j¢)�”}”(hjŒh]”hŒASSERT_EXCLUSIVE_BITS”…”�”}”(hj–h²hh³Nh´Nubah}”(h]”h ]”j­ah"]”h$]”h&]”uh1j¡hj’ubah}”(h]”h ]”(j´jµeh"]”h$]”h&]”hÅhÆuh1j›hjŽh²hh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M×ubah}”(h]”h ]”h"]”h$]”h&]”hÅhÆjÀˆuh1j•jÁjÂhjŠh²hh³j©h´M×ubah}”(h]”j…ah ]”(jÆjÇeh"]”h$]”h&]”jˈjÌ)jÍhuh1j�h³j©h´M×hj‡h²hubjÏ)�”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”uh1jÎhj‡h²hh³j©h´M×ubeh}”(h]”h ]”(jÜŒmacro”eh"]”h$]”h&]”jájÜjâjÂjãjÂjä‰jå‰jæ‰uh1jŠh²hhjZh³Nh´Nubhì)�”}”(hŒ%``ASSERT_EXCLUSIVE_BITS (var, mask)``”h]”jZ)�”}”(hjÈh]”hŒ!ASSERT_EXCLUSIVE_BITS (var, mask)”…”�”}”(hjÊh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjÆubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MÙhjZh²hubj )�”}”(hŒ9assert no concurrent writes to subset of bits in **var** ”h]”hì)�”}”(hŒ8assert no concurrent writes to subset of bits in **var**”h]”(hŒ1assert no concurrent writes to subset of bits in ”…”�”}”(hjâh²hh³Nh´Nubj )�”}”(hŒ**var**”h]”hŒvar”…”�”}”(hjêh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjâubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M×hjÞubah}”(h]”h ]”h"]”h$]”h&]”uh1jÿh³jþh´M×hjZh²hubj+ )�”}”(hXÁ**Parameters** ``var`` variable to assert on ``mask`` only check for modifications to bits set in **mask** **Description** Bit-granular variant of ASSERT_EXCLUSIVE_WRITER(). Assert that there are no concurrent writes to a subset of bits in **var**; concurrent readers are permitted. This assertion captures more detailed bit-level properties, compared to the other (word granularity) assertions. Only the bits set in **mask** are checked for concurrent modifications, while ignoring the remaining bits, i.e. concurrent writes (or reads) to ~mask bits are ignored. Use this for variables, where some bits must not be modified concurrently, yet other bits are expected to be modified concurrently. For example, variables where, after initialization, some bits are read-only, but other bits may still be modified concurrently. A reader may wish to assert that this is true as follows: .. code-block:: c ASSERT_EXCLUSIVE_BITS(flags, READ_ONLY_MASK); foo = (READ_ONCE(flags) & READ_ONLY_MASK) >> READ_ONLY_SHIFT; **Note** The access that immediately follows ASSERT_EXCLUSIVE_BITS() is assumed to access the masked bits only, and KCSAN optimistically assumes it is therefore safe, even in the presence of data races, and marking it with READ_ONCE() is optional from KCSAN's point-of-view. We caution, however, that it may still be advisable to do so, since we cannot reason about all compiler optimizations when it comes to bit manipulations (on the reader and writer side). If you are sure nothing can go wrong, we can write the above simply as: .. code-block:: c ASSERT_EXCLUSIVE_BITS(flags, READ_ONLY_MASK); foo = (flags & READ_ONLY_MASK) >> READ_ONLY_SHIFT; Another example, where this may be used, is when certain bits of **var** may only be modified when holding the appropriate lock, but other bits may still be modified concurrently. Writers, where other bits may change concurrently, could use the assertion as follows: .. code-block:: c spin_lock(&foo_lock); ASSERT_EXCLUSIVE_BITS(flags, FOO_MASK); old_flags = flags; new_flags = (old_flags & ~FOO_MASK) | (new_foo << FOO_SHIFT); if (cmpxchg(&flags, old_flags, new_flags) != old_flags) { ... } spin_unlock(&foo_lock);”h]”(hì)�”}”(hŒ**Parameters**”h]”j )�”}”(hj h]”hŒ Parameters”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hj ubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MÛhjubjI )�”}”(hhh]”(jN )�”}”(hŒ``var`` variable to assert on ”h]”(jT )�”}”(hŒ``var``”h]”jZ)�”}”(hj*h]”hŒvar”…”�”}”(hj,h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhj(ubah}”(h]”h ]”h"]”h$]”h&]”uh1jS h³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M hj$ubjn )�”}”(hhh]”hì)�”}”(hŒvariable to assert on”h]”hŒvariable to assert on”…”�”}”(hjCh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³j?h´M hj@ubah}”(h]”h ]”h"]”h$]”h&]”uh1jm hj$ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jM h³j?h´M hj!ubjN )�”}”(hŒ>``mask`` only check for modifications to bits set in **mask** ”h]”(jT )�”}”(hŒ``mask``”h]”jZ)�”}”(hjch]”hŒmask”…”�”}”(hjeh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjaubah}”(h]”h ]”h"]”h$]”h&]”uh1jS h³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M hj]ubjn )�”}”(hhh]”hì)�”}”(hŒ4only check for modifications to bits set in **mask**”h]”(hŒ,only check for modifications to bits set in ”…”�”}”(hj|h²hh³Nh´Nubj )�”}”(hŒ**mask**”h]”hŒmask”…”�”}”(hj„h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hj|ubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³jxh´M hjyubah}”(h]”h ]”h"]”h$]”h&]”uh1jm hj]ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jM h³jxh´M hj!ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jH hjubhì)�”}”(hŒ**Description**”h]”j )�”}”(hj¬h]”hŒ Description”…”�”}”(hj®h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjªubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M hjubhì)�”}”(hŒ2Bit-granular variant of ASSERT_EXCLUSIVE_WRITER().”h]”hŒ2Bit-granular variant of ASSERT_EXCLUSIVE_WRITER().”…”�”}”(hjÂh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MØhjubhì)�”}”(hX…Assert that there are no concurrent writes to a subset of bits in **var**; concurrent readers are permitted. This assertion captures more detailed bit-level properties, compared to the other (word granularity) assertions. Only the bits set in **mask** are checked for concurrent modifications, while ignoring the remaining bits, i.e. concurrent writes (or reads) to ~mask bits are ignored.”h]”(hŒBAssert that there are no concurrent writes to a subset of bits in ”…”�”}”(hjÑh²hh³Nh´Nubj )�”}”(hŒ**var**”h]”hŒvar”…”�”}”(hjÙh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjÑubhŒª; concurrent readers are permitted. This assertion captures more detailed bit-level properties, compared to the other (word granularity) assertions. Only the bits set in ”…”�”}”(hjÑh²hh³Nh´Nubj )�”}”(hŒ**mask**”h]”hŒmask”…”�”}”(hjëh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjÑubhŒŠ are checked for concurrent modifications, while ignoring the remaining bits, i.e. concurrent writes (or reads) to ~mask bits are ignored.”…”�”}”(hjÑh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MÚhjubhì)�”}”(hŒƒUse this for variables, where some bits must not be modified concurrently, yet other bits are expected to be modified concurrently.”h]”hŒƒUse this for variables, where some bits must not be modified concurrently, yet other bits are expected to be modified concurrently.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´Máhjubhì)�”}”(hŒ¹For example, variables where, after initialization, some bits are read-only, but other bits may still be modified concurrently. A reader may wish to assert that this is true as follows:”h]”hŒ¹For example, variables where, after initialization, some bits are read-only, but other bits may still be modified concurrently. A reader may wish to assert that this is true as follows:”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MähjubjB)�”}”(hŒkASSERT_EXCLUSIVE_BITS(flags, READ_ONLY_MASK); foo = (READ_ONCE(flags) & READ_ONLY_MASK) >> READ_ONLY_SHIFT;”h]”hŒkASSERT_EXCLUSIVE_BITS(flags, READ_ONLY_MASK); foo = (READ_ONCE(flags) & READ_ONLY_MASK) >> READ_ONLY_SHIFT;”…”�”}”hj"sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆjè ‰jé jÜjê }”uh1jAh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´Mèhjubhì)�”}”(hŒ**Note**”h]”j )�”}”(hj4h]”hŒNote”…”�”}”(hj6h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hj2ubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´Míhjubhì)�”}”(hX The access that immediately follows ASSERT_EXCLUSIVE_BITS() is assumed to access the masked bits only, and KCSAN optimistically assumes it is therefore safe, even in the presence of data races, and marking it with READ_ONCE() is optional from KCSAN's point-of-view. We caution, however, that it may still be advisable to do so, since we cannot reason about all compiler optimizations when it comes to bit manipulations (on the reader and writer side). If you are sure nothing can go wrong, we can write the above simply as:”h]”hX The access that immediately follows ASSERT_EXCLUSIVE_BITS() is assumed to access the masked bits only, and KCSAN optimistically assumes it is therefore safe, even in the presence of data races, and marking it with READ_ONCE() is optional from KCSAN’s point-of-view. We caution, however, that it may still be advisable to do so, since we cannot reason about all compiler optimizations when it comes to bit manipulations (on the reader and writer side). If you are sure nothing can go wrong, we can write the above simply as:”…”�”}”(hjJh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MîhjubjB)�”}”(hŒ`ASSERT_EXCLUSIVE_BITS(flags, READ_ONLY_MASK); foo = (flags & READ_ONLY_MASK) >> READ_ONLY_SHIFT;”h]”hŒ`ASSERT_EXCLUSIVE_BITS(flags, READ_ONLY_MASK); foo = (flags & READ_ONLY_MASK) >> READ_ONLY_SHIFT;”…”�”}”hjYsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆjè ‰jé jÜjê }”uh1jAh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´M÷hjubhì)�”}”(hX Another example, where this may be used, is when certain bits of **var** may only be modified when holding the appropriate lock, but other bits may still be modified concurrently. Writers, where other bits may change concurrently, could use the assertion as follows:”h]”(hŒAAnother example, where this may be used, is when certain bits of ”…”�”}”(hjih²hh³Nh´Nubj )�”}”(hŒ**var**”h]”hŒvar”…”�”}”(hjqh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjiubhŒÂ may only be modified when holding the appropriate lock, but other bits may still be modified concurrently. Writers, where other bits may change concurrently, could use the assertion as follows:”…”�”}”(hjih²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´MühjubjB)�”}”(hŒæspin_lock(&foo_lock); ASSERT_EXCLUSIVE_BITS(flags, FOO_MASK); old_flags = flags; new_flags = (old_flags & ~FOO_MASK) | (new_foo << FOO_SHIFT); if (cmpxchg(&flags, old_flags, new_flags) != old_flags) { ... } spin_unlock(&foo_lock);”h]”hŒæspin_lock(&foo_lock); ASSERT_EXCLUSIVE_BITS(flags, FOO_MASK); old_flags = flags; new_flags = (old_flags & ~FOO_MASK) | (new_foo << FOO_SHIFT); if (cmpxchg(&flags, old_flags, new_flags) != old_flags) { ... } spin_unlock(&foo_lock);”…”�”}”hjŠsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆjè ‰jé jÜjê }”uh1jAh³Œ]/var/lib/git/docbuild/linux/Documentation/dev-tools/kcsan:238: ./include/linux/kcsan-checks.h”h´Mhjubeh}”(h]”h ]”Œ kernelindent”ah"]”h$]”h&]”uh1j* hjZh²hh³Nh´Nubeh}”(h]”Œ race-detection-beyond-data-races”ah ]”h"]”Œ race detection beyond data races”ah$]”h&]”uh1hÖhhØh²hh³hÇh´Kæubh×)�”}”(hhh]”(hÜ)�”}”(hŒImplementation Details”h]”hŒImplementation Details”…”�”}”(hj¬h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhj©h²hh³hÇh´Kôubhì)�”}”(hXCKCSAN relies on observing that two accesses happen concurrently. Crucially, we want to (a) increase the chances of observing races (especially for races that manifest rarely), and (b) be able to actually observe them. We can accomplish (a) by injecting various delays, and (b) by using address watchpoints (or breakpoints).”h]”hXCKCSAN relies on observing that two accesses happen concurrently. Crucially, we want to (a) increase the chances of observing races (especially for races that manifest rarely), and (b) be able to actually observe them. We can accomplish (a) by injecting various delays, and (b) by using address watchpoints (or breakpoints).”…”�”}”(hjºh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´Köhj©h²hubhì)�”}”(hXÉIf we deliberately stall a memory access, while we have a watchpoint for its address set up, and then observe the watchpoint to fire, two accesses to the same address just raced. Using hardware watchpoints, this is the approach taken in `DataCollider `_. Unlike DataCollider, KCSAN does not use hardware watchpoints, but instead relies on compiler instrumentation and "soft watchpoints".”h]”(hŒíIf we deliberately stall a memory access, while we have a watchpoint for its address set up, and then observe the watchpoint to fire, two accesses to the same address just raced. Using hardware watchpoints, this is the approach taken in ”…”�”}”(hjÈh²hh³Nh´Nubhö)�”}”(hŒV`DataCollider `_”h]”hŒ DataCollider”…”�”}”(hjÐh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”Œ DataCollider”jXŒDhttp://usenix.org/legacy/events/osdi10/tech/full_papers/Erickson.pdf”uh1hõhjÈubjš)�”}”(hŒG ”h]”h}”(h]”Œ datacollider”ah ]”h"]”Œ datacollider”ah$]”h&]”Œrefuri”jàuh1j™j§KhjÈubhŒŠ. Unlike DataCollider, KCSAN does not use hardware watchpoints, but instead relies on compiler instrumentation and “soft watchpointsâ€�.”…”�”}”(hjÈh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´Kühj©h²hubhì)�”}”(hX-In KCSAN, watchpoints are implemented using an efficient encoding that stores access type, size, and address in a long; the benefits of using "soft watchpoints" are portability and greater flexibility. KCSAN then relies on the compiler instrumenting plain accesses. For each instrumented plain access:”h]”hX1In KCSAN, watchpoints are implemented using an efficient encoding that stores access type, size, and address in a long; the benefits of using “soft watchpointsâ€� are portability and greater flexibility. KCSAN then relies on the compiler instrumenting plain accesses. For each instrumented plain access:”…”�”}”(hjøh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´Mhj©h²hubjÒ )�”}”(hhh]”(j)�”}”(hŒxCheck if a matching watchpoint exists; if yes, and at least one access is a write, then we encountered a racing access. ”h]”hì)�”}”(hŒwCheck if a matching watchpoint exists; if yes, and at least one access is a write, then we encountered a racing access.”h]”hŒwCheck if a matching watchpoint exists; if yes, and at least one access is a write, then we encountered a racing access.”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´M hj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjh²hh³hÇh´Nubj)�”}”(hŒlPeriodically, if no matching watchpoint exists, set up a watchpoint and stall for a small randomized delay. ”h]”hì)�”}”(hŒkPeriodically, if no matching watchpoint exists, set up a watchpoint and stall for a small randomized delay.”h]”hŒkPeriodically, if no matching watchpoint exists, set up a watchpoint and stall for a small randomized delay.”…”�”}”(hj%h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´M hj!ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjh²hh³hÇh´Nubj)�”}”(hŒ�Also check the data value before the delay, and re-check the data value after delay; if the values mismatch, we infer a race of unknown origin. ”h]”hì)�”}”(hŒ�Also check the data value before the delay, and re-check the data value after delay; if the values mismatch, we infer a race of unknown origin.”h]”hŒ�Also check the data value before the delay, and re-check the data value after delay; if the values mismatch, we infer a race of unknown origin.”…”�”}”(hj=h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´Mhj9ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjh²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”j0 j1 j2 hj3 j4 uh1jÑ hj©h²hh³hÇh´M ubhì)�”}”(hX˜To detect data races between plain and marked accesses, KCSAN also annotates marked accesses, but only to check if a watchpoint exists; i.e. KCSAN never sets up a watchpoint on marked accesses. By never setting up watchpoints for marked operations, if all accesses to a variable that is accessed concurrently are properly marked, KCSAN will never trigger a watchpoint and therefore never report the accesses.”h]”hX˜To detect data races between plain and marked accesses, KCSAN also annotates marked accesses, but only to check if a watchpoint exists; i.e. KCSAN never sets up a watchpoint on marked accesses. By never setting up watchpoints for marked operations, if all accesses to a variable that is accessed concurrently are properly marked, KCSAN will never trigger a watchpoint and therefore never report the accesses.”…”�”}”(hjWh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´Mhj©h²hubh×)�”}”(hhh]”(hÜ)�”}”(hŒModeling Weak Memory”h]”hŒModeling Weak Memory”…”�”}”(hjhh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjeh²hh³hÇh´Mubhì)�”}”(hX9KCSAN's approach to detecting data races due to missing memory barriers is based on modeling access reordering (with ``CONFIG_KCSAN_WEAK_MEMORY=y``). Each plain memory access for which a watchpoint is set up, is also selected for simulated reordering within the scope of its function (at most 1 in-flight access).”h]”(hŒwKCSAN’s approach to detecting data races due to missing memory barriers is based on modeling access reordering (with ”…”�”}”(hjvh²hh³Nh´NubjZ)�”}”(hŒ``CONFIG_KCSAN_WEAK_MEMORY=y``”h]”hŒCONFIG_KCSAN_WEAK_MEMORY=y”…”�”}”(hj~h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjvubhŒ¦). Each plain memory access for which a watchpoint is set up, is also selected for simulated reordering within the scope of its function (at most 1 in-flight access).”…”�”}”(hjvh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´Mhjeh²hubhì)�”}”(hŒïOnce an access has been selected for reordering, it is checked along every other access until the end of the function scope. If an appropriate memory barrier is encountered, the access will no longer be considered for simulated reordering.”h]”hŒïOnce an access has been selected for reordering, it is checked along every other access until the end of the function scope. If an appropriate memory barrier is encountered, the access will no longer be considered for simulated reordering.”…”�”}”(hj–h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´M"hjeh²hubhì)�”}”(hŒ¾When the result of a memory operation should be ordered by a barrier, KCSAN can then detect data races where the conflict only occurs as a result of a missing barrier. Consider the example::”h]”hŒ½When the result of a memory operation should be ordered by a barrier, KCSAN can then detect data races where the conflict only occurs as a result of a missing barrier. Consider the example:”…”�”}”(hj¤h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´M'hjeh²hubjB)�”}”(hXint x, flag; void T1(void) { x = 1; // data race! WRITE_ONCE(flag, 1); // correct: smp_store_release(&flag, 1) } void T2(void) { while (!READ_ONCE(flag)); // correct: smp_load_acquire(&flag) ... = x; // data race! }”h]”hXint x, flag; void T1(void) { x = 1; // data race! WRITE_ONCE(flag, 1); // correct: smp_store_release(&flag, 1) } void T2(void) { while (!READ_ONCE(flag)); // correct: smp_load_acquire(&flag) ... = x; // data race! }”…”�”}”hj²sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jAh³hÇh´M+hjeh²hubhì)�”}”(hX¢When weak memory modeling is enabled, KCSAN can consider ``x`` in ``T1`` for simulated reordering. After the write of ``flag``, ``x`` is again checked for concurrent accesses: because ``T2`` is able to proceed after the write of ``flag``, a data race is detected. With the correct barriers in place, ``x`` would not be considered for reordering after the proper release of ``flag``, and no data race would be detected.”h]”(hŒ9When weak memory modeling is enabled, KCSAN can consider ”…”�”}”(hjÀh²hh³Nh´NubjZ)�”}”(hŒ``x``”h]”hŒx”…”�”}”(hjÈh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjÀubhŒ in ”…”�”}”(hjÀh²hh³Nh´NubjZ)�”}”(hŒ``T1``”h]”hŒT1”…”�”}”(hjÚh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjÀubhŒ. for simulated reordering. After the write of ”…”�”}”(hjÀh²hh³Nh´NubjZ)�”}”(hŒ``flag``”h]”hŒflag”…”�”}”(hjìh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjÀubhŒ, ”…”�”}”(hjÀh²hh³Nh´NubjZ)�”}”(hŒ``x``”h]”hŒx”…”�”}”(hjþh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjÀubhŒ3 is again checked for concurrent accesses: because ”…”�”}”(hjÀh²hh³Nh´NubjZ)�”}”(hŒ``T2``”h]”hŒT2”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjÀubhŒ' is able to proceed after the write of ”…”�”}”(hjÀh²hh³Nh´NubjZ)�”}”(hŒ``flag``”h]”hŒflag”…”�”}”(hj"h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjÀubhŒ?, a data race is detected. With the correct barriers in place, ”…”�”}”(hjÀh²hh³Nh´NubjZ)�”}”(hŒ``x``”h]”hŒx”…”�”}”(hj4h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjÀubhŒD would not be considered for reordering after the proper release of ”…”�”}”(hjÀh²hh³Nh´NubjZ)�”}”(hŒ``flag``”h]”hŒflag”…”�”}”(hjFh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjÀubhŒ%, and no data race would be detected.”…”�”}”(hjÀh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´M7hjeh²hubhì)�”}”(hXÿDeliberate trade-offs in complexity but also practical limitations mean only a subset of data races due to missing memory barriers can be detected. With currently available compiler support, the implementation is limited to modeling the effects of "buffering" (delaying accesses), since the runtime cannot "prefetch" accesses. Also recall that watchpoints are only set up for plain accesses, and the only access type for which KCSAN simulates reordering. This means reordering of marked accesses is not modeled.”h]”hXDeliberate trade-offs in complexity but also practical limitations mean only a subset of data races due to missing memory barriers can be detected. With currently available compiler support, the implementation is limited to modeling the effects of “bufferingâ€� (delaying accesses), since the runtime cannot “prefetchâ€� accesses. Also recall that watchpoints are only set up for plain accesses, and the only access type for which KCSAN simulates reordering. This means reordering of marked accesses is not modeled.”…”�”}”(hj^h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´M>hjeh²hubhì)�”}”(hX/A consequence of the above is that acquire operations do not require barrier instrumentation (no prefetching). Furthermore, marked accesses introducing address or control dependencies do not require special handling (the marked access cannot be reordered, later dependent accesses cannot be prefetched).”h]”hX/A consequence of the above is that acquire operations do not require barrier instrumentation (no prefetching). Furthermore, marked accesses introducing address or control dependencies do not require special handling (the marked access cannot be reordered, later dependent accesses cannot be prefetched).”…”�”}”(hjlh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´MFhjeh²hubeh}”(h]”Œmodeling-weak-memory”ah ]”h"]”Œmodeling weak memory”ah$]”h&]”uh1hÖhj©h²hh³hÇh´Mubh×)�”}”(hhh]”(hÜ)�”}”(hŒKey Properties”h]”hŒKey Properties”…”�”}”(hj…h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhj‚h²hh³hÇh´MLubjÒ )�”}”(hhh]”(j)�”}”(hŒÎ**Memory Overhead:** The overall memory overhead is only a few MiB depending on configuration. The current implementation uses a small array of longs to encode watchpoint information, which is negligible. ”h]”hì)�”}”(hŒÍ**Memory Overhead:** The overall memory overhead is only a few MiB depending on configuration. The current implementation uses a small array of longs to encode watchpoint information, which is negligible.”h]”(j )�”}”(hŒ**Memory Overhead:**”h]”hŒMemory Overhead:”…”�”}”(hjžh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjšubhŒ¹ The overall memory overhead is only a few MiB depending on configuration. The current implementation uses a small array of longs to encode watchpoint information, which is negligible.”…”�”}”(hjšh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´MNhj–ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj“h²hh³hÇh´Nubj)�”}”(hXŠ**Performance Overhead:** KCSAN's runtime aims to be minimal, using an efficient watchpoint encoding that does not require acquiring any shared locks in the fast-path. For kernel boot on a system with 8 CPUs: - 5.0x slow-down with the default KCSAN config; - 2.8x slow-down from runtime fast-path overhead only (set very large ``KCSAN_SKIP_WATCH`` and unset ``KCSAN_SKIP_WATCH_RANDOMIZE``). ”h]”(hì)�”}”(hŒÐ**Performance Overhead:** KCSAN's runtime aims to be minimal, using an efficient watchpoint encoding that does not require acquiring any shared locks in the fast-path. For kernel boot on a system with 8 CPUs:”h]”(j )�”}”(hŒ**Performance Overhead:**”h]”hŒPerformance Overhead:”…”�”}”(hjÄh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjÀubhŒ¹ KCSAN’s runtime aims to be minimal, using an efficient watchpoint encoding that does not require acquiring any shared locks in the fast-path. For kernel boot on a system with 8 CPUs:”…”�”}”(hjÀh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´MRhj¼ubj)�”}”(hhh]”(j)�”}”(hŒ-5.0x slow-down with the default KCSAN config;”h]”hì)�”}”(hjáh]”hŒ-5.0x slow-down with the default KCSAN config;”…”�”}”(hjãh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´MVhjßubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÜubj)�”}”(hŒ„2.8x slow-down from runtime fast-path overhead only (set very large ``KCSAN_SKIP_WATCH`` and unset ``KCSAN_SKIP_WATCH_RANDOMIZE``). ”h]”hì)�”}”(hŒƒ2.8x slow-down from runtime fast-path overhead only (set very large ``KCSAN_SKIP_WATCH`` and unset ``KCSAN_SKIP_WATCH_RANDOMIZE``).”h]”(hŒD2.8x slow-down from runtime fast-path overhead only (set very large ”…”�”}”(hjúh²hh³Nh´NubjZ)�”}”(hŒ``KCSAN_SKIP_WATCH``”h]”hŒKCSAN_SKIP_WATCH”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjúubhŒ and unset ”…”�”}”(hjúh²hh³Nh´NubjZ)�”}”(hŒ``KCSAN_SKIP_WATCH_RANDOMIZE``”h]”hŒKCSAN_SKIP_WATCH_RANDOMIZE”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhjúubhŒ).”…”�”}”(hjúh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´MWhjöubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÜubeh}”(h]”h ]”h"]”h$]”h&]”j—Œ-”uh1jh³hÇh´MVhj¼ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhj“h²hh³Nh´Nubj)�”}”(hŒœ**Annotation Overheads:** Minimal annotations are required outside the KCSAN runtime. As a result, maintenance overheads are minimal as the kernel evolves. ”h]”hì)�”}”(hŒ›**Annotation Overheads:** Minimal annotations are required outside the KCSAN runtime. As a result, maintenance overheads are minimal as the kernel evolves.”h]”(j )�”}”(hŒ**Annotation Overheads:**”h]”hŒAnnotation Overheads:”…”�”}”(hjGh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjCubhŒ‚ Minimal annotations are required outside the KCSAN runtime. As a result, maintenance overheads are minimal as the kernel evolves.”…”�”}”(hjCh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´MZhj?ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj“h²hh³hÇh´Nubj)�”}”(hŒŽ**Detects Racy Writes from Devices:** Due to checking data values upon setting up watchpoints, racy writes from devices can also be detected. ”h]”hì)�”}”(hŒ�**Detects Racy Writes from Devices:** Due to checking data values upon setting up watchpoints, racy writes from devices can also be detected.”h]”(j )�”}”(hŒ%**Detects Racy Writes from Devices:**”h]”hŒ!Detects Racy Writes from Devices:”…”�”}”(hjmh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjiubhŒh Due to checking data values upon setting up watchpoints, racy writes from devices can also be detected.”…”�”}”(hjih²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´M^hjeubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj“h²hh³hÇh´Nubj)�”}”(hŒ…**Memory Ordering:** KCSAN is aware of only a subset of LKMM ordering rules; this may result in missed data races (false negatives). ”h]”hì)�”}”(hŒ„**Memory Ordering:** KCSAN is aware of only a subset of LKMM ordering rules; this may result in missed data races (false negatives).”h]”(j )�”}”(hŒ**Memory Ordering:**”h]”hŒMemory Ordering:”…”�”}”(hj“h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hj�ubhŒp KCSAN is aware of only a subset of LKMM ordering rules; this may result in missed data races (false negatives).”…”�”}”(hj�h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´Mahj‹ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj“h²hh³hÇh´Nubj)�”}”(hŒ¶**Analysis Accuracy:** For observed executions, due to using a sampling strategy, the analysis is *unsound* (false negatives possible), but aims to be complete (no false positives). ”h]”hì)�”}”(hŒµ**Analysis Accuracy:** For observed executions, due to using a sampling strategy, the analysis is *unsound* (false negatives possible), but aims to be complete (no false positives).”h]”(j )�”}”(hŒ**Analysis Accuracy:**”h]”hŒAnalysis Accuracy:”…”�”}”(hj¹h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjµubhŒL For observed executions, due to using a sampling strategy, the analysis is ”…”�”}”(hjµh²hh³Nh´Nubjì)�”}”(hŒ *unsound*”h]”hŒunsound”…”�”}”(hjËh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jëhjµubhŒJ (false negatives possible), but aims to be complete (no false positives).”…”�”}”(hjµh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´Mdhj±ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj“h²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”j0 j1 j2 hj3 j4 uh1jÑ hj‚h²hh³hÇh´MNubeh}”(h]”Œkey-properties”ah ]”h"]”Œkey properties”ah$]”h&]”uh1hÖhj©h²hh³hÇh´MLubeh}”(h]”Œimplementation-details”ah ]”h"]”Œimplementation details”ah$]”h&]”uh1hÖhhØh²hh³hÇh´Kôubh×)�”}”(hhh]”(hÜ)�”}”(hŒAlternatives Considered”h]”hŒAlternatives Considered”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjÿh²hh³hÇh´Miubhì)�”}”(hX€An alternative data race detection approach for the kernel can be found in the `Kernel Thread Sanitizer (KTSAN) `_. KTSAN is a happens-before data race detector, which explicitly establishes the happens-before order between memory operations, which can then be used to determine data races as defined in `Data Races`_.”h]”(hŒOAn alternative data race detection approach for the kernel can be found in the ”…”�”}”(hjh²hh³Nh´Nubhö)�”}”(hŒe`Kernel Thread Sanitizer (KTSAN) `_”h]”hŒKernel Thread Sanitizer (KTSAN)”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”ŒKernel Thread Sanitizer (KTSAN)”jXŒ@https://github.com/google/kernel-sanitizers/blob/master/KTSAN.md”uh1hõhjubjš)�”}”(hŒC ”h]”h}”(h]”Œkernel-thread-sanitizer-ktsan”ah ]”h"]”Œkernel thread sanitizer (ktsan)”ah$]”h&]”Œrefuri”j(uh1j™j§KhjubhŒ¾. KTSAN is a happens-before data race detector, which explicitly establishes the happens-before order between memory operations, which can then be used to determine data races as defined in ”…”�”}”(hjh²hh³Nh´Nubhö)�”}”(hŒ `Data Races`_”h]”hŒ Data Races”…”�”}”(hj:h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”Œ Data Races”jjuh1hõhjj KubhŒ.”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´Mkhjÿh²hubhì)�”}”(hX8To build a correct happens-before relation, KTSAN must be aware of all ordering rules of the LKMM and synchronization primitives. Unfortunately, any omission leads to large numbers of false positives, which is especially detrimental in the context of the kernel which includes numerous custom synchronization mechanisms. To track the happens-before relation, KTSAN's implementation requires metadata for each memory location (shadow memory), which for each page corresponds to 4 pages of shadow memory, and can translate into overhead of tens of GiB on a large system.”h]”hX:To build a correct happens-before relation, KTSAN must be aware of all ordering rules of the LKMM and synchronization primitives. Unfortunately, any omission leads to large numbers of false positives, which is especially detrimental in the context of the kernel which includes numerous custom synchronization mechanisms. To track the happens-before relation, KTSAN’s implementation requires metadata for each memory location (shadow memory), which for each page corresponds to 4 pages of shadow memory, and can translate into overhead of tens of GiB on a large system.”…”�”}”(hjTh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hëh³hÇh´Mrhjÿh²hubeh}”(h]”Œalternatives-considered”ah ]”h"]”Œalternatives considered”ah$]”h&]”uh1hÖhhØh²hh³hÇh´Miubeh}”(h]”Œ"kernel-concurrency-sanitizer-kcsan”ah ]”h"]”Œ$kernel concurrency sanitizer (kcsan)”ah$]”h&]”uh1hÖhhh²hh³hÇh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÇuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)�”}”(hÛNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”j•Œerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÇŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”(Œ data races”]”(h÷j:eŒ,"marking shared-memory accesses" in the lkmm”]”jHaŒdebugfs interface”]”jîaŒ+"plain accesses and data races" in the lkmm”]”j5auŒrefids”}”Œnameids”}”(jojljÏjÌjïjìjzjwj¤j¡jÏjþjÇjÄjWjjYjVjPjMj¦j£j j jüjùjêjçjj|jôjñjgjdj2j/uŒ nametypes”}”(jo‰jωjï‰jz‰j¤ˆjωjljjW‰jYˆjP‰j¦‰j ˆjü‰jêˆj‰jô‰jg‰j2ˆuh}”(jlhØjÌjjìjsjwjòj¡j›jþj}jÄjÒjjÒjVjPjMj\j£jZjˆj‘j' j, jƒ jˆ j j jH jM j…jŠjùj©jçjáj|jejñj‚jdjÿj/j)uŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.