€•IBŒ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/locking/rt-mutex”Œ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/locking/rt-mutex”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ$/translations/it_IT/locking/rt-mutex”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ$/translations/ja_JP/locking/rt-mutex”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ$/translations/ko_KR/locking/rt-mutex”Œ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/locking/rt-mutex”Œ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/locking/rt-mutex”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒ"RT-mutex subsystem with PI support”h]”hŒ"RT-mutex subsystem with PI support”…””}”(hh¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhh·h²hh³Œ>/var/lib/git/docbuild/linux/Documentation/locking/rt-mutex.rst”h´KubhŒ paragraph”“”)”}”(hŒåRT-mutexes with priority inheritance are used to support PI-futexes, which enable pthread_mutex_t priority inheritance attributes (PTHREAD_PRIO_INHERIT). [See Documentation/locking/pi-futex.rst for more details about PI-futexes.]”h]”hŒåRT-mutexes with priority inheritance are used to support PI-futexes, which enable pthread_mutex_t priority inheritance attributes (PTHREAD_PRIO_INHERIT). [See Documentation/locking/pi-futex.rst for more details about PI-futexes.]”…””}”(hhÍh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khh·h²hubhÌ)”}”(hŒXThis technology was developed in the -rt tree and streamlined for pthread_mutex support.”h]”hŒXThis technology was developed in the -rt tree and streamlined for pthread_mutex support.”…””}”(hhÛh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K hh·h²hubh¶)”}”(hhh]”(h»)”}”(hŒBasic principles:”h]”hŒBasic principles:”…””}”(hhìh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhhéh²hh³hÊh´KubhÌ)”}”(hŒWRT-mutexes extend the semantics of simple mutexes by the priority inheritance protocol.”h]”hŒWRT-mutexes extend the semantics of simple mutexes by the priority inheritance protocol.”…””}”(hhúh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khhéh²hubhÌ)”}”(hX^A low priority owner of a rt-mutex inherits the priority of a higher priority waiter until the rt-mutex is released. If the temporarily boosted owner blocks on a rt-mutex itself it propagates the priority boosting to the owner of the other rt_mutex it gets blocked on. The priority boosting is immediately removed once the rt_mutex has been unlocked.”h]”hX^A low priority owner of a rt-mutex inherits the priority of a higher priority waiter until the rt-mutex is released. If the temporarily boosted owner blocks on a rt-mutex itself it propagates the priority boosting to the owner of the other rt_mutex it gets blocked on. The priority boosting is immediately removed once the rt_mutex has been unlocked.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khhéh²hubhÌ)”}”(hXAThis approach allows us to shorten the block of high-prio tasks on mutexes which protect shared resources. Priority inheritance is not a magic bullet for poorly designed applications, but it allows well-designed applications to use userspace locks in critical parts of an high priority thread, without losing determinism.”h]”hXAThis approach allows us to shorten the block of high-prio tasks on mutexes which protect shared resources. Priority inheritance is not a magic bullet for poorly designed applications, but it allows well-designed applications to use userspace locks in critical parts of an high priority thread, without losing determinism.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khhéh²hubhÌ)”}”(hXËThe enqueueing of the waiters into the rtmutex waiter tree is done in priority order. For same priorities FIFO order is chosen. For each rtmutex, only the top priority waiter is enqueued into the owner's priority waiters tree. This tree too queues in priority order. Whenever the top priority waiter of a task changes (for example it timed out or got a signal), the priority of the owner task is readjusted. The priority enqueueing is handled by "pi_waiters".”h]”hXÑThe enqueueing of the waiters into the rtmutex waiter tree is done in priority order. For same priorities FIFO order is chosen. For each rtmutex, only the top priority waiter is enqueued into the owner’s priority waiters tree. This tree too queues in priority order. Whenever the top priority waiter of a task changes (for example it timed out or got a signal), the priority of the owner task is readjusted. The priority enqueueing is handled by “pi_waitersâ€.”…””}”(hj$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K hhéh²hubhÌ)”}”(hX RT-mutexes are optimized for fastpath operations and have no internal locking overhead when locking an uncontended mutex or unlocking a mutex without waiters. The optimized fastpath operations require cmpxchg support. [If that is not available then the rt-mutex internal spinlock is used]”h]”hX RT-mutexes are optimized for fastpath operations and have no internal locking overhead when locking an uncontended mutex or unlocking a mutex without waiters. The optimized fastpath operations require cmpxchg support. [If that is not available then the rt-mutex internal spinlock is used]”…””}”(hj2h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K(hhéh²hubhÌ)”}”(hŒSThe state of the rt-mutex is tracked via the owner field of the rt-mutex structure:”h]”hŒSThe state of the rt-mutex is tracked via the owner field of the rt-mutex structure:”…””}”(hj@h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K.hhéh²hubhÌ)”}”(hŒtlock->owner holds the task_struct pointer of the owner. Bit 0 is used to keep track of the "lock has waiters" state:”h]”hŒxlock->owner holds the task_struct pointer of the owner. Bit 0 is used to keep track of the “lock has waiters†state:”…””}”(hjNh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K1hhéh²hubhŒ block_quote”“”)”}”(hX============ ======= ================================================ owner bit0 Notes ============ ======= ================================================ NULL 0 lock is free (fast acquire possible) NULL 1 lock is free and has waiters and the top waiter is going to take the lock [1]_ taskpointer 0 lock is held (fast release possible) taskpointer 1 lock is held and has waiters [2]_ ============ ======= ================================================ ”h]”hŒtable”“”)”}”(hhh]”hŒtgroup”“”)”}”(hhh]”(hŒcolspec”“”)”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”K uh1jlhjiubjm)”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”Kuh1jlhjiubjm)”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”K0uh1jlhjiubhŒthead”“”)”}”(hhh]”hŒrow”“”)”}”(hhh]”(hŒentry”“”)”}”(hhh]”hÌ)”}”(hŒowner”h]”hŒowner”…””}”(hj›h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K5hj˜ubah}”(h]”h ]”h"]”h$]”h&]”uh1j–hj“ubj—)”}”(hhh]”hÌ)”}”(hŒbit0”h]”hŒbit0”…””}”(hj²h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K5hj¯ubah}”(h]”h ]”h"]”h$]”h&]”uh1j–hj“ubj—)”}”(hhh]”hÌ)”}”(hŒNotes”h]”hŒNotes”…””}”(hjÉh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K5hjÆubah}”(h]”h ]”h"]”h$]”h&]”uh1j–hj“ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j‘hjŽubah}”(h]”h ]”h"]”h$]”h&]”uh1jŒhjiubhŒtbody”“”)”}”(hhh]”(j’)”}”(hhh]”(j—)”}”(hhh]”hÌ)”}”(hŒNULL”h]”hŒNULL”…””}”(hjôh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K7hjñubah}”(h]”h ]”h"]”h$]”h&]”uh1j–hjîubj—)”}”(hhh]”hÌ)”}”(hŒ0”h]”hŒ0”…””}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K7hjubah}”(h]”h ]”h"]”h$]”h&]”uh1j–hjîubj—)”}”(hhh]”hÌ)”}”(hŒ$lock is free (fast acquire possible)”h]”hŒ$lock is free (fast acquire possible)”…””}”(hj"h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K7hjubah}”(h]”h ]”h"]”h$]”h&]”uh1j–hjîubeh}”(h]”h ]”h"]”h$]”h&]”uh1j‘hjëubj’)”}”(hhh]”(j—)”}”(hhh]”hÌ)”}”(hŒNULL”h]”hŒNULL”…””}”(hjBh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K8hj?ubah}”(h]”h ]”h"]”h$]”h&]”uh1j–hj<ubj—)”}”(hhh]”hÌ)”}”(hŒ1”h]”hŒ1”…””}”(hjYh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K8hjVubah}”(h]”h ]”h"]”h$]”h&]”uh1j–hj<ubj—)”}”(hhh]”hÌ)”}”(hŒNlock is free and has waiters and the top waiter is going to take the lock [1]_”h]”(hŒJlock is free and has waiters and the top waiter is going to take the lock ”…””}”(hjph²hh³Nh´NubhŒfootnote_reference”“”)”}”(hŒ[1]_”h]”hŒ1”…””}”(hjzh²hh³Nh´Nubah}”(h]”Œid1”ah ]”h"]”h$]”h&]”Œrefid”Œid3”Œdocname”Œlocking/rt-mutex”uh1jxhjpŒresolved”Kubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K8hjmubah}”(h]”h ]”h"]”h$]”h&]”uh1j–hj<ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j‘hjëubj’)”}”(hhh]”(j—)”}”(hhh]”hÌ)”}”(hŒ taskpointer”h]”hŒ taskpointer”…””}”(hj¦h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K:hj£ubah}”(h]”h ]”h"]”h$]”h&]”uh1j–hj ubj—)”}”(hhh]”hÌ)”}”(hj h]”hŒ0”…””}”(hj½h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K:hjºubah}”(h]”h ]”h"]”h$]”h&]”uh1j–hj ubj—)”}”(hhh]”hÌ)”}”(hŒ$lock is held (fast release possible)”h]”hŒ$lock is held (fast release possible)”…””}”(hjÓh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K:hjÐubah}”(h]”h ]”h"]”h$]”h&]”uh1j–hj ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j‘hjëubj’)”}”(hhh]”(j—)”}”(hhh]”hÌ)”}”(hŒ taskpointer”h]”hŒ taskpointer”…””}”(hjóh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K;hjðubah}”(h]”h ]”h"]”h$]”h&]”uh1j–hjíubj—)”}”(hhh]”hÌ)”}”(hj[h]”hŒ1”…””}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K;hjubah}”(h]”h ]”h"]”h$]”h&]”uh1j–hjíubj—)”}”(hhh]”hÌ)”}”(hŒ!lock is held and has waiters [2]_”h]”(hŒlock is held and has waiters ”…””}”(hj h²hh³Nh´Nubjy)”}”(hŒ[2]_”h]”hŒ2”…””}”(hj(h²hh³Nh´Nubah}”(h]”Œid2”ah ]”h"]”h$]”h&]”j‰Œid4”j‹jŒuh1jxhj jKubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K;hjubah}”(h]”h ]”h"]”h$]”h&]”uh1j–hjíubeh}”(h]”h ]”h"]”h$]”h&]”uh1j‘hjëubeh}”(h]”h ]”h"]”h$]”h&]”uh1jéhjiubeh}”(h]”h ]”h"]”h$]”h&]”Œcols”Kuh1jghjdubah}”(h]”h ]”h"]”h$]”h&]”uh1jbhj^ubah}”(h]”h ]”h"]”h$]”h&]”uh1j\h³hÊh´K4hhéh²hubhÌ)”}”(hŒkThe fast atomic compare exchange based acquire and release is only possible when bit 0 of lock->owner is 0.”h]”hŒkThe fast atomic compare exchange based acquire and release is only possible when bit 0 of lock->owner is 0.”…””}”(hjch²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K>hhéh²hubhŒfootnote”“”)”}”(hX It also can be a transitional state when grabbing the lock with ->wait_lock is held. To prevent any fast path cmpxchg to the lock, we need to set the bit0 before looking at the lock, and the owner may be NULL in this small time, hence this can be a transitional state. ”h]”(hŒlabel”“”)”}”(hŒ1”h]”hŒ1”…””}”(hjyh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jwhjsubhÌ)”}”(hX It also can be a transitional state when grabbing the lock with ->wait_lock is held. To prevent any fast path cmpxchg to the lock, we need to set the bit0 before looking at the lock, and the owner may be NULL in this small time, hence this can be a transitional state.”h]”hX It also can be a transitional state when grabbing the lock with ->wait_lock is held. To prevent any fast path cmpxchg to the lock, we need to set the bit0 before looking at the lock, and the owner may be NULL in this small time, hence this can be a transitional state.”…””}”(hj‡h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KAhjsubeh}”(h]”jŠah ]”h"]”Œ1”ah$]”h&]”j„aj‹jŒuh1jqh³hÊh´KAhhéh²hjKubjr)”}”(hŒåThere is a small time when bit 0 is set but there are no waiters. This can happen when grabbing the lock in the slow path. To prevent a cmpxchg of the owner releasing the lock, we need to set this bit before looking at the lock. ”h]”(jx)”}”(hŒ2”h]”hŒ2”…””}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jwhjœubhÌ)”}”(hŒäThere is a small time when bit 0 is set but there are no waiters. This can happen when grabbing the lock in the slow path. To prevent a cmpxchg of the owner releasing the lock, we need to set this bit before looking at the lock.”h]”hŒäThere is a small time when bit 0 is set but there are no waiters. This can happen when grabbing the lock in the slow path. To prevent a cmpxchg of the owner releasing the lock, we need to set this bit before looking at the lock.”…””}”(hj®h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KFhjœubeh}”(h]”j7ah ]”h"]”Œ2”ah$]”h&]”j2aj‹jŒuh1jqh³hÊh´KFhhéh²hjKubhÌ)”}”(hŒÈBTW, there is still technically a "Pending Owner", it's just not called that anymore. The pending owner happens to be the top_waiter of a lock that has no owner and has been woken up to grab the lock.”h]”hŒÎBTW, there is still technically a “Pending Ownerâ€, it’s just not called that anymore. The pending owner happens to be the top_waiter of a lock that has no owner and has been woken up to grab the lock.”…””}”(hjÃh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KKhhéh²hubeh}”(h]”Œbasic-principles”ah ]”h"]”Œbasic principles:”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kubeh}”(h]”Œ"rt-mutex-subsystem-with-pi-support”ah ]”h"]”Œ"rt-mutex subsystem with pi support”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”j–Œ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”}”(Œ1”]”jzaŒ2”]”j(auŒrefids”}”Œnameids”}”(jÞjÛjÖjÓj™jŠjÀj7uŒ nametypes”}”(jÞ‰jÖ‰j™ˆjÀˆuh}”(jÛh·jÓhéj„jzj2j(jŠjsj7jœuŒ footnote_refs”}”(jC]”jzajE]”j(auŒ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”(jsjœeŒ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”jKs…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.