€•3Œ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/admin-guide/cgroup-v1/pids”Œ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/admin-guide/cgroup-v1/pids”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ./translations/it_IT/admin-guide/cgroup-v1/pids”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ./translations/ja_JP/admin-guide/cgroup-v1/pids”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ./translations/ko_KR/admin-guide/cgroup-v1/pids”Œ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/admin-guide/cgroup-v1/pids”Œ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ŒProcess Number Controller”h]”hŒProcess Number Controller”…””}”(hh¨hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hh£hžhhŸŒH/var/lib/git/docbuild/linux/Documentation/admin-guide/cgroup-v1/pids.rst”h Kubh¢)”}”(hhh]”(h§)”}”(hŒAbstract”h]”hŒAbstract”…””}”(hhºhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hh·hžhhŸh¶h KubhŒ paragraph”“”)”}”(hŒšThe process number controller is used to allow a cgroup hierarchy to stop any new tasks from being fork()'d or clone()'d after a certain limit is reached.”h]”hŒžThe process number controller is used to allow a cgroup hierarchy to stop any new tasks from being fork()’d or clone()’d after a certain limit is reached.”…””}”(hhÊhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h Khh·hžhubhÉ)”}”(hXSince it is trivial to hit the task limit without hitting any kmemcg limits in place, PIDs are a fundamental resource. As such, PID exhaustion must be preventable in the scope of a cgroup hierarchy by allowing resource limiting of the number of tasks in a cgroup.”h]”hXSince it is trivial to hit the task limit without hitting any kmemcg limits in place, PIDs are a fundamental resource. As such, PID exhaustion must be preventable in the scope of a cgroup hierarchy by allowing resource limiting of the number of tasks in a cgroup.”…””}”(hhØhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h K hh·hžhubeh}”(h]”Œabstract”ah ]”h"]”Œabstract”ah$]”h&]”uh1h¡hh£hžhhŸh¶h Kubh¢)”}”(hhh]”(h§)”}”(hŒUsage”h]”hŒUsage”…””}”(hhñhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hhîhžhhŸh¶h KubhÉ)”}”(hŒÜIn order to use the `pids` controller, set the maximum number of tasks in pids.max (this is not available in the root cgroup for obvious reasons). The number of processes currently in the cgroup is given by pids.current.”h]”(hŒIn order to use the ”…””}”(hhÿhžhhŸNh NubhŒtitle_reference”“”)”}”(hŒ`pids`”h]”hŒpids”…””}”(hj hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhhÿubhŒÂ controller, set the maximum number of tasks in pids.max (this is not available in the root cgroup for obvious reasons). The number of processes currently in the cgroup is given by pids.current.”…””}”(hhÿhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h KhhîhžhubhÉ)”}”(hXÓOrganisational operations are not blocked by cgroup policies, so it is possible to have pids.current > pids.max. This can be done by either setting the limit to be smaller than pids.current, or attaching enough processes to the cgroup such that pids.current > pids.max. However, it is not possible to violate a cgroup policy through fork() or clone(). fork() and clone() will return -EAGAIN if the creation of a new process would cause a cgroup policy to be violated.”h]”hXÓOrganisational operations are not blocked by cgroup policies, so it is possible to have pids.current > pids.max. This can be done by either setting the limit to be smaller than pids.current, or attaching enough processes to the cgroup such that pids.current > pids.max. However, it is not possible to violate a cgroup policy through fork() or clone(). fork() and clone() will return -EAGAIN if the creation of a new process would cause a cgroup policy to be violated.”…””}”(hj!hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h KhhîhžhubhÉ)”}”(hŒÃTo set a cgroup to have no limit, set pids.max to "max". This is the default for all new cgroups (N.B. that PID limits are hierarchical, so the most stringent limit in the hierarchy is followed).”h]”hŒÇTo set a cgroup to have no limit, set pids.max to “maxâ€. This is the default for all new cgroups (N.B. that PID limits are hierarchical, so the most stringent limit in the hierarchy is followed).”…””}”(hj/hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h KhhîhžhubhÉ)”}”(hŒtpids.current tracks all child cgroup hierarchies, so parent/pids.current is a superset of parent/child/pids.current.”h]”hŒtpids.current tracks all child cgroup hierarchies, so parent/pids.current is a superset of parent/child/pids.current.”…””}”(hj=hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h K"hhîhžhubhÉ)”}”(hŒ-The pids.events file contains event counters:”h]”hŒ-The pids.events file contains event counters:”…””}”(hjKhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h K%hhîhžhubhŒ block_quote”“”)”}”(hŒ_- max: Number of times fork failed in the cgroup because limit was hit in self or ancestors. ”h]”hŒ bullet_list”“”)”}”(hhh]”hŒ list_item”“”)”}”(hŒ[max: Number of times fork failed in the cgroup because limit was hit in self or ancestors. ”h]”hÉ)”}”(hŒZmax: Number of times fork failed in the cgroup because limit was hit in self or ancestors.”h]”hŒZmax: Number of times fork failed in the cgroup because limit was hit in self or ancestors.”…””}”(hjjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h K'hjfubah}”(h]”h ]”h"]”h$]”h&]”uh1jdhjaubah}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ-”uh1j_hŸh¶h K'hj[ubah}”(h]”h ]”h"]”h$]”h&]”uh1jYhŸh¶h K'hhîhžhubeh}”(h]”Œusage”ah ]”h"]”Œusage”ah$]”h&]”uh1h¡hh£hžhhŸh¶h Kubh¢)”}”(hhh]”(h§)”}”(hŒExample”h]”hŒExample”…””}”(hj—hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hj”hžhhŸh¶h K+ubhÉ)”}”(hŒ%First, we mount the pids controller::”h]”hŒ$First, we mount the pids controller:”…””}”(hj¥hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h K-hj”hžhubhŒ literal_block”“”)”}”(hŒQ# mkdir -p /sys/fs/cgroup/pids # mount -t cgroup -o pids none /sys/fs/cgroup/pids”h]”hŒQ# mkdir -p /sys/fs/cgroup/pids # mount -t cgroup -o pids none /sys/fs/cgroup/pids”…””}”hjµsbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1j³hŸh¶h K/hj”hžhubhÉ)”}”(hŒCThen we create a hierarchy, set limits and attach processes to it::”h]”hŒBThen we create a hierarchy, set limits and attach processes to it:”…””}”(hjÅhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h K2hj”hžhubj´)”}”(hŒÀ# mkdir -p /sys/fs/cgroup/pids/parent/child # echo 2 > /sys/fs/cgroup/pids/parent/pids.max # echo $$ > /sys/fs/cgroup/pids/parent/cgroup.procs # cat /sys/fs/cgroup/pids/parent/pids.current 2 #”h]”hŒÀ# mkdir -p /sys/fs/cgroup/pids/parent/child # echo 2 > /sys/fs/cgroup/pids/parent/pids.max # echo $$ > /sys/fs/cgroup/pids/parent/cgroup.procs # cat /sys/fs/cgroup/pids/parent/pids.current 2 #”…””}”hjÓsbah}”(h]”h ]”h"]”h$]”h&]”jÃjÄuh1j³hŸh¶h K4hj”hžhubhÉ)”}”(hŒWIt should be noted that attempts to overcome the set limit (2 in this case) will fail::”h]”hŒVIt should be noted that attempts to overcome the set limit (2 in this case) will fail:”…””}”(hjáhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h K;hj”hžhubj´)”}”(hŒ‘# cat /sys/fs/cgroup/pids/parent/pids.current 2 # ( /bin/echo "Here's some processes for you." | cat ) sh: fork: Resource temporary unavailable #”h]”hŒ‘# cat /sys/fs/cgroup/pids/parent/pids.current 2 # ( /bin/echo "Here's some processes for you." | cat ) sh: fork: Resource temporary unavailable #”…””}”hjïsbah}”(h]”h ]”h"]”h$]”h&]”jÃjÄuh1j³hŸh¶h K>hj”hžhubhÉ)”}”(hŒ«Even if we migrate to a child cgroup (which doesn't have a set limit), we will not be able to overcome the most stringent limit in the hierarchy (in this case, parent's)::”h]”hŒ®Even if we migrate to a child cgroup (which doesn’t have a set limit), we will not be able to overcome the most stringent limit in the hierarchy (in this case, parent’s):”…””}”(hjýhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h KDhj”hžhubj´)”}”(hX5# echo $$ > /sys/fs/cgroup/pids/parent/child/cgroup.procs # cat /sys/fs/cgroup/pids/parent/pids.current 2 # cat /sys/fs/cgroup/pids/parent/child/pids.current 2 # cat /sys/fs/cgroup/pids/parent/child/pids.max max # ( /bin/echo "Here's some processes for you." | cat ) sh: fork: Resource temporary unavailable #”h]”hX5# echo $$ > /sys/fs/cgroup/pids/parent/child/cgroup.procs # cat /sys/fs/cgroup/pids/parent/pids.current 2 # cat /sys/fs/cgroup/pids/parent/child/pids.current 2 # cat /sys/fs/cgroup/pids/parent/child/pids.max max # ( /bin/echo "Here's some processes for you." | cat ) sh: fork: Resource temporary unavailable #”…””}”hj sbah}”(h]”h ]”h"]”h$]”h&]”jÃjÄuh1j³hŸh¶h KHhj”hžhubhÉ)”}”(hŒ«We can set a limit that is smaller than pids.current, which will stop any new processes from being forked at all (note that the shell itself counts towards pids.current)::”h]”hŒªWe can set a limit that is smaller than pids.current, which will stop any new processes from being forked at all (note that the shell itself counts towards pids.current):”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h KShj”hžhubj´)”}”(hX!# echo 1 > /sys/fs/cgroup/pids/parent/pids.max # /bin/echo "We can't even spawn a single process now." sh: fork: Resource temporary unavailable # echo 0 > /sys/fs/cgroup/pids/parent/pids.max # /bin/echo "We can't even spawn a single process now." sh: fork: Resource temporary unavailable #”h]”hX!# echo 1 > /sys/fs/cgroup/pids/parent/pids.max # /bin/echo "We can't even spawn a single process now." sh: fork: Resource temporary unavailable # echo 0 > /sys/fs/cgroup/pids/parent/pids.max # /bin/echo "We can't even spawn a single process now." sh: fork: Resource temporary unavailable #”…””}”hj'sbah}”(h]”h ]”h"]”h$]”h&]”jÃjÄuh1j³hŸh¶h KWhj”hžhubeh}”(h]”Œexample”ah ]”h"]”Œexample”ah$]”h&]”uh1h¡hh£hžhhŸh¶h K+ubeh}”(h]”Œprocess-number-controller”ah ]”h"]”Œprocess number controller”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”jhŒ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”}”(jBj?hëhèj‘jŽj:j7uŒ nametypes”}”(jB‰hë‰j‘‰j:‰uh}”(j?h£hèh·jŽhîj7j”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.