€•¿:Œ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/scheduler/sched-arch”Œ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/scheduler/sched-arch”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/it_IT/scheduler/sched-arch”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/ja_JP/scheduler/sched-arch”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/ko_KR/scheduler/sched-arch”Œ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/scheduler/sched-arch”Œ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/scheduler/sched-arch”Œ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ŒACPU Scheduler implementation hints for architecture specific code”h]”hŒACPU Scheduler implementation hints for architecture specific code”…””}”(hh¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhh·h²hh³ŒB/var/lib/git/docbuild/linux/Documentation/scheduler/sched-arch.rst”h´KubhŒ block_quote”“”)”}”(hŒNick Piggin, 2005 ”h]”hŒ paragraph”“”)”}”(hŒNick Piggin, 2005”h]”hŒNick Piggin, 2005”…””}”(hhÓh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´KhhÍubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khh·h²hubh¶)”}”(hhh]”(h»)”}”(hŒContext switch”h]”hŒContext switch”…””}”(hhêh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhhçh²hh³hÊh´KubhÒ)”}”(hŒô1. Runqueue locking By default, the switch_to arch function is called with the runqueue locked. This is usually not a problem unless switch_to may need to take the runqueue lock. This is usually due to a wake up operation in the context switch.”h]”hŒô1. Runqueue locking By default, the switch_to arch function is called with the runqueue locked. This is usually not a problem unless switch_to may need to take the runqueue lock. This is usually due to a wake up operation in the context switch.”…””}”(hhøh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´K hhçh²hubhÒ)”}”(hŒ²To request the scheduler call switch_to with the runqueue unlocked, you must `#define __ARCH_WANT_UNLOCKED_CTXSW` in a header file (typically the one where switch_to is defined).”h]”(hŒMTo request the scheduler call switch_to with the runqueue unlocked, you must ”…””}”(hjh²hh³Nh´NubhŒtitle_reference”“”)”}”(hŒ$`#define __ARCH_WANT_UNLOCKED_CTXSW`”h]”hŒ"#define __ARCH_WANT_UNLOCKED_CTXSW”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubhŒA in a header file (typically the one where switch_to is defined).”…””}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´Khhçh²hubhÒ)”}”(hŒ†Unlocked context switches introduce only a very minor performance penalty to the core scheduler implementation in the CONFIG_SMP case.”h]”hŒ†Unlocked context switches introduce only a very minor performance penalty to the core scheduler implementation in the CONFIG_SMP case.”…””}”(hj(h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´Khhçh²hubeh}”(h]”Œcontext-switch”ah ]”h"]”Œcontext switch”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kubh¶)”}”(hhh]”(h»)”}”(hŒCPU idle”h]”hŒCPU idle”…””}”(hjAh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj>h²hh³hÊh´KubhÒ)”}”(hŒ8Your cpu_idle routines need to obey the following rules:”h]”hŒ8Your cpu_idle routines need to obey the following rules:”…””}”(hjOh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´Khj>h²hubhŒenumerated_list”“”)”}”(hhh]”(hŒ list_item”“”)”}”(hŒoPreempt should now disabled over idle routines. Should only be enabled to call schedule() then disabled again. ”h]”hÒ)”}”(hŒnPreempt should now disabled over idle routines. Should only be enabled to call schedule() then disabled again.”h]”hŒnPreempt should now disabled over idle routines. Should only be enabled to call schedule() then disabled again.”…””}”(hjhh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´Khjdubah}”(h]”h ]”h"]”h$]”h&]”uh1jbhj_h²hh³hÊh´Nubjc)”}”(hŒÇneed_resched/TIF_NEED_RESCHED is only ever set, and will never be cleared until the running task has called schedule(). Idle threads need only ever query need_resched, and may never set or clear it. ”h]”hÒ)”}”(hŒÆneed_resched/TIF_NEED_RESCHED is only ever set, and will never be cleared until the running task has called schedule(). Idle threads need only ever query need_resched, and may never set or clear it.”h]”hŒÆneed_resched/TIF_NEED_RESCHED is only ever set, and will never be cleared until the running task has called schedule(). Idle threads need only ever query need_resched, and may never set or clear it.”…””}”(hj€h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´Khj|ubah}”(h]”h ]”h"]”h$]”h&]”uh1jbhj_h²hh³hÊh´Nubjc)”}”(hŒtWhen cpu_idle finds (need_resched() == 'true'), it should call schedule(). It should not call schedule() otherwise. ”h]”hÒ)”}”(hŒsWhen cpu_idle finds (need_resched() == 'true'), it should call schedule(). It should not call schedule() otherwise.”h]”hŒwWhen cpu_idle finds (need_resched() == ‘true’), it should call schedule(). It should not call schedule() otherwise.”…””}”(hj˜h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´K"hj”ubah}”(h]”h ]”h"]”h$]”h&]”uh1jbhj_h²hh³hÊh´Nubjc)”}”(hXThe only time interrupts need to be disabled when checking need_resched is if we are about to sleep the processor until the next interrupt (this doesn't provide any protection of need_resched, it prevents losing an interrupt): 4a. Common problem with this type of sleep appears to be:: local_irq_disable(); if (!need_resched()) { local_irq_enable(); *** resched interrupt arrives here *** __asm__("sleep until next interrupt"); } ”h]”(hÒ)”}”(hŒâThe only time interrupts need to be disabled when checking need_resched is if we are about to sleep the processor until the next interrupt (this doesn't provide any protection of need_resched, it prevents losing an interrupt):”h]”hŒäThe only time interrupts need to be disabled when checking need_resched is if we are about to sleep the processor until the next interrupt (this doesn’t provide any protection of need_resched, it prevents losing an interrupt):”…””}”(hj°h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´K%hj¬ubhÌ)”}”(hX4a. Common problem with this type of sleep appears to be:: local_irq_disable(); if (!need_resched()) { local_irq_enable(); *** resched interrupt arrives here *** __asm__("sleep until next interrupt"); } ”h]”(hÒ)”}”(hŒ:4a. Common problem with this type of sleep appears to be::”h]”hŒ94a. Common problem with this type of sleep appears to be:”…””}”(hjÂh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´K*hj¾ubhŒ literal_block”“”)”}”(hŒ§local_irq_disable(); if (!need_resched()) { local_irq_enable(); *** resched interrupt arrives here *** __asm__("sleep until next interrupt"); }”h]”hŒ§local_irq_disable(); if (!need_resched()) { local_irq_enable(); *** resched interrupt arrives here *** __asm__("sleep until next interrupt"); }”…””}”hjÒsbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1jÐh³hÊh´K,hj¾ubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K*hj¬ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jbhj_h²hh³hÊh´Nubjc)”}”(hXûTIF_POLLING_NRFLAG can be set by idle routines that do not need an interrupt to wake them up when need_resched goes high. In other words, they must be periodically polling need_resched, although it may be reasonable to do some background work or enter a low CPU priority. - 5a. If TIF_POLLING_NRFLAG is set, and we do decide to enter an interrupt sleep, it needs to be cleared then a memory barrier issued (followed by a test of need_resched with interrupts disabled, as explained in 3). ”h]”(hÒ)”}”(hXTIF_POLLING_NRFLAG can be set by idle routines that do not need an interrupt to wake them up when need_resched goes high. In other words, they must be periodically polling need_resched, although it may be reasonable to do some background work or enter a low CPU priority.”h]”hXTIF_POLLING_NRFLAG can be set by idle routines that do not need an interrupt to wake them up when need_resched goes high. In other words, they must be periodically polling need_resched, although it may be reasonable to do some background work or enter a low CPU priority.”…””}”(hjòh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´K3hjîubhÌ)”}”(hŒÞ- 5a. If TIF_POLLING_NRFLAG is set, and we do decide to enter an interrupt sleep, it needs to be cleared then a memory barrier issued (followed by a test of need_resched with interrupts disabled, as explained in 3). ”h]”hŒ bullet_list”“”)”}”(hhh]”jc)”}”(hŒÖ5a. If TIF_POLLING_NRFLAG is set, and we do decide to enter an interrupt sleep, it needs to be cleared then a memory barrier issued (followed by a test of need_resched with interrupts disabled, as explained in 3). ”h]”hÒ)”}”(hŒÕ5a. If TIF_POLLING_NRFLAG is set, and we do decide to enter an interrupt sleep, it needs to be cleared then a memory barrier issued (followed by a test of need_resched with interrupts disabled, as explained in 3).”h]”hŒÕ5a. If TIF_POLLING_NRFLAG is set, and we do decide to enter an interrupt sleep, it needs to be cleared then a memory barrier issued (followed by a test of need_resched with interrupts disabled, as explained in 3).”…””}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´K9hj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jbhjubah}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ-”uh1jh³hÊh´K9hjubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K9hjîubeh}”(h]”h ]”h"]”h$]”h&]”uh1jbhj_h²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”Œenumtype”Œarabic”Œprefix”hŒsuffix”Œ.”uh1j]hj>h²hh³hÊh´KubhÒ)”}”(hŒSarch/x86/kernel/process.c has examples of both polling and sleeping idle functions.”h]”hŒSarch/x86/kernel/process.c has examples of both polling and sleeping idle functions.”…””}”(hj@h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´K>hj>h²hubeh}”(h]”Œcpu-idle”ah ]”h"]”Œcpu idle”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kubh¶)”}”(hhh]”(h»)”}”(hŒPossible arch/ problems”h]”hŒPossible arch/ problems”…””}”(hjYh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjVh²hh³hÊh´KCubhÒ)”}”(hŒCPossible arch problems I found (and either tried to fix or didn't):”h]”hŒEPossible arch problems I found (and either tried to fix or didn’t):”…””}”(hjgh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´KEhjVh²hubhŒdefinition_list”“”)”}”(hhh]”hŒdefinition_list_item”“”)”}”(hŒ}sparc - IRQs on at this point(?), change local_irq_save to _disable. - TODO: needs secondary CPUs to disable preempt (See #1)”h]”(hŒterm”“”)”}”(hŒDsparc - IRQs on at this point(?), change local_irq_save to _disable.”h]”hŒDsparc - IRQs on at this point(?), change local_irq_save to _disable.”…””}”(hj‚h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j€h³hÊh´KGhj|ubhŒ definition”“”)”}”(hhh]”j)”}”(hhh]”jc)”}”(hŒ6TODO: needs secondary CPUs to disable preempt (See #1)”h]”hÒ)”}”(hjšh]”hŒ6TODO: needs secondary CPUs to disable preempt (See #1)”…””}”(hjœh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑh³hÊh´KHhj˜ubah}”(h]”h ]”h"]”h$]”h&]”uh1jbhj•ubah}”(h]”h ]”h"]”h$]”h&]”j'j(uh1jh³hÊh´KHhj’ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj|ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jzh³hÊh´KGhjwubah}”(h]”h ]”h"]”h$]”h&]”uh1juhjVh²hh³Nh´Nubeh}”(h]”Œpossible-arch-problems”ah ]”h"]”Œpossible arch/ problems”ah$]”h&]”uh1hµhh·h²hh³hÊh´KCubeh}”(h]”ŒAcpu-scheduler-implementation-hints-for-architecture-specific-code”ah ]”h"]”ŒAcpu scheduler implementation hints for architecture specific code”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”}”Œrefids”}”Œnameids”}”(jÔjÑj;j8jSjPjÌjÉuŒ nametypes”}”(jÔ‰j;‰jS‰j̉uh}”(jÑh·j8hçjPj>jÉjVuŒ 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.