€•Ü9Œ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Œ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 ”…””}”(hhòhžhhŸNh NubhŒtitle_reference”“”)”}”(hŒ$`#define __ARCH_WANT_UNLOCKED_CTXSW`”h]”hŒ"#define __ARCH_WANT_UNLOCKED_CTXSW”…””}”(hhühžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1húhhòubhŒA in a header file (typically the one where switch_to is defined).”…””}”(hhòhž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.”…””}”(hjhž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”…””}”(hj-hž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:”…””}”(hj;hž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.”…””}”(hjThžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h½hŸh¶h KhjPubah}”(h]”h ]”h"]”h$]”h&]”uh1jNhjKhžhhŸh¶h NubjO)”}”(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.”…””}”(hjlhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h½hŸh¶h Khjhubah}”(h]”h ]”h"]”h$]”h&]”uh1jNhjKhžhhŸh¶h NubjO)”}”(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&]”uh1jNhjKhžhhŸh¶h NubjO)”}”(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&]”uh1jNhjKhžhhŸh¶h NubjO)”}”(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]”jO)”}”(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&]”uh1jNhjòubah}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ-”uh1jðhŸh¶h K9hjìubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K9hjÚubeh}”(h]”h ]”h"]”h$]”h&]”uh1jNhjKhžhhŸh¶h Nubeh}”(h]”h ]”h"]”h$]”h&]”Œenumtype”Œarabic”Œprefix”hŒsuffix”Œ.”uh1jIhj*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”…””}”(hjEhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hjBhž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):”…””}”(hjShžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h½hŸh¶h KEhjBhž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.”…””}”(hjnhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jlhŸh¶h KGhjhubhŒ definition”“”)”}”(hhh]”jñ)”}”(hhh]”jO)”}”(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&]”uh1jNhjubah}”(h]”h ]”h"]”h$]”h&]”jjuh1jðhŸh¶h KHhj~ubah}”(h]”h ]”h"]”h$]”h&]”uh1j|hjhubeh}”(h]”h ]”h"]”h$]”h&]”uh1jfhŸh¶h KGhjcubah}”(h]”h ]”h"]”h$]”h&]”uh1jahjBhž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'j$j?j<j¸jµuŒ nametypes”}”(jÀ‰j'‰j?‰j¸‰uh}”(j½h£j$hÓj<j*jµjBuŒ 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.