€•vAŒ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Œ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.”…””}”(hhôhž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â€.”…””}”(hjhž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]”…””}”(hjhž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:”…””}”(hj:hž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 uh1jXhjUubjY)”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”Kuh1jXhjUubjY)”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”K0uh1jXhjUubhŒ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‚hjubjƒ)”}”(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‚hjubjƒ)”}”(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‚hjubeh}”(h]”h ]”h"]”h$]”h&]”uh1j}hjzubah}”(h]”h ]”h"]”h$]”h&]”uh1jxhjUubhŒ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 K7hjôubah}”(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)”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K7hj ubah}”(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”…””}”(hj.hž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”…””}”(hjEhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K8hjBubah}”(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 ”…””}”(hj\hžhhŸNh NubhŒfootnote_reference”“”)”}”(hŒ[1]_”h]”hŒ1”…””}”(hjfhžhhŸNh Nubah}”(h]”Œid1”ah ]”h"]”h$]”h&]”Œrefid”Œid3”Œdocname”Œlocking/rt-mutex”uh1jdhj\Œresolved”Kubeh}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K8hjYubah}”(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:hjubah}”(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¸)”}”(hjGh]”hŒ1”…””}”(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 and has waiters [2]_”h]”(hŒlock is held and has waiters ”…””}”(hj hžhhŸNh Nubje)”}”(hŒ[2]_”h]”hŒ2”…””}”(hjhžhhŸNh Nubah}”(h]”Œid2”ah ]”h"]”h$]”h&]”juŒid4”jwjxuh1jdhj jyKubeh}”(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×ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÕhjUubeh}”(h]”h ]”h"]”h$]”h&]”Œcols”Kuh1jShjPubah}”(h]”h ]”h"]”h$]”h&]”uh1jNhjJubah}”(h]”h ]”h"]”h$]”h&]”uh1jHhŸ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.”…””}”(hjOhž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”…””}”(hjehžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jchj_ubh¸)”}”(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.”…””}”(hjshžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h KAhj_ubeh}”(h]”jvah ]”h"]”Œ1”ah$]”h&]”jpajwjxuh1j]hŸh¶h KAhhÕhžhjyKubj^)”}”(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]”(jd)”}”(hŒ2”h]”hŒ2”…””}”(hjŒhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jchjˆ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]”j#ah ]”h"]”Œ2”ah$]”h&]”jajwjxuh1j]hŸh¶h KFhhÕhžhjyKubh¸)”}”(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”]”jfaŒ2”]”jauŒrefids”}”Œnameids”}”(jÊjÇjÂj¿j…jvj¬j#uŒ nametypes”}”(jʉj‰j…ˆj¬ˆuh}”(jÇh£j¿hÕjpjfjjjvj_j#jˆuŒ footnote_refs”}”(j/]”jfaj1]”jauŒ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”(j_jˆeŒ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”jýKs…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nhžhub.