diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/.gitignore" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/.gitignore" new file mode 100644 index 0000000000000000000000000000000000000000..8300e42e7fd656cef23dd69d17109a6f36a05928 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/.gitignore" @@ -0,0 +1,15 @@ +.idea/ +logs/ +__pycache__/ +*.o +*.a +*.d +*.cmd +*.test +*.ko +*.mod +*.mod.c +Module.symvers +modules.order +compile_commands.json +tst_lib/cgroup_util/bin/* \ No newline at end of file diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/.gitmodules" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/.gitmodules" new file mode 100644 index 0000000000000000000000000000000000000000..eb26ca38370e372e4ba6d48ae766856cbbf1cdc0 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/.gitmodules" @@ -0,0 +1,3 @@ +[submodule "tst_common"] + path = tst_common + url = https://gitee.com/opencloudos-stream/test-suite-base.git diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/LICENSE" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/LICENSE" new file mode 100644 index 0000000000000000000000000000000000000000..d06cc9f83a6dcc6be19943abc87f9dccccc17230 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/LICENSE" @@ -0,0 +1,824 @@ +Tencent is pleased to support the open source community by making OpenCloudOS Kernel Stream available. + +Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. The below software in this distribution may have been modified by THL A29 Limited ("Tencent Modifications"). All Tencent Modifications are Copyright (C) THL A29 Limited. + +OpenCloudOS Kernel Stream is licensed under the the Mulan Permissive Software License 2.0 except for the third-party components listed below. + + +Terms of the Mulan Permissive Software License 2.0: +-------------------------------------------------------------------- + 木兰宽松许可证, 第2版 + +2020年1月 http://license.coscl.org.cn/MulanPSL2 + +您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束: + +0. 定义 + +“软件”是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。 + +“贡献”是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。 + +“贡献者”是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。 + +“法人实体”是指提交贡献的机构及其“关联实体”。 + +“关联实体”是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。 + +1. 授予版权许可 + +每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。 + +2. 授予专利许可 + +每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。 + +3. 无商标许可 + +“本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。 + +4. 分发限制 + +您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。 + +5. 免责声明与责任限制 + +“软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。 + +6. 语言 + +“本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。 + +条款结束 + +如何将木兰宽松许可证,第2版,应用到您的软件 + +如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步: + +1,请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字; + +2,请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中; + +3,请将如下声明文本放入每个源文件的头部注释中。 + +Copyright (c) [Year] [name of copyright holder] [Software Name] is licensed under Mulan PSL v2. You can use this software according to the terms and conditions of the Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2 THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the Mulan PSL v2 for more details. + +January 2020 http://license.coscl.org.cn/MulanPSL2 + +Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions: + +0. Definition + +Software means the program and related documents which are licensed under this License and comprise all Contribution(s). + +Contribution means the copyrightable work licensed by a particular Contributor under this License. + +Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License. + +Legal Entity means the entity making a Contribution and all its Affiliates. + +Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity. + +1. Grant of Copyright License + +Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not. + +2. Grant of Patent License + +Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken. + +3. No Trademark License + +No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in Section 4. + +4. Distribution Restriction + +You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software. + +5. Disclaimer of Warranty and Limitation of Liability + +THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +6. Language + +THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL. + +END OF THE TERMS AND CONDITIONS + + + +Other dependencies and licenses: + + +Open Source Software Licensed under the GPL v2.0 with Linux-syscall-note, and Other Licenses of the Third-Party Components therein: +The below software in this distribution may have been modified by THL A29 Limited ("Tencent Modifications"). All Tencent Modifications are Copyright (C) 2021 THL A29 Limited. +-------------------------------------------------------------------- +1. kernel +Copyright © kernel original author and authors + + +The Linux Kernel is provided under: + + SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note + +Being under the terms of the GNU General Public License version 2 only, +according with: + + LICENSES/preferred/GPL-2.0 + +With an explicit syscall exception, as stated at: + + LICENSES/exceptions/Linux-syscall-note + +In addition, other licenses may also apply. Please see: + + Documentation/process/license-rules.rst + +for more details. + +All contributions to the Linux Kernel are subject to this COPYING file. + +Valid-License-Identifier: GPL-2.0 +Valid-License-Identifier: GPL-2.0-only +Valid-License-Identifier: GPL-2.0+ +Valid-License-Identifier: GPL-2.0-or-later +SPDX-URL: https://spdx.org/licenses/GPL-2.0.html +Usage-Guide: + To use this license in source code, put one of the following SPDX + tag/value pairs into a comment according to the placement + guidelines in the licensing rules documentation. + For 'GNU General Public License (GPL) version 2 only' use: + SPDX-License-Identifier: GPL-2.0 + or + SPDX-License-Identifier: GPL-2.0-only + For 'GNU General Public License (GPL) version 2 or any later version' use: + SPDX-License-Identifier: GPL-2.0+ + or + SPDX-License-Identifier: GPL-2.0-or-later +License-Text: + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. + +SPDX-Exception-Identifier: Linux-syscall-note +SPDX-URL: https://spdx.org/licenses/Linux-syscall-note.html +SPDX-Licenses: GPL-2.0, GPL-2.0+, GPL-1.0+, LGPL-2.0, LGPL-2.0+, LGPL-2.1, LGPL-2.1+, GPL-2.0-only, GPL-2.0-or-later +Usage-Guide: + This exception is used together with one of the above SPDX-Licenses + to mark user space API (uapi) header files so they can be included + into non GPL compliant user space application code. + To use this exception add it with the keyword WITH to one of the + identifiers in the SPDX-Licenses tag: + SPDX-License-Identifier: WITH Linux-syscall-note +License-Text: + + NOTE! This copyright does *not* cover user programs that use kernel + services by normal system calls - this is merely considered normal use + of the kernel, and does *not* fall under the heading of "derived work". + Also note that the GPL below is copyrighted by the Free Software + Foundation, but the instance of code that it refers to (the Linux + kernel) is copyrighted by me and others who actually wrote it. + + Also note that the only valid version of the GPL as far as the kernel + is concerned is _this_ particular version of the license (ie v2, not + v2.2 or v3.x or whatever), unless explicitly otherwise stated. + + Linus Torvalds + +For the licenses of other third parties, please refer to the following URL: +https://github.com/torvalds/linux/tree/v5.18-rc5/LICENSES + +Linux kernel licensing rules +The Linux Kernel is provided under the terms of the GNU General Public License version 2 only (GPL-2.0), as provided in LICENSES/preferred/GPL-2.0, with an explicit syscall exception described in LICENSES/exceptions/Linux-syscall-note, as described in the COPYING file. + +This documentation file provides a description of how each source file should be annotated to make its license clear and unambiguous. It doesn't replace the Kernel's license. + +The license described in the COPYING file applies to the kernel source as a whole, though individual source files can have a different license which is required to be compatible with the GPL-2.0: + +GPL-1.0+ : GNU General Public License v1.0 or later +GPL-2.0+ : GNU General Public License v2.0 or later +LGPL-2.0 : GNU Library General Public License v2 only +LGPL-2.0+ : GNU Library General Public License v2 or later +LGPL-2.1 : GNU Lesser General Public License v2.1 only +LGPL-2.1+ : GNU Lesser General Public License v2.1 or later +Aside from that, individual files can be provided under a dual license, e.g. one of the compatible GPL variants and alternatively under a permissive license like BSD, MIT etc. + +The User-space API (UAPI) header files, which describe the interface of user-space programs to the kernel are a special case. According to the note in the kernel COPYING file, the syscall interface is a clear boundary, which does not extend the GPL requirements to any software which uses it to communicate with the kernel. Because the UAPI headers must be includable into any source files which create an executable running on the Linux kernel, the exception must be documented by a special license expression. + +The common way of expressing the license of a source file is to add the matching boilerplate text into the top comment of the file. Due to formatting, typos etc. these "boilerplates" are hard to validate for tools which are used in the context of license compliance. + +An alternative to boilerplate text is the use of Software Package Data Exchange (SPDX) license identifiers in each source file. SPDX license identifiers are machine parsable and precise shorthands for the license under which the content of the file is contributed. SPDX license identifiers are managed by the SPDX Workgroup at the Linux Foundation and have been agreed on by partners throughout the industry, tool vendors, and legal teams. For further information see https://spdx.org/ + +The Linux kernel requires the precise SPDX identifier in all source files. The valid identifiers used in the kernel are explained in the section License identifiers and have been retrieved from the official SPDX license list at https://spdx.org/licenses/ along with the license texts. + +License identifier syntax +Placement: + +The SPDX license identifier in kernel files shall be added at the first possible line in a file which can contain a comment. For the majority of files this is the first line, except for scripts which require the '#!PATH_TO_INTERPRETER' in the first line. For those scripts the SPDX identifier goes into the second line. + + +Style: + +The SPDX license identifier is added in form of a comment. The comment style depends on the file type: + +C source: // SPDX-License-Identifier: +C header: /* SPDX-License-Identifier: */ +ASM: /* SPDX-License-Identifier: */ +scripts: # SPDX-License-Identifier: +.rst: .. SPDX-License-Identifier: +.dts{i}: // SPDX-License-Identifier: +If a specific tool cannot handle the standard comment style, then the appropriate comment mechanism which the tool accepts shall be used. This is the reason for having the "/* */" style comment in C header files. There was build breakage observed with generated .lds files where 'ld' failed to parse the C++ comment. This has been fixed by now, but there are still older assembler tools which cannot handle C++ style comments. + + +Syntax: + +A is either an SPDX short form license identifier found on the SPDX License List, or the combination of two SPDX short form license identifiers separated by "WITH" when a license exception applies. When multiple licenses apply, an expression consists of keywords "AND", "OR" separating sub-expressions and surrounded by "(", ")" . + +License identifiers for licenses like [L]GPL with the 'or later' option are constructed by using a "+" for indicating the 'or later' option.: + +// SPDX-License-Identifier: GPL-2.0+ +// SPDX-License-Identifier: LGPL-2.1+ +WITH should be used when there is a modifier to a license needed. For example, the linux kernel UAPI files use the expression: + +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note +// SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note +Other examples using WITH exceptions found in the kernel are: + +// SPDX-License-Identifier: GPL-2.0 WITH mif-exception +// SPDX-License-Identifier: GPL-2.0+ WITH GCC-exception-2.0 +Exceptions can only be used with particular License identifiers. The valid License identifiers are listed in the tags of the exception text file. For details see the point Exceptions in the chapter License identifiers. + +OR should be used if the file is dual licensed and only one license is to be selected. For example, some dtsi files are available under dual licenses: + +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause +Examples from the kernel for license expressions in dual licensed files: + +// SPDX-License-Identifier: GPL-2.0 OR MIT +// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause +// SPDX-License-Identifier: GPL-2.0 OR Apache-2.0 +// SPDX-License-Identifier: GPL-2.0 OR MPL-1.1 +// SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR MIT +// SPDX-License-Identifier: GPL-1.0+ OR BSD-3-Clause OR OpenSSL +AND should be used if the file has multiple licenses whose terms all apply to use the file. For example, if code is inherited from another project and permission has been given to put it in the kernel, but the original license terms need to remain in effect: + +// SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) AND MIT +Another other example where both sets of license terms need to be adhered to is: + +// SPDX-License-Identifier: GPL-1.0+ AND LGPL-2.1+ +License identifiers +The licenses currently used, as well as the licenses for code added to the kernel, can be broken down into: + +Preferred licenses: + +Whenever possible these licenses should be used as they are known to be fully compatible and widely used. These licenses are available from the directory: + +LICENSES/preferred/ +in the kernel source tree. + +The files in this directory contain the full license text and Metatags. The file names are identical to the SPDX license identifier which shall be used for the license in source files. + +Examples: + +LICENSES/preferred/GPL-2.0 +Contains the GPL version 2 license text and the required metatags: + +LICENSES/preferred/MIT +Contains the MIT license text and the required metatags + +Metatags: + +The following meta tags must be available in a license file: + +Valid-License-Identifier: + +One or more lines which declare which License Identifiers are valid inside the project to reference this particular license text. Usually this is a single valid identifier, but e.g. for licenses with the 'or later' options two identifiers are valid. + +SPDX-URL: + +The URL of the SPDX page which contains additional information related to the license. + +Usage-Guidance: + +Freeform text for usage advice. The text must include correct examples for the SPDX license identifiers as they should be put into source files according to the License identifier syntax guidelines. + +License-Text: + +All text after this tag is treated as the original license text + +File format examples: + +Valid-License-Identifier: GPL-2.0 +Valid-License-Identifier: GPL-2.0+ +SPDX-URL: https://spdx.org/licenses/GPL-2.0.html +Usage-Guide: + To use this license in source code, put one of the following SPDX + tag/value pairs into a comment according to the placement + guidelines in the licensing rules documentation. + For 'GNU General Public License (GPL) version 2 only' use: + SPDX-License-Identifier: GPL-2.0 + For 'GNU General Public License (GPL) version 2 or any later version' use: + SPDX-License-Identifier: GPL-2.0+ +License-Text: + Full license text +SPDX-License-Identifier: MIT +SPDX-URL: https://spdx.org/licenses/MIT.html +Usage-Guide: + To use this license in source code, put the following SPDX + tag/value pair into a comment according to the placement + guidelines in the licensing rules documentation. + SPDX-License-Identifier: MIT +License-Text: + Full license text + +Deprecated licenses: + +These licenses should only be used for existing code or for importing code from a different project. These licenses are available from the directory: + +LICENSES/deprecated/ +in the kernel source tree. + +The files in this directory contain the full license text and Metatags. The file names are identical to the SPDX license identifier which shall be used for the license in source files. + +Examples: + +LICENSES/deprecated/ISC +Contains the Internet Systems Consortium license text and the required metatags: + +LICENSES/deprecated/GPL-1.0 +Contains the GPL version 1 license text and the required metatags. + +Metatags: + +The metatag requirements for 'other' licenses are identical to the requirements of the Preferred licenses. + +File format example: + +Valid-License-Identifier: ISC +SPDX-URL: https://spdx.org/licenses/ISC.html +Usage-Guide: + Usage of this license in the kernel for new code is discouraged + and it should solely be used for importing code from an already + existing project. + To use this license in source code, put the following SPDX + tag/value pair into a comment according to the placement + guidelines in the licensing rules documentation. + SPDX-License-Identifier: ISC +License-Text: + Full license text + +Dual Licensing Only + +These licenses should only be used to dual license code with another license in addition to a preferred license. These licenses are available from the directory: + +LICENSES/dual/ +in the kernel source tree. + +The files in this directory contain the full license text and Metatags. The file names are identical to the SPDX license identifier which shall be used for the license in source files. + +Examples: + +LICENSES/dual/MPL-1.1 +Contains the Mozilla Public License version 1.1 license text and the required metatags: + +LICENSES/dual/Apache-2.0 +Contains the Apache License version 2.0 license text and the required metatags. + +Metatags: + +The metatag requirements for 'other' licenses are identical to the requirements of the Preferred licenses. + +File format example: + +Valid-License-Identifier: MPL-1.1 +SPDX-URL: https://spdx.org/licenses/MPL-1.1.html +Usage-Guide: + Do NOT use. The MPL-1.1 is not GPL2 compatible. It may only be used for + dual-licensed files where the other license is GPL2 compatible. + If you end up using this it MUST be used together with a GPL2 compatible + license using "OR". + To use the Mozilla Public License version 1.1 put the following SPDX + tag/value pair into a comment according to the placement guidelines in + the licensing rules documentation: +SPDX-License-Identifier: MPL-1.1 +License-Text: + Full license text + +Exceptions: + +Some licenses can be amended with exceptions which grant certain rights which the original license does not. These exceptions are available from the directory: + +LICENSES/exceptions/ +in the kernel source tree. The files in this directory contain the full exception text and the required Exception Metatags. + +Examples: + +LICENSES/exceptions/Linux-syscall-note +Contains the Linux syscall exception as documented in the COPYING file of the Linux kernel, which is used for UAPI header files. e.g. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */: + +LICENSES/exceptions/GCC-exception-2.0 +Contains the GCC 'linking exception' which allows to link any binary independent of its license against the compiled version of a file marked with this exception. This is required for creating runnable executables from source code which is not compatible with the GPL. + +Exception Metatags: + +The following meta tags must be available in an exception file: + +SPDX-Exception-Identifier: + +One exception identifier which can be used with SPDX license identifiers. + +SPDX-URL: + +The URL of the SPDX page which contains additional information related to the exception. + +SPDX-Licenses: + +A comma separated list of SPDX license identifiers for which the exception can be used. + +Usage-Guidance: + +Freeform text for usage advice. The text must be followed by correct examples for the SPDX license identifiers as they should be put into source files according to the License identifier syntax guidelines. + +Exception-Text: + +All text after this tag is treated as the original exception text + +File format examples: + +SPDX-Exception-Identifier: Linux-syscall-note +SPDX-URL: https://spdx.org/licenses/Linux-syscall-note.html +SPDX-Licenses: GPL-2.0, GPL-2.0+, GPL-1.0+, LGPL-2.0, LGPL-2.0+, LGPL-2.1, LGPL-2.1+ +Usage-Guidance: + This exception is used together with one of the above SPDX-Licenses + to mark user-space API (uapi) header files so they can be included + into non GPL compliant user-space application code. + To use this exception add it with the keyword WITH to one of the + identifiers in the SPDX-Licenses tag: + SPDX-License-Identifier: WITH Linux-syscall-note +Exception-Text: + Full exception text +SPDX-Exception-Identifier: GCC-exception-2.0 +SPDX-URL: https://spdx.org/licenses/GCC-exception-2.0.html +SPDX-Licenses: GPL-2.0, GPL-2.0+ +Usage-Guidance: + The "GCC Runtime Library exception 2.0" is used together with one + of the above SPDX-Licenses for code imported from the GCC runtime + library. + To use this exception add it with the keyword WITH to one of the + identifiers in the SPDX-Licenses tag: + SPDX-License-Identifier: WITH GCC-exception-2.0 +Exception-Text: + Full exception text +All SPDX license identifiers and exceptions must have a corresponding file in the LICENSES subdirectories. This is required to allow tool verification (e.g. checkpatch.pl) and to have the licenses ready to read and extract right from the source, which is recommended by various FOSS organizations, e.g. the FSFE REUSE initiative. + +MODULE_LICENSE +Loadable kernel modules also require a MODULE_LICENSE() tag. This tag is neither a replacement for proper source code license information (SPDX-License-Identifier) nor in any way relevant for expressing or determining the exact license under which the source code of the module is provided. + +The sole purpose of this tag is to provide sufficient information whether the module is free software or proprietary for the kernel module loader and for user space tools. + +The valid license strings for MODULE_LICENSE() are: + +"GPL" Module is licensed under GPL version 2. This does not express any distinction between GPL-2.0-only or GPL-2.0-or-later. The exact license information can only be determined via the license information in the corresponding source files. +"GPL v2" Same as "GPL". It exists for historic reasons. +"GPL and additional rights" Historical variant of expressing that the module source is dual licensed under a GPL v2 variant and MIT license. Please do not use in new code. +"Dual MIT/GPL" The correct way of expressing that the module is dual licensed under a GPL v2 variant or MIT license choice. +"Dual BSD/GPL" The module is dual licensed under a GPL v2 variant or BSD license choice. The exact variant of the BSD license can only be determined via the license information in the corresponding source files. +"Dual MPL/GPL" The module is dual licensed under a GPL v2 variant or Mozilla Public License (MPL) choice. The exact variant of the MPL license can only be determined via the license information in the corresponding source files. +"Proprietary" The module is under a proprietary license. This string is solely for proprietary third party modules and cannot be used for modules which have their source code in the kernel tree. Modules tagged that way are tainting the kernel with the 'P' flag when loaded and the kernel module loader refuses to link such modules against symbols which are exported with EXPORT_SYMBOL_GPL(). \ No newline at end of file diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/Makefile" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/Makefile" new file mode 100644 index 0000000000000000000000000000000000000000..0ae2951157e1405b05f44cf2a1f8d12eab8b3826 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/Makefile" @@ -0,0 +1,27 @@ +export TST_TS_TOPDIR := $(shell pwd) +DIRS := cmd testcase kmod +LIBS := tst_common tst_lib + +all: libs + @for d in $(DIRS); do \ + echo try make $$d; \ + make -C $$d all; \ + done + +libs: + @for d in $(LIBS); do \ + echo try make $$d; \ + make -C $$d all; \ + done + +clean: + @for d in $(DIRS) $(LIBS); do \ + echo try clean $$d; \ + make -C $$d clean; \ + done + +cleanall: + @for d in $(DIRS) $(LIBS); do \ + echo try cleanall $$d; \ + make -C $$d cleanall; \ + done diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/Makefile.common" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/Makefile.common" new file mode 100644 index 0000000000000000000000000000000000000000..1d9d2dade3b256721cdccc66b3eb80483ae403be --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/Makefile.common" @@ -0,0 +1,3 @@ +CFLAGS += -Wall -g -I$(TST_TS_TOPDIR)/tst_common/lib -I$(TST_TS_TOPDIR)/tst_lib +LDFLAGS += -L$(TST_TS_TOPDIR)/tst_common/lib -L$(TST_TS_TOPDIR)/tst_lib +LDFLAGS += -lm -lrt -lpthread -Wl,--whole-archive -lcommon -ltscommon -Wl,--no-whole-archive diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/README.md" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/README.md" new file mode 100644 index 0000000000000000000000000000000000000000..9c815f0f9fdce2d110470b49b4256b58fb05168b --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/README.md" @@ -0,0 +1,99 @@ +# 概述 +为提高测试效率,开发了本项目,在测试用例上增加适配层,统一用例的执行接口。 +适配层以测试套的方式存在,支持C、Shell和Python三种语言开发的用例。 +当多个用例之间有一定关联性或存在公共代码时,可以组织成一个测试套,测试套内用例共享部分资源。 + +# 测试套目录结构 +```shell +suite_example ---------> 测试套顶层目录,绝对路径存储在环境变量TST_TS_TOPDIR中 +├── cmd ---------> 测试套公共命令 +│ ├── hello.c +│ └── Makefile +├── tst_common -----> 【不可修改】submodule,公共代码库:test-suite-base +│ ├── cmd +│ │ ├── Makefile +│ │ └── tsuite.c +│ ├── kmod +│ │ ├── kmod_common.c +│ │ └── Makefile +│ ├── lib +│ │ ├── assert.sh +│ │ ├── common.c +│ │ ├── common_func.sh +│ │ ├── common.h +│ │ ├── common.sh +│ │ ├── main.h +│ │ ├── Makefile +│ │ ├── signature.sh +│ │ ├── tst_ts_setup +│ │ ├── tst_ts_teardown +│ │ └── tsuite_func.sh +│ ├── Makefile +│ └── tsuite +├── kmod ---------> 内核模块,该目录下每个.c文件都会编译成同名的ko +│ ├── kmod_common.c +│ └── Makefile +├── lib ---------> 测试套公共库文件,.sh会被source,.c会被编译为静态库,.py会被import +│ ├── common.sh +│ ├── Makefile +│ ├── other_common.sh +│ ├── ts_setup +│ └── ts_teardown +├── logs ---------> 日志和其他运行时临时目录 +├── Makefile +├── testcase ---------> 测试用例目录,所有测试用例放在此目录下 +│ ├── Makefile +│ ├── test_cmd_ls.sh ---------> 测试用例,.sh和.py会被直接执行,.c会被编译为同名的可执行程序后执行 +│ └── test_c_testcase.c -------> 测试用例 +└── tsuite -> ./common/tsuite ---> 软连接,指向公共代码库中的tsuite文件 +``` + +# 新建测试项目 +可以一个测试套对应一个测试git仓库,也可以多个测试套保存在一个仓库。这里以多个测试套对应一个git仓库示例如下: +```shell +# 1、先在代码托管平台(如gitee、github等)新建git仓库 +# 这里的示例仓库为OpenCloudOS社区的软件包测试项目 +# HTTPS协议:https://gitee.com/OpenCloudOS/packages-testing.git +# SSH协议: git@gitee.com:OpenCloudOS/packages-testing.git + +# 2、下载测试项目 +git clone --recurse-submodules https://gitee.com/OpenCloudOS/packages-testing.git + +# 3、新建一个测试套,例如测试套名为:coreutils +cd ./packages-testing +# 3.1、下载测试套模板 +git clone https://gitee.com/opencloudos-stream/test-suite-example.git ./coreutils +# 3.2、删除无用的文件(git文件、用例示例等) +rm -rf ./coreutils/.git ./coreutils/.gitmodules ./coreutils/testcase/test* +rm -rf ./coreutils/tst_common ./coreutils/README.md +# 3.3、为测试套配置git子模块 +git submodule add https://gitee.com/opencloudos-stream/test-suite-base.git ./coreutils/tst_common + +# 4、将测试套提交到git +git add ./coreutils +git commit -asm "提交coreutils测试套模板" +``` + +# 开发测试用例 +测试用例要放在测试套的testcase目录下,推荐使用tsuite工具生成测试用例模板。 +tsuite工具的用法参考:https://gitee.com/opencloudos-stream/test-suite-base +开发测试用例步骤如下: +```shell +# 1、假设需要开发的用例名为tc-mkdir-01,用例使用shell脚本开发 +cd ./coreutils +./tsuite new case sh tc-mkdir-01 +# 1.1、编辑用例文件,增加测试逻辑 +vim testcase/tc-mkdir-01.sh + +# 2、部分用例有C代码,需要编译,直接执行make all即可 +./tsuite compile + +# 3、用例开发完成后可以执行和调试用例 +./tsuite run ./testcase/tc-mkdir-01.sh +# 3.1、或直接执行用例 +./testcase/tc-mkdir-01.sh + +# 4、用例调试通过后提交用例到git +git add ./testcase/tc-mkdir-01.sh +git commit -asm "新增测试用例tc-mkdir-01验证mkdir命令功能" +``` \ No newline at end of file diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/cmd/Makefile" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/cmd/Makefile" new file mode 100644 index 0000000000000000000000000000000000000000..133158c83eceb271077f1178bb0994fa35f817e5 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/cmd/Makefile" @@ -0,0 +1,20 @@ +export TST_TS_TOPDIR ?= $(shell pwd)/.. +include $(TST_TS_TOPDIR)/Makefile.common +ALL_SRC := $(wildcard *.c) +ALL_OBJ := $(patsubst %.c,%.o,$(ALL_SRC)) +ALL_BIN := $(patsubst %.o,%.cmd,$(ALL_OBJ)) +CFLAGS += +LDFLAGS += + +all: $(ALL_BIN) + +$(ALL_BIN):%.cmd:%.o + $(CC) $^ -o $@ $(LDFLAGS) + +$(ALL_OBJ):%.o:%.c + $(CC) $(CFLAGS) -c $^ -o $@ + +clean: + rm -rfv $(ALL_OBJ) $(ALL_BIN) + +cleanall: clean diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/cmd/hello.c" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/cmd/hello.c" new file mode 100644 index 0000000000000000000000000000000000000000..c70b44218abc7ea8528c9516dc3ae9116c3d8de2 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/cmd/hello.c" @@ -0,0 +1,6 @@ +#include + +int main(void) { + printf("hello world\n"); + return 0; +} diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/install_package.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/install_package.sh" new file mode 100644 index 0000000000000000000000000000000000000000..e1f7163b3450916f7b912eee1b082025f9ceb83a --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/install_package.sh" @@ -0,0 +1,25 @@ +#!/bin/bash + +if ! command -v yum &> /dev/null; then + dnf install -y yum +fi +# 定义要安装的软件包及其安装命令 +packages=( + "git" + "numactl" + "iperf3" + "iproute-tc" + "perf" + "sysstat" + "make" + "gcc" + "bc" +) + +# 遍历软件包列表并安装 +for package in "${packages[@]}"; do + echo "Installing $package..." + yum install -y "$package" +done + +echo "All packages installed successfully!" diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/kmod/Makefile" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/kmod/Makefile" new file mode 100644 index 0000000000000000000000000000000000000000..01632efcce85312d752f75db4c9da8922ece5c41 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/kmod/Makefile" @@ -0,0 +1,28 @@ +# General Purpose Makefile for Linux Kernel module +# 以下编译适合于在内核代码树之外编译内核模块。 +# 整个过程会导致本Makefile文件被加载执行两遍。 +# 第一遍执行时,由于`KERNELRELEASE`没有被定义,所以先执行`else`下的逻辑。 +# `-C $(KERNEL_DIR)`指明跳转到内核源码目录下读取那里的Makefile; +# `M=$(CURDIR)`表明然后返回到当前目录继续读入当前的Makefile并执行之。此为第二遍执行。 +# 第二遍执行时,此时从内核源码目录返回时,KERNELRELEASE已被被定义, +# kbuild也被启动去解析kbuild语法的语句,make将继续读取else之前的内容。 +# else之前的内容为kbuild语法的语句, 指明模块源码中各文件的依赖关系,以及要生成的目标模块名。 + +CURDIR ?= $(shell pwd) +KERNEL_VER := $(shell uname -r) +KERNEL_DIR ?= /lib/modules/$(KERNEL_VER)/build +export ALL_SRC ?= $(filter-out %.mod.c, $(wildcard *.c)) +export ALL_OBJ ?= $(patsubst %.c,%.o,$(ALL_SRC)) +export ALL_MOD ?= $(patsubst %.o,%.ko,$(ALL_OBJ)) + +ifneq ($(KERNELRELEASE),) + obj-m += $(ALL_OBJ) +else +all: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) modules +endif + +clean: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) clean + +cleanall: clean diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/kmod/ts_kcommon.c" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/kmod/ts_kcommon.c" new file mode 100644 index 0000000000000000000000000000000000000000..41a779a0caa17f4cc2c3c60ec40a6842d312fd7a --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/kmod/ts_kcommon.c" @@ -0,0 +1,14 @@ +#include + +static int __init kmod_common_init(void) { + printk("Hello, World!\n"); + return 0; +} +static void __exit kmod_common_exit(void) { + printk("Goodbye, World!\n"); +} + +module_init(kmod_common_init); +module_exit(kmod_common_exit); + +MODULE_LICENSE("GPL"); diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/Makefile" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/Makefile" new file mode 100644 index 0000000000000000000000000000000000000000..1b4db5bcbf65a82a67d32917028e601b2dd629ba --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/Makefile" @@ -0,0 +1,21 @@ +export TST_TS_TOPDIR ?= $(shell pwd)/.. +include $(TST_TS_TOPDIR)/Makefile.common +ALL_SRC := $(filter-out %.mod.c, $(wildcard *.c)) +ALL_OBJ := $(patsubst %.c,%.o,$(ALL_SRC)) +ALL_BIN := $(patsubst %.o,%.test,$(ALL_OBJ)) +CFLAGS += +LDFLAGS += +LDFLAGS += + +all: $(ALL_BIN) + +$(ALL_BIN):%.test:%.o + $(CC) $^ -o $@ $(LDFLAGS) + +$(ALL_OBJ):%.o:%.c + $(CC) $(CFLAGS) -c $^ -o $@ + +clean: + rm -rfv $(ALL_OBJ) $(ALL_BIN) + +cleanall: clean diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-blkio-bfq-weight.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-blkio-bfq-weight.sh" new file mode 100755 index 0000000000000000000000000000000000000000..90d5cade00a142e6ee2f644dc809958b46ee7034 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-blkio-bfq-weight.sh" @@ -0,0 +1,130 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240721-163304-894253469 +# @用例名称: cgroup-v1-blkio-bfq-weight +# @用例级别: 1 +# @用例标签: cgroup-v1 blkio bfq-weight +# @用例类型: 测试接口文件blkio.bfq.weight +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-blkio-bfq-weight" +CHILD0="$CGROUP/child0" +CHILD1="$CGROUP/child1" +CHILD2="$CGROUP/child2" +TMP_FILE0="$(mktemp)" +TMP_FILE1="$(mktemp)" +TMP_FILE2="$(mktemp)" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否安装了dd工具 + if ! is_dd_installed; then + skip_test "未安装dd命令" + fi + # @预置条件: 检查是否开启CONFIG_BLK_CGROUP配置 + if ! grep -q CONFIG_BLK_CGROUP=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_BLK_CGROUP配置未开启" + fi + + # @预置条件: 创建两个cgroup组 + mkdir "$CGROUP_TOPDIR"/blkio/$CGROUP + mkdir "$CGROUP_TOPDIR"/blkio/$CHILD0 + mkdir "$CGROUP_TOPDIR"/blkio/$CHILD1 + mkdir "$CGROUP_TOPDIR"/blkio/$CHILD2 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取硬盘设备 + if [[ -e /dev/sda ]]; then + msg "disk is /dev/sda" + disk="sda" + else + msg "disk is /dev/vda" + disk="vda" + fi + + # @测试步骤:2: 保存当前调度器设置 + original_scheduler=$(grep -oP '\[\K[^\]]+' /sys/block/$disk/queue/scheduler) + echo "原始调度器: $original_scheduler" + + # @测试步骤:3: 设置调度器为bfq + echo bfq > /sys/block/$disk/queue/scheduler || return 1 + + + # @测试步骤:4: 设置CHILD0\CHILD1\CHILD2的blkio.bfq.weight + echo 100 >"$CGROUP_TOPDIR"/blkio/$CHILD0/blkio.bfq.weight + echo 200 >"$CGROUP_TOPDIR"/blkio/$CHILD1/blkio.bfq.weight + echo 300 >"$CGROUP_TOPDIR"/blkio/$CHILD2/blkio.bfq.weight + + # @测试步骤:5: 启动dd进程 + sync + echo 3 >/proc/sys/vm/drop_caches + echo $$ > "$CGROUP_TOPDIR"/blkio/$CHILD0/cgroup.procs + dd iflag=direct if=/dev/$disk of=/dev/null bs=1M count=1024 &>"$TMP_FILE0" & + task_pid0=$! + echo $$ > "$CGROUP_TOPDIR"/blkio/$CHILD1/cgroup.procs + dd iflag=direct if=/dev/$disk of=/dev/null bs=1M count=1024 &>"$TMP_FILE1" & + echo $$ > "$CGROUP_TOPDIR"/blkio/$CHILD2/cgroup.procs + dd iflag=direct if=/dev/$disk of=/dev/null bs=1M count=1024 &>"$TMP_FILE2" & + wait $task_pid0 + + msg "io serviced 0: $(cat "$CGROUP_TOPDIR"/blkio/$CHILD0/blkio.throttle.io_serviced)" + msg "io serviced 1: $(cat "$CGROUP_TOPDIR"/blkio/$CHILD1/blkio.throttle.io_serviced)" + msg "io serviced 2: $(cat "$CGROUP_TOPDIR"/blkio/$CHILD2/blkio.throttle.io_serviced)" + + # @测试步骤:5: 获取dd进程的读取速度 + read_speed1=$(grep 'copied' "$TMP_FILE0" | awk '{print $10}') + read_speed2=$(grep 'copied' "$TMP_FILE1" | awk '{print $10}') + read_speed3=$(grep 'copied' "$TMP_FILE2" | awk '{print $10}') + msg "read_speed1: $read_speed1" + msg "read_speed2: $read_speed2" + msg "read_speed3: $read_speed3" + + # @预期结果:1: CHIlD0的读取速度小于CHILD1的读取速度, CHILD1的读取速度小于CHILD2的读取速度 + assert_true [ "$(echo "$read_speed1 < $read_speed2" | bc)" -eq 1 ] + assert_true [ "$(echo "$read_speed2 < $read_speed3" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程从cgroup中移除 + echo $$ > "$CGROUP_TOPDIR"/blkio/cgroup.procs + # @清理工作: 恢复调度器设置 + echo "$original_scheduler" > /sys/block/"$disk"/queue/scheduler + # @清理工作: 删除创建的cgroup组 + rmdir "$CGROUP_TOPDIR"/blkio/$CHILD0 + rmdir "$CGROUP_TOPDIR"/blkio/$CHILD1 + rmdir "$CGROUP_TOPDIR"/blkio/$CHILD2 + rmdir "$CGROUP_TOPDIR"/blkio/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE0" + rm "$TMP_FILE1" + rm "$TMP_FILE2" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### \ No newline at end of file diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-blkio-bfq-weight_device.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-blkio-bfq-weight_device.sh" new file mode 100755 index 0000000000000000000000000000000000000000..a97956bbe3c61346d9df3ad96d9b1e176a8494d0 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-blkio-bfq-weight_device.sh" @@ -0,0 +1,128 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240721-163338-552003922 +# @用例名称: cgroup-v1-blkio-bfq-weight_device +# @用例级别: 1 +# @用例标签: cgroup-v1 blkio bfq-weight_device +# @用例类型: 测试接口文件blkio.bfq.weight_device +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-blkio-bfq-weight_device" +CHILD0="$CGROUP"/child0 +CHILD1="$CGROUP"/child1 +CHILD2="$CGROUP"/child2 +TMP_FILE0="$(mktemp)" +TMP_FILE1="$(mktemp)" +TMP_FILE2="$(mktemp)" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否安装了dd工具 + if ! is_dd_installed; then + skip_test "未安装dd命令" + fi + # @预置条件: 检查是否开启CONFIG_BLK_CGROUP配置 + if ! grep -q CONFIG_BLK_CGROUP=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_BLK_CGROUP配置未开启" + fi + + # @预置条件: 创建cgroup组 + mkdir "$CGROUP_TOPDIR"/blkio/$CGROUP + mkdir "$CGROUP_TOPDIR"/blkio/$CHILD0 + mkdir "$CGROUP_TOPDIR"/blkio/$CHILD1 + mkdir "$CGROUP_TOPDIR"/blkio/$CHILD2 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取硬盘设备 + if [[ -e /dev/sda ]]; then + msg "disk is /dev/sda" + disk="sda" + else + msg "disk is /dev/vda" + disk="vda" + fi + major_device_number=$(stat -c '%t' /dev/$disk) + minor_device_number=$(stat -c '%T' /dev/$disk) + device_number="$major_device_number:$minor_device_number" + + # @测试步骤:3: 保存当前调度器设置 + original_scheduler=$(grep -oP '\[\K[^\]]+' /sys/block/$disk/queue/scheduler) + echo "原始调度器: $original_scheduler" + + # @测试步骤:4: 设置调度器为bfq + echo bfq >/sys/block/$disk/queue/scheduler + + # @测试步骤:5: 设置CHILD0\CHILD1\CHILD2的blkio.bfq.weight_device + echo "$device_number 100" >"$CGROUP_TOPDIR"/blkio/$CHILD0/blkio.bfq.weight_device + echo "$device_number 200" >"$CGROUP_TOPDIR"/blkio/$CHILD1/blkio.bfq.weight_device + echo "$device_number 300" >"$CGROUP_TOPDIR"/blkio/$CHILD2/blkio.bfq.weight_device + + # @测试步骤:6: 启动dd进程 + sync + echo 3 >/proc/sys/vm/drop_caches + echo $$ >"$CGROUP_TOPDIR"/blkio/$CHILD0/cgroup.procs + dd iflag=direct if=/dev/$disk of=/dev/null bs=1M count=1024 &>"$TMP_FILE0" & + task_pid0=$! + echo $$ >"$CGROUP_TOPDIR"/blkio/$CHILD1/cgroup.procs + dd iflag=direct if=/dev/$disk of=/dev/null bs=1M count=1024 &>"$TMP_FILE1" & + echo $$ >"$CGROUP_TOPDIR"/blkio/$CHILD2/cgroup.procs + dd iflag=direct if=/dev/$disk of=/dev/null bs=1M count=1024 &>"$TMP_FILE2" & + wait $task_pid0 + + # @测试步骤:7: 获取dd进程的读取速度 + read_speed1=$(grep 'copied' "$TMP_FILE0" | awk '{print $10}') + read_speed2=$(grep 'copied' "$TMP_FILE1" | awk '{print $10}') + read_speed3=$(grep 'copied' "$TMP_FILE2" | awk '{print $10}') + msg "read_speed1: $read_speed1" + msg "read_speed2: $read_speed2" + msg "read_speed3: $read_speed3" + + # @预期结果:1: CHIlD0的读取速度小于CHILD1的读取速度, CHILD1的读取速度小于CHILD2的读取速度 + assert_true [ "$(echo "$read_speed1 < $read_speed2" | bc)" -eq 1 ] + assert_true [ "$(echo "$read_speed2 < $read_speed3" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程从cgroup中移除 + echo $$ >"$CGROUP_TOPDIR"/blkio/cgroup.procs + # @清理工作: 恢复调度器设置 + echo "$original_scheduler" >/sys/block/"$disk"/queue/scheduler + # @清理工作: 删除cgroup组 + rmdir "$CGROUP_TOPDIR"/blkio/$CHILD0 + rmdir "$CGROUP_TOPDIR"/blkio/$CHILD1 + rmdir "$CGROUP_TOPDIR"/blkio/$CHILD2 + rmdir "$CGROUP_TOPDIR"/blkio/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE0" + rm "$TMP_FILE1" + rm "$TMP_FILE2" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-blkio-throttle-read_bps_device.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-blkio-throttle-read_bps_device.sh" new file mode 100755 index 0000000000000000000000000000000000000000..72dd8a40810a51a7a3ef18f62a699db0df8ae2d8 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-blkio-throttle-read_bps_device.sh" @@ -0,0 +1,97 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240721-144526-288264693 +# @用例名称: cgroup-v1-blkio-throttle-read_bps_device +# @用例级别: 1 +# @用例标签: cgroup-v1 blkio throttle.read_bps_device +# @用例类型: 测试接口文件blkio.throttle.read_bps_device +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-blkio-throttle-read_bps_device" +TMP_FILE="$(mktemp)" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否安装了dd工具 + if ! is_dd_installed; then + skip_test "未安装dd命令" + fi + # @预置条件: 检查是否开启CONFIG_BLK_CGROUP配置 + if ! grep -q CONFIG_BLK_CGROUP=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_BLK_CGROUP配置未开启" + fi + # @预置条件: 检查是否开启CONFIG_BLK_DEV_THROTTLING配置 + if ! grep -q CONFIG_BLK_DEV_THROTTLING=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_BLK_DEV_THROTTLING配置未开启" + fi + + # @预置条件:创建cgroup组 + mkdir "$CGROUP_TOPDIR"/blkio/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取硬盘设备 + if [[ -e /dev/sda ]]; then + msg "disk is /dev/sda" + disk="sda" + else + msg "disk is /dev/vda" + disk="vda" + fi + major_device_number=$(stat -c '%t' /dev/$disk) + minor_device_number=$(stat -c '%T' /dev/$disk) + device_number="$major_device_number:$minor_device_number" + + # @测试步骤:2: 设置blkio.throttle.read_bps_device,限制速度为1MB/s + echo "$device_number 1048576" >"$CGROUP_TOPDIR"/blkio/$CGROUP/blkio.throttle.read_bps_device + + # @测试步骤:3: 启动一个dd进程 + echo $$ >"$CGROUP_TOPDIR"/blkio/$CGROUP/cgroup.procs + dd iflag=direct if=/dev/$disk of=/dev/null bs=1M count=3 2>&1 | tee "$TMP_FILE" + + # @测试步骤:4: 获取dd进程的读取速度 + read_bps=$(grep 'copied' "$TMP_FILE" | awk '{print $10}') + msg "read_bps: $read_bps" + up_read_bps=1.2 + down_read_bps=0.8 + + # @预期结果:1: 如果读取速率在1MB/s左右,说明限速成功 + assert_true [ "$(echo "$read_bps > $down_read_bps" | bc)" -eq 1 ] + assert_true [ "$(echo "$read_bps < $up_read_bps" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程从cgroup中移除 + echo $$ >"$CGROUP_TOPDIR"/blkio/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/blkio/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-blkio-throttle-read_iops_device.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-blkio-throttle-read_iops_device.sh" new file mode 100755 index 0000000000000000000000000000000000000000..64f63f19034049615f2a63de11227daf0b8b7a19 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-blkio-throttle-read_iops_device.sh" @@ -0,0 +1,100 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240721-144536-700486958 +# @用例名称: cgroup-v1-blkio-throttle-read_iops_device +# @用例级别: 1 +# @用例标签: cgroup-v1 blkio throttle.read_iops_device +# @用例类型: 测试接口文件blkio.throttle.read_iops_device +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-blkio-throttle-read_iops_device" +TMP_FILE="$(mktemp)" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否安装了dd工具 + if ! is_dd_installed; then + skip_test "未安装dd命令" + fi + # @预置条件: 检查是否开启CONFIG_BLK_CGROUP配置 + if ! grep -q CONFIG_BLK_CGROUP=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_BLK_CGROUP配置未开启" + fi + # @预置条件: 检查是否开启CONFIG_BLK_DEV_THROTTLING配置 + if ! grep -q CONFIG_BLK_DEV_THROTTLING=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_BLK_DEV_THROTTLING配置未开启" + fi + + # @预置条件: 创建cgroup组 + mkdir "$CGROUP_TOPDIR"/blkio/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取硬盘设备 + if [[ -e /dev/sda ]]; then + msg "disk is /dev/sda" + disk="sda" + else + msg "disk is /dev/vda" + disk="vda" + fi + major_device_number=$(stat -c '%t' /dev/$disk) + minor_device_number=$(stat -c '%T' /dev/$disk) + device_number="$major_device_number:$minor_device_number" + + # @测试步骤:2: 设置blkio.throttle.read_iops_device,限制速度为100 IO/s + echo "$device_number 100" >"$CGROUP_TOPDIR"/blkio/$CGROUP/blkio.throttle.read_iops_device + + # @测试步骤:3: 启动一个dd进程 + echo $$ >"$CGROUP_TOPDIR"/blkio/$CGROUP/cgroup.procs + dd iflag=direct if=/dev/$disk of=/dev/null bs=4k count=300 2>&1 | tee "$TMP_FILE" + time=$(grep -oP '(?<=, )\d+\.\d+(?= s)' "$TMP_FILE") + msg "time: $time" + + # @测试步骤:4: 获取读取速度 + read_iops=$(grep "$device_number Read" "$CGROUP_TOPDIR"/blkio/$CGROUP/blkio.throttle.io_serviced | awk '{print $3}') + read_iops_per_second=$(echo "scale=2; $read_iops / $time" | bc) + msg "read_iops: $read_iops_per_second" + up_read_iops=110 + down_read_iops=90 + + # @预期结果:1: 如果读取速率在100 IO/s左右,说明限速成功 + assert_true [ "$(echo "$read_iops_per_second > $down_read_iops" | bc)" -eq 1 ] + assert_true [ "$(echo "$read_iops_per_second < $up_read_iops" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程从cgroup中移除 + echo $$ >"$CGROUP_TOPDIR"/blkio/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/blkio/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-blkio-throttle-write_bps_device.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-blkio-throttle-write_bps_device.sh" new file mode 100755 index 0000000000000000000000000000000000000000..583ff796bfd595ace8eb65ba748965b7e55c4af8 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-blkio-throttle-write_bps_device.sh" @@ -0,0 +1,97 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240721-144529-920054873 +# @用例名称: cgroup-v1-blkio-throttle-write_bps_device +# @用例级别: 1 +# @用例标签: cgroup-v1 blkio throttle.write_bps_device +# @用例类型: 测试接口文件blkio.throttle.write_bps_device +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-blkio-throttle-write_bps_device" +TMP_FILE="$(mktemp)" +TMP_WIRTE_FILE="$(mktemp)" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否安装了dd工具 + if ! is_dd_installed; then + skip_test "未安装dd命令" + fi + # @预置条件: 检查是否开启CONFIG_BLK_CGROUP配置 + if ! grep -q CONFIG_BLK_CGROUP=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_BLK_CGROUP配置未开启" + fi + # @预置条件: 检查是否开启CONFIG_BLK_DEV_THROTTLING配置 + if ! grep -q CONFIG_BLK_DEV_THROTTLING=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_BLK_DEV_THROTTLING配置未开启" + fi + + # @预置条件: 创建cgroup组 + mkdir "$CGROUP_TOPDIR"/blkio/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取硬盘设备 + if [[ -e /dev/sda ]]; then + msg "disk is /dev/sda" + disk="sda" + else + msg "disk is /dev/vda" + disk="vda" + fi + major_device_number=$(stat -c '%t' /dev/$disk) + minor_device_number=$(stat -c '%T' /dev/$disk) + device_number="$major_device_number:$minor_device_number" + + # @测试步骤:2: 设置blkio.throttle.write_bps_device,限制速度为1MB/s + echo "$device_number 1048576" >"$CGROUP_TOPDIR"/blkio/$CGROUP/blkio.throttle.write_bps_device + + # @测试步骤:3: 启动一个dd进程 + echo $$ >"$CGROUP_TOPDIR"/blkio/$CGROUP/cgroup.procs + dd if=/dev/$disk of="$TMP_WIRTE_FILE" bs=1M count=3 oflag=direct 2>&1 | tee "$TMP_FILE" + + # @测试步骤:4: 获取dd进程的写入速度 + write_bps=$(grep 'copied' "$TMP_FILE" | awk '{print $10}') + msg "write_bps: $write_bps" + up_write_bps=1.2 + down_write_bps=0.8 + + # @预期结果:1: 如果写入速率在1MB/s左右,说明限速成功 + assert_true [ "$(echo "$write_bps > $down_write_bps" | bc)" -eq 1 ] + assert_true [ "$(echo "$write_bps < $up_write_bps" | bc)" -eq 1 ] + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除后台进程 + echo $$ >"$CGROUP_TOPDIR"/blkio/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/blkio/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE" "$TMP_WIRTE_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-blkio-throttle-write_iops_device.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-blkio-throttle-write_iops_device.sh" new file mode 100755 index 0000000000000000000000000000000000000000..789337a4dfac58d98b62669b7a10c67486b31e0f --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-blkio-throttle-write_iops_device.sh" @@ -0,0 +1,100 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240721-144539-871526222 +# @用例名称: cgroup-v1-blkio-throttle-write_iops_device +# @用例级别: 1 +# @用例标签: cgroup-v1 blkio throttle.write_iops_device +# @用例类型: 测试接口文件blkio.throttle.write_iops_device +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-blkio-throttle-write_iops_device" +TMP_FILE="$(mktemp)" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否安装了dd工具 + if ! is_dd_installed; then + skip_test "未安装dd命令" + fi + # @预置条件: 检查是否开启CONFIG_BLK_CGROUP配置 + if ! grep -q CONFIG_BLK_CGROUP=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_BLK_CGROUP配置未开启" + fi + # @预置条件: 检查是否开启CONFIG_BLK_DEV_THROTTLING配置 + if ! grep -q CONFIG_BLK_DEV_THROTTLING=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_BLK_DEV_THROTTLING配置未开启" + fi + + # @预置条件: 创建cgroup组 + mkdir "$CGROUP_TOPDIR"/blkio/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取硬盘设备 + if [[ -e /dev/sda ]]; then + msg "disk is /dev/sda" + disk="sda" + else + msg "disk is /dev/vda" + disk="vda" + fi + major_device_number=$(stat -c '%t' /dev/$disk) + minor_device_number=$(stat -c '%T' /dev/$disk) + device_number="$major_device_number:$minor_device_number" + + # @测试步骤:2: 设置blkio.throttle.write_iops_device,限制速度为100 IO/s + echo "$device_number 100" >"$CGROUP_TOPDIR"/blkio/$CGROUP/blkio.throttle.write_iops_device + + # @测试步骤:3: 启动一个dd进程 + echo $$ >"$CGROUP_TOPDIR"/blkio/$CGROUP/cgroup.procs + dd if=/dev/$disk of=/tmp/testfile bs=4k count=500 oflag=direct 2>&1 | tee "$TMP_FILE" + time=$(grep -oP '(?<=, )\d+\.\d+(?= s)' "$TMP_FILE") + msg "time: $time" + + # @测试步骤:4: 获取写入速度 + write_iops=$(grep "$device_number Write" "$CGROUP_TOPDIR"/blkio/$CGROUP/blkio.throttle.io_serviced | awk '{print $3}') + write_iops_per_second=$(echo "scale=2; $write_iops / $time" | bc) + msg "write_iops_per_second: $write_iops_per_second" + up_write_iops=110 + down_write_iops=90 + + # @预期结果:1: 如果写入速率在100 IO/s左右,说明限速成功 + assert_true [ "$(echo "$write_iops_per_second > $down_write_iops" | bc)" -eq 1 ] + assert_true [ "$(echo "$write_iops_per_second < $up_write_iops" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除后台进程 + echo $$ >"$CGROUP_TOPDIR"/blkio/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/blkio/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpu-cfs-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpu-cfs-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..f834e38dcd79847ab87fc92eef1566d1af819745 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpu-cfs-001.sh" @@ -0,0 +1,83 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240711-115955-308386734 +# @用例名称: cgroup-v1-cpu-cfs-001 +# @用例级别: 1 +# @用例标签: cgroup-v1 cpu cfs +# @用例类型: 测试cpu.cfs_period_us和cpu.cfs_quota_us接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_T + OPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-cpu-cfs-001" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + + # @预置条件: 创建一个新的cgroup + mkdir "$CGROUP_TOPDIR"/cpu/$CGROUP + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置cpu.cfs_period_us和cpu.cfs_quota_us + echo 500000 >"$CGROUP_TOPDIR"/cpu/"${CGROUP}"/cpu.cfs_period_us + echo 400000 >"$CGROUP_TOPDIR"/cpu/"${CGROUP}"/cpu.cfs_quota_us + + # @测试步骤:2: 启动一个占用CPU的进程,并将其放入cgroup + { + while true; do :; done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/cpu/$CGROUP/cgroup.procs + + sleep 3 + + # @测试步骤:3: 读取cpu.stat文件 + cpu_stat=$(cat "$CGROUP_TOPDIR"/cpu/"${CGROUP}"/cpu.stat) + nr_periods=$(echo "$cpu_stat" | grep nr_periods | awk '{print $2}') + nr_throttled=$(echo "$cpu_stat" | grep nr_throttled | awk '{print $2}') + throttled_time=$(echo "$cpu_stat" | grep throttled_time | awk '{print $2}') + msg "nr_periods: $nr_periods" + msg "nr_throttled: $nr_throttled" + msg "throttled_time: $throttled_time" + + # @预期结果:1: cpu.stat文件中的nr_periods和nr_throttled,throttled_time均不为零 + assert_true [ "$nr_periods" -gt 0 ] + assert_true [ "$nr_throttled" -gt 0 ] + assert_true [ "$throttled_time" -gt 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/cpu/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpu-cfs-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpu-cfs-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..d9fcb5f347c8c13a6e7a34cb7bc59bced130e15a --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpu-cfs-002.sh" @@ -0,0 +1,83 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240812-171005-611037314 +# @用例名称: cgroup-v1-cpu-cfs-002 +# @用例级别: 1 +# @用例标签: cgroup-v1 cpu cfs +# @用例类型: 测试cpu.cfs_period_us和cpu.cfs_quota_us接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR + +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-cpu-cfs-002" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + + # @预置条件: 创建一个新的cgroup + mkdir "$CGROUP_TOPDIR"/cpu/$CGROUP + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置cpu.cfs_period_us和cpu.cfs_quota_us + echo 500000 >"$CGROUP_TOPDIR"/cpu/"${CGROUP}"/cpu.cfs_period_us + echo 1000000 >"$CGROUP_TOPDIR"/cpu/"${CGROUP}"/cpu.cfs_quota_us + + # @测试步骤:2: 启动一个占用CPU的进程,并将其放入cgroup + { + while true; do :; done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/cpu/$CGROUP/cgroup.procs + + sleep 3 + + # @测试步骤:3: 读取cpu.stat文件 + cpu_stat=$(cat "$CGROUP_TOPDIR"/cpu/"${CGROUP}"/cpu.stat) + nr_periods=$(echo "$cpu_stat" | grep nr_periods | awk '{print $2}') + nr_throttled=$(echo "$cpu_stat" | grep nr_throttled | awk '{print $2}') + throttled_time=$(echo "$cpu_stat" | grep throttled_time | awk '{print $2}') + msg "nr_periods: $nr_periods" + msg "nr_throttled: $nr_throttled" + msg "throttled_time: $throttled_time" + + # @预期结果:1: cpu.stat文件中的nr_periods等于6s, nr_throttled和throttled_time等于0 + assert_true [ "$nr_periods" -eq 6 ] + assert_true [ "$nr_throttled" -eq 0 ] + assert_true [ "$throttled_time" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/cpu/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpu-shares.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpu-shares.sh" new file mode 100755 index 0000000000000000000000000000000000000000..1826e2155b466bad5e703cbc1c9bf9416bcf243f --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpu-shares.sh" @@ -0,0 +1,141 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240711-102849-220066922 +# @用例名称: cgroup-v1-cpu-shares +# @用例级别: 1 +# @用例标签: cgroup-v1 cpu shares +# @用例类型: 测试cpu.shares接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-cpu-shares" +CHILD0="$CGROUP/child0" +CHILD1="$CGROUP/child1" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件:检查numactl命令是否存在 + if ! is_numactl_installed; then + skip_test "numactl 未安装, 请先安装numactl" + fi + # @预置条件:检查是否支持NUMA + numa_nodes=$(numactl -H | grep "available" | cut -d' ' -f2) + if [ "$numa_nodes" = "0" ]; then + skip_test "系统不支持NUMA架构" + fi + + # @预置条件:创建cgroup + mkdir "$CGROUP_TOPDIR"/cpu/$CGROUP + mkdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + mkdir "$CGROUP_TOPDIR"/cpu/$CHILD0 + mkdir "$CGROUP_TOPDIR"/cpuset/$CHILD0 + mkdir "$CGROUP_TOPDIR"/cpu/$CHILD1 + mkdir "$CGROUP_TOPDIR"/cpuset/$CHILD1 + # @预置条件: 设置cpuset.mems文件 + echo 0 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.mems + echo 0 >"$CGROUP_TOPDIR"/cpuset/$CHILD0/cpuset.mems + echo 0 >"$CGROUP_TOPDIR"/cpuset/$CHILD1/cpuset.mems + # @预置条件: 获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取cpu online list + file_path="$CGROUP_TOPDIR"/cpuset/cpuset.effective_cpus + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:2: 获取没被独占的一个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + if [ -z "$first_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CHILD0/cpuset.cpus + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CHILD1/cpuset.cpus + + # @测试步骤:3: 独占该CPU + echo 1 >"$CGROUP_TOPDIR"/cpuset/cpuset.cpu_exclusive + echo 1 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpu_exclusive + + # 测试步骤:4: 对不同的cgroup设置不同的cpu.shares值 + echo 2048 >"$CGROUP_TOPDIR"/cpu/"$CHILD0"/cpu.shares + echo 512 >"$CGROUP_TOPDIR"/cpu/"$CHILD1"/cpu.shares + + # @测试步骤:5: 启动两个占用CPU的进程,并将其放入不同的cgroup + { + while true; do :; done + } & + task_pid0=$! + echo $task_pid0 >"$CGROUP_TOPDIR"/cpu/"$CHILD0"/cgroup.procs + echo $task_pid0 >"$CGROUP_TOPDIR"/cpuset/"$CHILD0"/cgroup.procs + { + while true; do :; done + } & + task_pid1=$! + echo $task_pid1 >"$CGROUP_TOPDIR"/cpu/"$CHILD1"/cgroup.procs + echo $task_pid1 >"$CGROUP_TOPDIR"/cpuset/"$CHILD1"/cgroup.procs + sleep 3 + + # @测试步骤:6: 获取两个cgroup的CPU使用时间 + usage1=$(cat "$CGROUP_TOPDIR"/cpu/"$CHILD0"/cpuacct.usage) + usage2=$(cat "$CGROUP_TOPDIR"/cpu/"$CHILD1"/cpuacct.usage) + + msg "usage1: $usage1" + msg "usage2: $usage2" + + # @预期结果:1: 验证CPU使用时间比例是否符合预期,4:1 + usage_ratio=$(echo "scale=2; $usage1 / $usage2" | bc) + usage_ratio=$(printf "%.0f" "$usage_ratio") + expected_ratio=4 + assert_true [ "$(echo "$usage_ratio >= $expected_ratio" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid0" "$task_pid1" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/cpu/$CHILD0 + rmdir "$CGROUP_TOPDIR"/cpu/$CHILD1 + rmdir "$CGROUP_TOPDIR"/cpu/$CGROUP + rmdir "$CGROUP_TOPDIR"/cpuset/$CHILD0 + rmdir "$CGROUP_TOPDIR"/cpuset/$CHILD1 + rmdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-stat.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-stat.sh" new file mode 100755 index 0000000000000000000000000000000000000000..776c7e443f0e4a0179cdc073f41ce72f3421508e --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-stat.sh" @@ -0,0 +1,82 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240709-001807-562305058 +# @用例名称: cgroup-v1-cpuacct-stat +# @用例级别: 1 +# @用例标签: cgroup-v1 cpuacct stat +# @用例类型: 测试cpuacct.stat接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-cpuacct-stat" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_CGROUP_CPUACCT配置 + if ! grep -q CONFIG_CGROUP_CPUACCT=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_CPUACCT配置未开启" + fi + + # @预置条件: 创建一个新的cgroup + mkdir "$CGROUP_TOPDIR"/cpuacct/$CGROUP + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 记录运行任务前stat值,单位为USER_HZ + stat_before=$(cat "$CGROUP_TOPDIR"/cpuacct/$CGROUP/cpuacct.stat) + msg "stat_before: $stat_before" + + # @测试步骤:2: 启动一个任务并将其加入cgroup + { + for _ in {1..100}; do + echo -e "line1\nline2\nline3" | awk 'END {print NR}' &> /dev/null + done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/cpuacct/$CGROUP/cgroup.procs + wait $task_pid + + # @测试步骤:3: 记录运行任务后的stat值 + stat_after=$(cat "$CGROUP_TOPDIR"/cpuacct/$CGROUP/cpuacct.stat) + msg "stat_after: $stat_after" + user_before=$(echo "$stat_before" | grep user | awk '{print $2}') + sys_before=$(echo "$stat_before" | grep system | awk '{print $2}') + user_after=$(echo "$stat_after" | grep user | awk '{print $2}') + sys_after=$(echo "$stat_after" | grep system | awk '{print $2}') + + # @预期结果:1:如果用户态和内核态CPU使用情况都有增加,则认为测试通过 + assert_true [ "$user_after" -gt "$user_before" ] + assert_true [ "$sys_after" -gt "$sys_before" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/cpuacct/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-usage.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-usage.sh" new file mode 100755 index 0000000000000000000000000000000000000000..f73fc469c94627530ec62ece76216857cb8a19d0 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-usage.sh" @@ -0,0 +1,79 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240707-111241-514473309 +# @用例名称: cgroup-v1-cpuacct-usage +# @用例级别: 1 +# @用例标签: cgroup-v1 cpuacct usage +# @用例类型: 测试cpuacct.usage接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-cpuacct-usage" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_CGROUP_CPUACCT配置 + if ! grep -q CONFIG_CGROUP_CPUACCT=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_CPUACCT配置未开启" + fi + + # @预置条件:创建一个新的cgroup + mkdir "$CGROUP_TOPDIR"/cpuacct/$CGROUP + return 0 +} + +do_test() { + msg "Running test" + + # @测试步骤:1: 将脚本自身进程放入cgroup + echo $$ >"$CGROUP_TOPDIR"/cpuacct/$CGROUP/cgroup.procs + + # @测试步骤:2: 运行一个CPU密集型任务 + for i in {1..10000}; do echo "$i" >/dev/null; done + + # @测试步骤:3: 获取cpuacct.usage统计数据 + usage_before=$(cat "$CGROUP_TOPDIR"/cpuacct/$CGROUP/cpuacct.usage) + msg "usage_before: $usage_before ns" + + # @测试步骤:4: 再运行一个CPU密集型任务 + for i in {1..10000}; do echo "$i" >/dev/null; done + + # @测试步骤:5: 获取cpuacct.usage统计数据 + usage_after=$(sudo cat "$CGROUP_TOPDIR"/cpuacct/$CGROUP/cpuacct.usage) + msg "usage_after: $usage_after ns" + + # @预期结果:1: 验证统计数据是否正确反映了CPU使用情况,即CPU使用时间增加 + assert_true [ "$usage_after" -gt "$usage_before" ] + + return 0 +} + +tc_teardown() { + msg "Cleaning up test environment" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cpuacct/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/cpuacct/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-usage_all.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-usage_all.sh" new file mode 100755 index 0000000000000000000000000000000000000000..84a47856133c5dffc4e4e52605778cebc769eb31 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-usage_all.sh" @@ -0,0 +1,119 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240812-185112-361462878 +# @用例名称: cgroup-v1-cpuacct-usage_all +# @用例级别: 2 +# @用例标签: cgroup-v1 cpuacct usage_all +# @用例类型: 测试cpuacct.usage_all接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-cpuacct-usage_all" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_CGROUP_CPUACCT配置 + if ! grep -q CONFIG_CGROUP_CPUACCT=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_CPUACCT配置未开启" + fi + + # @预置条件: 创建一个新的cgroup + mkdir "$CGROUP_TOPDIR"/cpuacct/$CGROUP + mkdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + # @预置条件: 设置cpuset.mems文件 + echo 0 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.mems + # @获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取cpu online list + file_path="$CGROUP_TOPDIR"/cpuset/cpuset.effective_cpus + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:2: 获取没被独占的一个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + if [ -z "$first_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + + # @测试步骤:3: 独占该CPU + echo 1 >"$CGROUP_TOPDIR"/cpuset/cpuset.cpu_exclusive + echo 1 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpu_exclusive + + # @测试步骤:4: 记录运行任务前的usage_all值 + usage_all_before=$(cat "$CGROUP_TOPDIR"/cpuacct/$CGROUP/cpuacct.usage_all) + uasge_user_before=$(echo "$usage_all_before" | awk -v row="$((first_online_cpu + 2))" 'NR==row {print $2}') + msg "uasge_user_before: $uasge_user_before" + uasge_sys_before=$(echo "$usage_all_before" | awk -v row="$((first_online_cpu + 2))" 'NR==row {print $3}') + msg "uasge_sys_before: $uasge_sys_before" + + + # @测试步骤:2: 启动一个任务并将其放入cgroup + { + for _ in {1..100}; do + echo -e "line1\nline2\nline3" | awk 'END {print NR}' &> /dev/null + done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/cpuacct/$CGROUP/cgroup.procs + echo $task_pid >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cgroup.procs + wait $task_pid + + # @测试步骤:3: 记录运行任务后的usage_all值 + usage_all_after=$(cat "$CGROUP_TOPDIR"/cpuacct/$CGROUP/cpuacct.usage_all) + usage_user_after=$(echo "$usage_all_after" | awk -v row="$((first_online_cpu + 2))" 'NR==row {print $2}') + msg "usage_user_after: $usage_user_after" + usage_sys_after=$(echo "$usage_all_after" | awk -v row="$((first_online_cpu + 2))" 'NR==row {print $3}') + msg "usage_sys_after: $usage_sys_after" + + # @预期结果:1: 验证统计数据是否正确反映了用户态和内核态CPU使用情况 + assert_true [ "$usage_user_after" -gt "$uasge_user_before" ] + assert_true [ "$usage_sys_after" -gt "$uasge_sys_before" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除创建的cgroup + rmdir "$CGROUP_TOPDIR"/cpuacct/$CGROUP + rmdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-usage_percpu.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-usage_percpu.sh" new file mode 100755 index 0000000000000000000000000000000000000000..f92799cd2463aa06d6017c7ce78d519d4008ded1 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-usage_percpu.sh" @@ -0,0 +1,112 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240708-202749-391700569 +# @用例名称: cgroup-v1-cpuacct-usage_percpu +# @用例级别: 1 +# @用例标签: cgroup-v1 cpuacct usage_percpu +# @用例类型: 测试cpuacct.usage_percpu接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-cpuacct-usage_percpu" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_CGROUP_CPUACCT配置 + if ! grep -q CONFIG_CGROUP_CPUACCT=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_CPUACCT配置未开启" + fi + + # @预置条件: 创建一个新的cgroup + mkdir "$CGROUP_TOPDIR"/cpuacct/$CGROUP + mkdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + # @预置条件: 设置cpuset.mems文件 + echo 0 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.mems + # @获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取cpu online list + file_path="$CGROUP_TOPDIR"/cpuset/cpuset.effective_cpus + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:2: 获取没被独占的一个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + if [ -z "$first_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + + # @测试步骤:3: 独占该CPU + echo 1 >"$CGROUP_TOPDIR"/cpuset/cpuset.cpu_exclusive + echo 1 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpu_exclusive + + # @测试步骤:4: 记录运行任务前的每个CPU使用时间 + usage_percpu_before=$(cat "$CGROUP_TOPDIR"/cpuacct/$CGROUP/cpuacct.usage_percpu) + usage_percpu_before=$(echo "$usage_percpu_before" | awk -v col="$((first_online_cpu + 1))" '{print $col}') + msg "usage_percpu_before: $usage_percpu_before" + + # @测试步骤:5: 启动一个CPU密集型任务并将其放入cgroup + { + while true; do :; done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/cpuacct/$CGROUP/cgroup.procs + echo $task_pid >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cgroup.procs + sleep 3 + + # @测试步骤:6: 记录运行任务后的每CPU使用时间 + usage_percpu_after=$(cat "$CGROUP_TOPDIR"/cpuacct/$CGROUP/cpuacct.usage_percpu) + usage_percpu_after=$(echo "$usage_percpu_after" | awk -v col="$((first_online_cpu + 1))" '{print $col}') + msg "usage_percpu_after: $usage_percpu_after" + + # @预期结果:1: 验证统计数据是否正确反映了CPU使用情况 + assert_true [ "$usage_percpu_after" -gt "$usage_percpu_before" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/cpuacct/$CGROUP + rmdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-usage_percpu_sys.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-usage_percpu_sys.sh" new file mode 100755 index 0000000000000000000000000000000000000000..cde60ca62ab90f15477597020ee2b4636a109541 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-usage_percpu_sys.sh" @@ -0,0 +1,113 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240812-183828-115078858 +# @用例名称: cgroup-v1-cpuacct-usage_percpu_sys +# @用例级别: 2 +# @用例标签: cgroup-v1 cpuacct usage_percpu_sys +# @用例类型: 测试cpuacct.usage_percpu_sys接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-cpuacct-usage_percpu_sys" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_CGROUP_CPUACCT配置 + if ! grep -q CONFIG_CGROUP_CPUACCT=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_CPUACCT配置未开启" + fi + + # @预置条件: 创建一个新的cgroup + mkdir "$CGROUP_TOPDIR"/cpuacct/$CGROUP + mkdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + # @预置条件: 设置cpuset.mems文件 + echo 0 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.mems + # @获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取cpu online list + file_path="$CGROUP_TOPDIR"/cpuset/cpuset.effective_cpus + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:2: 获取没被独占的一个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + if [ -z "$first_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + + # @测试步骤:3: 独占该CPU + echo 1 >"$CGROUP_TOPDIR"/cpuset/cpuset.cpu_exclusive + echo 1 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpu_exclusive + + # @测试步骤:4: 记录运行任务前的所有任务在每个CPU上使用内核态CPU的时间 + usage_percpu_sys_before=$(cat "$CGROUP_TOPDIR"/cpuacct/$CGROUP/cpuacct.usage_percpu_sys) + usage_percpu_sys_before=$(echo "$usage_percpu_sys_before" | awk -v col="$((first_online_cpu + 1))" '{print $col}') + msg "usege_percpu_sys_before: $usage_percpu_sys_before" + + # @测试步骤:5: 启动一个任务并将其放入cgroup + { + for _ in {1..100}; do + dd if=/dev/zero of=/dev/null bs=1M count=1 &> /dev/null + done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/cpuacct/$CGROUP/cgroup.procs + echo $task_pid >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cgroup.procs + wait $task_pid + + # @测试步骤:6: 记录运行任务后的所有任务在每个CPU上使用内核态CPU的时间 + usage_percpu_sys_after=$(cat "$CGROUP_TOPDIR"/cpuacct/$CGROUP/cpuacct.usage_percpu_sys) + usage_percpu_sys_after=$(echo "$usage_percpu_sys_after" | awk -v col="$((first_online_cpu + 1))" '{print $col}') + msg "usage_percpu_sys_after: $usage_percpu_sys_after" + + # @预期结果:1: 验证统计数据是否正确反映了内核态CPU使用情况,即内核态CPU使用时间增加 + assert_true [ "$usage_percpu_sys_after" -gt "$usage_percpu_sys_before" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + rmdir "$CGROUP_TOPDIR"/cpuacct/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-usage_percpu_user.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-usage_percpu_user.sh" new file mode 100755 index 0000000000000000000000000000000000000000..f3820a6859aab85a37b08db3541db0ff24095702 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-usage_percpu_user.sh" @@ -0,0 +1,114 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240812-183608-543735442 +# @用例名称: cgroup-v1-cpuacct-usage_percpu_user +# @用例级别: 2 +# @用例标签: cgroup-v1 cpuacct usage_percpu_user +# @用例类型: 测试cpuacct.usage_percpu_user接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-cpuacct-usage_percpu_user" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_CGROUP_CPUACCT配置 + if ! grep -q CONFIG_CGROUP_CPUACCT=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_CPUACCT配置未开启" + fi + + # @预置条件: 创建一个新的cgroup + mkdir "$CGROUP_TOPDIR"/cpuacct/$CGROUP + mkdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + # @预置条件: 设置cpuset.mems文件 + echo 0 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.mems + # @获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取cpu online list + file_path="$CGROUP_TOPDIR"/cpuset/cpuset.effective_cpus + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:2: 获取没被独占的一个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + if [ -z "$first_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + + # @测试步骤:3: 独占该CPU + echo 1 >"$CGROUP_TOPDIR"/cpuset/cpuset.cpu_exclusive + echo 1 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpu_exclusive + + # @测试步骤:4: 记录运行任务前的所有任务在每个CPU上使用用户态CPU的时间 + usage_percpu_user_before=$(cat "$CGROUP_TOPDIR"/cpuacct/$CGROUP/cpuacct.usage_percpu_user) + usage_percpu_user_before=$(echo "$usage_percpu_user_before" | awk -v col="$((first_online_cpu + 1))" '{print $col}') + msg "usege_percpu_user_before: $usage_percpu_user_before" + + # @测试步骤:5: 启动一个任务并将其放入cgroup + { + for _ in {1..100}; do + echo -e "line1\nline2\nline3" | awk 'END {print NR}' &>/dev/null + done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/cpuacct/$CGROUP/cgroup.procs + echo $task_pid >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cgroup.procs + wait $task_pid + + # @测试步骤:6: 记录运行任务后的所有任务在每个CPU上使用用户态CPU的时间 + usage_percpu_user_after=$(cat "$CGROUP_TOPDIR"/cpuacct/$CGROUP/cpuacct.usage_percpu_user) + usage_percpu_user_after=$(echo "$usage_percpu_user_after" | awk -v col="$((first_online_cpu + 1))" '{print $col}') + msg "usage_percpu_user_after: $usage_percpu_user_after" + + # @预期结果:1: 验证统计数据是否正确反映了用户态CPU使用情况,即用户态CPU使用时间增加 + assert_true [ "$usage_percpu_user_before" -eq 0 ] + assert_true [ "$usage_percpu_user_after" -gt "$usage_percpu_user_before" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/cpuacct/$CGROUP + rmdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-usage_sys.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-usage_sys.sh" new file mode 100755 index 0000000000000000000000000000000000000000..980aee50ac3cb281c3c636147176aa259f4c8322 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-usage_sys.sh" @@ -0,0 +1,79 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240708-210528-911301197 +# @用例名称: cgroup-v1-cpuacct-usage_sys +# @用例级别: 2 +# @用例标签: cgourp-v1 cpuacct usage_sys +# @用例类型: 测试cpuacct.usage_sys接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-cpuacct-usage_sys" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_CGROUP_CPUACCT配置 + if ! grep -q CONFIG_CGROUP_CPUACCT=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_CPUACCT配置未开启" + fi + + # @预置条件: 创建一个新的cgroup + mkdir "$CGROUP_TOPDIR"/cpuacct/$CGROUP + + return 0 +} + +do_test() { + msg "this is do_test" + + # @测试步骤:1: 记录运行任务前的内核态CPU使用时间 + usage_sys_before=$(cat "$CGROUP_TOPDIR"/cpuacct/$CGROUP/cpuacct.usage_sys) + msg "usege_sys_before: $usage_sys_before ns" + + # @测试步骤:2: 启动一个任务并将其放入cgroup + { + for _ in {1..100}; do + dd if=/dev/zero of=/dev/null bs=1M count=1 &>/dev/null + done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/cpuacct/$CGROUP/cgroup.procs + wait $task_pid + + # @测试步骤:3: 记录运行任务后的内核态CPU使用时间 + usage_sys_after=$(cat "$CGROUP_TOPDIR"/cpuacct/$CGROUP/cpuacct.usage_sys) + msg "usage_sys_after: $usage_sys_after ns" + + # @预期结果:1: 验证统计数据是否正确反映了内核态CPU使用情况,即内核态CPU使用时间增加 + assert_true [ "$usage_sys_after" -gt "$usage_sys_before" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/cpuacct/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-usage_user.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-usage_user.sh" new file mode 100755 index 0000000000000000000000000000000000000000..3a7cd1eba5f3b06307ad4b56bc19e36b9d9a303d --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuacct-usage_user.sh" @@ -0,0 +1,78 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240708-214708-138227018 +# @用例名称: cgroup-v1-cpuacct-usage_user +# @用例级别: 2 +# @用例标签: cgroup-v1 cpuacct usage_user +# @用例类型: 测试cpuacct.usage_user接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-cpuacct-usage_user" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_CGROUP_CPUACCT配置 + if ! grep -q CONFIG_CGROUP_CPUACCT=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_CPUACCT配置未开启" + fi + + # @预置条件: 创建一个新的cgroup + mkdir "$CGROUP_TOPDIR"/cpuacct/$CGROUP + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 记录运行任务前的用户态CPU使用时间 + usage_user_before=$(cat "$CGROUP_TOPDIR"/cpuacct/$CGROUP/cpuacct.usage_user) + msg "usage_user_before: $usage_user_before ns" + + # @测试步骤:2: 启用一个任务并将其放入cgroup + { + for _ in {1..100}; do + echo -e "line1\nline2\nline3" | awk 'END {print NR}' &> /dev/null + done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/cpuacct/$CGROUP/cgroup.procs + wait $task_pid + + # @测试步骤:3: 记录运行任务后的用户态CPU使用时间 + usage_user_after=$(cat "$CGROUP_TOPDIR"/cpuacct/$CGROUP/cpuacct.usage_user) + msg "usage_user_after: $usage_user_after ns" + + # @预期结果:1: 验证统计数据是否正确反映了用户态CPU使用情况,即用户态CPU使用时间增加 + assert_true [ "$usage_user_after" -gt "$usage_user_before" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/cpuacct/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-cpu_exclusive.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-cpu_exclusive.sh" new file mode 100755 index 0000000000000000000000000000000000000000..66a18b2a495467071d65d34b7a009bbafad81377 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-cpu_exclusive.sh" @@ -0,0 +1,113 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240714-215345-717910787 +# @用例名称: cgroup-v1-cpuset-cpu_exclusive +# @用例级别: 3 +# @用例标签: cgroup-v1 cpuset cpu_exclusive +# @用例类型: 测试cpu_exclusive接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-cpuset-cpu_exclusive" +CHILD0="$CGROUP/child0" +CHILD1="$CGROUP/child1" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + mkdir "$CGROUP_TOPDIR"/cpuset/$CHILD0 + mkdir "$CGROUP_TOPDIR"/cpuset/$CHILD1 + # @预置条件: 设置cpuset.mems文件 + echo 0 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.mems + echo 0 >"$CGROUP_TOPDIR"/cpuset/$CHILD0/cpuset.mems + echo 0 >"$CGROUP_TOPDIR"/cpuset/$CHILD1/cpuset.mems + # @获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取cpu online list + file_path="$CGROUP_TOPDIR"/cpuset/cpuset.effective_cpus + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:2: 获取没被独占的两个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + second_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 2))" '{print $col}') + msg "second_online_cpu: $second_online_cpu" + if [ -z "$first_online_cpu" ] || [ -z "$second_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu-$second_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + + # @测试步骤:3: 设置root cgroup和CGROUP的cpuset.cpu_exclusive为1 + echo 1 >"$CGROUP_TOPDIR"/cpuset/cpuset.cpu_exclusive + echo 1 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpu_exclusive + + # @测试步骤:4: 设置CHILD0独占first_online_cpu + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CHILD0/cpuset.cpus + echo 1 >"$CGROUP_TOPDIR"/cpuset/$CHILD0/cpuset.cpu_exclusive + + # @测试步骤:5: 尝试在CHILD1中设置包含被CHILD0独占的first_online_cpu + ret=-1 + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CHILD1/cpuset.cpus || ret=0 + + # @预期结果:1: 验证设置cpuset.cpus失败 + assert_true [ $ret -eq 0 ] + + # @测试步骤:6: 设置CHILD1独占second_online_cpu + echo "$second_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CHILD1/cpuset.cpus + echo 1 >"$CGROUP_TOPDIR"/cpuset/$CHILD1/cpuset.cpu_exclusive + + # @测试步骤:7: 尝试在CHILD0中设置包含被CHILD1独占的second_online_cpu + ret=-1 + echo "$second_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CHILD0/cpuset.cpus || ret=0 + + # @预期结果:2: 验证设置cpuset.cpus失败 + assert_true [ $ret -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/cpuset/$CHILD0 + rmdir "$CGROUP_TOPDIR"/cpuset/$CHILD1 + rmdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-cpus.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-cpus.sh" new file mode 100755 index 0000000000000000000000000000000000000000..e2753c676e3cc1575ad2d279be22a9ecf1fc7f23 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-cpus.sh" @@ -0,0 +1,111 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240714-134537-428824230 +# @用例名称: cgroup-v1-cpuset-cpus +# @用例级别: 1 +# @用例标签: cgroup-v1 cpuset cpus +# @用例类型: 测试cpuset.cpus接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-cpuset-cpus" +TMP_FILE="$(mktemp)" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否安装了mpstat命令 + if ! is_sysstat_installed; then + skip_test "没有安装mpstat命令" + fi + + # @预置条件: 创建一个新的cgroup + mkdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + # @预置条件: 设置cpuset.mems文件 + echo 0 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.mems + # @预置条件: 获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取cpu online list + file_path="$CGROUP_TOPDIR"/cpuset/cpuset.effective_cpus + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:2: 获取没被独占的一个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + if [ -z "$first_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + + # @测试步骤:3: 独占该CPU + echo 1 >"$CGROUP_TOPDIR"/cpuset/cpuset.cpu_exclusive + echo 1 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpu_exclusive + + # @测试步骤:4: 启动一个进程并将其放入cgroup + { + while true; do :; done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cgroup.procs + sleep 3 + + # @测试步骤:5: 通过mpstat获取first_online_cpu的使用情况(3s) + cpu0_user_time=$(mpstat -P "$first_online_cpu" 1 3 | grep Average | awk 'NR==2 {print $3}') + msg "cpu0_user_time: $cpu0_user_time" + + # @预期结果:1: 验证CPU的使用率大于50% + assert_true [ "$(echo "$cpu0_user_time > 50.0" | bc)" -eq 1 ] + + # @测试步骤:6: 检查进程绑定的CPU + cpus_allowed=$(cat /proc/$task_pid/status | grep "Cpus_allowed_list" | awk '{print $2}') + + # @预期结果:2: 验证进程是否只在指定的CPU上运行 + assert_true [ "$cpus_allowed" = "$first_online_cpu" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-mem_exclusive.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-mem_exclusive.sh" new file mode 100755 index 0000000000000000000000000000000000000000..ddaf3c1666d50891b40a65b56650c9d075032927 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-mem_exclusive.sh" @@ -0,0 +1,140 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240716-153117-722732954 +# @用例名称: cgroup-v1-cpuset-mem_exclusive +# @用例级别: 1 +# @用例标签: cgroup-v cpuset mem_exclusive +# @用例类型: 测试cpuset.mem_exclusive接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-cpuset-mem_exclusive" +CHILD0="$CGROUP/child0" +CHILD1="$CGROUP/child1" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件:检查numactl命令是否存在 + if ! is_numactl_installed; then + skip_test "numactl 未安装, 请先安装numactl" + fi + # @预置条件:检查是否支持NUMA + numa_nodes=$(numactl -H | grep "available" | cut -d' ' -f2) + if [ "$numa_nodes" = "0" ]; then + skip_test "系统不支持NUMA架构" + fi + # @预置条件:检查NUMA节点数量是否大于1 + if [ "$numa_nodes" -lt 2 ]; then + skip_test "系统NUMA节点数量小于2" + fi + + # @预置条件: 创建两个新的cgroup + mkdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + mkdir "$CGROUP_TOPDIR"/cpuset/$CHILD0 + mkdir "$CGROUP_TOPDIR"/cpuset/$CHILD1 + # @预置条件: 获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取cpu online list + file_path="$CGROUP_TOPDIR"/cpuset/cpuset.effective_cpus + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:2: 获取没被独占的一个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + if [ -z "$first_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CHILD0/cpuset.cpus + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CHILD1/cpuset.cpus + + # @测试步骤:3: 设置root cgroup和CGROUP的cpuset.cpu_exclusive为1 + echo 1 >"$CGROUP_TOPDIR"/cpuset/cpuset.cpu_exclusive + echo 1 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpu_exclusive + + # @测试步骤:4: 获取mem online list + file_path="$CGROUP_TOPDIR"/cpuset/cpuset.effective_mems + mem_online_list=$(get_online_mem_list "$file_path") + msg "mem_online_list: $mem_online_list" + + # @测试步骤:5: 获取两个在线mem + first_online_mem=$(echo "$mem_online_list" | awk '{print $1}') + msg "first_online_mem: $first_online_mem" + second_online_mem=$(echo "$mem_online_list" | awk '{print $2}') + msg "second_online_mem: $second_online_mem" + + # @测试步骤:6: 设置CGROUP的cpuset.mems + echo "$first_online_mem-$second_online_mem" >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.mems + + # @测试步骤:7: 设置CGROUp的cpuset.mem_exclusive文件 + echo 1 >"$CGROUP_TOPDIR"/cpuset/cpuset.mem_exclusive + echo 1 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.mem_exclusive + + # @测试步骤:8: 设置CHILD0独占first_online_mem + echo "$first_online_mem" >"$CGROUP_TOPDIR"/cpuset/$CHILD0/cpuset.mems + echo 1 >"$CGROUP_TOPDIR"/cpuset/$CHILD0/cpuset.mem_exclusive + + # @测试步骤:9: 尝试在CHILD1中设置包含被CHILD0独占的first_online_mem + ret=-1 + echo "$first_online_mem" >"$CGROUP_TOPDIR"/cpuset/$CHILD1/cpuset.mems || ret=0 + + # @预期结果:1: 验证设置cpuset.mems失败 + assert_true [ $ret -eq 0 ] + + # @测试步骤:10: 设置CHILD1独占second_online_mem + echo "$second_online_mem" >"$CGROUP_TOPDIR"/cpuset/$CHILD1/cpuset.mems + echo 1 >"$CGROUP_TOPDIR"/cpuset/$CHILD1/cpuset.mem_exclusive + + # @测试步骤:11: 尝试在CHILD0中设置包含被CHILD1独占的second_online_mem + ret=-1 + echo "$second_online_mem" >"$CGROUP_TOPDIR"/cpuset/$CHILD0/cpuset.mems || ret=0 + + # @预期结果:2: 验证设置cpuset.mems失败 + assert_true [ $ret -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/cpuset/$CHILD0 + rmdir "$CGROUP_TOPDIR"/cpuset/$CHILD1 + rmdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-memory_migrate-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-memory_migrate-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..a9d990e8494a784db3afb43d0ab7d48e81cfff1f --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-memory_migrate-001.sh" @@ -0,0 +1,129 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240716-170043-088308720 +# @用例名称: cgroup-v1-cpuset-memory_migrate-001 +# @用例级别: 2 +# @用例标签: cgroup-v cpuset memory_migrate +# @用例类型: 测试memory_migrate接口文件, 测试启用内存迁移 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-cpuset-memory_migrate-001" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件:检查numactl命令是否存在 + if ! is_numactl_installed; then + skip_test "numactl 未安装, 请先安装numactl" + fi + # @预置条件:检查是否支持NUMA + numa_nodes=$(numactl -H | grep "available" | cut -d' ' -f2) + if [ "$numa_nodes" = "0" ]; then + skip_test "系统不支持NUMA架构" + fi + # @预置条件:检查NUMA节点数量是否大于1 + if [ "$numa_nodes" -lt 2 ]; then + skip_test "系统NUMA节点数量小于2" + fi + + # @预置条件: 创建一个新的cgroup + mkdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + # @预置条件: 获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取cpu online list + file_path="$CGROUP_TOPDIR"/cpuset/cpuset.effective_cpus + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:2: 获取没被独占的一个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + if [ -z "$first_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + + # @测试步骤:3: 独占该CPU + echo 1 >"$CGROUP_TOPDIR"/cpuset/cpuset.cpu_exclusive + echo 1 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpu_exclusive + + # @测试步骤:4: 获取mem online list + file_path="$CGROUP_TOPDIR"/cpuset/cpuset.effective_mems + mem_online_list=$(get_online_mem_list "$file_path") + msg "mem_online_list: $mem_online_list" + + # @测试步骤:5: 获取两个在线mem + first_online_mem=$(echo "$mem_online_list" | awk '{print $1}') + msg "first_online_mem: $first_online_mem" + second_online_mem=$(echo "$mem_online_list" | awk '{print $2}') + msg "second_online_mem: $second_online_mem" + echo "$first_online_mem" >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.mems + + # @测试步骤:6: 启用memory_migrate控制文件 + echo 1 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.memory_migrate + + # @测试步骤:7: 启动一个进程并将其放入cgroup + { + while true; do :; done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cgroup.procs + + # @测试步骤:8: 修改cpuset.mems + echo "$second_online_mem" >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.mems + sleep 3 + + # @测试步骤:9: 检查内存页是否迁移,使用numastat命令 + memory_usage_in_numa0=$(numastat -p $task_pid | awk 'END{print $2}') + memory_usage_in_numa1=$(numastat -p $task_pid | awk 'END{print $3}') + + # @预期结果:1:进程在numa node1上有内存使用,在numa node0没有内存使用 + assert_true [ "$memory_usage_in_numa0" = "0.00" ] + assert_true [ "$(echo "$memory_usage_in_numa1 > 0" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-memory_migrate-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-memory_migrate-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..c084d5382be4bb61f4dfd6f9a99921bfa0680194 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-memory_migrate-002.sh" @@ -0,0 +1,127 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240811-222550-389275834 +# @用例名称: cgroup-v1-cpuset-memory_migrate-002 +# @用例级别: 2 +# @用例标签: cgroup-v cpuset memory_migrate +# @用例类型: 测试memory_migrate接口文件, 测试不启用内存迁移 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-cpuset-memory_migrate-002" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件:检查numactl命令是否存在 + if ! is_numactl_installed; then + skip_test "numactl 未安装, 请先安装numactl" + fi + # @预置条件:检查是否支持NUMA + numa_nodes=$(numactl -H | grep "available" | cut -d' ' -f2) + if [ "$numa_nodes" = "0" ]; then + skip_test "系统不支持NUMA架构" + fi + # @预置条件:检查NUMA节点数量是否大于1 + if [ "$numa_nodes" -lt 2 ]; then + skip_test "系统NUMA节点数量小于2" + fi + + # @预置条件: 创建一个新的cgroup + mkdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + # @预置条件: 获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取cpu online list + file_path="$CGROUP_TOPDIR"/cpuset/cpuset.effective_cpus + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:2: 获取没被独占的一个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + if [ -z "$first_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + + # @测试步骤:3: 独占该CPU + echo 1 >"$CGROUP_TOPDIR"/cpuset/cpuset.cpu_exclusive + echo 1 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpu_exclusive + + # @测试步骤:4: 获取mem online list + file_path="$CGROUP_TOPDIR"/cpuset/cpuset.effective_mems + mem_online_list=$(get_online_mem_list "$file_path") + msg "mem_online_list: $mem_online_list" + + # @测试步骤:5: 获取两个在线mem + first_online_mem=$(echo "$mem_online_list" | awk '{print $1}') + msg "first_online_mem: $first_online_mem" + second_online_mem=$(echo "$mem_online_list" | awk '{print $2}') + msg "second_online_mem: $second_online_mem" + echo "$first_online_mem" >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.mems + + # @测试步骤:6: 启动一个进程并将其放入cgroup + { + while true; do :; done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cgroup.procs + + # @测试步骤:7: 修改cpuset.mems + echo "$second_online_mem" >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.mems + sleep 3 + + # @测试步骤:8: 检查内存页是否迁移,使用numastat命令 + memory_usage_in_numa0=$(numastat -p $task_pid | awk 'END{print $2}') + memory_usage_in_numa1=$(numastat -p $task_pid | awk 'END{print $3}') + + # @预期结果:1: 进程在numa_node0上有内存使用,在numa_node1也有内存使用 + assert_true [ "$(echo "$memory_usage_in_numa0 > 0" | bc)" -eq 1 ] + assert_true [ "$(echo "$memory_usage_in_numa1 > 0" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-memory_spread_page-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-memory_spread_page-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..aa1211b4b25e84bf1d30fc83dd95de9c55953843 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-memory_spread_page-001.sh" @@ -0,0 +1,142 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240719-105612-324932394 +# @用例名称: cgroup-v1-cpuset-memory_spread_page-001 +# @用例级别: 2 +# @用例标签: cgroup-v1 cpuset memory_spread_page +# @用例类型: 测试cpuset.memory_spread_page接口文件,测试不将page cache平均分布道各个节点中 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-cpuset-memory_spread_page-001" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件:检查numactl命令是否存在 + if ! is_numactl_installed; then + skip_test "numactl 未安装, 请先安装numactl" + fi + # @预置条件:检查是否支持NUMA + numa_nodes=$(numactl -H | grep "available" | cut -d' ' -f2) + if [ "$numa_nodes" = "0" ]; then + skip_test "系统不支持NUMA架构" + fi + # @预置条件:检查NUMA节点数量是否大于1 + if [ "$numa_nodes" -lt 2 ]; then + skip_test "系统NUMA节点数量小于2" + fi + + # @预置条件: 创建新的cgroup + mkdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + # @预置条件: 获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取cpu online list + file_path="$CGROUP_TOPDIR"/cpuset/cpuset.effective_cpus + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:2: 获取没被独占的一个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + if [ -z "$first_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + + # @测试步骤:3: 独占该CPU + echo 1 >"$CGROUP_TOPDIR"/cpuset/cpuset.cpu_exclusive + echo 1 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpu_exclusive + + # @测试步骤:4: 获取mem online list + file_path="$CGROUP_TOPDIR"/cpuset/cpuset.effective_mems + mem_online_list=$(get_online_mem_list "$file_path") + msg "mem_online_list: $mem_online_list" + + # @测试步骤:5: 获取两个在线mem + first_online_mem=$(echo "$mem_online_list" | awk '{print $1}') + msg "first_online_mem: $first_online_mem" + second_online_cpu=$(echo "$mem_online_list" | awk '{print $2}') + msg "second_online_cpu: $second_online_cpu" + echo "$first_online_mem-$second_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.mems + + # @测试步骤:6: 获取numa node0和numa node1的FilePages + node0_pagecache=$(numastat -m | grep FilePages | awk '{print $2}') + node1_pagecache=$(numastat -m | grep FilePages | awk '{print $3}') + msg "node0_pagecache: $node0_pagecache" + msg "node1_pagecache: $node1_pagecache" + + # @测试步骤:7: 运行一个需要申请page cache的程序 + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_pagecache 100M & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cgroup.procs + sleep 2 + + # @测试步骤:8: 不断检查numa节点的FilePages大小 + total_node0_pagecache=0 + total_node1_pagecache=0 + for _ in $(seq 1 8); do + node0_current_pagecache=$(numastat -m | grep FilePages | awk '{print $2}') + node1_current_pagecache=$(numastat -m | grep FilePages | awk '{print $3}') + total_node0_pagecache=$(echo "$node0_current_pagecache + $total_node0_pagecache" | bc) + total_node1_pagecache=$(echo "$node1_current_pagecache + $total_node1_pagecache" | bc) + sleep 1 + done + aver_node0_pagecache=$(echo "scale=2; $total_node0_pagecache / 8" | bc) + aver_node1_pagecache=$(echo "scale=2; $total_node1_pagecache / 8" | bc) + msg "aver_node0_pagecache: $aver_node0_pagecache" + msg "aver_node1_pagecache: $aver_node1_pagecache" + + # @预期结果:1: 在误差允许的范围内,node0_diff = 100, node1_diff < 3 + node0_diff=$(echo "scale=2; $aver_node0_pagecache - $node0_pagecache" | bc) + abs_node0_diff=${node0_diff//-/} + node1_diff=$(echo "scale=2; $aver_node1_pagecache - $node1_pagecache" | bc) + abs_node1_diff=${node1_diff//-/} + assert_true [ "$(echo "$abs_node0_diff >= 98" | bc)" -eq 1 ] + assert_true [ "$(echo "$abs_node0_diff <= 102" | bc)" -eq 1 ] + assert_true [ "$(echo "$abs_node1_diff < 3" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + sleep 1 + # @清理动作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-memory_spread_page-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-memory_spread_page-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..64cb32d76f0a669ee0452b34ff9c55bf6ef0ad38 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-memory_spread_page-002.sh" @@ -0,0 +1,148 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240719-150059-269990543 +# @用例名称: cgroup-v1-cpuset-memory_spread_page-002 +# @用例级别: 2 +# @用例标签: cgroup-v1 cpuset memory_spread_page +# @用例类型: 测试cpuset.memory_spread_page接口文件,测试将page cache平均分布道各个节点中 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-cpuset-memory_spread_page-002" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件:检查numactl命令是否存在 + if ! is_numactl_installed; then + skip_test "numactl 未安装, 请先安装numactl" + fi + # @预置条件:检查是否支持NUMA + numa_nodes=$(numactl -H | grep "available" | cut -d' ' -f2) + if [ "$numa_nodes" = "0" ]; then + skip_test "系统不支持NUMA架构" + fi + # @预置条件:检查NUMA节点数量是否大于1 + if [ "$numa_nodes" -lt 2 ]; then + skip_test "系统NUMA节点数量小于2" + fi + + # @预置条件: 创建新的cgroup + mkdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + # @预置条件: 获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取cpu online list + file_path="$CGROUP_TOPDIR"/cpuset/cpuset.effective_cpus + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:2: 获取没被独占的一个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + if [ -z "$first_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + + # @测试步骤:3: 独占该CPU + echo 1 >"$CGROUP_TOPDIR"/cpuset/cpuset.cpu_exclusive + echo 1 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpu_exclusive + + # @测试步骤:4: 获取mem online list + file_path="$CGROUP_TOPDIR"/cpuset/cpuset.effective_mems + mem_online_list=$(get_online_mem_list "$file_path") + msg "mem_online_list: $mem_online_list" + + # @测试步骤:5: 获取两个在线mem + first_online_mem=$(echo "$mem_online_list" | awk '{print $1}') + msg "first_online_mem: $first_online_mem" + second_online_cpu=$(echo "$mem_online_list" | awk '{print $2}') + msg "second_online_cpu: $second_online_cpu" + echo "$first_online_mem-$second_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.mems + + # @测试步骤:6: 启用cpuset.memory_spread_page + echo 1 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.memory_spread_page + + # @测试步骤:7: 获取numa node0和numa node1的FilePages + node0_file_pages=$(numastat -m | grep FilePages | awk '{print $2}') + node1_file_pages=$(numastat -m | grep FilePages | awk '{print $3}') + msg "node0_file_pages: $node0_file_pages" + msg "node1_file_pages: $node1_file_pages" + + # @测试步骤:8: 运行一个需要申请page cache的程序 + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_pagecache 100M & + task_pid=$! + msg "task_pid: $task_pid" + echo $task_pid >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cgroup.procs + sleep 2 + + # @测试步骤:9: 不断检查numa节点的FilePages大小 + total_node0_pagecache=0 + total_node1_pagecache=0 + for _ in $(seq 1 8); do + node0_current_pagecache=$(numastat -m | grep FilePages | awk '{print $2}') + node1_current_pagecache=$(numastat -m | grep FilePages | awk '{print $3}') + msg "node0_current_pagecache: $node0_current_pagecache" + msg "node1_current_pagecache: $node1_current_pagecache" + total_node0_pagecache=$(echo "$node0_current_pagecache + $total_node0_pagecache" | bc) + total_node1_pagecache=$(echo "$node1_current_pagecache + $total_node1_pagecache" | bc) + sleep 1 + done + aver_node0_pagecache=$(echo "scale=2; $total_node0_pagecache / 8" | bc) + aver_node1_pagecache=$(echo "scale=2; $total_node1_pagecache / 8" | bc) + msg "aver_node0_pagecache: $aver_node0_pagecache" + msg "aver_node1_pagecache: $aver_node1_pagecache" + + # @预期结果:1: 在误差允许范围内,node0_diff = 50, node1_diff = 50 + num0_diff=$(echo "scale=2; $aver_node0_pagecache - $node0_file_pages" | bc) + abs_num0_diff=${num0_diff//-/} + num1_diff=$(echo "scale=2; $aver_node1_pagecache - $node1_file_pages" | bc) + abs_num1_diff=${num1_diff//-/} + assert_true [ "$(echo "$abs_num0_diff > 48 " | bc)" -eq 1 ] + assert_true [ "$(echo "$abs_num0_diff < 52" | bc)" -eq 1 ] + assert_true [ "$(echo "$abs_num1_diff > 48" | bc)" -eq 1 ] + assert_true [ "$(echo "$abs_num1_diff < 52" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理动作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-mems.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-mems.sh" new file mode 100755 index 0000000000000000000000000000000000000000..c6039eb273f44c68cf9e0644ca77947ce9e9d22e --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-mems.sh" @@ -0,0 +1,127 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240714-191803-023497569 +# @用例名称: cgroup-v1-cpuset-mems +# @用例级别: 1 +# @用例标签: cgroup-v1 cpuset mems +# @用例类型: 测试cpuset.mems接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-cpuset-mems" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件:检查numactl命令是否存在 + if ! is_numactl_installed; then + skip_test "numactl 未安装, 请先安装numactl" + fi + # @预置条件:检查是否支持NUMA + numa_nodes=$(numactl -H | grep "available" | cut -d' ' -f2) + if [ "$numa_nodes" = "0" ]; then + skip_test "系统不支持NUMA架构" + fi + # @预置条件:检查NUMA节点数量是否大于1 + if [ "$numa_nodes" -lt 2 ]; then + skip_test "系统NUMA节点数量小于2" + fi + + # @预置条件: 创建一个新的cgroup + mkdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + # @预置条件: 获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取cpu online list + file_path="$CGROUP_TOPDIR"/cpuset/cpuset.effective_cpus + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:2: 获取没被独占的一个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + if [ -z "$first_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + + # @测试步骤:3: 设置root cgroup和CGROUP的cpuset.cpu_exclusive为1 + echo 1 >"$CGROUP_TOPDIR"/cpuset/cpuset.cpu_exclusive + echo 1 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpu_exclusive + + # @测试步骤:4: 获取mem online list + file_path="$CGROUP_TOPDIR"/cpuset/cpuset.effective_mems + mem_online_list=$(get_online_mem_list "$file_path") + msg "mem_online_list: $mem_online_list" + + # @测试步骤:5: 获取两个在线mem + first_online_mem=$(echo "$mem_online_list" | awk '{print $1}') + msg "first_online_mem: $first_online_mem" + + # @测试步骤:6: 设置CGROUP的cpuset.mems + echo "$first_online_mem" >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.mems + + # @测试步骤:7: 启动一个进程并将其放入cgroup + { + while true; do :; done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cgroup.procs + sleep 1 + + # @测试步骤:8: 获取进程绑定的NUMA节点的内存使用量 + memory_usage=$(numastat -p $task_pid | awk -v col="$((first_online_mem + 2))" 'END{print $col}') + + # @预期结果:1: memory_usage大于0 + assert_true [ "$(echo "$memory_usage > 0" | bc)" -eq 1 ] + + # @测试步骤:3: 检查进程绑定的NUMA节点 + mems_allowed=$(cat /proc/$task_pid/status | grep "Mems_allowed_list" | awk '{print $2}') + + # @预测结果:2: 验证进程是否只在指定的内存节点上运行 + assert_true [ "$mems_allowed" = "$first_online_mem" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清空后台进程 + kill -9 "$task_pid" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-sched_load_balance.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-sched_load_balance.sh" new file mode 100755 index 0000000000000000000000000000000000000000..cf3a06ccd63a7392a43172de62b1afcd0390ecfe --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-cpuset-sched_load_balance.sh" @@ -0,0 +1,140 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240719-213044-128698057 +# @用例名称: cgroup-v1-cpuset-sched_load_balance +# @用例级别: 1 +# @用例标签: cgroup-v1 cpuset sched_load_balance +# @用例类型: 测试cpuset.sched_load_balance接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-cpuset-sched_load_balance" +TMP_FILE="$(mktemp)" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否安装了mpstat命令 + if ! is_sysstat_installed; then + skip_test "没有安装mpstat命令" + fi + + # @预置条件: 创建一个新的cgroup + mkdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + # @预置条件: 设置cpuset.mems文件 + echo 0 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.mems + # @预置条件: 获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取cpu online list + file_path="$CGROUP_TOPDIR"/cpuset/cpuset.effective_cpus + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:2: 获取没被独占的两个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + second_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 2))" '{print $col}') + msg "second_online_cpu: $second_online_cpu" + if [ -z "$first_online_cpu" ] || [ -z "$second_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu-$second_online_cpu" >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + + # @测试步骤:3: 独占该CPU + echo 1 >"$CGROUP_TOPDIR"/cpuset/cpuset.cpu_exclusive + echo 1 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.cpu_exclusive + + # @测试步骤:4: 禁用负载平衡 + echo 0 >"$CGROUP_TOPDIR"/cpuset/cpuset.sched_load_balance + echo 0 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.sched_load_balance + + # @测试步骤:5: 将当前shell放入CGROUP并启动两个CPU压力进程 + echo $$ >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cgroup.procs + { + while true; do :; done + } & + task_pid0=$! + { + while true; do :; done + } & + task_pid1=$! + + # @测试步骤:6: 通过mpstat获取first_online_cpu和second_online_cpu的使用情况(3s) + cpu0_user_time=$(mpstat -P "$first_online_cpu" 1 3 | grep Average | awk 'NR==2 {print $3}') + msg "cpu0_user_time: $cpu0_user_time" + cpu1_user_time=$(mpstat -P "$second_online_cpu" 1 3 | grep Average | awk 'NR==2 {print $3}') + msg "cpu1_user_time: $cpu1_user_time" + + # @预期结果:1: first_online_cpu或者second_online_cpu其中有一个利用率为0 + echo $$ >"$CGROUP_TOPDIR"/cpuset/cgroup.procs + if [ "$(echo "$cpu0_user_time > 70.0" | bc)" -eq 1 ]; then + assert_true [ "$(echo "$cpu1_user_time < 3" | bc)" -eq 1 ] + elif [ "$(echo "$cpu0_user_time < 3" | bc)" -eq 1 ]; then + assert_true [ "$(echo "$cpu1_user_time > 70.0" | bc)" -eq 1 ] + else + return 1 + fi + + # @测试步骤:7: 启用负载平衡 + echo 1 >"$CGROUP_TOPDIR"/cpuset/cpuset.sched_load_balance + echo 1 >"$CGROUP_TOPDIR"/cpuset/$CGROUP/cpuset.sched_load_balance + sleep 1 + + # @测试步骤:8: 通过mpstat获取first_online_cpu和second_online_cpu的使用情况(3s) + cpu0_user_time=$(mpstat -P "$first_online_cpu" 1 3 | grep Average | awk 'NR==2 {print $3}') + msg "cpu0_user_time: $cpu0_user_time" + cpu1_user_time=$(mpstat -P "$second_online_cpu" 1 3 | grep Average | awk 'NR==2 {print $3}') + msg "cpu1_user_time: $cpu1_user_time" + + # @预期结果:2: first_online_cpu和second_online_cpu利用率都不为0 + echo $$ >"$CGROUP_TOPDIR"/cpuset/cgroup.procs + assert_true [ "$(echo "$cpu0_user_time > 70.0" | bc)" -eq 1 ] + assert_true [ "$(echo "$cpu1_user_time > 70.0" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: kill后台进程 + kill -9 "$task_pid0" "$task_pid1" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/cpuset/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-devices-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-devices-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..83c3eadbf546868d6446c2a869ab94074a2b393f --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-devices-001.sh" @@ -0,0 +1,115 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240724-140024-496158227 +# @用例名称: cgroup-v1-devices-001 +# @用例级别: 1 +# @用例标签: cgroup-v1 devices +# @用例类型: 测试devices.allow接口文件和devices.deny接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-devices-001" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_CGROUP_DEVICE配置 + if ! grep -q CONFIG_CGROUP_DEVICE=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_DEVICE配置未开启" + fi + + # @预置条件: 创建一个cgroup + mkdir "$CGROUP_TOPDIR"/devices/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取硬盘设备 + if [[ -e /dev/sda ]]; then + msg "disk is /dev/sda" + disk="sda" + device_number="8:0" + else + msg "disk is /dev/vda" + disk="vda" + device_number="253:0" + fi + + # @测试步骤:2: 获取光驱设备 + if [[ -e /dev/sr0 ]]; then + msg "disk is /dev/sda" + cdrom="sr0" + else + msg "错误信息: 没有光驱设备CD-ROM" + exit 1 + fi + + # @测试步骤:3: 查看允许访问设备的白名单 + whitelist=$(cat "$CGROUP_TOPDIR"/devices/$CGROUP/devices.list) + + # @预期结果:1: 允许访问设备的白名单为a *:* rwm + assert_true [ "$whitelist" = "a *:* rwm" ] + + # @测试步骤:4: 限制所有设备访问 + echo "a *:* rwm" >"$CGROUP_TOPDIR"/devices/$CGROUP/devices.deny + + # @测试步骤:5: 查看允许访问设备的白名单 + whitelist=$(cat "$CGROUP_TOPDIR"/devices/$CGROUP/devices.list) + + # @预期结果:2: 允许访问设备的白名单为空 + assert_true [ -z "$whitelist" ] + + # @测试步骤:6: 允许访问设备 + echo "b $device_number rwm" >"$CGROUP_TOPDIR"/devices/$CGROUP/devices.allow + + # @测试步骤:7: 查看允许访问设备的白名单 + whitelist=$(cat "$CGROUP_TOPDIR"/devices/$CGROUP/devices.list) + + # @预期结果:3: 允许访问设备的白名单包含设备号 + assert_true [ "$(echo "$whitelist" | grep -c "$device_number")" -eq 1 ] + + # @测试步骤:8: 将当前shell进程加入cgroup + + # @预期结果:4: 验证设备访问限制 + # 访问被允许的设备 + echo $$ >"$CGROUP_TOPDIR"/devices/$CGROUP/cgroup.procs + ret=-1 + test -r /dev/"$disk" && ret=0 + echo $$ >"$CGROUP_TOPDIR"/devices/cgroup.procs + assert_true [ "$ret" -eq 0 ] + # 访问不被允许的设备 + echo $$ >"$CGROUP_TOPDIR"/devices/$CGROUP/cgroup.procs + ret=-1 + test -r /dev/"$cdrom" && ret=0 + echo $$ >"$CGROUP_TOPDIR"/devices/cgroup.procs + assert_false [ "$ret" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/devices/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-devices-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-devices-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..acaa6f7115d09c4b03d4f27f0a0495a053f3eea2 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-devices-002.sh" @@ -0,0 +1,90 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240724-142029-165605406 +# @用例名称: cgroup-v1-devices-002 +# @用例级别: 3 +# @用例标签: cgroup-v1 devices +# @用例类型: 测试deivces的层级结构 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-devices-001" +CHILD0="$CGROUP/child0" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_CGROUP_DEVICE配置 + if ! grep -q CONFIG_CGROUP_DEVICE=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_DEVICE配置未开启" + fi + + # @预置条件: 创建两个cgroup + mkdir "$CGROUP_TOPDIR"/devices/$CGROUP + mkdir "$CGROUP_TOPDIR"/devices/$CHILD0 + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取硬盘设备 + if [[ -e /dev/sda ]]; then + msg "disk is /dev/sda" + device_number_major="8" + device_number_minor="0" + else + msg "disk is /dev/vda" + device_number_major="253" + device_number_minor="0" + fi + + # @测试步骤:2: 限制CHILD0的所有设备访问 + echo "a *:* rwm" >"$CGROUP_TOPDIR"/devices/$CHILD0/devices.deny + + # @测试步骤:3: 允许CHILD0的硬盘设备访问 + echo "b $device_number_major:$device_number_minor rwm" >"$CGROUP_TOPDIR"/devices/$CHILD0/devices.allow + + # @测试步骤:4: 查看CHILD0的允许访问设备的白名单 + whitelist=$(cat "$CGROUP_TOPDIR"/devices/$CHILD0/devices.list) + + # @预期结果:1: CHILD0白名单中包硬盘设备 + assert_true [ "$(echo "$whitelist" | grep -c "$device_number_major:$device_number_minor")" -eq 1 ] + + # @测试步骤:5: 在父cgroup中禁用块设备访问(包含了硬盘设备) + echo "b *:* rwm" >"$CGROUP_TOPDIR"/devices/$CGROUP/devices.deny + + # @测试步骤:6: 查看CHILD0的允许访问设备的白名单 + whitelist=$(cat "$CGROUP_TOPDIR"/devices/$CHILD0/devices.list) + + # @预期结果:2: 此时CHILD0白名单将不再包含硬盘设备 + assert_true [ "$(echo "$whitelist" | grep -c "$device_number_major:$device_number_minor")" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/devices/$CHILD0 + rmdir "$CGROUP_TOPDIR"/devices/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-freezer-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-freezer-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..3d9c73324d185d0e740793926e861c38125a67d9 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-freezer-001.sh" @@ -0,0 +1,110 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240724-155849-953242621 +# @用例名称: cgroup-v1-freezer-001 +# @用例级别: 1 +# @用例标签: cgroup-v1 freezer +# @用例类型: 测试freezer的正常使用 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-freezer-001" +TMP_FILE="$(mktemp)" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_CGROUP_FREEZER配置 + if ! grep -q CONFIG_CGROUP_FREEZER=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_FREEZER配置未开启" + fi + + # @预置条件: 创建一个cgroup + mkdir "$CGROUP_TOPDIR"/freezer/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 查看当前的freezer状态 + freezer_state=$(cat "$CGROUP_TOPDIR"/freezer/$CGROUP/freezer.state) + + # @预期结果:1: 当前cgroup状态为THAWED + assert_true [ "$freezer_state" == "THAWED" ] + + # @测试步骤:2: 创建一个后台进程,定期输出到文件 + { + while true; do + echo "$(date +%s): Runnnig..." >>"$TMP_FILE" + sleep 1 + done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/freezer/$CGROUP/cgroup.procs + sleep 5 + + # @测试步骤:3: 将cgroup状态设置为FROZEN + echo "FROZEN" >"$CGROUP_TOPDIR"/freezer/$CGROUP/freezer.state + + # @测试步骤:4: 进程再睡眠5秒 + sleep 5 + + # @测试步骤:5: 获取文件最后更新 + last_update=$(tail -n 1 "$TMP_FILE" | cut -d ':' -f 1) + msg "last_update: $last_update" + current_time=$(date +%s) + msg "current_time: $current_time" + diff=$((current_time - last_update)) + msg "diff: $diff" + + # @预期结果:2: 文件最后更新时间比现在时间至少差5s + assert_true [ $diff -ge 5 ] + + # @测试步骤:6: 将cgroup状态设置为THAWED + echo "THAWED" >"$CGROUP_TOPDIR"/freezer/$CGROUP/freezer.state + sleep 1 + + # @测试步骤:7: 获取文件最后更新 + last_update=$(tail -n 1 "$TMP_FILE" | cut -d ':' -f 1) + msg "last_update: $last_update" + current_time=$(date +%s) + msg "current_time: $current_time" + diff=$((current_time - last_update)) + msg "diff: $diff" + + # @预期结果:3: 文件最后更新时间跟当前时间一致, 误差最大为1s + assert_true [ $diff -le 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid" + sleep 1 + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/freezer/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-freezer-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-freezer-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..262843f99ab87d1185e6b0c43120248bd4324911 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-freezer-002.sh" @@ -0,0 +1,97 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240724-155852-472494491 +# @用例名称: cgroup-v1-freezer-002 +# @用例级别: 2 +# @用例标签: cgroup-v1 freezer +# @用例类型: 测试freezer的层次结构 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-freezer-002" +CHILD0="$CGROUP/child0" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_CGROUP_FREEZER配置 + if ! grep -q CONFIG_CGROUP_FREEZER=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_FREEZER配置未开启" + fi + + # @预置条件: 创建两个cgroup + mkdir "$CGROUP_TOPDIR"/freezer/$CGROUP + mkdir "$CGROUP_TOPDIR"/freezer/$CHILD0 + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 查看CGROUP和CHILD0的状态 + freezer_state=$(cat "$CGROUP_TOPDIR"/freezer/$CGROUP/freezer.state) + sub_freezer_state=$(cat "$CGROUP_TOPDIR"/freezer/$CHILD0/freezer.state) + + # @预期结果:1: CGROUP状态和CHILD0状态为THAWED + assert_true [ "$freezer_state" = "THAWED" ] + assert_true [ "$sub_freezer_state" = "THAWED" ] + + # @测试步骤:2: 冻结CGROUP + echo "FROZEN" >"$CGROUP_TOPDIR"/freezer/$CGROUP/freezer.state + + # @测试步骤:3: 查看CGROUP和CHILD0的状态 + freezer_state=$(cat "$CGROUP_TOPDIR"/freezer/$CGROUP/freezer.state) + sub_freezer_state=$(cat "$CGROUP_TOPDIR"/freezer/$CHILD0/freezer.state) + + # @预期结果:2: CGROUP状态和CHILD0状态都为FROZEN + assert_true [ "$freezer_state" = "FROZEN" ] + assert_true [ "$sub_freezer_state" = "FROZEN" ] + + # @测试步骤:4: 解冻CHILD0 + echo "THAWED" >"$CGROUP_TOPDIR"/freezer/$CHILD0/freezer.state + + # @测试步骤:5: 查看CHILD0状态 + sub_freezer_state=$(cat "$CGROUP_TOPDIR"/freezer/$CHILD0/freezer.state) + + # @预期结果:3: CHILD0状态仍为FROZEN,因为此时CGROUP仍为FROZEN状态, CHILD0状态不会被有效更改 + assert_true [ "$sub_freezer_state" = "FROZEN" ] + + # @测试步骤:6: 解冻CGROUP + echo "THAWED" >"$CGROUP_TOPDIR"/freezer/$CGROUP/freezer.state + + # @测试步骤:7: 查看CGROUP和CHILD0的状态 + freezer_state=$(cat "$CGROUP_TOPDIR"/freezer/$CGROUP/freezer.state) + sub_freezer_state=$(cat "$CGROUP_TOPDIR"/freezer/$CHILD0/freezer.state) + + # @预期结果:4: CGROUP状态和CHILD0状态都为THAWED + assert_true [ "$freezer_state" = "THAWED" ] + assert_true [ "$sub_freezer_state" = "THAWED" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/freezer/$CHILD0 + rmdir "$CGROUP_TOPDIR"/freezer/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-limit_in_bytes-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-limit_in_bytes-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..67e8bd02a3aa6a04ac82b3cfe200eaf781befb79 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-limit_in_bytes-001.sh" @@ -0,0 +1,107 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240731-141907-292150738 +# @用例名称: cgropu-v1-hugetlb-limit_in_bytes-001 +# @用例级别: 1 +# @用例标签: cgroup-v1 hugetbl limit_in_bytes +# @用例类型: 测试hugetlb.2MB.limit_in_bytes接口文件,超过限制 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgropu-v1-hugetlb-limit_in_bytes-001" + +tc_setup() { + msg "this is tc_setup" + # @预置条l件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 查看是否有CONFIG_CGROUP_HUGETLB配置 + if ! grep -q "CONFIG_CGROUP_HUGETLB=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_HUGETLB配置未开启" + fi + # @预置条件: 查看是否有CONFIG_HUGETLB_PAGE配置 + if ! grep -q "CONFIG_HUGETLB_PAGE=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_HUGETLB_PAGE配置未开启" + fi + # @预置条件: 查看是否有CONFIG_HUGETLBFS配置 + if ! grep -q "CONFIG_HUGETLBFS=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_HUGETLBFS配置未开启" + fi + + # @预置条件: 创建一个cgroup + mkdir "$CGROUP_TOPDIR"/hugetlb/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取系统hugepage的数量 + hugepage_size=$(cat /proc/sys/vm/nr_hugepages) + + # @测试步骤:2: 修改系统hugepage的数量 + echo 4 >/proc/sys/vm/nr_hugepages + + # @测试步骤:3: 获取hugepage的大小 + HUGEPAGE_SIZE_KB=$(grep Hugepagesize /proc/meminfo | awk '{print $2}') + msg "hugepage size: $HUGEPAGE_SIZE_KB" + HUGEPAGE_SIZE_MB=$(conv_unit -o M -i K "$HUGEPAGE_SIZE_KB") + + # @测试步骤:4: 验证hugepage的大小是否为2MB + if [ "$HUGEPAGE_SIZE_MB" -ne 2 ]; then + skip_test "hugepage的大小不等于2MB" + fi + + # @测试步骤:5: 挂载hugetlbfs + mkdir -p /mnt/huge + mount none /mnt/huge -t hugetlbfs + + # @测试步骤:6: 设置cgroup的hugetlb.limit_in_bytes为2MB + echo 2M >"$CGROUP_TOPDIR"/hugetlb/$CGROUP/hugetlb.2MB.limit_in_bytes + + # @测试步骤:7:分配2个hugepage + echo $$ >"$CGROUP_TOPDIR"/hugetlb/$CGROUP/cgroup.procs + "${TST_TS_TOPDIR}"/tst_lib/cgroup_util/bin/alloc_hugepage 2 "$HUGEPAGE_SIZE_MB" &>/dev/null + + # @测试步骤:8: 获取cgroup的hugetlb.2MB.max_usage_in_bytes和hugetlb.2MB.failcnt + MAX_USAGE=$(cat "$CGROUP_TOPDIR"/hugetlb/$CGROUP/hugetlb.2MB.max_usage_in_bytes) + msg "max usage: $MAX_USAGE" + FAILCNT=$(cat "$CGROUP_TOPDIR"/hugetlb/$CGROUP/hugetlb.2MB.failcnt) + msg "failcnt: $FAILCNT" + + # @预期结果:1: max_usage_in_bytes等于2MB, failcnt大于0 + assert_true [ "$MAX_USAGE" -eq 2097152 ] + assert_true [ "$FAILCNT" -gt 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/hugetlb/cgroup.procs + # @清理工作: 卸载hugetlbfs + umount /mnt/huge + rmdir /mnt/huge + # @清理工作: 恢复系统本来的hugepage的大小 + echo "$hugepage_size" >/proc/sys/vm/nr_hugepages + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/hugetlb/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-limit_in_bytes-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-limit_in_bytes-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..02608e79ecbcaa399073f10b02d39928d184514d --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-limit_in_bytes-002.sh" @@ -0,0 +1,106 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240801-115350-763429803 +# @用例名称: cgroup-v1-hugetlb-limit_in_bytes-002 +# @用例级别: 2 +# @用例标签: cgroup-v1 hugetlb limit_in_bytes +# @用例类型: 测试hugetlb.2MB.limit_in_bytes接口文件, 不超过限制 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-hugetlb-limit_in_bytes-002" + +tc_setup() { + msg "this is tc_setup"是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 查看是否有CONFIG_CGROUP_HUGETLB配置 + if ! grep -q "CONFIG_CGROUP_HUGETLB=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_HUGETLB配置未开启" + fi + # @预置条件: 查看是否有CONFIG_HUGETLB_PAGE配置 + if ! grep -q "CONFIG_HUGETLB_PAGE=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_HUGETLB_PAGE配置未开启" + fi + # @预置条件: 查看是否有CONFIG_HUGETLBFS配置 + if ! grep -q "CONFIG_HUGETLBFS=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_HUGETLBFS配置未开启" + fi + + # @预置条件: 创建一个cgroup + mkdir "$CGROUP_TOPDIR"/hugetlb/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取系统hugepage的数量 + hugepage_size=$(cat /proc/sys/vm/nr_hugepages) + + # @测试步骤:2: 修改系统hugepage的数量 + echo 4 >/proc/sys/vm/nr_hugepages + + # @测试步骤:3: 获取hugepage的大小 + HUGEPAGE_SIZE_KB=$(grep Hugepagesize /proc/meminfo | awk '{print $2}') + msg "hugepage size: $HUGEPAGE_SIZE_KB" + HUGEPAGE_SIZE_MB=$(conv_unit -o M -i K "$HUGEPAGE_SIZE_KB") + + # @测试步骤:4: 验证hugepage的大小是否为2MB + if [ "$HUGEPAGE_SIZE_MB" -ne 2 ]; then + skip_test "hugepage的大小不等于2MB" + fi + + # @测试步骤:5: 挂载hugetlbfs + mkdir -p /mnt/huge + mount none /mnt/huge -t hugetlbfs + + # @测试步骤:6: 设置cgroup的hugetlb.limit_in_bytes为2MB + echo 2M >"$CGROUP_TOPDIR"/hugetlb/$CGROUP/hugetlb.2MB.limit_in_bytes + + # @测试步骤:7: 分配2个hugepage + echo $$ >"$CGROUP_TOPDIR"/hugetlb/$CGROUP/cgroup.procs + "${TST_TS_TOPDIR}"/tst_lib/cgroup_util/bin/alloc_hugepage 1 "$HUGEPAGE_SIZE_MB" &>/dev/null + + # @测试步骤:8: 获取cgroup的hugetlb.2MB.max_usage_in_bytes和hugetlb.2MB.failcnt + MAX_USAGE=$(cat "$CGROUP_TOPDIR"/hugetlb/$CGROUP/hugetlb.2MB.max_usage_in_bytes) + msg "max usage: $MAX_USAGE" + FAILCNT=$(cat "$CGROUP_TOPDIR"/hugetlb/$CGROUP/hugetlb.2MB.failcnt) + msg "failcnt: $FAILCNT" + + # @预期结果:1: max_usage_in_bytes等于2MB, failcnt等于0 + assert_true [ "$MAX_USAGE" -eq 2097152 ] + assert_true [ "$FAILCNT" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/hugetlb/cgroup.procs + # @清理工作: 卸载hugetlbfs + umount /mnt/huge + rmdir /mnt/huge + # @清理工作: 恢复系统本来的hugepage的大小 + echo "$hugepage_size" >/proc/sys/vm/nr_hugepages + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/hugetlb/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-limit_in_bytes-003.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-limit_in_bytes-003.sh" new file mode 100755 index 0000000000000000000000000000000000000000..abb7ba30f331d8d6875ea13f4d3650e83cfd1413 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-limit_in_bytes-003.sh" @@ -0,0 +1,100 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240801-115938-131086948 +# @用例名称: cgroup-v1-hugetlb-limit_in_bytes-003 +# @用例级别: 1 +# @用例标签: cgroup-v1 hugetbl limit_in_bytes +# @用例类型: 测试hugetlb.1GB.limit_in_bytes接口文件,超过限制 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-hugetlb-limit_in_bytes-003" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 查看是否有CONFIG_CGROUP_HUGETLB配置 + if ! grep -q "CONFIG_CGROUP_HUGETLB=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_HUGETLB配置未开启" + fi + # @预置条件: 查看是否有CONFIG_HUGETLB_PAGE配置 + if ! grep -q "CONFIG_HUGETLB_PAGE=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_HUGETLB_PAGE配置未开启" + fi + # @预置条件: 查看是否有CONFIG_HUGETLBFS配置 + if ! grep -q "CONFIG_HUGETLBFS=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_HUGETLBFS配置未开启" + fi + + # @预置条件: 创建一个cgroup + mkdir "$CGROUP_TOPDIR"/hugetlb/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取系统本来的hugepage的数量 + HUGEPAGE_SIZE=$(cat /proc/sys/vm/nr_hugepages) + echo 1 >/proc/sys/vm/nr_hugepages + + # @测试步骤:2: 获取hugepage的大小 + HUGEPAGE_SIZE_KB=$(grep Hugepagesize /proc/meminfo | awk '{print $2}') + msg "hugepage size: $HUGEPAGE_SIZE_KB" + HUGEPAGE_SIZE_MB=$(conv_unit -o M -i K "$HUGEPAGE_SIZE_KB") + if [ "$HUGEPAGE_SIZE_MB" -ne 1024 ]; then + skip_test "hugepage的大小不等于1GB" + fi + + # @测试步骤:3: 挂载hugetlbfs + mkdir -p /mnt/huge + mount none /mnt/huge -t hugetlbfs + + # @测试步骤:4: 设置cgroup的hugetlb.limit_in_bytes为512MB + echo 512M >"$CGROUP_TOPDIR"/hugetlb/$CGROUP/hugetlb.1GB.limit_in_bytes + + # @测试步骤:5: 将当前shell进程加入到cgroup中并运行分配hugepage的程序 + echo $$ >"$CGROUP_TOPDIR"/hugetlb/$CGROUP/cgroup.procs + "${TST_TS_TOPDIR}"/tst_lib/cgroup_util/bin/alloc_hugepage 1 "$HUGEPAGE_SIZE_MB" &>/dev/null + + # @测试步骤:6: 获取cgroup的hugetlb.1GB.failcnt + FAILCNT=$(cat "$CGROUP_TOPDIR"/hugetlb/$CGROUP/hugetlb.1GB.failcnt) + msg "failcnt: $FAILCNT" + + # @预期结果:1: failcnt大于0 + assert_true [ "$FAILCNT" -gt 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/hugetlb/cgroup.procs + # @清理工作: 卸载hugetlbfs + umount /mnt/huge + rmdir /mnt/huge + # @清理工作: 恢复系统本来的hugepage的大小 + echo "$HUGEPAGE_SIZE" >/proc/sys/vm/nr_hugepages + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/hugetlb/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-limit_in_bytes-004.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-limit_in_bytes-004.sh" new file mode 100755 index 0000000000000000000000000000000000000000..5a7aa2f4d19514a6ea6f748bb43ef96292a2f03a --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-limit_in_bytes-004.sh" @@ -0,0 +1,103 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240801-115940-264647997 +# @用例名称: cgroup-v1-hugetlb-limit_in_bytes-004 +# @用例级别: 2 +# @用例标签: cgroup-v1 hugetbl limit_in_bytes +# @用例类型: 测试hugetlb.1GB.limit_in_bytes接口文件,不超过限制 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-hugetlb-limit_in_bytes-004" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 查看是否有CONFIG_CGROUP_HUGETLB配置 + if ! grep -q "CONFIG_CGROUP_HUGETLB=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_HUGETLB配置未开启" + fi + # @预置条件: 查看是否有CONFIG_HUGETLB_PAGE配置 + if ! grep -q "CONFIG_HUGETLB_PAGE=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_HUGETLB_PAGE配置未开启" + fi + # @预置条件: 查看是否有CONFIG_HUGETLBFS配置 + if ! grep -q "CONFIG_HUGETLBFS=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_HUGETLBFS配置未开启" + fi + + # @预置条件: 创建一个cgroup + mkdir "$CGROUP_TOPDIR"/hugetlb/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取系统本来的hugepage的数量 + HUGEPAGE_SIZE=$(cat /proc/sys/vm/nr_hugepages) + echo 1 >/proc/sys/vm/nr_hugepages + + # @测试步骤:2: 获取hugepage的大小 + HUGEPAGE_SIZE_KB=$(grep Hugepagesize /proc/meminfo | awk '{print $2}') + msg "hugepage size: $HUGEPAGE_SIZE_KB" + HUGEPAGE_SIZE_MB=$(conv_unit -o M -i K "$HUGEPAGE_SIZE_KB") + if [ "$HUGEPAGE_SIZE_MB" -ne 1024 ]; then + skip_test "hugepage的大小不等于1GB" + fi + + # @测试步骤:3: 挂载hugetlbfs + mkdir -p /mnt/huge + mount none /mnt/huge -t hugetlbfs + + # @测试步骤:4: 设置cgroup的hugetlb.limit_in_bytes为1024MB + echo 1024M >"$CGROUP_TOPDIR"/hugetlb/$CGROUP/hugetlb.1GB.limit_in_bytes + + # @测试步骤:5: 将当前shell进程加入到cgroup中并运行分配hugepage的程序 + echo $$ >"$CGROUP_TOPDIR"/hugetlb/$CGROUP/cgroup.procs + "${TST_TS_TOPDIR}"/tst_lib/cgroup_util/bin/alloc_hugepage 1 "$HUGEPAGE_SIZE_MB" &>/dev/null + + # @测试步骤:6: 获取cgroup的hugetlb.1GB.max_usage_in_bytes和hugetlb.1GB.failcnt + MAX_USAGE=$(cat "$CGROUP_TOPDIR"/hugetlb/$CGROUP/hugetlb.1GB.max_usage_in_bytes) + msg "max usage: $MAX_USAGE" + FAILCNT=$(cat "$CGROUP_TOPDIR"/hugetlb/$CGROUP/hugetlb.1GB.failcnt) + msg "failcnt: $FAILCNT" + + # @预期结果:1: max_usage_in_bytes等于1GB, failcnt等于0 + assert_true [ "$MAX_USAGE" -eq 1073741824 ] + assert_true [ "$FAILCNT" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/hugetlb/cgroup.procs + # @清理工作: 卸载hugetlbfs + umount /mnt/huge + rmdir /mnt/huge + # @清理工作: 恢复系统本来的hugepage的大小 + echo "$HUGEPAGE_SIZE" >/proc/sys/vm/nr_hugepages + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/hugetlb/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-rsvd-limit_in_bytes-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-rsvd-limit_in_bytes-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..053536d6c3f4516fb69cbf5101d517285a6f827e --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-rsvd-limit_in_bytes-001.sh" @@ -0,0 +1,100 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240801-130244-196477079 +# @用例名称: cgroup-v1-hugetlb-rsvd-limit_in_bytes-001 +# @用例级别: 1 +# @用例标签: cgroup-v1 hugetbl rsvd limit_in_bytes +# @用例类型: 测试hugetlb.2MB.rsvd.limit_in_bytes接口文件,超过限制 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-hugetlb-rsvd-limit_in_bytes-001" + +tc_setup() { + msg "this is tc_setup" + # @预置条l件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 查看是否有CONFIG_CGROUP_HUGETLB配置 + if ! grep -q "CONFIG_CGROUP_HUGETLB=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_HUGETLB配置未开启" + fi + # @预置条件: 查看是否有CONFIG_HUGETLB_PAGE配置 + if ! grep -q "CONFIG_HUGETLB_PAGE=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_HUGETLB_PAGE配置未开启" + fi + # @预置条件: 查看是否有CONFIG_HUGETLBFS配置 + if ! grep -q "CONFIG_HUGETLBFS=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_HUGETLBFS配置未开启" + fi + + # @预置条件: 创建一个cgroup + mkdir "$CGROUP_TOPDIR"/hugetlb/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取系统本来的hugepage的数量 + HUGEPAGE_SIZE=$(cat /proc/sys/vm/nr_hugepages) + echo 4 >/proc/sys/vm/nr_hugepages + + # @测试步骤:2: 获取hugepage的大小 + HUGEPAGE_SIZE_KB=$(grep Hugepagesize /proc/meminfo | awk '{print $2}') + msg "hugepage size: $HUGEPAGE_SIZE_KB" + HUGEPAGE_SIZE_MB=$(conv_unit -o M -i K "$HUGEPAGE_SIZE_KB") + if [ "$HUGEPAGE_SIZE_MB" -ne 2 ]; then + skip_test "hugepage的大小不等于2MB" + fi + + # @测试步骤:3: 挂载hugetlbfs + mkdir -p /mnt/huge + mount none /mnt/huge -t hugetlbfs + + # @测试步骤:4: 设置cgroup的hugetlb.limit_in_bytes为2MB + echo 2M >"$CGROUP_TOPDIR"/hugetlb/$CGROUP/hugetlb.2MB.rsvd.limit_in_bytes + + # @测试步骤:5: 分配2个hugepage + echo $$ >"$CGROUP_TOPDIR"/hugetlb/$CGROUP/cgroup.procs + "${TST_TS_TOPDIR}"/tst_lib/cgroup_util/bin/alloc_hugepage_rsvd 2 "$HUGEPAGE_SIZE_MB" &>/dev/null + + # @测试步骤:6: 获取cgroup的hugetlb.2MB.rsvd.failcnt + FAILCNT=$(cat "$CGROUP_TOPDIR"/hugetlb/$CGROUP/hugetlb.2MB.rsvd.failcnt) + msg "failcnt: $FAILCNT" + + # @预期结果:1: failcnt大于0 + assert_true [ "$FAILCNT" -gt 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/hugetlb/cgroup.procs + # @清理工作: 卸载hugetlbfs + umount /mnt/huge + rmdir /mnt/huge + # @清理工作: 恢复系统本来的hugepage的大小 + echo "$HUGEPAGE_SIZE" >/proc/sys/vm/nr_hugepages + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/hugetlb/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-rsvd-limit_in_bytes-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-rsvd-limit_in_bytes-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..1e6ac6e4529a73fad2a44e94bcac0b4e5f9d36a4 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-rsvd-limit_in_bytes-002.sh" @@ -0,0 +1,102 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240801-130248-928221366 +# @用例名称: cgroup-v1-hugetlb-rsvd-limit_in_bytes-002 +# @用例级别: 2 +# @用例标签: cgroup-v1 hugetbl rsvd limit_in_bytes +# @用例类型: 测试hugetlb.2MB.rsvd.limit_in_bytes接口文件,不超过限制 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-hugetlb-rsvd-limit_in_bytes-002" + +tc_setup() { + msg "this is tc_setup" + # @预置条l件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 查看是否有CONFIG_CGROUP_HUGETLB配置 + if ! grep -q "CONFIG_CGROUP_HUGETLB=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_HUGETLB配置未开启" + fi + # @预置条件: 查看是否有CONFIG_HUGETLB_PAGE配置 + if ! grep -q "CONFIG_HUGETLB_PAGE=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_HUGETLB_PAGE配置未开启" + fi + # @预置条件: 查看是否有CONFIG_HUGETLBFS配置 + if ! grep -q "CONFIG_HUGETLBFS=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_HUGETLBFS配置未开启" + fi + + # @预置条件: 创建一个cgroup + mkdir "$CGROUP_TOPDIR"/hugetlb/$CGROUP + return 0 +} +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取系统本来的hugepage的数量 + HUGEPAGE_SIZE=$(cat /proc/sys/vm/nr_hugepages) + echo 4 >/proc/sys/vm/nr_hugepages + + # @测试步骤:2: 获取hugepage的大小 + HUGEPAGE_SIZE_KB=$(grep Hugepagesize /proc/meminfo | awk '{print $2}') + msg "hugepage size: $HUGEPAGE_SIZE_KB" + HUGEPAGE_SIZE_MB=$(conv_unit -o M -i K "$HUGEPAGE_SIZE_KB") + if [ "$HUGEPAGE_SIZE_MB" -ne 2 ]; then + skip_test "hugepage的大小不等于2MB" + fi + + # @测试步骤:3: 挂载hugetlbfs + mkdir -p /mnt/huge + mount none /mnt/huge -t hugetlbfs + + # @测试步骤:4: 设置cgroup的hugetlb.limit_in_bytes为2MB + echo 2M >"$CGROUP_TOPDIR"/hugetlb/$CGROUP/hugetlb.2MB.rsvd.limit_in_bytes + + # @测试步骤:5: 将当前shell进程加入到cgroup中并运行分配hugepage的程序 + echo $$ >"$CGROUP_TOPDIR"/hugetlb/$CGROUP/cgroup.procs + "${TST_TS_TOPDIR}"/tst_lib/cgroup_util/bin/alloc_hugepage_rsvd 1 "$HUGEPAGE_SIZE_MB" &>/dev/null + + # @测试步骤:6: 获取cgroup的hugetlb.2MB.rsvd.max_usage_in_bytes和hugetlb.2MB.rsvd.failcnt + MAX_USAGE=$(cat "$CGROUP_TOPDIR"/hugetlb/$CGROUP/hugetlb.2MB.rsvd.max_usage_in_bytes) + msg "max usage: $MAX_USAGE" + FAILCNT=$(cat "$CGROUP_TOPDIR"/hugetlb/$CGROUP/hugetlb.2MB.rsvd.failcnt) + msg "failcnt: $FAILCNT" + + # @预期结果:1: max_usage_in_bytes等于2MB, failcnt等于0 + assert_true [ "$MAX_USAGE" -eq 2097152 ] + assert_true [ "$FAILCNT" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/hugetlb/cgroup.procs + # @清理工作: 卸载hugetlbfs + umount /mnt/huge + rmdir /mnt/huge + # @清理工作: 恢复系统本来的hugepage的大小 + echo "$HUGEPAGE_SIZE" >/proc/sys/vm/nr_hugepages + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/hugetlb/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-rsvd-limit_in_bytes-003.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-rsvd-limit_in_bytes-003.sh" new file mode 100755 index 0000000000000000000000000000000000000000..2ea00904e28b79dfde848f920dc0df6b0725b185 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-rsvd-limit_in_bytes-003.sh" @@ -0,0 +1,100 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240801-130249-962716187 +# @用例名称: cgroup-v1-hugetlb-rsvd-limit_in_bytes-003 +# @用例级别: 1 +# @用例标签: cgroup-v1 hugetbl rsvd limit_in_bytes +# @用例类型: 测试hugetlb.1GB.rsvd.limit_in_bytes接口文件,超过限制 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-hugetlb-rsvd-limit_in_bytes-003" + +tc_setup() { + msg "this is tc_setup" + # @预置条l件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 查看是否有CONFIG_CGROUP_HUGETLB配置 + if ! grep -q "CONFIG_CGROUP_HUGETLB=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_HUGETLB配置未开启" + fi + # @预置条件: 查看是否有CONFIG_HUGETLB_PAGE配置 + if ! grep -q "CONFIG_HUGETLB_PAGE=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_HUGETLB_PAGE配置未开启" + fi + # @预置条件: 查看是否有CONFIG_HUGETLBFS配置 + if ! grep -q "CONFIG_HUGETLBFS=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_HUGETLBFS配置未开启" + fi + + # @预置条件: 创建一个cgroup + mkdir "$CGROUP_TOPDIR"/hugetlb/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取系统本来的hugepage的数量 + HUGEPAGE_SIZE=$(cat /proc/sys/vm/nr_hugepages) + echo 1 >/proc/sys/vm/nr_hugepages + + # @测试步骤:2: 获取hugepage的大小 + HUGEPAGE_SIZE_KB=$(grep Hugepagesize /proc/meminfo | awk '{print $2}') + msg "hugepage size: $HUGEPAGE_SIZE_KB" + HUGEPAGE_SIZE_MB=$(conv_unit -o M -i K "$HUGEPAGE_SIZE_KB") + if [ "$HUGEPAGE_SIZE_MB" -ne 1024 ]; then + skip_test "hugepage的大小不等于1GB" + fi + + # @测试步骤:3: 挂载hugetlbfs + mkdir -p /mnt/huge + mount none /mnt/huge -t hugetlbfs + + # @测试步骤:4: 设置cgroup的hugetlb.limit_in_bytes为512MB + echo 512M >"$CGROUP_TOPDIR"/hugetlb/$CGROUP/hugetlb.1GB.rsvd.limit_in_bytes + + # @测试步骤:5: 分配1个hugepage + echo $$ >"$CGROUP_TOPDIR"/hugetlb/$CGROUP/cgroup.procs + "${TST_TS_TOPDIR}"/tst_lib/cgroup_util/bin/alloc_hugepage_rsvd 1 "$HUGEPAGE_SIZE_MB" &>/dev/null + + # @测试步骤:6: 获取cgroup的hugetlb.1GB.rsvd.failcnt + FAILCNT=$(cat "$CGROUP_TOPDIR"/hugetlb/$CGROUP/hugetlb.1GB.rsvd.failcnt) + msg "failcnt: $FAILCNT" + + # @预期结果:1: failcnt大于0 + assert_true [ "$FAILCNT" -gt 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/hugetlb/cgroup.procs + # @清理工作: 卸载hugetlbfs + umount /mnt/huge + rmdir /mnt/huge + # @清理工作: 恢复系统本来的hugepage的大小 + echo "$HUGEPAGE_SIZE" >/proc/sys/vm/nr_hugepages + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/hugetlb/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-rsvd-limit_in_bytes-004.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-rsvd-limit_in_bytes-004.sh" new file mode 100755 index 0000000000000000000000000000000000000000..cab559b96e9481ee98c9d546a485d8f9ec32bb34 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-hugetlb-rsvd-limit_in_bytes-004.sh" @@ -0,0 +1,103 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240801-130251-278577040 +# @用例名称: cgroup-v1-hugetlb-rsvd-limit_in_bytes-004 +# @用例级别: 2 +# @用例标签: cgroup-v1 hugetbl rsvd limit_in_bytes +# @用例类型: 测试hugetlb.1GB.rsvd.limit_in_bytes接口文件, 不超过限制 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-hugetlb-rsvd-limit_in_bytes-004" + +tc_setup() { + msg "this is tc_setup" + # @预置条l件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 查看是否有CONFIG_CGROUP_HUGETLB配置 + if ! grep -q "CONFIG_CGROUP_HUGETLB=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_HUGETLB配置未开启" + fi + # @预置条件: 查看是否有CONFIG_HUGETLB_PAGE配置 + if ! grep -q "CONFIG_HUGETLB_PAGE=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_HUGETLB_PAGE配置未开启" + fi + # @预置条件: 查看是否有CONFIG_HUGETLBFS配置 + if ! grep -q "CONFIG_HUGETLBFS=y" "/boot/config-$(uname -r)"; then + skip_test "内核CONFIG_HUGETLBFS配置未开启" + fi + + # @预置条件: 创建一个cgroup + mkdir "$CGROUP_TOPDIR"/hugetlb/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取系统本来的hugepage的数量 + HUGEPAGE_SIZE=$(cat /proc/sys/vm/nr_hugepages) + echo 1 >/proc/sys/vm/nr_hugepages + + # @测试步骤:2: 获取hugepage的大小 + HUGEPAGE_SIZE_KB=$(grep Hugepagesize /proc/meminfo | awk '{print $2}') + msg "hugepage size: $HUGEPAGE_SIZE_KB" + HUGEPAGE_SIZE_MB=$(conv_unit -o M -i K "$HUGEPAGE_SIZE_KB") + if [ "$HUGEPAGE_SIZE_MB" -ne 1024 ]; then + skip_test "hugepage的大小不等于1GB" + fi + + # @测试步骤:3: 挂载hugetlbfs + mkdir -p /mnt/huge + mount none /mnt/huge -t hugetlbfs + + # @测试步骤:4: 设置cgroup的hugetlb.limit_in_bytes为2MB + echo 1024M >"$CGROUP_TOPDIR"/hugetlb/$CGROUP/hugetlb.1GB.rsvd.limit_in_bytes + + # @测试步骤:5: 将当前shell进程加入到cgroup中并运行分配hugepage的程序 + echo $$ >"$CGROUP_TOPDIR"/hugetlb/$CGROUP/cgroup.procs + "${TST_TS_TOPDIR}"/tst_lib/cgroup_util/bin/alloc_hugepage_rsvd 1 "$HUGEPAGE_SIZE_MB" &>/dev/null + + # @测试步骤:6: 获取cgroup的hugetlb.1GB.rsvd.failcnt + MAX_USAGE=$(cat "$CGROUP_TOPDIR"/hugetlb/$CGROUP/hugetlb.1GB.rsvd.max_usage_in_bytes) + msg "max usage: $MAX_USAGE" + FAILCNT=$(cat "$CGROUP_TOPDIR"/hugetlb/$CGROUP/hugetlb.1GB.rsvd.failcnt) + msg "failcnt: $FAILCNT" + + # @预期结果:1: failcnt等于0 + assert_true [ "$MAX_USAGE" -eq 1073741824 ] + assert_true [ "$FAILCNT" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/hugetlb/cgroup.procs + # @清理工作: 卸载hugetlbfs + umount /mnt/huge + rmdir /mnt/huge + # @清理工作: 恢复系统本来的hugepage的大小 + echo "$HUGEPAGE_SIZE" >/proc/sys/vm/nr_hugepages + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/hugetlb/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-limit_in_bytes.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-limit_in_bytes.sh" new file mode 100755 index 0000000000000000000000000000000000000000..55d42aaae19d154f9acf0f6f8f5c133ba98cc3b7 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-limit_in_bytes.sh" @@ -0,0 +1,87 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240723-110114-444553088 +# @用例名称: cgroup-v1-memory-limit_in_bytes +# @用例级别: 1 +# @用例标签: cgroup-v1 memory limit_in_bytes +# @用例类型: 测试memory.limit_in_bytes接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-memory-limit_in_bytes" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_MEMCG配置 + if ! grep -q CONFIG_MEMCG=y /boot/config-"$(uname -r)"; then + skip_test "CONFIG_MEMCG 配置未开启" + fi + + # @预置条件: 创建一个cgroup + mkdir "$CGROUP_TOPDIR"/memory/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 关闭系统上的所有交换空间并设置cgroup的内存限制为50M + swapoff -a + echo 50M >/sys/fs/cgroup/memory/$CGROUP/memory.limit_in_bytes + + # @测试步骤:2: 分配51M内存 + echo $$ >"$CGROUP_TOPDIR"/memory/$CGROUP/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 51M + + # @测试步骤:3: 获取cgroup的最大内存使用量以及内存达到memory.limit_in_bytes的次数 + max_usage_in_bytes=$(cat "$CGROUP_TOPDIR"/memory/$CGROUP/memory.max_usage_in_bytes) + msg "max_usage_in_bytes: $max_usage_in_bytes" + failcnt=$(cat "$CGROUP_TOPDIR"/memory/$CGROUP/memory.failcnt) + msg "failcnt: $failcnt" + + # @测试步骤:4: 获取该cgroup被oom killer杀死的进程数 + oom_control=$(cat "$CGROUP_TOPDIR"/memory/$CGROUP/memory.oom_control) + oom_kill=$(echo "$oom_control" | awk 'NR==3 {print $2}') + msg "oom_kill: $oom_kill" + + # @预期结果:1: 在误差允许的范围内最大内存使用量等于50M且oom_kill大于0 + max_usage_in_bytes=$(echo "$max_usage_in_bytes / 1024 /1024 " | bc ) + assert_true [ "$max_usage_in_bytes" -eq "50" ] + assert_true [ "$oom_kill" -gt "0" ] + # @预期结果:2: 内存达到memory.limit_in_bytes的次数大于0 + assert_true [ "$failcnt" -gt "0" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程从cgroup中移除 + echo $$ >"$CGROUP_TOPDIR"/memory/cgroup.procs + # @清理工作: 开启系统的交换空间 + swapon -a + # @清理工作: 清空所有内存页 + echo 0 >"$CGROUP_TOPDIR"/memory/$CGROUP/memory.force_empty + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/memory/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-memsw-limit_in_bytes.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-memsw-limit_in_bytes.sh" new file mode 100755 index 0000000000000000000000000000000000000000..a87fe2e80d1d7ae90776b920a6da1f183d4c7534 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-memsw-limit_in_bytes.sh" @@ -0,0 +1,89 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240723-131832-170355139 +# @用例名称: cgroup-v1-memory-memsw-limit_in_byte +# @用例级别: 1 +# @用例标签: cgroup-v1 memory memsw limit_in_bytes +# @用例类型: 测试memory.memsw.limit_in_bytes接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-memory-memsw-limit_in_byte" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_MEMCG配置 + if ! grep -q CONFIG_MEMCG=y /boot/config-"$(uname -r)"; then + skip_test "CONFIG_MEMCG 配置未开启" + fi + # @预置条件: 检查是否开启了CONFIG_SWAP配置 + if ! grep -q CONFIG_SWAP=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_SWAP配置未开启" + fi + + # @预置条件: 创建一个cgroup + mkdir "$CGROUP_TOPDIR"/memory/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置cgroup的内存和交换空间限制为50M + echo 50M >/sys/fs/cgroup/memory/$CGROUP/memory.limit_in_bytes + echo 50M >/sys/fs/cgroup/memory/$CGROUP/memory.memsw.limit_in_bytes + + # @测试步骤:2: 分配51M内存 + echo $$ >"$CGROUP_TOPDIR"/memory/$CGROUP/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 51M + + # @测试步骤:3: 获取cgroup的最大内存使用量以及内存达到memory.memsw.limit_in_bytes的次数 + max_memsw_usage_in_bytes=$(cat "$CGROUP_TOPDIR"/memory/$CGROUP/memory.memsw.max_usage_in_bytes) + msg "max_usage_in_bytes: $max_memsw_usage_in_bytes" + memsw_failcnt=$(cat "$CGROUP_TOPDIR"/memory/$CGROUP/memory.memsw.failcnt) + msg "failcnt: $memsw_failcnt" + + # @测试步骤:4: 获取该cgroup被oom killer杀死的进程数 + oom_control=$(cat "$CGROUP_TOPDIR"/memory/$CGROUP/memory.oom_control) + oom_kill=$(echo "$oom_control" | awk 'NR==3 {print $2}') + msg "oom_kill: $oom_kill" + + # @预期结果:1: 在误差允许的范围内最大内存使用量等于50M且oom_kill大于0 + max_memsw_usage_in_bytes=$(echo "$max_memsw_usage_in_bytes / 1024 /1024 " | bc ) + assert_true [ "$max_memsw_usage_in_bytes" -eq 50 ] + assert_true [ "$oom_kill" -gt 0 ] + # @预期结果:2: 内存达到memory.memsw.limit_in_bytes的次数大于0 + assert_true [ "$memsw_failcnt" -gt 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程从cgroup中移除 + echo $$ >"$CGROUP_TOPDIR"/memory/cgroup.procs + # @清理工作: 清空所有内存页 + echo 0 >"$CGROUP_TOPDIR"/memory/$CGROUP/memory.force_empty + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/memory/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-oom_control-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-oom_control-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..71d537ac84c8fa2026abcce6b5cfa655d516c6c6 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-oom_control-001.sh" @@ -0,0 +1,73 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240723-201026-919111329 +# @用例名称: cgroup-v1-memory-oom_control-001 +# @用例级别: 1 +# @用例标签: cgroup-v1 memory oom_control +# @用例类型: 测试memory.oom_control接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-memory-oom_control-001" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_MEMCG配置 + if ! grep -q CONFIG_MEMCG=y /boot/config-"$(uname -r)"; then + skip_test "CONFIG_MEMCG 配置未开启" + fi + + # @预置条件: 创建一个cgroup + mkdir "$CGROUP_TOPDIR"/memory/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置内存限制 + echo 50M >/sys/fs/cgroup/memory/$CGROUP/memory.limit_in_bytes + echo 50M >/sys/fs/cgroup/memory/$CGROUP/memory.memsw.limit_in_bytes + + # @测试步骤:2: 51M内存 + echo $$ >"$CGROUP_TOPDIR"/memory/$CGROUP/cgroup.procs + "$TST_TS_TOPDIR/tst_lib/cgroup_util/bin/alloc_anon" 51M + + # @测试步骤:3: 获取被oom_killer杀死的进程数 + oom_control=$(cat "$CGROUP_TOPDIR"/memory/$CGROUP/memory.oom_control) + oom_kill=$(echo "$oom_control" | awk 'NR==3 {print $2}') + msg "oom_kill: $oom_kill" + + # @预期结果:1: 被oom_killer杀死的进程数大于0 + assert_true [ "$oom_kill" -gt "0" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程从cgroup中移除 + echo $$ >"$CGROUP_TOPDIR"/memory/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/memory/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-oom_control-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-oom_control-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..0afcff2eeb92507de77a16445b5ca2b30e285441 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-oom_control-002.sh" @@ -0,0 +1,79 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240723-201033-714742346 +# @用例名称: cgroup-v1-memory-oom_control-002 +# @用例级别: 2 +# @用例标签: cgroup-v1 memory oom_control +# @用例类型: 测试memory.oom_control接口文件,禁用oom_control +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-memory-oom_control-002" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_MEMCG配置 + if ! grep -q CONFIG_MEMCG=y /boot/config-"$(uname -r)"; then + skip_test "CONFIG_MEMCG 配置未开启" + fi + + # @预置条件: 创建一个cgroup + mkdir "$CGROUP_TOPDIR"/memory/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 禁用oom_control + echo 1 >"$CGROUP_TOPDIR"/memory/$CGROUP/memory.oom_control + + # @测试步骤:2: 设置内存限制 + echo 50M >"$CGROUP_TOPDIR"/memory/$CGROUP/memory.limit_in_bytes + echo 50M >"$CGROUP_TOPDIR"/memory/$CGROUP/memory.memsw.limit_in_bytes + + # @测试步骤:3: 运行一个分配100M内存的进程 + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 100M & + task_pid0=$! + echo $task_pid0 >"$CGROUP_TOPDIR"/memory/$CGROUP/cgroup.procs + sleep 10 + + # @测试步骤:4: 获取被oom_killer杀死的进程数 + oom_control=$(cat "$CGROUP_TOPDIR"/memory/$CGROUP/memory.oom_control) + oom_kill=$(echo "$oom_control" | awk 'NR==3 {print $2}') + msg "oom_kill: $oom_kill" + + # @预期结果:1: 被oom_killer杀死的进程数等于0 + assert_true [ "$oom_kill" -eq "0" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid0" + sleep 1 + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/memory/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-pressure_level.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-pressure_level.sh" new file mode 100755 index 0000000000000000000000000000000000000000..9d2a222c93a2dc9ab8261894348a686effe741dc --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-pressure_level.sh" @@ -0,0 +1,82 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240723-193002-248259812 +# @用例名称: cgroup-v1-memory-pressure_level +# @用例级别: 3 +# @用例标签: cgroup-v1 memory pressure_level +# @用例类型: 测试memory.pressure_level控制文件,设置内存压力通知 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-memory-pressure_level" +TMP_FILE=$(mktemp) + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_MEMCG配置 + if ! grep -q CONFIG_MEMCG=y /boot/config-"$(uname -r)"; then + skip_test "CONFIG_MEMCG 配置未开启" + fi + # @预置条件: 检查是否没有开启CONFIG_PREEMPT_RT配置 + if grep -q CONFIG_PREEMPT_RT=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_PREEMPT_RT配置开启" + fi + + # @预置条件: 新建一个cgroup + mkdir "$CGROUP_TOPDIR"/memory/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 在后台运行监听器 + stdbuf -oL "${TST_TS_TOPDIR}"/tst_lib/cgroup_util/bin/cgroup_event_listener "$CGROUP_TOPDIR"/memory/$CGROUP/memory.pressure_level critical,hierarchy &>"$TMP_FILE" & + + # @测试步骤:2: 设置内存限制 + echo 50M >"$CGROUP_TOPDIR"/memory/$CGROUP/memory.limit_in_bytes + echo 50M >"$CGROUP_TOPDIR"/memory/$CGROUP/memory.memsw.limit_in_bytes + + # @测试步骤:3: 分配51M内存 + echo $$ >"$CGROUP_TOPDIR"/memory/$CGROUP/cgroup.procs + for _ in $(seq 1 10); do + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 51M + done + + # @预期结果:1: 临时文件应该非空,有内存压力通知 + assert_true [ -s "$TMP_FILE" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程从cgroup中移除 + echo $$ >"$CGROUP_TOPDIR"/memory/cgroup.procs + # @清理工作: 清空所有内存页 + echo 0 >"$CGROUP_TOPDIR"/memory/$CGROUP/memory.force_empty + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/memory/$CGROUP + # @清理工作:删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-soft_limit_in_bytes.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-soft_limit_in_bytes.sh" new file mode 100755 index 0000000000000000000000000000000000000000..69fa1b50f1bdf039909d467ae46bdf63558644cf --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-soft_limit_in_bytes.sh" @@ -0,0 +1,84 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240723-133429-048617311 +# @用例名称: cgroup-v1-memory-soft_limit_in_bytes +# @用例级别: 2 +# @用例标签: cgroup-v1 memory soft_limit_in_bytes +# @用例类型: 测试memory.soft_limit_in_bytes控制文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-memory-soft_limit_in_bytes-001" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_MEMCG配置 + if ! grep -q CONFIG_MEMCG=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_MEMCG配置未开启" + fi + # @预置条件: 检查是否没有CONFIG_PREEMPT_RT配置 + if grep -q CONFIG_PREEMPT_RT=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_PREEMPT_RT配置开启" + fi + + # @预置条件: 创建一个cgroup + mkdir "$CGROUP_TOPDIR"/memory/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 关闭系统上的所有交换空间并设置cgroup的内存限制为50M + echo 0 >"$CGROUP_TOPDIR"/memory/$CGROUP/memory.swappiness + echo 50M >"$CGROUP_TOPDIR"/memory/$CGROUP/memory.soft_limit_in_bytes + + # @测试步骤:2: 分配100M内存 + echo $$ >"$CGROUP_TOPDIR"/memory/$CGROUP/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 100M + + # @测试步骤:3: 获取cgroup的最大内存使用量 + max_usage_in_bytes=$(cat "$CGROUP_TOPDIR"/memory/$CGROUP/memory.max_usage_in_bytes) + msg "max_usage_in_bytes: $max_usage_in_bytes" + + # @测试步骤:4: 获取该cgroup被oom killer杀死的进程数 + oom_control=$(cat "$CGROUP_TOPDIR"/memory/$CGROUP/memory.oom_control) + oom_kill=$(echo "$oom_control" | awk 'NR==3 {print $2}') + msg "oom_kill: $oom_kill" + + # @预期结果:1: 最大内存使用量超过了50M且oom_kill等于0 + assert_true [ "$max_usage_in_bytes" -gt "52428800" ] + assert_true [ "$oom_kill" -eq "0" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程从cgroup中移除 + echo $$ >"$CGROUP_TOPDIR"/memory/cgroup.procs + # @清理工作: 清空所有内存页 + echo 0 >"$CGROUP_TOPDIR"/memory/$CGROUP/memory.force_empty + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/memory/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-swappiness-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-swappiness-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..c079036a3af6678bc0ad3ddbe1bec83394692a04 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-swappiness-001.sh" @@ -0,0 +1,86 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240723-142731-893019797 +# @用例名称: cgroup-v1-memory-swappiness-001 +# @用例级别: 1 +# @用例标签: cgroup-v1 memory swappiness +# @用例类型: 测试memory.swappiness控制文件,当swappiness为0时,内存不会被交换到swap空间 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-memory-swappiness-001" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_MEMCG配置 + if ! grep -q CONFIG_MEMCG=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_MEMCG配置未开启" + fi + + # @预置条件: 创建一个cgroup + mkdir "$CGROUP_TOPDIR"/memory/$CGROUP + # @预置条件: 查看系统是否启用了swapping + if [ -z "$(swapon --show)" ]; then + skip_test "系统未启用swap或没有swapfile" + fi + # @预置条件: 清空swap空间内存 + sudo swapoff -a + sudo swapon -a + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置cgroup的内存限制为50M + echo 50M >"$CGROUP_TOPDIR"/memory/$CGROUP/memory.limit_in_bytes + + # @测试步骤:2: 设置cgroup的内存swappiness为0 + echo 0 >"$CGROUP_TOPDIR"/memory/$CGROUP/memory.swappiness + + # @测试步骤:3: 运行一个分配50M内存的进程 + echo $$ >"$CGROUP_TOPDIR"/memory/$CGROUP/cgroup.procs + "$TST_TS_TOPDIR/tst_lib/cgroup_util/bin/alloc_anon" 50M + + # @测试步骤:4: 获取swap空间内存使用量 + swap_usage=$(grep swap "$CGROUP_TOPDIR"/memory/$CGROUP/memory.stat | head -n 1 | awk '{print $2}') + msg "swap_usage: $swap_usage" + + # @预期结果:1: swap空间内存使用量为0 + assert_true [ "$swap_usage" -eq "0" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程从cgroup中移除 + echo $$ >"$CGROUP_TOPDIR"/memory/cgroup.procs + # @清理工作: 清空所有内存页 + echo 0 >"$CGROUP_TOPDIR"/memory/$CGROUP/memory.force_empty + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/memory/$CGROUP + # @清理工作: 清理swap空间 + sudo swapoff -a + sudo swapon -a + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-swappiness-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-swappiness-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..6e2fdd747635663104fb06573fe9f6999a888f8d --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-memory-swappiness-002.sh" @@ -0,0 +1,86 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240723-162157-535660907 +# @用例名称: cgroup-v1-memory-swappiness-002 +# @用例级别: 2 +# @用例标签: cgroup-v1 memory swappiness +# @用例类型: 测试memory.swappiness控制文件,当swappiness为100时,内存会被交换到swap空间 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-memory-swappiness-002" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_MEMCG配置 + if ! grep -q CONFIG_MEMCG=y /boot/config-"$(uname -r)"; then + skip_test "CONFIG_MEMCG 配置未开启" + fi + + # @预置条件: 创建一个cgroup + mkdir "$CGROUP_TOPDIR"/memory/$CGROUP + # @预置条件: 查看系统是否启用了swapping + if [ -z "$(swapon --show)" ]; then + skip_test "系统未启用swap或没有swapfile" + fi + # @预置条件: 清空swap空间内存 + sudo swapoff -a + sudo swapon -a + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置cgroup的内存限制为50M + echo 50M >"$CGROUP_TOPDIR"/memory/$CGROUP/memory.limit_in_bytes + + # @测试步骤:2: 设置cgroup的内存swappiness为100 + echo 100 >"$CGROUP_TOPDIR"/memory/$CGROUP/memory.swappiness + + # @测试步骤:3: 分配50M内存 + echo $$ >"$CGROUP_TOPDIR"/memory/$CGROUP/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 50M + + # @测试步骤:4: 获取swap空间内存使用量 + swap_usage=$(grep swap "$CGROUP_TOPDIR"/memory/$CGROUP/memory.stat | head -n 1 | awk '{print $2}') + msg "swap_usage: $swap_usage" + + # @预期结果:1: swap空间内存使用量大于0 + assert_true [ "$swap_usage" -gt "0" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程从cgroup中移除 + echo $$ >"$CGROUP_TOPDIR"/memory/cgroup.procs + # @清理工作: 清空所有内存页 + echo 0 >"$CGROUP_TOPDIR"/memory/$CGROUP/memory.force_empty + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/memory/$CGROUP + # @清理工作: 清理swap空间 + sudo swapoff -a + sudo swapon -a + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-net_cls-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-net_cls-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..84cda1065f2cb29d11fbc04468cff5df25516cc0 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-net_cls-001.sh" @@ -0,0 +1,115 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240726-114714-002803899 +# @用例名称: cgroup-v1-net_cls-001 +# @用例级别: 1 +# @用例标签: cgroup-v1 net_cls +# @用例类型: 测试设置带宽限制的情况 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-net_cls-001" +TMP_FILE=$(mktemp) + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_CGROUP_NET_CLASSID配置 + if ! grep -q CONFIG_CGROUP_NET_CLASSID=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_NET_CLASSID配置未开启" + fi + # @预置条件: 检查是否安装了tc工具 + if ! is_tc_installed; then + skip_test "没有安装tc工具" + fi + # @预置条件: 检查是否安装了iperf3工具 + if ! is_iperf3_installed; then + skip_test "没有安装iperf3工具" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/net_cls/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 检查是否有回环接口 + if ! ip addr show lo &>/dev/null; then + msg "错误信息: 没有找到回环接口lo" + exit 1 + fi + + # @测试步骤:2: 获取lo接口的ip地址 + lo_ip=$(ip -4 addr show lo | grep -oP '(?<=inet\s)\d+(\.\d+){3}') + msg "lo接口的IP地址是: $lo_ip" + + # @测试步骤:3: 设置net_cls.classid + echo 0x100001 >"$CGROUP_TOPDIR"/net_cls/$CGROUP/net_cls.classid + + # @预期结果:1: 检查是否设置成功 + classid=$(cat "$CGROUP_TOPDIR"/net_cls/$CGROUP/net_cls.classid) + assert_true [ "$classid" = "1048577" ] + + # @测试步骤:4: 给lo接口添加新的队列规则 + tc qdisc add dev lo root handle 10: htb + + # @测试步骤:5: 给lo接口添加新的类 + tc class add dev lo parent 10: classid 10:1 htb rate 5mbit + + # @测试步骤:6: 创建过滤器 + tc filter add dev lo parent 10: protocol ip prio 10 handle 1: cgroup + + # @测试步骤:7: 使用ipef3启动服务端 + iperf3 -s &>/dev/null & + task_pid=$! + + # @测试步骤:8: 将进程加入cgroup;启动iperf3客户端发送数据包到服务端 + echo $$ >"$CGROUP_TOPDIR"/net_cls/$CGROUP/cgroup.procs + iperf3 -c "$lo_ip" -i 1 -t 5 &>"$TMP_FILE" + + # @测试步骤:9: 获取iperf3的接收数据端的bitrate + bitrate=$(grep 'receiver' "$TMP_FILE" | awk '{print $7}') + msg "reciever bitrate: $bitrate" + up_bitrate=6 + down_bitrate=4 + + # @预期结果:2: 在误差允许范围内,检查是否限制了带宽 + kill -9 "$task_pid" + assert_true [ "$(echo "$bitrate > $down_bitrate" | bc)" -eq 1 ] + assert_true [ "$(echo "$bitrate < $up_bitrate" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo 0 >"$CGROUP_TOPDIR"/net_cls/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/net_cls/$CGROUP + # @清理工作: 删除队列规则 + tc qdisc del dev lo root + # @清理工作: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-net_cls-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-net_cls-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..11c032aece9a80262394839ffb79de0a25f17de6 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-net_cls-002.sh" @@ -0,0 +1,97 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240726-114715-271502110 +# @用例名称: cgroup-v1-net_cls-002 +# @用例级别: 2 +# @用例标签: cgroup-v1 net_cls +# @用例类型: 测试不设置带宽限制的情况 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-net_cls-002" +TMP_FILE=$(mktemp) + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_CGROUP_NET_CLASSID配置 + if ! grep -q CONFIG_CGROUP_NET_CLASSID=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_NET_CLASSID配置未开启" + fi + # @预置条件: 检查是否安装了tc工具 + if ! is_tc_installed; then + skip_test "没有安装tc工具" + fi + # @预置条件: 检查是否安装了iperf3工具 + if ! is_iperf3_installed; then + skip_test "没有安装iperf3工具" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/net_cls/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 检查是否有回环接口 + if ! ip addr show lo &>/dev/null; then + msg "错误信息: 没有找到回环接口lo" + exit 1 + fi + + # @测试步骤:2: 获取lo接口的ip地址 + lo_ip=$(ip -4 addr show lo | grep -oP '(?<=inet\s)\d+(\.\d+){3}') + msg "lo接口的IP地址是: $lo_ip" + + # @测试步骤:3: 使用ipef3启动服务端 + iperf3 -s &>/dev/null & + task_pid=$! + + # @测试步骤:4: 将进程加入cgroup;启动iperf3客户端发送数据包到服务端 + echo $$ >"$CGROUP_TOPDIR"/net_cls/$CGROUP/cgroup.procs + iperf3 -c "$lo_ip" -i 1 -t 5 &>"$TMP_FILE" + + # @测试步骤:5: 获取iperf3的接收数据端的bitrate + bitrate=$(grep 'receiver' "$TMP_FILE" | awk '{print $7}') + msg "reciever bitrate: $bitrate" + up_bitrate=6 + + # @预期结果:1: 检查是否没有限制带宽 + kill -9 "$task_pid" + assert_true [ "$(echo "$bitrate > $up_bitrate" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo 0 >"$CGROUP_TOPDIR"/net_cls/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/net_cls/$CGROUP + # @清理工作: 删除队列规则 + tc qdisc del dev lo root + # @清理工作: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-net_prio.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-net_prio.sh" new file mode 100755 index 0000000000000000000000000000000000000000..5aa957b0e491b5355c3a5c19e076cb14315a37a6 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-net_prio.sh" @@ -0,0 +1,72 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240726-211229-939897776 +# @用例名称: cgroup-v1-net_prio +# @用例级别: 3 +# @用例标签: cgroup-v1 net_prio +# @用例类型: 测试net_prio.ifpriomap是否能成功设置 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-net_prio" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_CGROUP_NET_PRIO配置 + if ! grep -q CONFIG_CGROUP_NET_PRIO=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_NET_PRIO配置未开启" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/net_prio/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 检查是否有回环接口 + if ! ip addr show lo &>/dev/null; then + msg "错误信息: 没有找到回环接口lo" + exit 1 + fi + + # @测试步骤:2: 设置net_prio.ifpriomap + echo "lo 5" >"$CGROUP_TOPDIR"/net_prio/$CGROUP/net_prio.ifpriomap + + # @测试步骤:3: 获取net_prio.ifpriomap配置 + ifpriomap=$(cat "$CGROUP_TOPDIR"/net_prio/$CGROUP/net_prio.ifpriomap) + io_ifpriomap=$(echo "$ifpriomap" | grep "lo" | awk '{print $2}') + msg "io_ifpriomap: $io_ifpriomap" + + # @预期结果:1: 检查是否设置成功 + assert_true [ "$io_ifpriomap" -eq 5 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/net_prio/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-perf_event.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-perf_event.sh" new file mode 100755 index 0000000000000000000000000000000000000000..6768042b11a844a8ffb408a1f768ad92c47948ab --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-perf_event.sh" @@ -0,0 +1,91 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240730-141048-321945091 +# @用例名称: cgroup-v1-perf_event +# @用例级别: 3 +# @用例标签: cgroup-v1 perf_event +# @用例类型: 测试perf_event子系统 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-perf_event" +CHILD0="$CGROUP/child0" +CHILD1="$CGROUP/child1" +TMP_FILE=$(mktemp) + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否安装了perf工具 + if ! is_perf_installed; then + skip_test "没有安装perf工具" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/perf_event/$CGROUP + mkdir "$CGROUP_TOPDIR"/perf_event/$CHILD0 + mkdir "$CGROUP_TOPDIR"/perf_event/$CHILD1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 启动一个进程并将其加入CHILD0 + { + while true; do :; done + } & + task_pid0=$! + echo "$task_pid0" >"$CGROUP_TOPDIR"/perf_event/$CHILD0/cgroup.procs + + # @测试步骤:2: 启动一个进程并将其加入CHILD1 + { + while true; do :; done + } & + task_pid1=$! + echo "$task_pid1" >"$CGROUP_TOPDIR"/perf_event/$CHILD1/cgroup.procs + + # @测试步骤:2: 使用perf工具监控进程, 睡眠1s + perf stat -e cpu-clock -a -G $CGROUP sleep 1 &>"$TMP_FILE" + cpu_clock=$(grep "cpu-clock" "$TMP_FILE" | awk '{print $1}' | tr -d ',') + cpu_clock=$(echo "scale=2; $cpu_clock / 1000" | bc) + msg "cpu_clock: $cpu_clock" + + # @预期结果:1: 因为CGROUP中有两个进程, 所以cpu-clock在误差允许的范围内等于2s + assert_true [ "$(echo "$cpu_clock > 1.8" | bc)" -eq 1 ] + assert_true [ "$(echo "$cpu_clock < 2.2" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: kill后台进程 + kill -9 "$task_pid0" "$task_pid1" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/perf_event/$CHILD0 + rmdir "$CGROUP_TOPDIR"/perf_event/$CHILD1 + rmdir "$CGROUP_TOPDIR"/perf_event/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-pids-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-pids-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..f4894e84a5098e0be661d605872a7b3aeef15ffa --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-pids-001.sh" @@ -0,0 +1,76 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240801-154850-001570487 +# @用例名称: cgroup-v1-pids-001 +# @用例级别: 1 +# @用例标签: cgroup-v1 pids +# @用例类型: 测试pids.max控制文件, 进程数超过限制 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-pids-001" +TMP_FILE=$(mktemp) + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_CGROUP_PIDS配置 + if ! grep -q CONFIG_CGROUP_PIDS=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_PIDS配置未开启" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/pids/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置pids.max为2 + echo 2 >"$CGROUP_TOPDIR"/pids/$CGROUP/pids.max + + # @测试步骤:2: 将当前shell加入cgroup + echo $$ >"$CGROUP_TOPDIR"/pids/$CGROUP/cgroup.procs + + # @测试步骤:3: 运行两个子进程 + (echo "Here's some processes for you." | cat) &>"$TMP_FILE" + echo $$ >"$CGROUP_TOPDIR"/pids/cgroup.procs + + # @测试步骤:4: 获取超过最大进程数的次数 + FAILCNT=$(grep max "$CGROUP_TOPDIR"/pids/$CGROUP/pids.events | awk '{print $2}') + + # @预期结果:1: 运行失败 + if grep -q "Resource temporarily unavailable" "$TMP_FILE"; then + assert_true [ "$FAILCNT" -gt 0 ] + else + return 1 + fi + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/pids/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-pids-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-pids-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..1042dbc16ecdd1d68a67740d687005bba8df7914 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-pids-002.sh" @@ -0,0 +1,75 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240801-191404-256040067 +# @用例名称: cgroup-v1-pids-002 +# @用例级别: 2 +# @用例标签: cgroup-v1 pids +# @用例类型: 测试pids.max控制文件, 进程数不超过限制 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-pids-002" +TMP_FILE="$(mktemp)" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_CGROUP_PIDS配置 + if ! grep -q CONFIG_CGROUP_PIDS=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_PIDS配置未开启" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/pids/$CGROUP + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置pids.max为2 + echo 2 >"$CGROUP_TOPDIR"/pids/$CGROUP/pids.max + + # @测试步骤:2: 将当前shell加入cgroup + echo $$ >"$CGROUP_TOPDIR"/pids/$CGROUP/cgroup.procs + + # @测试步骤:3: 运行进程并获取pids.current + PID_NUM=$(cat "$CGROUP_TOPDIR"/pids/$CGROUP/pids.current) + echo $$ >"$CGROUP_TOPDIR"/pids/cgroup.procs + + # @测试步骤:4: 获取超过最大进程数的次数 + FAILCNT=$(grep max "$CGROUP_TOPDIR"/pids/$CGROUP/pids.events | awk '{print $2}') + + # @预期结果:1: PID_NUM为2 + assert_true [ "$PID_NUM" -eq 2 ] + assert_true [ "$FAILCNT" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/pids/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-pids-003.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-pids-003.sh" new file mode 100755 index 0000000000000000000000000000000000000000..2d8e7b6f602d770cc7a7e91882a828376e749cee --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v1-pids-003.sh" @@ -0,0 +1,87 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240801-191225-778933447 +# @用例名称: cgroup-v1-pids-003 +# @用例级别: 2 +# @用例标签: cgroup-v1 pids +# @用例类型: 测试pids的层次结构 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v1-pids-003" +CHILD0="$CGROUP/child0" +TMP_FILE=$(mktemp) + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v1 + if ! check_cgroup_version_is_v1; then + skip_test "cgroup版本不是v1" + fi + # @预置条件: 检查是否开启了CONFIG_CGROUP_PIDS配置 + if ! grep -q CONFIG_CGROUP_PIDS=y /boot/config-"$(uname -r)"; then + skip_test "内核CONFIG_CGROUP_PIDS配置未开启" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/pids/$CGROUP + mkdir "$CGROUP_TOPDIR"/pids/$CHILD0 + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置pids.max为2 + echo 2 >"$CGROUP_TOPDIR"/pids/$CGROUP/pids.max + + # @测试步骤:2: 获取subcgroup的pids.max + PID_MAX=$(cat "$CGROUP_TOPDIR"/pids/$CHILD0/pids.max) + + # @预期结果:1: subcgroup的pids.max为max + assert_true [ "$PID_MAX" = "max" ] + + # @测试步骤:3: 将当前shell加入subcgroup + echo $$ >"$CGROUP_TOPDIR"/pids/$CHILD0/cgroup.procs + + # @测试步骤:4: 运行了两个子进程 + (echo "Here's some processes for you." | cat) &>"$TMP_FILE" + echo $$ >"$CGROUP_TOPDIR"/pids/cgroup.procs + + # @测试步骤:5: 获取超过最大进程数的次数 + FAILCNT=$(grep max "$CGROUP_TOPDIR"/pids/$CHILD0/pids.events | awk '{print $2}') + + # @预期结果:2: 运行失败 + if grep -q "Resource temporarily unavailable" "$TMP_FILE"; then + assert_true [ "$FAILCNT" -gt 0 ] + else + return 1 + fi + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/pids/$CHILD0 + rmdir "$CGROUP_TOPDIR"/pids/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-idle-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-idle-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..a91418ebd743d86697d804470886db1f936aa0be --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-idle-001.sh" @@ -0,0 +1,132 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240805-223037-169024376 +# @用例名称: cgroup-v2-cpu-idle-001 +# @用例级别: 1 +# @用例标签: cgroup-v2 cpu idle +# @用例类型: 测试cpu.idle接口文件,设置SCHD_IDLE调度策略 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-cpu-idle-001" +CHILD0="$CGROUP/child0" +CHILD1="$CGROUP/child1" +TMP_FILE=$(mktemp) + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查父cgroup是否能启用cpu控制器 + if ! check_string_in_file "cpu" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用cpu控制器" + fi + # @预置条件: 启用cpu控制器 + echo "+cpu" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + echo "+cpu" >"$CGROUP_TOPDIR"/$CGROUP/cgroup.subtree_control || return 1 + # @预置条件: 获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取cpu online list + file_path="$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus.effective + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:2: 获取没被独占的一个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + if [ -z "$first_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + + # @测试步骤:3: 独占该CPU + echo "root" >"$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus.partition + + # @测试步骤:4: 创建子cgroup + mkdir "$CGROUP_TOPDIR"/$CHILD0 + mkdir "$CGROUP_TOPDIR"/$CHILD1 + + # @测试步骤:5: 设置CHILD0的cpu.idle值为1 + echo 1 >"$CGROUP_TOPDIR"/$CHILD0/cpu.idle + + # @测试步骤:6: 启动一个占用CPU的进程,并将其放入CHILD0 + { + while true; do :; done + } & + task_pid1=$! + echo $task_pid1 >"$CGROUP_TOPDIR"/$CHILD0/cgroup.procs + + # @测试步骤:7: 启动另一个占用CPU的进程, 并将其放入CHILD1 + { + while true; do :; done + } & + task_pid2=$! + echo $task_pid2 >"$CGROUP_TOPDIR"/$CHILD1/cgroup.procs + + # @测试步骤:8: 使用top命令循环获取task_pid的cpu利用率 + total_cpu_usage=0 + for _ in $(seq 1 10); do + top -b -n 1 -p $task_pid1 >"$TMP_FILE" + cpu_usage=$(grep -A 1 "%CPU" "$TMP_FILE" | tail -n 1 | awk '{print $9}') + total_cpu_usage=$(echo "$total_cpu_usage + $cpu_usage" | bc) + sleep 1 + done + aver_cpu_usage=$(echo "scale=2; $total_cpu_usage / 10" | bc) + msg "average CPU usage: $aver_cpu_usage" + + # @预期结果:1: 在误差范围内,task_pid的cpu利用率应该为0 + aver_cpu_usage_max=5 + assert_true [ "$(echo "$aver_cpu_usage <= $aver_cpu_usage_max" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid1" "$task_pid2" + sleep 1 + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CHILD1 + rmdir "$CGROUP_TOPDIR"/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-idle-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-idle-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..55f08ca4ba69e57990d329d99765f5c7e5d3310b --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-idle-002.sh" @@ -0,0 +1,128 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240805-223054-480591007 +# @用例名称: cgroup-v2-cpu-idle-002 +# @用例级别: 2 +# @用例标签: cgroup-v2 cpu idle +# @用例类型: 测试cpu.idle接口文件,不设置SCHD_IDLE调度策略 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-cpu-idle-002" +CHILD0="$CGROUP/child0" +CHILD1="$CGROUP/child1" +TMP_FILE=$(mktemp) + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用cpu控制器 + if ! check_string_in_file "cpu" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用cpu控制器" + fi + # @预置条件: 启用cpu控制器 + echo "+cpu" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + echo "+cpu" >"$CGROUP_TOPDIR"/$CGROUP/cgroup.subtree_control || return 1 + # @预置条件: 获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取cpu online list + file_path="$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus.effective + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:2: 获取没被独占的一个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + if [ -z "$first_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + + # @测试步骤:3: 独占该CPU + echo "root" >"$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus.partition + + # @测试步骤:4: 创建子cgroup + mkdir "$CGROUP_TOPDIR"/$CHILD0 + mkdir "$CGROUP_TOPDIR"/$CHILD1 + + # @测试步骤:5: 启动一个占用CPU的进程,并将其放入CHILD0 + { + while true; do :; done + } & + task_pid1=$! + echo $task_pid1 >"$CGROUP_TOPDIR"/$CHILD0/cgroup.procs + + # @测试步骤:6: 启动另一个占用CPU的进程并将其放入CHILD1 + { + while true; do :; done + } & + task_pid2=$! + echo $task_pid2 >"$CGROUP_TOPDIR"/$CHILD1/cgroup.procs + + # @测试步骤:7: 使用top命令循环获取task_pid的cpu利用率 + total_cpu_usage=0 + for _ in $(seq 1 10); do + top -b -n 1 -p $task_pid1 >"$TMP_FILE" + cpu_usage=$(grep -A 1 "%CPU" "$TMP_FILE" | tail -n 1 | awk '{print $9}') + total_cpu_usage=$(echo "$total_cpu_usage + $cpu_usage" | bc) + sleep 1 + done + aver_cpu_usage=$(echo "scale=2; $total_cpu_usage / 10" | bc) + msg "average CPU usage: $aver_cpu_usage" + + # @预期结果:1: 在误差范围内,task_pid1的cpu利用率不为0 + assert_true [ "$(echo "$aver_cpu_usage > 0" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid1" "$task_pid2" + sleep 1 + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CHILD1 + rmdir "$CGROUP_TOPDIR"/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-max-burst-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-max-burst-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..cb10c423e4a828bf46db432da55d647aedf3b600 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-max-burst-001.sh" @@ -0,0 +1,85 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240804-223507-640719663 +# @用例名称: cgroup-v2-cpu-max-burst-001 +# @用例级别: 1 +# @用例标签: cgroup-v2 cpu max burst +# @用例类型: 测试cpu.max.burst接口文件,设置限制,并设置burst时间 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-cpu-max-burst-001" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用cpu控制器 + if ! check_string_in_file "cpu" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用cpu控制器" + fi + # @预置条件: 启用cpu控制器 + echo "+cpu" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置cpu.max值 + echo "100000 1000000" >"$CGROUP_TOPDIR"/$CGROUP/cpu.max + + # @测试步骤:2: 设置cpu.max.burst值 + echo "50000" >"$CGROUP_TOPDIR"/$CGROUP/cpu.max.burst + + # @测试步骤:3: 启动一个占用CPU的进程,并将其放入cgroup + { + while true; do :; done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + sleep 3 + + # @测试步骤:4: 读取cpu.stat文件 + cpu_stat=$(cat "$CGROUP_TOPDIR"/$CGROUP/cpu.stat) + msg "cpu_stat: " + msg "$cpu_stat" + nr_bursts=$(echo "$cpu_stat" | grep nr_bursts | awk '{print $2}') + burst_usec=$(echo "$cpu_stat" | grep burst_usec | awk '{print $2}') + + # @预期结果:1: cpu.stat文件中的burst_usec和nr_bursts均大于0 + assert_true [ "$nr_bursts" -gt 0 ] + assert_true [ "$burst_usec" -eq 50000 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid" + sleep 1 + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-max-burst-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-max-burst-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..d3e486fcb1f150eb59c69f8ceae581b19fabfca7 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-max-burst-002.sh" @@ -0,0 +1,83 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240804-224758-298815496 +# @用例名称: cgroup-v2-cpu-max-burst-002 +# @用例级别: 2 +# @用例标签: cgroup-v2 cpu max burst +# @用例类型: 测试cpu.max.burst接口文件,设置限制,不设置burst时间 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-cpu-max-burst-002" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用cpu控制器 + if ! check_string_in_file "cpu" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用cpu控制器" + fi + # @预置条件: 启用cpu控制器 + echo "+cpu" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置cpu.max值 + echo "100000 1000000" >"$CGROUP_TOPDIR"/$CGROUP/cpu.max + + # @测试步骤:2: 启动一个占用CPU的进程,并将其放入cgroup + { + while true; do :; done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + sleep 3 + + # @测试步骤:3: 读取cpu.stat文件 + cpu_stat=$(cat "$CGROUP_TOPDIR"/$CGROUP/cpu.stat) + nr_burst=$(echo "$cpu_stat" | grep nr_burst | awk '{print $2}') + msg "nr_burst: $nr_burst" + burst_usec=$(echo "$cpu_stat" | grep burst_usec | awk '{print $2}') + msg "burst_usec: $burst_usec" + + # @预期结果:1: cpu.stat文件中的burst_usec和nr_bursts均等于0 + assert_true [ "$nr_burst" -eq 0 ] + assert_true [ "$burst_usec" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid" + sleep 1 + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-max.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-max.sh" new file mode 100755 index 0000000000000000000000000000000000000000..23eb632e053d91794fa369d9793c955e9ee5948a --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-max.sh" @@ -0,0 +1,84 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240804-180942-698874070 +# @用例名称: cgroup-v2-cpu-max +# @用例级别: 1 +# @用例标签: cgroup-v2 cpu max +# @用例类型: 测试cpu.max接口文件,设置限制 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-cpu-max" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用cpu控制器 + if ! check_string_in_file "cpu" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用cpu控制器" + fi + # @预置条件: 启用cpu控制器 + echo "+cpu" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置CGROUP的cpu.max值 + echo "100000 1000000" >"$CGROUP_TOPDIR"/$CGROUP/cpu.max + + # @测试步骤:2: 启动一个占用CPU的进程,并将其放入cgroup + { + while true; do :; done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + sleep 3 + + # @测试步骤:3: 读取cpu.stat文件 + cpu_stat=$(cat "$CGROUP_TOPDIR"/$CGROUP/cpu.stat) + nr_periods=$(echo "$cpu_stat" | grep nr_periods | awk '{print $2}') + nr_throttled=$(echo "$cpu_stat" | grep nr_throttled | awk '{print $2}') + throttled_usec=$(echo "$cpu_stat" | grep throttled_usec | awk '{print $2}') + msg "nr_periods: $nr_periods, nr_throttled: $nr_throttled, throttled_usec: $throttled_usec" + + # @预期结果:1: cpu.stat文件中的nr_periods和nr_throttled,throttled_usec均大于0 + assert_true [ "$nr_periods" -gt 0 ] + assert_true [ "$nr_throttled" -gt 0 ] + assert_true [ "$throttled_usec" -gt 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid" + sleep 1 + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-pressure.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-pressure.sh" new file mode 100755 index 0000000000000000000000000000000000000000..6a675f30abff9140d964f0d434a33795f11c84f0 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-pressure.sh" @@ -0,0 +1,132 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240804-225021-343953847 +# @用例名称: cgroup-v2-cpu-pressure +# @用例级别: 2 +# @用例标签: cgroup-v2 cpu pressure +# @用例类型: 测试cpu.pressure接口文件,设置CPU压力通知 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-cpu-pressure" +TMP_FILE=$(mktemp) + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用cpu控制器 + if ! check_string_in_file "cpu" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用cpu控制器" + fi + # @预置条件: 启用cpu控制器 + echo "+cpu" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + # @预置条件: 获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 启用cgroup.pressure + echo 1 >"$CGROUP_TOPDIR"/$CGROUP/cgroup.pressure || return 1 + + # @测试步骤:2: 获取cpu online list + file_path="$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus.effective + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:3: 获取没被独占的一个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + if [ -z "$first_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + + # @测试步骤:4: 独占该CPU + echo "root" >"$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus.partition + + # @测试步骤:5: 设置CGROUP的cpuset.cpus为first_online_cpu + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus + + # @测试步骤:6: 独占该CPU + echo "root" >"$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus.partition + + # @测试步骤:7: 注册触发器 + stdbuf -oL "${TST_TS_TOPDIR}"/tst_lib/cgroup_util/bin/pressure_listener "$CGROUP_TOPDIR"/$CGROUP/cpu.pressure &>"$TMP_FILE" & + + # @测试步骤:8: 运行两个进程并将其运行在一个CPU核心上 + { + while true; do :; done + } & + task_pid1=$! + echo $task_pid1 >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + { + while true; do :; done + } & + task_pid2=$! + echo $task_pid2 >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + sleep 10 + + # @测试步骤:9: 读取cpu.pressure文件 + cpu_pressure=$(cat "$CGROUP_TOPDIR"/$CGROUP/cpu.pressure) + msg "cpu_pressure: " + msg "$cpu_pressure" + avg10=$(echo "$cpu_pressure" | awk 'NR==1 {for(i=1;i<=NF;i++) if ($i ~ /^avg10=/) {split($i, a, "="); print a[2]}}') + msg "avg10: $avg10" + + # @预期结果:1: avg10值应该大于0 + assert_true [ "$(echo "$avg10 > 0" | bc)" -eq 1 ] + + # @预期结果:2: 触发器应该被触发 + is_trigered=-1 + if grep -q "event triggered" "$TMP_FILE"; then + is_trigered=0 + fi + assert_true [ "$is_trigered" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid1" "$task_pid2" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-stat.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-stat.sh" new file mode 100755 index 0000000000000000000000000000000000000000..61ef58815e2fdab18f59252d9c31c907d604e9c9 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-stat.sh" @@ -0,0 +1,81 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240810-100137-362330129 +# @用例名称: cgroup-v2-cpu-stat +# @用例级别: 1 +# @用例标签: cgroup-v2 cpu stat +# @用例类型: 测试cpu.stat接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-cpu-stat" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用cpu控制器 + if ! check_string_in_file "cpu" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用cpu控制器" + fi + # @预置条件: 启用cpu控制器 + echo "+cpu" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 运行一个进程 + { + for _ in {1..100}; do + echo -e "line1\nline2\nline3" | awk 'END {print NR}' &>/dev/null + done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + wait $task_pid + + # @测试步骤:2: 读取cpu.stat中的usage_usec字段, user_usec字段的值和system_usec字段的值 + usage_usec=$(grep usage_usec "$CGROUP_TOPDIR"/$CGROUP/cpu.stat | awk '{print $2}') + msg "usage_usec: $usage_usec" + user_usec=$(grep user_usec "$CGROUP_TOPDIR"/$CGROUP/cpu.stat | awk '{print $2}') + msg "user_usec: $user_usec" + system_usec=$(grep system_usec "$CGROUP_TOPDIR"/$CGROUP/cpu.stat | awk '{print $2}') + msg "system_usec: $system_usec" + + # @预期结果:1: usage_usec字段的值大于0, user_usec字段的值大于0, system_usec字段的值大于0 + assert_true [ "$usage_usec" -gt 0 ] + assert_true [ "$user_usec" -gt 0 ] + assert_true [ "$system_usec" -gt 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-weight-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-weight-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..4156807303b5c789b5b92f12f00800d7c2aec186 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-weight-001.sh" @@ -0,0 +1,127 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240804-155658-686144114 +# @用例名称: cgroup-v2-cpu-weight-001 +# @用例级别: 1 +# @用例标签: cgroup-v2 cpu weight +# @用例类型: 测试cpu.weight接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-cpu-weight-001" +CHILD0="$CGROUP/child0" +CHILD1="$CGROUP/child1" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用cpu控制器 + if ! check_string_in_file "cpu" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用cpu控制器" + fi + # @预置条件: 启用cpu控制器 + echo "+cpu" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + echo "+cpu" >"$CGROUP_TOPDIR"/$CGROUP/cgroup.subtree_control || return 1 + # @预置条件: 获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取cpu online list + file_path="$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus.effective + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:2: 获取没被独占的一个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + if [ -z "$first_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + + # @测试步骤:3: 独占该CPU + echo "root" >"$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus.partition + + # @测试步骤:4: 创建子cgroup + mkdir "$CGROUP_TOPDIR"/$CHILD0 + mkdir "$CGROUP_TOPDIR"/$CHILD1 + + # @测试步骤:5: 对不同的cgroup设置不同的cpu.weight值 + echo 2048 >"$CGROUP_TOPDIR"/$CHILD0/cpu.weight + echo 512 >"$CGROUP_TOPDIR"/$CHILD1/cpu.weight + + # @测试步骤:6: 启动两个占用CPU的进程,并将其放入不同的cgroup,保证两个进程在同一个CPU核心上运行 + { + while true; do :; done + } & + task_pid1=$! + echo $task_pid1 >"$CGROUP_TOPDIR"/"$CHILD0"/cgroup.procs + + { + while true; do :; done + } & + task_pid2=$! + echo $task_pid2 >"$CGROUP_TOPDIR"/"$CHILD1"/cgroup.procs + sleep 3 + + # @测试步骤:7: 获取两个sub_cgroup的CPU使用时间 + cpu_usage_usec1=$(grep usage_usec "$CGROUP_TOPDIR"/"$CHILD0"/cpu.stat | awk '{print $2}') + cpu_usage_usec2=$(grep usage_usec "$CGROUP_TOPDIR"/"$CHILD1"/cpu.stat | awk '{print $2}') + msg "cpu usage usec1: $cpu_usage_usec1" + msg "cpu usage usec2: $cpu_usage_usec2" + + # @预期结果:1: 验证CPU使用时间比例是否符合预期,4:1 + usage_ratio=$(echo "scale=2; $cpu_usage_usec1 / $cpu_usage_usec2 + 0.5" | bc) + usage_ratio=$(printf "%.0f" "$usage_ratio") + msg "usage_ratio: $usage_ratio" + assert_true [ "$usage_ratio" -eq 4 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid1" "$task_pid2" + sleep 1 + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CHILD1 + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-weight-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-weight-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..66a8f1196d36759cee50165ed35e778ab1e33bcf --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-weight-002.sh" @@ -0,0 +1,148 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240804-174805-982987650 +# @用例名称: cgroup-v2-cpu-weight-002 +# @用例级别: 1 +# @用例标签: cgroup-v2 cpu weight +# @用例类型: 测试cpu.weight接口文件,测试层次结构 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-cpu-weight-002" +CHILD0="$CGROUP/child0" +CHILD1="$CGROUP/child1" +CHILD10="$CHILD1/child0" +CHILD11="$CHILD1/child1" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用cpu控制器 + if ! check_string_in_file "cpu" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用cpu控制器" + fi + # @预置条件: 启用cpu控制器 + echo "+cpu" >"$CGROUP_TOPDIR"/cgroup.subtree_control + echo "+cpu" >"$CGROUP_TOPDIR"/$CGROUP/cgroup.subtree_control || return 1 + # @预置条件: 获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取cpu online list + file_path="$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus.effective + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:2: 获取没被独占的一个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + if [ -z "$first_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + + # @测试步骤:3: 独占该CPU + echo "root" >"$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus.partition + + # @测试步骤:4: 创建子cgroup + mkdir "$CGROUP_TOPDIR"/$CHILD0 + mkdir "$CGROUP_TOPDIR"/$CHILD1 + echo "+cpu" >"$CGROUP_TOPDIR"/$CHILD1/cgroup.subtree_control || return 1 + mkdir "$CGROUP_TOPDIR"/$CHILD10 + mkdir "$CGROUP_TOPDIR"/$CHILD11 + + # @测试步骤:5: 对不同的cgroup设置不同的cpu.weight值 + echo 2048 >"$CGROUP_TOPDIR"/$CHILD0/cpu.weight + echo 2048 >"$CGROUP_TOPDIR"/$CHILD1/cpu.weight + echo 1000 >"$CGROUP_TOPDIR"/$CHILD10/cpu.weight + echo 1000 >"$CGROUP_TOPDIR"/$CHILD11/cpu.weight + + # @测试步骤:6: 启动三个占用CPU的进程,并将其放入不同的cgroup,保证三个进程在同一个CPU核心上运行 + { + while true; do :; done + } & + task_pid1=$! + echo $task_pid1 >"$CGROUP_TOPDIR"/"$CHILD0"/cgroup.procs + { + while true; do :; done + } & + task_pid2=$! + echo $task_pid2 >"$CGROUP_TOPDIR"/"$CHILD10"/cgroup.procs + { + while true; do :; done + } & + task_pid3=$! + echo $task_pid3 >"$CGROUP_TOPDIR"/"$CHILD11"/cgroup.procs + + sleep 5 + + # @测试步骤:7: 获取三个cgroup的CPU使用时间 + cpu_usage_usec1=$(grep usage_usec "$CGROUP_TOPDIR"/"$CHILD0"/cpu.stat | awk '{print $2}') + cpu_usage_usec2=$(grep usage_usec "$CGROUP_TOPDIR"/"$CHILD10"/cpu.stat | awk '{print $2}') + cpu_usage_usec3=$(grep usage_usec "$CGROUP_TOPDIR"/"$CHILD11"/cpu.stat | awk '{print $2}') + msg "cpu usage usec1: $cpu_usage_usec1" + msg "cpu usage usec2: $cpu_usage_usec2" + msg "cpu usage usec3: $cpu_usage_usec3" + + # @预期结果:1: 验证CPU使用时间比例是否符合预期,即2:1:1 + usage_ratio0=$(echo "scale=2; $cpu_usage_usec1 / $cpu_usage_usec2" | bc) + usage_ratio0=$(printf "%.0f" "$usage_ratio0") + msg "usage_ratio0: $usage_ratio0" + assert_true [ "$usage_ratio0" -eq 2 ] + usage_ratio1=$(echo "scale=2; $cpu_usage_usec2 / $cpu_usage_usec3" | bc) + msg "usage_ratio1: $usage_ratio1" + usage_ratio1=$(printf "%.0f" "$usage_ratio1") + msg "usage_ratio1: $usage_ratio1" + assert_true [ "$usage_ratio1" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid1" "$task_pid2" "$task_pid3" + sleep 1 + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD10 + rmdir "$CGROUP_TOPDIR"/$CHILD11 + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CHILD1 + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-weight-nice-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-weight-nice-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..6daac0b0df80c16653f2c8fe7afebedd42786913 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-weight-nice-001.sh" @@ -0,0 +1,124 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240804-175245-433198185 +# @用例名称: cgroup-v2-cpu-weight-nice-001 +# @用例级别: 2 +# @用例标签: cgroup-v2 cpu weight nice +# @用例类型: 测试cpu.weight.nice接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-cpu-weight-nice-001" +CHILD0="$CGROUP/child0" +CHILD1="$CGROUP/child1" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用cpu控制器 + if ! check_string_in_file "cpu" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用cpu控制器" + fi + # @预置条件: 启用cpu控制器 + echo "+cpu" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + echo "+cpu" >"$CGROUP_TOPDIR"/$CGROUP/cgroup.subtree_control || return 1 + # @预置条件: 获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取cpu online list + file_path="$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus.effective + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:2: 获取没被独占的一个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + if [ -z "$first_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + + # @测试步骤:3: 独占该CPU + echo "root" >"$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus.partition + + # @测试步骤:4: 创建子cgroup + mkdir "$CGROUP_TOPDIR"/$CHILD0 + mkdir "$CGROUP_TOPDIR"/$CHILD1 + + # @测试步骤:5: 对不同的cgroup设置不同的cpu.weight.nice值 + echo 10 >"$CGROUP_TOPDIR"/$CHILD0/cpu.weight.nice + echo 0 >"$CGROUP_TOPDIR"/$CHILD1/cpu.weight.nice + + # @测试步骤:6: 启动两个占用CPU的进程,并将其放入不同的cgroup,保证两个进程在同一个CPU核心上运行 + { + while true; do :; done + } & + task_pid1=$! + echo $task_pid1 >"$CGROUP_TOPDIR"/"$CHILD0"/cgroup.procs + { + while true; do :; done + } & + task_pid2=$! + echo $task_pid2 >"$CGROUP_TOPDIR"/"$CHILD1"/cgroup.procs + + sleep 3 + + # @测试步骤:7: 获取两个cgroup的CPU使用时间 + cpu_usage_usec1=$(grep usage_usec "$CGROUP_TOPDIR"/"$CHILD0"/cpu.stat | awk '{print $2}') + cpu_usage_usec2=$(grep usage_usec "$CGROUP_TOPDIR"/"$CHILD1"/cpu.stat | awk '{print $2}') + msg "cpu usage usec1: $cpu_usage_usec1" + msg "cpu usage usec2: $cpu_usage_usec2" + + # @预期结果:1: 验证CPU使用时间比例是否符合预期,cgroup1小于cgroup2 + assert_true [ "$cpu_usage_usec1" -lt "$cpu_usage_usec2" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid1" "$task_pid2" + sleep 1 + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CHILD1 + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-weight-nice-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-weight-nice-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..110d826a75e29f60458ff28eebe288fa0b1d0bd0 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpu-weight-nice-002.sh" @@ -0,0 +1,141 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240810-103238-037013530 +# @用例名称: cgroup-v2-cpu-weight-nice-002 +# @用例级别: 2 +# @用例标签: cgroup-v2 cpu weight nice +# @用例类型: 测试cpu.weight.nice接口文件, 测试层次结构 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-cpu-weight-nice-001" +CHILD0="$CGROUP/child0" +CHILD1="$CGROUP/child1" +CHILD10="$CHILD1/child0" +CHILD11="$CHILD1/child1" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用cpu控制器 + if ! check_string_in_file "cpu" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用cpu控制器" + fi + # @预置条件: 启用cpu控制器 + echo "+cpu" >"$CGROUP_TOPDIR"/cgroup.subtree_control + echo "+cpu" >"$CGROUP_TOPDIR"/$CGROUP/cgroup.subtree_control || return 1 + # @预置条件: 获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取cpu online list + file_path="$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus.effective + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:2: 获取没被独占的一个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + if [ -z "$first_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + + # @测试步骤:3: 独占该CPU + echo "root" >"$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus.partition + + # @测试步骤:4: 创建子cgroup + mkdir "$CGROUP_TOPDIR"/$CHILD0 + mkdir "$CGROUP_TOPDIR"/$CHILD1 + echo "+cpu" >"$CGROUP_TOPDIR"/$CHILD1/cgroup.subtree_control || return 1 + mkdir "$CGROUP_TOPDIR"/$CHILD10 + mkdir "$CGROUP_TOPDIR"/$CHILD11 + + # @测试步骤:5: 对不同的cgroup设置不同的cpu.weight.nice值 + echo 10 >"$CGROUP_TOPDIR"/$CHILD0/cpu.weight.nice + echo 0 >"$CGROUP_TOPDIR"/$CHILD1/cpu.weight.nice + echo 10 >"$CGROUP_TOPDIR"/$CHILD10/cpu.weight.nice + echo 0 >"$CGROUP_TOPDIR"/$CHILD11/cpu.weight.nice + + # @测试步骤:6: 启动三个占用CPU的进程,并将其放入不同的cgroup,保证三个进程在同一个CPU核心上运行 + { + while true; do :; done + } & + task_pid1=$! + echo $task_pid1 >"$CGROUP_TOPDIR"/"$CHILD0"/cgroup.procs + { + while true; do :; done + } & + task_pid2=$! + echo $task_pid2 >"$CGROUP_TOPDIR"/"$CHILD10"/cgroup.procs + { + while true; do :; done + } & + task_pid3=$! + echo $task_pid3 >"$CGROUP_TOPDIR"/"$CHILD11"/cgroup.procs + sleep 5 + + # @测试步骤:7: 获取三个cgroup的CPU使用时间 + cpu_usage_usec1=$(grep usage_usec "$CGROUP_TOPDIR"/"$CHILD0"/cpu.stat | awk '{print $2}') + cpu_usage_usec2=$(grep usage_usec "$CGROUP_TOPDIR"/"$CHILD10"/cpu.stat | awk '{print $2}') + cpu_usage_usec3=$(grep usage_usec "$CGROUP_TOPDIR"/"$CHILD11"/cpu.stat | awk '{print $2}') + msg "cpu usage usec1: $cpu_usage_usec1" + msg "cpu usage usec2: $cpu_usage_usec2" + msg "cpu usage usec3: $cpu_usage_usec3" + + # @预期结果:1: 验证CPU使用时间比例是否符合预期,CHILD0小于CHILD1,CHILD10小于CHILD11 + total_cpu_usage_usec=$((cpu_usage_usec2 + cpu_usage_usec3)) + assert_true [ "$cpu_usage_usec1" -lt "$total_cpu_usage_usec" ] + assert_true [ "$cpu_usage_usec2" -lt "$cpu_usage_usec3" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid1" "$task_pid2" "$task_pid3" + sleep 1 + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD10 + rmdir "$CGROUP_TOPDIR"/$CHILD11 + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CHILD1 + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpuset-cpus-partition.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpuset-cpus-partition.sh" new file mode 100755 index 0000000000000000000000000000000000000000..e4a14b89294a92c4baa8bb598551d2366b571ca0 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpuset-cpus-partition.sh" @@ -0,0 +1,123 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240809-112859-075549357 +# @用例名称: cgroup-v2-cpuset-cpus-partition +# @用例级别: 2 +# @用例标签: cgroup-v2 cpuset cpus partition +# @用例类型: 测试cpuset.cpus.patition接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-cpuset-cpus-partition" +CHILD0="$CGROUP/child0" +CHILD1="$CGROUP/child1" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用cpuset控制器 + if ! check_string_in_file "cpuset" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用cpuset控制器" + fi + # @预置条件: 启用cpuset控制器 + echo "+cpuset" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + echo "+cpuset" >"$CGROUP_TOPDIR"/$CGROUP/cgroup.subtree_control || return 1 + # @预置条件: 获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + if [ "$for_cpu_nums" -le 2 ]; then + skip_test "当前系统cpu小于等于两个" + fi + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取cpu online list + file_path="$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus.effective + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:2: 获取没被独占的两个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + second_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 2))" '{print $col}') + msg "second_online_cpu: $second_online_cpu" + if [ -z "$first_online_cpu" ] || [ -z "$second_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu-$second_online_cpu" >"$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + + # @测试步骤:3: 设置CGROUP为partition root + echo "root" >"$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus.partition + + # @测试步骤:4: 创建子cgroup + mkdir "$CGROUP_TOPDIR"/$CHILD0 + mkdir "$CGROUP_TOPDIR"/$CHILD1 + + # @预期结果:1: 查看CGROUP/CHILD0/CHILD1的cpuset.cpus.effevtive是否为online_cpu + cgroup_cpuset_cpus_effective=$(cat "$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus.effective) + assert_true [ "$cgroup_cpuset_cpus_effective" = "$first_online_cpu-$second_online_cpu" ] + child0_cpuset_cpus_effective=$(cat "$CGROUP_TOPDIR"/$CHILD0/cpuset.cpus.effective) + assert_true [ "$child0_cpuset_cpus_effective" = "$first_online_cpu-$second_online_cpu" ] + child1_cpuset_cpus_effective=$(cat "$CGROUP_TOPDIR"/$CHILD1/cpuset.cpus.effective) + assert_true [ "$child1_cpuset_cpus_effective" = "$first_online_cpu-$second_online_cpu" ] + + # @测试步骤:5: 设置CHILD0的cpuset.cpus为first_online_cpu + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/$CHILD0/cpuset.cpus + + # @测试步骤:6: 设置CHILD0为partition root + echo "root" >"$CGROUP_TOPDIR"/$CHILD0/cpuset.cpus.partition + + # @预期结果:2: 查看CHILD0的cpuset.cpus.effevtive是否为first_online_cpu + child0_cpuset_cpus_effective=$(cat "$CGROUP_TOPDIR"/$CHILD0/cpuset.cpus.effective) + assert_true [ "$child0_cpuset_cpus_effective" = "$first_online_cpu" ] + + # @预期结果:3: 查看CGROUP/CHILD1的cpuset.cpus.effevtive是否去除了first_online_cpu + cgroup_cpuset_cpus_effective=$(cat "$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus.effective) + assert_true [ "$cgroup_cpuset_cpus_effective" = "$second_online_cpu" ] + child1_cpuset_cpus_effective=$(cat "$CGROUP_TOPDIR"/$CHILD1/cpuset.cpus.effective) + assert_true [ "$child1_cpuset_cpus_effective" = "$second_online_cpu" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CHILD1 + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpuset-cpus.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpuset-cpus.sh" new file mode 100755 index 0000000000000000000000000000000000000000..4d81c761faa296e35c8ac31addb4d16a970a8900 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpuset-cpus.sh" @@ -0,0 +1,113 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240809-093638-075516592 +# @用例名称: cgroup-v2-cpuset-cpus +# @用例级别: 1 +# @用例标签: cgroup-v2 cpuset cpus +# @用例类型: 测试cpuset.cpus和cpuset.cpus.effetive接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-cpuset-cpus" +TMP_FILE=$(mktemp) + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用cpuset控制器 + if ! check_string_in_file "cpuset" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用cpuset控制器" + fi + # @预置条件: 启用cpuset控制器 + echo "+cpuset" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + # @预置条件: 获取系统cpu的数量 + cpu_nums=$(grep -c ^processor /proc/cpuinfo) + msg "cpu_nums: $cpu_nums" + for_cpu_nums=$((cpu_nums - 2)) + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取cpu online list + file_path="$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus.effective + cpu_online_list=$(get_online_cpu_list "$file_path") + msg "cpu_online_list: $cpu_online_list" + + # @测试步骤:2: 获取没被独占的一个在线cpu + ret=-1 + for i in $(seq 0 "$for_cpu_nums"); do + first_online_cpu=$(echo "$cpu_online_list" | awk -v col="$((i + 1))" '{print $col}') + msg "first_online_cpu: $first_online_cpu" + if [ -z "$first_online_cpu" ]; then + skip_test "没有足够的在线cpu" + fi + + echo "$first_online_cpu" >"$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus && ret=0 && break + done + if [ $ret -ne 0 ]; then + skip_test "没有可独占的CPU" + fi + + # @测试步骤:3: 独占该CPU + echo "root" >"$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus.partition + + # @预期结果:1: 验证CGROUP的可用cpu是否为first_online_cpu + online_cpus=$(cat "$CGROUP_TOPDIR"/$CGROUP/cpuset.cpus.effective) + assert_true [ "$online_cpus" -eq "$first_online_cpu" ] + + # @测试步骤:4: 启动一个进程并将其放入CGROUP + { + while true; do :; done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + sleep 2 + + # @预期结果:2: 验证进程是否绑定了指定的cpu + cpus_allowed=$(cat /proc/$task_pid/status | grep "Cpus_allowed_list" | awk '{print $2}') + assert_true [ "$cpus_allowed" = "$first_online_cpu" ] + + # @测试步骤:5: 通过mpstat获取first_online_cpu的使用情况(3s) + cpu0_user_time=$(mpstat -P "$first_online_cpu" 1 3 | grep Average | awk 'NR==2 {print $3}') + msg "cpu0_user_time: $cpu0_user_time" + + # @预期结果:3: 验证CPU的使用率大于80% + assert_true [ "$(echo "$cpu0_user_time > 80.0" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + # @删除临时文件: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpuset-mems.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpuset-mems.sh" new file mode 100755 index 0000000000000000000000000000000000000000..9a590e91bcc376f361a8b01b7cb0237efc554b1f --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-cpuset-mems.sh" @@ -0,0 +1,103 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240809-113705-534422637 +# @用例名称: cgroup-v2-cpuset-mems +# @用例级别: 1 +# @用例标签: cgroup-v2 cpuset mems +# @用例类型: 测试cpuset.mems和cpuset.mems.effetive接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-cpuset-mems" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + # @预置条件:检查numactl命令是否存在 + if ! is_numactl_installed; then + skip_test "numactl 未安装, 请先安装numactl" + fi + # @预置条件:检查是否支持NUMA + numa_nodes=$(numactl -H | grep "available" | cut -d' ' -f2) + if [ "$numa_nodes" = "0" ]; then + skip_test "系统不支持NUMA架构" + fi + # @预置条件:检查NUMA节点数量是否大于1 + if [ "$numa_nodes" -lt 2 ]; then + skip_test "系统NUMA节点数量小于2" + fi + # @预置条件: 检查是否安装了numastat + if ! is_numastat_installed; then + skip_test "numastat 未安装, 请先安装numastat" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用cpuset控制器 + if ! check_string_in_file "cpuset" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用cpuset控制器" + fi + # @预置条件: 启用cpuset控制器 + echo "+cpuset" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置cpuset.mems + echo 1 >"$CGROUP_TOPDIR"/$CGROUP/cpuset.mems + + # @预期结果:1: 验证CGROUP的可用内存节点是否为1 + online_mems=$(cat "$CGROUP_TOPDIR"/$CGROUP/cpuset.mems.effective) + assert_true [ "$online_mems" -eq 1 ] + + # @测试步骤:2: 启动一个进程并将其放入CGROUP + { + while true; do :; done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + sleep 1 + + # @预期结果:2: 验证进程是否绑定了指定的内存节点 + mems_allowed=$(cat /proc/$task_pid/status | grep "Mems_allowed_list" | awk '{print $2}') + assert_true [ "$mems_allowed" -eq 1 ] + + # @测试步骤:3: 获取指定内存节点上进程的内存使用情况 + mems_usage_in_numa1=$(numastat -p $task_pid | awk 'END{print $3}') + msg "mems_usage_in_numa1: $mems_usage_in_numa1" + + # @预期结果:3: mems_usage_in_numa1大于0 + assert_true [ "$(echo "$mems_usage_in_numa1 > 0" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清空后台进程 + kill -9 "$task_pid" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-freeze-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-freeze-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..8a2d0d1ae9d56fae66d5ded31641897cbbebd3dd --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-freeze-001.sh" @@ -0,0 +1,90 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240809-225328-709368100 +# @用例名称: cgroup-v2-freeze-001 +# @用例级别: 1 +# @用例标签: cgroup-v2 freeze +# @用例类型: 测试cgroup.freeze接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-freeze-001" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 运行一个进程 + { + while true; do + : + done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + + # @测试步骤:2: 查看CGROUP的cgorup.event中的frozen字段 + frozen=$(grep frozen "$CGROUP_TOPDIR"/$CGROUP/cgroup.events | awk '{print $2}') + + # @预期结果:1: frozen字段为0 + assert_true [ "$frozen" -eq 0 ] + + # @测试步骤:3: 冻结CGROUP的进程 + echo 1 >"$CGROUP_TOPDIR"/$CGROUP/cgroup.freeze + sleep 1 + + # @测试步骤:4: 查看CGROUP的cgorup.event中的frozen字段 + frozen=$(grep frozen "$CGROUP_TOPDIR"/$CGROUP/cgroup.events | awk '{print $2}') + + # @预期结果:2: frozen字段为1 + assert_true [ "$frozen" -eq 1 ] + + # @测试步骤:5: 解冻CGROUP的进程 + echo 0 >"$CGROUP_TOPDIR"/$CGROUP/cgroup.freeze + sleep 1 + + # @测试步骤:6: 查看CGROUP的cgorup.event中的frozen字段 + frozen=$(grep frozen "$CGROUP_TOPDIR"/$CGROUP/cgroup.events | awk '{print $2}') + + # @预期结果:3: frozen字段为0 + assert_true [ "$frozen" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid" + sleep 1 + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-freeze-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-freeze-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..4edbd0dabae1e7ceb05ccf66d8fd45ea8693e63b --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-freeze-002.sh" @@ -0,0 +1,155 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240809-230001-993472792 +# @用例名称: cgroup-v2-freeze-002 +# @用例级别: 1 +# @用例标签: cgroup-v2 freeze +# @用例类型: 测试cgroup.freeze接口文件, 测试cgroup的层次结构 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +# CGROUP +# / | \ +# CHILD0 CHILD1 CHILD2 +# / \ | +# CHILD00 CHILD01 CHILD10 +# | +# CHILD100 +# | +# CHILD1000 +CGROUP="cgroup-v2-freeze-002" +CHILD0="$CGROUP/child0" +CHILD1="$CGROUP/child1" +CHILD2="$CGROUP/child3" +CHILD00="$CHILD0/child0" +CHILD01="$CHILD0/child1" +CHILD10="$CHILD1/child0" +CHILD100="$CHILD10/child0" +CHILD1000="$CHILD100/child0" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + mkdir "$CGROUP_TOPDIR"/$CHILD0 + mkdir "$CGROUP_TOPDIR"/$CHILD1 + mkdir "$CGROUP_TOPDIR"/$CHILD2 + mkdir "$CGROUP_TOPDIR"/$CHILD00 + mkdir "$CGROUP_TOPDIR"/$CHILD01 + mkdir "$CGROUP_TOPDIR"/$CHILD10 + mkdir "$CGROUP_TOPDIR"/$CHILD100 + mkdir "$CGROUP_TOPDIR"/$CHILD1000 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 在CHILD01上运行一个进程 + { + while true; do :; done + } & + task_pid0=$! + echo $task_pid0 >"$CGROUP_TOPDIR"/$CHILD01/cgroup.procs + + # @测试步骤:2: 在CHILD1000上运行一个进程 + { + while true; do :; done + } & + task_pid1=$! + echo $task_pid1 >"$CGROUP_TOPDIR"/$CHILD1000/cgroup.procs + + # @测试步骤:3: 在CHILD2上运行一个进程 + { + while true; do :; done + } & + task_pid2=$! + echo $task_pid2 >"$CGROUP_TOPDIR"/$CHILD2/cgroup.procs + + # @测试步骤:4: 冻结CHILD0 + echo 1 >"$CGROUP_TOPDIR"/$CHILD0/cgroup.freeze + + # @测试步骤:5: 冻结CHILD10 + echo 1 >"$CGROUP_TOPDIR"/$CHILD10/cgroup.freeze + + # @测试步骤:6: 冻结CHILD100 + echo 1 >"$CGROUP_TOPDIR"/$CHILD100/cgroup.freeze + + # @预期结果:1: CGROUP和CHILD1的cgroup.event中的frozen字段为0 + frozen=$(grep frozen "$CGROUP_TOPDIR"/$CGROUP/cgroup.events | awk '{print $2}') + assert_true [ "$frozen" -eq 0 ] + frozen=$(grep frozen "$CGROUP_TOPDIR"/$CHILD1/cgroup.events | awk '{print $2}') + assert_true [ "$frozen" -eq 0 ] + + # # @测试步骤:7: 冻结CGROUP + echo 1 >"$CGROUP_TOPDIR"/$CGROUP/cgroup.freeze + + # @预期结果:2: CGROUP, CHILD0, CHILD1的cgroup.event中的frozen字段为1 + frozen=$(grep frozen "$CGROUP_TOPDIR"/$CGROUP/cgroup.events | awk '{print $2}') + assert_true [ "$frozen" -eq 1 ] + frozen=$(grep frozen "$CGROUP_TOPDIR"/$CHILD0/cgroup.events | awk '{print $2}') + assert_true [ "$frozen" -eq 1 ] + frozen=$(grep frozen "$CGROUP_TOPDIR"/$CHILD1/cgroup.events | awk '{print $2}') + assert_true [ "$frozen" -eq 1 ] + + # @测试步骤:8: 解冻CHILD0, CHILD10, CHILD100 + echo 0 >"$CGROUP_TOPDIR"/$CHILD0/cgroup.freeze + echo 0 >"$CGROUP_TOPDIR"/$CHILD10/cgroup.freeze + echo 0 >"$CGROUP_TOPDIR"/$CHILD100/cgroup.freeze + + # @预期结果:3: CHILD00, CHILD1000的cgroup.event中的frozen字段为1 + frozen=$(grep frozen "$CGROUP_TOPDIR"/$CHILD00/cgroup.events | awk '{print $2}') + assert_true [ "$frozen" -eq 1 ] + frozen=$(grep frozen "$CGROUP_TOPDIR"/$CHILD1000/cgroup.events | awk '{print $2}') + assert_true [ "$frozen" -eq 1 ] + + # @测试步骤:9: 解冻CGROUP + echo 0 >"$CGROUP_TOPDIR"/$CGROUP/cgroup.freeze + + # @预期结果:4: CHILD00, CHILD2的cgroup.event中的frozen字段为0 + frozen=$(grep frozen "$CGROUP_TOPDIR"/$CHILD00/cgroup.events | awk '{print $2}') + assert_true [ "$frozen" -eq 0 ] + frozen=$(grep frozen "$CGROUP_TOPDIR"/$CHILD2/cgroup.events | awk '{print $2}') + assert_true [ "$frozen" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid0" "$task_pid1" "$task_pid2" + sleep 1 + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD1000 + rmdir "$CGROUP_TOPDIR"/$CHILD100 + rmdir "$CGROUP_TOPDIR"/$CHILD10 + rmdir "$CGROUP_TOPDIR"/$CHILD01 + rmdir "$CGROUP_TOPDIR"/$CHILD00 + rmdir "$CGROUP_TOPDIR"/$CHILD2 + rmdir "$CGROUP_TOPDIR"/$CHILD1 + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-freeze-003.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-freeze-003.sh" new file mode 100755 index 0000000000000000000000000000000000000000..4134fb1e55dd00b8c8c288281ae1576d42478196 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-freeze-003.sh" @@ -0,0 +1,75 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240809-232855-348990156 +# @用例名称: cgroup-v2-freeze-003 +# @用例级别: 2 +# @用例标签: cgroup-v2 freeze +# @用例类型: 测试cgroup.freeze接口文件, 测试cgroup的层次结构 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-freeze-003" +CHILD0="$CGROUP/child0" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 冻结CGROUP的进程 + echo 1 >"$CGROUP_TOPDIR"/$CGROUP/cgroup.freeze + + # @测试步骤:2: 创建子cgroup + mkdir "$CGROUP_TOPDIR"/$CHILD0 + + # @测试步骤:3: 在CHILD0中运行一个进程 + { + while true; do :; done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/$CHILD0/cgroup.procs + + # @预期结果:1: CHILD0, CGROUP的cgorup.event中的frozen字段为1 + frozen=$(grep frozen "$CGROUP_TOPDIR"/$CHILD0/cgroup.events | awk '{print $2}') + assert_true [ "$frozen" -eq 1 ] + frozen=$(grep frozen "$CGROUP_TOPDIR"/$CGROUP/cgroup.events | awk '{print $2}') + assert_true [ "$frozen" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-freeze-004.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-freeze-004.sh" new file mode 100755 index 0000000000000000000000000000000000000000..8ab0384617b27c1d24d55d1cae3c95e76b3d71bc --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-freeze-004.sh" @@ -0,0 +1,73 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240809-233224-494284037 +# @用例名称: cgroup-v2-freeze-004 +# @用例级别: 2 +# @用例标签: cgroup-v2 freeze +# @用例类型: 测试cgroup.freeze接口文件, 测试cgroup的层次结构 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-freeze-004" +CHILD0="$CGROUP/child0" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + mkdir "$CGROUP_TOPDIR"/$CHILD0 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 冻结CGROUP的进程 + echo 1 >"$CGROUP_TOPDIR"/$CGROUP/cgroup.freeze + + # @测试步骤:2: 删除CHILD0 + rmdir "$CGROUP_TOPDIR"/$CHILD0 + + # @预期结果:1: CGROUP的cgorup.event中的frozen字段为1 + frozen=$(grep frozen "$CGROUP_TOPDIR"/$CGROUP/cgroup.events | awk '{print $2}') + assert_true [ "$frozen" -eq 1 ] + + # @测试步骤:3: 创建CHILD0 + mkdir "$CGROUP_TOPDIR"/$CHILD0 + + # @预期结果:2: CHILD0的cgorup.event中的frozen字段为1 + frozen=$(grep frozen "$CGROUP_TOPDIR"/$CHILD0/cgroup.events | awk '{print $2}') + assert_true [ "$frozen" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @测试清理: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-freeze-005.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-freeze-005.sh" new file mode 100755 index 0000000000000000000000000000000000000000..0e41447c736a5ef17c0ae491ddc8ebbbaec963f1 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-freeze-005.sh" @@ -0,0 +1,98 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240809-233752-330450571 +# @用例名称: cgroup-v2-freeze-005 +# @用例级别: 2 +# @用例标签: cgroup-v2 freeze +# @用例类型: 测试cgroup.freeze接口文件, 测试迁移的情况 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP0="cgroup-v2-freeze-004-01" +CGROUP1="cgroup-v2-freeze-004-02" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP0 + mkdir "$CGROUP_TOPDIR"/$CGROUP1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 在CGROUP0中运行一个进程 + { + while true; do :; done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/$CGROUP0/cgroup.procs + + # @测试步骤:2: 冻结CGROUP1 + echo 1 >"$CGROUP_TOPDIR"/$CGROUP1/cgroup.freeze + + # @测试步骤:3: 将进程迁移到CGROUP1 + echo $task_pid >"$CGROUP_TOPDIR"/$CGROUP1/cgroup.procs + + # @预期结果:1: CGROUP1的cgorup.event中的frozen字段为1,CGROUP0的frozen字段为0 + frozen=$(grep frozen "$CGROUP_TOPDIR"/$CGROUP1/cgroup.events | awk '{print $2}') + assert_true [ "$frozen" -eq 1 ] + frozen=$(grep frozen "$CGROUP_TOPDIR"/$CGROUP0/cgroup.events | awk '{print $2}') + assert_true [ "$frozen" -eq 0 ] + + # @测试步骤:4: 将进程迁回CGROUP0 + echo $task_pid >"$CGROUP_TOPDIR"/$CGROUP0/cgroup.procs + + # @预期结果:2: CGROUP0的cgorup.event中的frozen字段为0,CGROUP1的frozen字段为1 + frozen=$(grep frozen "$CGROUP_TOPDIR"/$CGROUP0/cgroup.events | awk '{print $2}') + assert_true [ "$frozen" -eq 0 ] + frozen=$(grep frozen "$CGROUP_TOPDIR"/$CGROUP1/cgroup.events | awk '{print $2}') + assert_true [ "$frozen" -eq 1 ] + + # @测试步骤:5: 冻结CGROUP0 + echo 1 >"$CGROUP_TOPDIR"/$CGROUP0/cgroup.freeze + + # @测试步骤:6: 将进程迁移到CGROUP1 + echo $task_pid >"$CGROUP_TOPDIR"/$CGROUP1/cgroup.procs + + # @预期结果:3: CGROUP1的cgorup.event中的frozen字段为1,CGROUP0的frozen字段为1 + frozen=$(grep frozen "$CGROUP_TOPDIR"/$CGROUP1/cgroup.events | awk '{print $2}') + assert_true [ "$frozen" -eq 1 ] + frozen=$(grep frozen "$CGROUP_TOPDIR"/$CGROUP0/cgroup.events | awk '{print $2}') + assert_true [ "$frozen" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP0 + rmdir "$CGROUP_TOPDIR"/$CGROUP1 + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-max-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-max-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..979512f9a3adde0a970675802075c1e7095d6094 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-max-001.sh" @@ -0,0 +1,104 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240809-160906-120322462 +# @用例名称: cgroup-v2-hugetlb-max-001 +# @用例级别: 1 +# @用例标签: cgroup-v2 hugetlb max +# @用例类型:测试hugetlb.2MB.max接口文件,超过限制 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-hugetlb-max-001" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用hugetlb控制器 + if ! check_string_in_file "hugetlb" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用hugetlb控制器" + fi + # @预置条件: 启用hugetlb控制器 + echo "+hugetlb" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取系统hugepage数量 + hugepage_size=$(cat /proc/sys/vm/nr_hugepages) + + # @测试步骤:2: 修改系统hugepage数量 + echo 4 >/proc/sys/vm/nr_hugepages + + # @测试步骤:3: 获取hugepage大小 + hugepage_size_kb=$(grep Hugepagesize /proc/meminfo | awk '{print $2}') + msg "hugepage size: $hugepage_size_kb" + hugepage_size_mb=$(conv_unit -o M -i K "$hugepage_size_kb") + + # @测试步骤:4: 验证hugepage大小是否为2MB + if [ "$hugepage_size_mb" -ne 2 ]; then + skip_test "hugepage大小不等于2MB" + fi + + # @测试步骤:5: 挂载hugetlbfs + mkdir -p /mnt/huge + mount none /mnt/huge -t hugetlbfs + + # @测试步骤:6: 获取CGROUP的hugetlb.2MB.max值 + max=$(cat "$CGROUP_TOPDIR"/$CGROUP/hugetlb.2MB.max) + + # @预期结果:1: 验证hugetlb.2MB.max的值是否为max + assert_true [ "$max" = "max" ] + + # @测试步骤:7: 设置CGROUP的hugetlb.2MB.max为2MB + echo 2M >"$CGROUP_TOPDIR"/$CGROUP/hugetlb.2MB.max + + # @测试步骤:8: 分配2个hugepage + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + "${TST_TS_TOPDIR}"/tst_lib/cgroup_util/bin/alloc_hugepage 2 "$hugepage_size_mb" &>/dev/null + + # @测试步骤:9: 获取hugetlb.2MB.events的max字段 + max_cnt=$(grep "max" "$CGROUP_TOPDIR"/$CGROUP/hugetlb.2MB.events | awk '{print $2}') + + # @预期结果:2: max_cnt大于0 + assert_true [ "$max_cnt" -gt 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 卸载hugetlbfs + umount /mnt/huge + rmdir /mnt/huge + # @清理工作: 恢复系统本来的hugepage的大小 + echo "$hugepage_size" >/proc/sys/vm/nr_hugepages + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-max-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-max-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..11fb1f7964a68d02470ef0813c582c563481ad0b --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-max-002.sh" @@ -0,0 +1,115 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240809-165555-512291475 +# @用例名称: cgroup-v2-hugetlb-max-002 +# @用例级别: 2 +# @用例标签: cgroup-v2 hugetlb max +# @用例类型:测试hugetlb.2MB.max接口文件, 不超过限制 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-hugetlb-max-002" +TOLERANCE=0.3 + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用hugetlb控制器 + if ! check_string_in_file "hugetlb" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用hugetlb控制器" + fi + # @预置条件: 启用hugetlb控制器 + echo "+hugetlb" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取系统hugepage的数量 + hugepage_size=$(cat /proc/sys/vm/nr_hugepages) + + # @测试步骤:2: 修改系统hugepage的数量 + echo 4 >/proc/sys/vm/nr_hugepages + + # @测试步骤:3: 获取hugepage大小 + hugepage_size_kb=$(grep Hugepagesize /proc/meminfo | awk '{print $2}') + msg "hugepage size: $hugepage_size_kb" + hugepage_size_mb=$(conv_unit -o M -i K "$hugepage_size_kb") + + # @测试步骤:4: 验证hugepage大小是否为2MB + if [ "$hugepage_size_mb" -ne 2 ]; then + skip_test "hugepage大小不等于2MB" + fi + + # @测试步骤:5: 挂载hugetlbfs + mkdir -p /mnt/huge + mount none /mnt/huge -t hugetlbfs + + # @测试步骤:6: 设置CGROUP的hugetlb.2MB.max为2MB + echo 2M >"$CGROUP_TOPDIR"/$CGROUP/hugetlb.2MB.max + + # @测试步骤:7: 分配1个hugepage + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + "${TST_TS_TOPDIR}"/tst_lib/cgroup_util/bin/alloc_hugepage 1 "$hugepage_size_mb" &>/dev/null & + + # @测试步骤:8: 获取hugetlb.2MB.current + total_hugepage_current=0 + for _ in $(seq 1 5); do + current=$(cat "$CGROUP_TOPDIR"/$CGROUP/hugetlb.2MB.current) + current=$(echo "$current / 1024 / 1024" | bc) + total_hugepage_current=$(echo "$total_hugepage_current + $current" | bc) + sleep 1 + done + aver_hugepage_current=$(echo "$total_hugepage_current / 5" | bc) + msg "aver_hugepage_current: $aver_hugepage_current" + + # @预期结果:1: 在误差允许的范围内,aver_hugepage_current等于2 + diff=$((aver_hugepage_current - 2)) + abs_diff=${diff#-} + assert_true [ "$(echo "$abs_diff < $TOLERANCE" | bc)" -eq 1 ] + + # @测试步骤:9: 获取hugetlb.2MB.events的max字段 + max_cnt=$(grep "max" "$CGROUP_TOPDIR"/$CGROUP/hugetlb.2MB.events | awk '{print $2}') + + # @预期结果:2: max_cnt等于0 + assert_true [ "$max_cnt" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 卸载hugetlbfs + umount /mnt/huge + rmdir /mnt/huge + # @清理工作: 恢复系统本来的hugepage的大小 + echo "$hugepage_size" >/proc/sys/vm/nr_hugepages + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-max-003.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-max-003.sh" new file mode 100755 index 0000000000000000000000000000000000000000..3a4e2ce7ec074abe853a212650fbe532ff3cdf1b --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-max-003.sh" @@ -0,0 +1,104 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240809-171017-765935943 +# @用例名称: cgroup-v2-hugetlb-max-003 +# @用例级别: 1 +# @用例标签: cgroup v2 hugetlb max +# @用例类型:测试hugetlb.1GB.max接口文件, 超过限制 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-hugetlb-max-003" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用hugetlb控制器 + if ! check_string_in_file "hugetlb" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用hugetlb控制器" + fi + # @预置条件: 启用hugetlb控制器 + echo "+hugetlb" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取系统hugepage数量 + hugepage_size=$(cat /proc/sys/vm/nr_hugepages) + + # @测试步骤:2: 修改系统hugepage数量 + echo 1 >/proc/sys/vm/nr_hugepages + + # @测试步骤:3: 获取hugepage大小 + hugepage_size_kb=$(grep Hugepagesize /proc/meminfo | awk '{print $2}') + msg "hugepage size: $hugepage_size_kb" + hugepage_size_mb=$(conv_unit -o M -i K "$hugepage_size_kb") + + # @测试步骤:4: 验证hugepage大小是否为1GB + if [ "$hugepage_size_mb" -ne 1024 ]; then + skip_test "hugepage大小不等于2MB" + fi + + # @测试步骤:5: 挂载hugetlbfs + mkdir -p /mnt/huge + mount none /mnt/huge -t hugetlbfs + + # @测试步骤:6: 获取CGROUP的hugetlb.1GB.max值 + max=$(cat "$CGROUP_TOPDIR"/$CGROUP/hugetlb.1GB.max) + + # @预期结果:1: 验证hugetlb.1GB.max的值是否为max + assert_true [ "$max" = "max" ] + + # @测试步骤:7: 设置CGROUP的hugetlb.1GB.max为512MB + echo 512M >"$CGROUP_TOPDIR"/$CGROUP/hugetlb.1GB.max + + # @测试步骤:8: 分配1个hugepage + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + "${TST_TS_TOPDIR}"/tst_lib/cgroup_util/bin/alloc_hugepage_rsvd 1 "$hugepage_size_mb" &>/dev/null + + # @测试步骤:9: 获取hugetlb.1GB.events的max字段 + max_cnt=$(grep "max" "$CGROUP_TOPDIR"/$CGROUP/hugetlb.1GB.events | awk '{print $2}') + + # @预期结果:2: max_cnt大于0 + assert_true [ "$max_cnt" -gt 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 卸载hugetlbfs + umount /mnt/huge + rmdir /mnt/huge + # @清理工作: 恢复系统本来的hugepage的大小 + echo "$hugepage_size" >/proc/sys/vm/nr_hugepages + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-max-004.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-max-004.sh" new file mode 100755 index 0000000000000000000000000000000000000000..14bb4a33bfc7f00d93ae30aa26683f1495e17243 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-max-004.sh" @@ -0,0 +1,116 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240809-171019-081310498 +# @用例名称: cgroup-v2-hugetlb-max-004 +# @用例级别: 2 +# @用例标签: cgroup v2 hugetlb max +# @用例类型:测试hugetlb.1GB.max接口文件, 不超过限制 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-hugetlb-max-004" +TOLERANCE=0.3 + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用hugetlb控制器 + if ! check_string_in_file "hugetlb" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用hugetlb控制器" + fi + # @预置条件: 启用hugetlb控制器 + echo "+hugetlb" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取系统hugepage数量 + hugepage_size=$(cat /proc/sys/vm/nr_hugepages) + + # @测试步骤:2: 修改系统hugepage数量 + echo 1 >/proc/sys/vm/nr_hugepages + + # @测试步骤:3: 获取hugepage大小 + hugepage_size_kb=$(grep Hugepagesize /proc/meminfo | awk '{print $2}') + msg "hugepage size: $hugepage_size_kb" + hugepage_size_mb=$(conv_unit -o M -i K "$hugepage_size_kb") + + # @测试步骤:4: 验证hugepage大小是否为1GB + if [ "$hugepage_size_mb" -ne 1024 ]; then + skip_test "hugepage大小不等于2MB" + fi + + # @测试步骤:5: 挂载hugetlbfs + mkdir -p /mnt/huge + mount none /mnt/huge -t hugetlbfs + + # @测试步骤:6: 设置CGROUP的hugetlb.1GB.max为1GB + echo 1024M >"$CGROUP_TOPDIR"/$CGROUP/hugetlb.1GB.max + + # @测试步骤:7: 分配1个hugepage + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + "${TST_TS_TOPDIR}"/tst_lib/cgroup_util/bin/alloc_hugepage_rsvd 1 "$hugepage_size_mb" &>/dev/null & + + # @测试步骤:8: 获取hugetlb.1GB.current + total_hugepage_current=0 + for _ in $(seq 1 5); do + current=$(cat "$CGROUP_TOPDIR"/$CGROUP/hugetlb.1GB.current) + current=$(echo "$current / 1024 / 1024" | bc) + total_hugepage_current=$(echo "$total_hugepage_current + $current" | bc) + sleep 1 + done + aver_hugepage_current=$(echo "$total_hugepage_current / 5" | bc) + msg "aver_hugepage_current: $aver_hugepage_current" + sleep 2 + + # @预期结果:1: 在误差允许的范围内,aver_hugepage_current等于1024 + diff=$((aver_hugepage_current - 1024)) + abs_diff=${diff#-} + assert_true [ "$(echo "$abs_diff < $TOLERANCE" | bc)" -eq 1 ] + + # @测试步骤:9: 获取hugetlb.1GB.events的max字段 + max_cnt=$(grep "max" "$CGROUP_TOPDIR"/$CGROUP/hugetlb.1GB.events | awk '{print $2}') + + # @预期结果:2: max_cnt等于0 + assert_true [ "$max_cnt" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 卸载hugetlbfs + umount /mnt/huge + rmdir /mnt/huge + # @清理工作: 恢复系统本来的hugepage的大小 + echo "$hugepage_size" >/proc/sys/vm/nr_hugepages + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-rsvd-max-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-rsvd-max-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..b10faee74256f47e5a097ec5c6f25b0cc29c0b01 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-rsvd-max-001.sh" @@ -0,0 +1,104 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240809-185414-695820636 +# @用例名称: cgroup-v2-hugetlb-rsvd-max-001 +# @用例级别: 1 +# @用例标签: cgroup-v2 hugetlb rsvd max +# @用例类型:测试hugetlb.2MB.rsvd.max接口文件,超过限制 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-hugetlb-rsvd-max-001" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用hugetlb控制器 + if ! check_string_in_file "hugetlb" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用hugetlb控制器" + fi + # @预置条件: 启用hugetlb控制器 + echo "+hugetlb" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取系统hugepage数量 + hugepage_size=$(cat /proc/sys/vm/nr_hugepages) + + # @测试步骤:2: 修改系统hugepage数量 + echo 4 >/proc/sys/vm/nr_hugepages + + # @测试步骤:3: 获取hugepage大小 + hugepage_size_kb=$(grep Hugepagesize /proc/meminfo | awk '{print $2}') + msg "hugepage size: $hugepage_size_kb" + hugepage_size_mb=$(conv_unit -o M -i K "$hugepage_size_kb") + + # @测试步骤:4: 验证hugepage大小是否为2MB + if [ "$hugepage_size_mb" -ne 2 ]; then + skip_test "hugepage大小不等于2MB" + fi + + # @测试步骤:5: 挂载hugetlbfs + mkdir -p /mnt/huge + mount none /mnt/huge -t hugetlbfs + + # @测试步骤:6: 获取CGROUP的hugetlb.2MB.rsvd.max值 + max=$(cat "$CGROUP_TOPDIR"/$CGROUP/hugetlb.2MB.rsvd.max) + + # @预期结果:1: 验证hugetlb.2MB.rsvd.max的值是否为max + assert_true [ "$max" = "max" ] + + # @测试步骤:7: 设置CGROUP的hugetlb.2MB.rsvd.max为2MB + echo 2M >"$CGROUP_TOPDIR"/$CGROUP/hugetlb.2MB.rsvd.max + + # @测试步骤:8: 分配2个hugepage + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + "${TST_TS_TOPDIR}"/tst_lib/cgroup_util/bin/alloc_hugepage_rsvd 2 "$hugepage_size_mb" &>/dev/null + + # @测试步骤:9: 获取hugetlb.2MB.events的max字段 + max_cnt=$(grep "max" "$CGROUP_TOPDIR"/$CGROUP/hugetlb.2MB.events | awk '{print $2}') + + # @预期结果:2: max_cnt大于0 + assert_true [ "$max_cnt" -gt 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 卸载hugetlbfs + umount /mnt/huge + rmdir /mnt/huge + # @清理工作: 恢复系统本来的hugepage的大小 + echo "$hugepage_size" >/proc/sys/vm/nr_hugepages + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-rsvd-max-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-rsvd-max-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..ae575d7f90e551faaba0a536e1e272ba09bf3c8e --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-rsvd-max-002.sh" @@ -0,0 +1,115 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240809-185415-655135944 +# @用例名称: cgroup-v2-hugetlb-rsvd-max-002 +# @用例级别: 2 +# @用例标签: cgroup-v2 hugetlb rsvd max +# @用例类型:测试hugetlb.2MB.rsvd.max接口文件,不超过限制 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-hugetlb-rsvd-max-002" +TOLERANCE=0.3 + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用hugetlb控制器 + if ! check_string_in_file "hugetlb" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用hugetlb控制器" + fi + # @预置条件: 启用hugetlb控制器 + echo "+hugetlb" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取系统hugepage数量 + hugepage_size=$(cat /proc/sys/vm/nr_hugepages) + + # @测试步骤:2: 修改系统hugepage数量 + echo 4 >/proc/sys/vm/nr_hugepages + + # @测试步骤:3: 获取hugepage大小 + hugepage_size_kb=$(grep Hugepagesize /proc/meminfo | awk '{print $2}') + msg "hugepage size: $hugepage_size_kb" + hugepage_size_mb=$(conv_unit -o M -i K "$hugepage_size_kb") + + # @测试步骤:4: 验证hugepage大小是否为2MB + if [ "$hugepage_size_mb" -ne 2 ]; then + skip_test "hugepage大小不等于2MB" + fi + + # @测试步骤:5: 挂载hugetlbfs + mkdir -p /mnt/huge + mount none /mnt/huge -t hugetlbfs + + # @测试步骤:6: 设置CGROUP的hugetlb.2MB.rsvd.max为2MB + echo 2M >"$CGROUP_TOPDIR"/$CGROUP/hugetlb.2MB.rsvd.max + + # @测试步骤:7: 分配1个hugepage + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + "${TST_TS_TOPDIR}"/tst_lib/cgroup_util/bin/alloc_hugepage_rsvd 1 "$hugepage_size_mb" &>/dev/null & + + # @测试步骤:8: 获取hugetlb.2MB.rsvd.current + total_hugepage_current=0 + for _ in $(seq 1 5); do + current=$(cat "$CGROUP_TOPDIR"/$CGROUP/hugetlb.2MB.rsvd.current) + current=$(echo "$current / 1024 / 1024" | bc) + total_hugepage_current=$(echo "$total_hugepage_current + $current" | bc) + sleep 1 + done + aver_hugepage_current=$(echo "$total_hugepage_current / 5" | bc) + msg "aver_hugepage_current: $aver_hugepage_current" + + # @预期结果:1: 在误差允许的范围内,aver_hugepage_current等于2 + diff=$((aver_hugepage_current - 2)) + abs_diff=${diff#-} + assert_true [ "$(echo "$abs_diff < $TOLERANCE" | bc)" -eq 1 ] + + # @测试步骤:9: 获取hugetlb.2MB.events的max字段 + max_cnt=$(grep "max" "$CGROUP_TOPDIR"/$CGROUP/hugetlb.2MB.events | awk '{print $2}') + + # @预期结果:2: max_cnt等于0 + assert_true [ "$max_cnt" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 卸载hugetlbfs + umount /mnt/huge + rmdir /mnt/huge + # @清理工作: 恢复系统本来的hugepage的大小 + echo "$hugepage_size" >/proc/sys/vm/nr_hugepages + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-rsvd-max-003.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-rsvd-max-003.sh" new file mode 100755 index 0000000000000000000000000000000000000000..1723b5005c397878d59aafe02b277314891268f3 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-rsvd-max-003.sh" @@ -0,0 +1,104 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240809-185416-658896566 +# @用例名称: cgroup-v2-hugetlb-rsvd-max-003 +# @用例级别: 1 +# @用例标签: cgroup v2 hugetlb rsvd max +# @用例类型:测试hugetlb.1GB.rsvd.max接口文件, 超过限制 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-hugetlb-rsvd-max-003" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用hugetlb控制器 + if ! check_string_in_file "hugetlb" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用hugetlb控制器" + fi + # @预置条件: 启用hugetlb控制器 + echo "+hugetlb" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取系统hugepage数量 + hugepage_size=$(cat /proc/sys/vm/nr_hugepages) + + # @测试步骤:2: 修改系统hugepage数量 + echo 1 >/proc/sys/vm/nr_hugepages + + # @测试步骤:3: 获取hugepage大小 + hugepage_size_kb=$(grep Hugepagesize /proc/meminfo | awk '{print $2}') + msg "hugepage size: $hugepage_size_kb" + hugepage_size_mb=$(conv_unit -o M -i K "$hugepage_size_kb") + + # @测试步骤:4: 验证hugepage大小是否为1GB + if [ "$hugepage_size_mb" -ne 1024 ]; then + skip_test "hugepage大小不等于2MB" + fi + + # @测试步骤:5: 挂载hugetlbfs + mkdir -p /mnt/huge + mount none /mnt/huge -t hugetlbfs + + # @测试步骤:6: 获取CGROUP的hugetlb.1GB.rsvd.max值 + max=$(cat "$CGROUP_TOPDIR"/$CGROUP/hugetlb.1GB.rsvd.max) + + # @预期结果:1: 验证hugetlb.1GB.max的值是否为max + assert_true [ "$max" = "max" ] + + # @测试步骤:7: 设置CGROUP的hugetlb.1GB.rsvd.max为512MB + echo 512M >"$CGROUP_TOPDIR"/$CGROUP/hugetlb.1GB.rsvd.max + + # @测试步骤:8: 分配1个hugepage + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + "${TST_TS_TOPDIR}"/tst_lib/cgroup_util/bin/alloc_hugepage 1 "$hugepage_size_mb" &>/dev/null + + # @测试步骤:9: 获取hugetlb.1GBB.events的max字段 + max_cnt=$(grep "max" "$CGROUP_TOPDIR"/$CGROUP/hugetlb.1GB.events | awk '{print $2}') + + # @预期结果:2: max_cnt大于0 + assert_true [ "$max_cnt" -gt 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 卸载hugetlbfs + umount /mnt/huge + rmdir /mnt/huge + # @清理工作: 恢复系统本来的hugepage的大小 + echo "$hugepage_size" >/proc/sys/vm/nr_hugepages + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-rsvd-max-004.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-rsvd-max-004.sh" new file mode 100755 index 0000000000000000000000000000000000000000..4f5f891062fc43540ddaa43c971ff5a4cfb8f82a --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-hugetlb-rsvd-max-004.sh" @@ -0,0 +1,116 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240809-185417-880857496 +# @用例名称: cgroup-v2-hugetlb-rsvd-max-004 +# @用例级别: 2 +# @用例标签: cgroup v2 hugetlb rsvd max +# @用例类型:测试hugetlb.1GB.rsvd.max接口文件, 不超过限制 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-hugetlb-rsvd-max-004" +TOLERANCE=0.3 + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用hugetlb控制器 + if ! check_string_in_file "hugetlb" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用hugetlb控制器" + fi + # @预置条件: 启用hugetlb控制器 + echo "+hugetlb" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取系统hugepage数量 + hugepage_size=$(cat /proc/sys/vm/nr_hugepages) + + # @测试步骤:2: 修改系统hugepage数量 + echo 1 >/proc/sys/vm/nr_hugepages + + # @测试步骤:3: 获取hugepage大小 + hugepage_size_kb=$(grep Hugepagesize /proc/meminfo | awk '{print $2}') + msg "hugepage size: $hugepage_size_kb" + hugepage_size_mb=$(conv_unit -o M -i K "$hugepage_size_kb") + + # @测试步骤:4: 验证hugepage大小是否为1GB + if [ "$hugepage_size_mb" -ne 1024 ]; then + skip_test "hugepage大小不等于2MB" + fi + + # @测试步骤:5: 挂载hugetlbfs + mkdir -p /mnt/huge + mount none /mnt/huge -t hugetlbfs + + # @测试步骤:6: 设置CGROUP的hugetlb.1GB.rsvd.max为1GB + echo 1024M >"$CGROUP_TOPDIR"/$CGROUP/hugetlb.1GB.rsvd.max + + # @测试步骤:7: 分配1个hugepage + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + "${TST_TS_TOPDIR}"/tst_lib/cgroup_util/bin/alloc_hugepage 1 "$hugepage_size_mb" &>/dev/null & + + # @测试步骤:8: 获取hugetlb.1GB.rsvd.current + total_hugepage_current=0 + for _ in $(seq 1 5); do + current=$(cat "$CGROUP_TOPDIR"/$CGROUP/hugetlb.1GB.rsvd.current) + current=$(echo "$current / 1024 / 1024" | bc) + total_hugepage_current=$(echo "$total_hugepage_current + $current" | bc) + sleep 1 + done + aver_hugepage_current=$(echo "$total_hugepage_current / 5" | bc) + msg "aver_hugepage_current: $aver_hugepage_current" + sleep 2 + + # @预期结果:1: 在误差允许的范围内,aver_hugepage_current等于1024 + diff=$((aver_hugepage_current - 1024)) + abs_diff=${diff#-} + assert_true [ "$(echo "$abs_diff < $TOLERANCE" | bc)" -eq 1 ] + + # @测试步骤:9: 获取hugetlb.1GB.events的max字段 + max_cnt=$(grep "max" "$CGROUP_TOPDIR"/$CGROUP/hugetlb.1GB.events | awk '{print $2}') + + # @预期结果:2: max_cnt等于0 + assert_true [ "$max_cnt" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 卸载hugetlbfs + umount /mnt/huge + rmdir /mnt/huge + # @清理工作: 恢复系统本来的hugepage的大小 + echo "$hugepage_size" >/proc/sys/vm/nr_hugepages + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-io-max-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-io-max-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..e5181648b3a7a50ac37c8dd900e12ff954402663 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-io-max-001.sh" @@ -0,0 +1,96 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240808-103852-626399690 +# @用例名称: cgroup-v2-io-max-001 +# @用例级别: 1 +# @用例标签: cgroup-v2 io max +# @用例类型: 测试io.max接口文件的rbps +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-io-max-001" +TMP_FILE="$(mktemp)" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + # @预置条件: 检查是否安装了dd工具 + if ! is_dd_installed; then + skip_test "未安装dd命令" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用io控制器 + if ! check_string_in_file "io" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用io控制器" + fi + # @预置条件: 启用io控制器 + echo "+io" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取硬盘设备 + if [[ -e /dev/sda ]]; then + msg "disk is /dev/sda" + disk="sda" + else + msg "disk is /dev/vda" + disk="vda" + fi + major_device_number=$(stat -c '%t' /dev/$disk) + minor_device_number=$(stat -c '%T' /dev/$disk) + device_number="$major_device_number:$minor_device_number" + + # @测试步骤:2: 设置io.max,限制rbps为1MB/s + echo "$device_number rbps=1048576" >"$CGROUP_TOPDIR"/$CGROUP/io.max + + # @测试步骤:3: 启动一个dd进程 + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + dd iflag=direct if=/dev/$disk of=/dev/null bs=1M count=3 &>"$TMP_FILE" + + # @测试步骤:4: 获取dd进程的读取速度 + read_bps=$(grep 'copied' "$TMP_FILE" | awk '{print $10}') + msg "read_bps: $read_bps" + up_read_bps=1.2 + down_read_bps=0.8 + + # @预期结果:1: 如果读取速率在1MB/s左右,说明限速成功 + assert_true [ "$(echo "$read_bps > $down_read_bps" | bc)" -eq 1 ] + assert_true [ "$(echo "$read_bps < $up_read_bps" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-io-max-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-io-max-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..d8e358e62ad286692cb64cd30e1a2c967aeec860 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-io-max-002.sh" @@ -0,0 +1,97 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240808-110216-648820128 +# @用例名称: cgroup-v2-io-max-002 +# @用例级别: 1 +# @用例标签: cgroup-v2 io max +# @用例类型: 测试io.max接口文件的wbps +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-io-max-002" +TMP_FILE="$(mktemp)" +TMP_WIRTE_FILE="$(mktemp)" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + # @预置条件: 检查是否安装了dd工具 + if ! is_dd_installed; then + skip_test "未安装dd命令" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用io控制器 + if ! check_string_in_file "io" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用io控制器" + fi + # @预置条件: 启用io控制器 + echo "+io" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取硬盘设备 + if [[ -e /dev/sda ]]; then + msg "disk is /dev/sda" + disk="sda" + else + msg "disk is /dev/vda" + disk="vda" + fi + major_device_number=$(stat -c '%t' /dev/$disk) + minor_device_number=$(stat -c '%T' /dev/$disk) + device_number="$major_device_number:$minor_device_number" + + # @测试步骤:2: 设置io.max + echo "$device_number wbps=1048576" >"$CGROUP_TOPDIR"/$CGROUP/io.max + + # @测试步骤:3: 启动一个dd进程 + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + dd if=/dev/$disk of="$TMP_WIRTE_FILE" bs=1M count=3 oflag=direct &>"$TMP_FILE" + + # @测试步骤:4: 获取dd进程的写入速度 + write_bps=$(grep 'copied' "$TMP_FILE" | awk '{print $10}') + msg "write_bps: $write_bps" + up_write_bps=1.2 + down_write_bps=0.8 + + # @预期结果:1: 如果写入速率在1MB/s左右,说明限速成功 + assert_true [ "$(echo "$write_bps > $down_write_bps" | bc)" -eq 1 ] + assert_true [ "$(echo "$write_bps < $up_write_bps" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE" "$TMP_WIRTE_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-io-max-003.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-io-max-003.sh" new file mode 100755 index 0000000000000000000000000000000000000000..ee6311744149f51241e48db7c421be0dc86985c1 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-io-max-003.sh" @@ -0,0 +1,100 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240808-110220-353546271 +# @用例名称: cgroup-v2-io-max-003 +# @用例级别: 1 +# @用例标签: cgroup-v2 io max +# @用例类型: 测试io.max接口文件的riops +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-io-max-003" +TMP_FILE="$(mktemp)" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + # @预置条件: 检查是否安装了dd工具 + if ! is_dd_installed; then + skip_test "未安装dd命令" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用io控制器 + if ! check_string_in_file "io" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用io控制器" + fi + # @预置条件: 启用io控制器 + echo "+io" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取硬盘设备 + if [[ -e /dev/sda ]]; then + msg "disk is /dev/sda" + disk="sda" + else + msg "disk is /dev/vda" + disk="vda" + fi + major_device_number=$(stat -c '%t' /dev/$disk) + minor_device_number=$(stat -c '%T' /dev/$disk) + device_number="$major_device_number:$minor_device_number" + + # @测试步骤:2: 设置io.max + echo "$device_number riops=100" >"$CGROUP_TOPDIR"/$CGROUP/io.max + + # @测试步骤:3: 启动dd进程 + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + dd iflag=direct if=/dev/$disk of=/dev/null bs=4K count=500 &>"$TMP_FILE" + time=$(grep -oP '(?<=, )\d+\.\d+(?= s)' "$TMP_FILE") + msg "time: $time" + + # @测试步骤:4: 获取读取速度 + deivce_line=$(grep "$device_number" "$CGROUP_TOPDIR"/$CGROUP/io.stat) + read_iops=$(echo "$deivce_line" | grep -oP "rios=\K\d+") + read_iops_per_second=$(echo "scale=2; $read_iops / $time" | bc) + msg "read_iops: $read_iops_per_second" + up_read_iops=110 + down_read_iops=90 + + # @预期结果:1: 如果读取速率在100 IO/s左右,说明限速成功 + assert_true [ "$(echo "$read_iops_per_second > $down_read_iops" | bc)" -eq 1 ] + assert_true [ "$(echo "$read_iops_per_second < $up_read_iops" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-io-max-004.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-io-max-004.sh" new file mode 100755 index 0000000000000000000000000000000000000000..786644d10d41d21e83d89ab56b19d16043ae5534 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-io-max-004.sh" @@ -0,0 +1,100 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240808-110221-955418429 +# @用例名称: cgroup-v2-io-max-004 +# @用例级别: 1 +# @用例标签: cgroup-v2 io max +# @用例类型: 测试io.max接口文件的wiops +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-io-max-004" +TMP_FILE="$(mktemp)" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + # @预置条件: 检查是否安装了dd工具 + if ! is_dd_installed; then + skip_test "未安装dd命令" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用io控制器 + if ! check_string_in_file "io" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用io控制器" + fi + # @预置条件: 启用io控制器 + echo "+io" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取硬盘设备 + if [[ -e /dev/sda ]]; then + msg "disk is /dev/sda" + disk="sda" + else + msg "disk is /dev/vda" + disk="vda" + fi + major_device_number=$(stat -c '%t' /dev/$disk) + minor_device_number=$(stat -c '%T' /dev/$disk) + device_number="$major_device_number:$minor_device_number" + + # @测试步骤:2: 设置io.max + echo "$device_number wiops=100" >"$CGROUP_TOPDIR"/$CGROUP/io.max + + # @测试步骤:3: 启动一个dd进程 + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + dd if=/dev/$disk of=/tmp/testfile bs=4k count=500 oflag=direct &>"$TMP_FILE" + time=$(grep -oP '(?<=, )\d+\.\d+(?= s)' "$TMP_FILE") + msg "time: $time" + + # @测试步骤:4: 获取写入速度 + deivce_line=$(grep "$device_number" "$CGROUP_TOPDIR"/$CGROUP/io.stat) + wirte_iops=$(echo "$deivce_line" | grep -oP "wios=\K\d+") + write_iops_per_second=$(echo "scale=2; $wirte_iops / $time" | bc) + msg "read_iops: $write_iops_per_second" + up_wirte_iops=110 + down_wirte_iops=90 + + # @预期结果:1: 如果读取速率在100 IO/s左右,说明限速成功 + assert_true [ "$(echo "$write_iops_per_second > $down_wirte_iops" | bc)" -eq 1 ] + assert_true [ "$(echo "$write_iops_per_second < $up_wirte_iops" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-io-pressure.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-io-pressure.sh" new file mode 100755 index 0000000000000000000000000000000000000000..3cfda04afec82359194b4218b1dad8b7221f503f --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-io-pressure.sh" @@ -0,0 +1,106 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240808-112444-602586740 +# @用例名称: cgroup-v2-io-pressure +# @用例级别: 3 +# @用例标签: cgroup-v2 io pressure +# @用例类型: 测试io.pressure接口文件,设置io压力通知 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-io-pressure" +TMP_FILE=$(mktemp) + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + # @预置条件: 检查是否安装了dd工具 + if ! is_dd_installed; then + skip_test "未安装dd命令" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用io控制器 + if ! check_string_in_file "io" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用io控制器" + fi + # @预置条件: 启用io控制器 + echo "+io" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 启用cgroup.pressure + echo 1 >"$CGROUP_TOPDIR"/$CGROUP/cgroup.pressure + + # @测试步骤:2: 获取硬盘设备 + if [[ -e /dev/sda ]]; then + msg "disk is /dev/sda" + disk="sda" + else + msg "disk is /dev/vda" + disk="vda" + fi + major_device_number=$(stat -c '%t' /dev/$disk) + minor_device_number=$(stat -c '%T' /dev/$disk) + device_number="$major_device_number:$minor_device_number" + + # @测试步骤:3: 设置io.max,限制rbps为1MB/s + echo "$device_number rbps=1048576" >"$CGROUP_TOPDIR"/$CGROUP/io.max + + # @测试步骤:4: 注册触发器 + stdbuf -oL "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/pressure_listener "$CGROUP_TOPDIR"/$CGROUP/io.pressure &>"$TMP_FILE" & + + # @测试步骤:5: 启动两个dd进程 + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + dd iflag=direct if=/dev/$disk of=/dev/null bs=1M count=5 + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + + # @测试步骤:6: 读取io.pressure文件 + io_pressure=$(cat "$CGROUP_TOPDIR"/$CGROUP/io.pressure) + avg10=$(echo "$io_pressure" | awk 'NR==1 {for(i=1;i<=NF;i++) if ($i ~ /^avg10=/) {split($i, a, "="); print a[2]}}') + msg "avg10: $avg10" + + # @预期结果:1: avg10值应该大于0 + assert_true [ "$(echo "$avg10 > 0" | bc)" -eq 1 ] + + # @预期结果:2: 触发器应该被触发 + is_trigered=-1 + if grep -q "event triggered" "$TMP_FILE"; then + is_trigered=0 + fi + assert_true [ "$is_trigered" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-io-weight.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-io-weight.sh" new file mode 100755 index 0000000000000000000000000000000000000000..9ec86c3c28f27ca4f7757126f35f68f28d6ebdad --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-io-weight.sh" @@ -0,0 +1,126 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240807-224514-698927621 +# @用例名称: cgroup-v2-io-weight +# @用例级别: 1 +# @用例标签: cgroup-v2 io weight +# @用例类型: 测试io.weight接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-io-weight" +CHILD0="$CGROUP/child0" +CHILD1="$CGROUP/child1" +CHILD2="$CGROUP/child2" +TMP_FILE0="$(mktemp)" +TMP_FILE1="$(mktemp)" +TMP_FILE2="$(mktemp)" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + # @预置条件: 检查是否安装了dd工具 + if ! is_dd_installed; then + skip_test "未安装dd命令" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + mkdir "$CGROUP_TOPDIR"/$CHILD0 + mkdir "$CGROUP_TOPDIR"/$CHILD1 + mkdir "$CGROUP_TOPDIR"/$CHILD2 + # @预置条件: 检查当前cgroup是否能启用io控制器 + if ! check_string_in_file "io" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用io控制器" + fi + # @预置条件: 启用io控制器 + echo "+io" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + echo "+io" >"$CGROUP_TOPDIR"/$CGROUP/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 获取硬盘设备 + if [[ -e /dev/sda ]]; then + msg "disk is /dev/sda" + disk="sda" + else + msg "disk is /dev/vda" + disk="vda" + fi + major_device_number=$(stat -c '%t' /dev/$disk) + minor_device_number=$(stat -c '%T' /dev/$disk) + device_number="$major_device_number:$minor_device_number" + + # @测试步骤:2: 启用io.cost.qos + echo "$device_number enable=1 ctrl=auto" >"$CGROUP_TOPDIR"/io.cost.qos + + # @测试步骤:3: 设置CHILD0\CHILD1\CHILD2的io.weight + echo "$device_number 100" >"$CGROUP_TOPDIR/$CHILD0/io.weight" + echo "$device_number 200" >"$CGROUP_TOPDIR/$CHILD1/io.weight" + echo "$device_number 300" >"$CGROUP_TOPDIR/$CHILD2/io.weight" + + # @测试步骤:4: 启动dd进程 + echo $$ >"$CGROUP_TOPDIR/$CHILD0/cgroup.procs" + dd iflag=direct if=/dev/$disk of=/dev/null bs=1M count=512 &>"$TMP_FILE0" & + task_pid=$! + + echo $$ >"$CGROUP_TOPDIR/$CHILD1/cgroup.procs" + dd iflag=direct if=/dev/$disk of=/dev/null bs=1M count=512 &>"$TMP_FILE1" & + + echo $$ >"$CGROUP_TOPDIR/$CHILD2/cgroup.procs" + dd iflag=direct if=/dev/$disk of=/dev/null bs=1M count=512 &>"$TMP_FILE2" & + + wait $task_pid + + # @测试步骤:5: 获取dd进程的读取速度 + read_speed1=$(grep 'copied' "$TMP_FILE0" | awk '{print $10}') + read_speed2=$(grep 'copied' "$TMP_FILE1" | awk '{print $10}') + read_speed3=$(grep 'copied' "$TMP_FILE2" | awk '{print $10}') + msg "read_speed1: $read_speed1" + msg "read_speed2: $read_speed2" + msg "read_speed3: $read_speed3" + + # @预期结果:1: CHIlD0的读取速度小于CHILD1的读取速度, CHILD1的读取速度小于CHILD2的读取速度 + assert_true [ "$(echo "$read_speed1 < $read_speed2" | bc)" -eq 1 ] + assert_true [ "$(echo "$read_speed2 < $read_speed3" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 关闭io.cost.qos + echo "$device_number enable=0" >"$CGROUP_TOPDIR"/io.cost.qos + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR/cgroup.procs" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CHILD1 + rmdir "$CGROUP_TOPDIR"/$CHILD2 + rmdir "$CGROUP_TOPDIR"/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE0" "$TMP_FILE1" "$TMP_FILE2" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-kill-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-kill-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..ab6e5880e85775de3f951e42da27b05d77fbea89 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-kill-001.sh" @@ -0,0 +1,74 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240809-234742-111875618 +# @用例名称: cgroup-v2-kill-001 +# @用例级别: 1 +# @用例标签: cgroup-v2 kill +# @用例类型: 测试cgroup.kill接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-kill-001" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 运行一个进程 + { + while true; do :; done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + + # @预期结果:1: CGROUP的cgroup.event中的populated字段为1 + populated=$(grep populated "$CGROUP_TOPDIR"/$CGROUP/cgroup.events | awk '{print $2}') + assert_true [ "$populated" -eq 1 ] + + # @测试步骤:2: 写入cgroup.kill + echo 1 >"$CGROUP_TOPDIR"/$CGROUP/cgroup.kill + + # @预期结果:2: CGROUP的cgroup.event中的populated字段为0 + populated=$(grep populated "$CGROUP_TOPDIR"/$CGROUP/cgroup.events | awk '{print $2}') + assert_true [ "$populated" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid" + sleep 1 + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-kill-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-kill-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..7884786168fbaeef08fe694300a6bad565756dbe --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-kill-002.sh" @@ -0,0 +1,116 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240809-235140-559937243 +# @用例名称: cgroup-v2-kill-002 +# @用例级别: 2 +# @用例标签: cgroup-v2 kill +# @用例类型: 测试cgroup.kill接口文件, 测试层次结构 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +# CGROUP +# / | \ +# CHILD0 CHILD1 CHILD2 +# / \ | +# CHILD00 CHILD01 CHILD10 +# | +# CHILD100 +# | +# CHILD1000 +CGROUP="cgroup-v2-kill-002" +CHILD0="$CGROUP/child0" +CHILD1="$CGROUP/child1" +CHILD2="$CGROUP/child3" +CHILD00="$CHILD0/child0" +CHILD01="$CHILD0/child1" +CHILD10="$CHILD1/child0" +CHILD100="$CHILD10/child0" +CHILD1000="$CHILD100/child0" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + mkdir "$CGROUP_TOPDIR"/$CHILD0 + mkdir "$CGROUP_TOPDIR"/$CHILD1 + mkdir "$CGROUP_TOPDIR"/$CHILD2 + mkdir "$CGROUP_TOPDIR"/$CHILD00 + mkdir "$CGROUP_TOPDIR"/$CHILD01 + mkdir "$CGROUP_TOPDIR"/$CHILD10 + mkdir "$CGROUP_TOPDIR"/$CHILD100 + mkdir "$CGROUP_TOPDIR"/$CHILD1000 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 在CHILD01上运行一个进程 + { + while true; do :; done + } & + task_pid0=$! + echo $task_pid0 >"$CGROUP_TOPDIR"/$CHILD01/cgroup.procs + + # @测试步骤:2: 在CHILD1000上运行一个进程 + { + while true; do :; done + } & + task_pid1=$! + echo $task_pid1 >"$CGROUP_TOPDIR"/$CHILD1000/cgroup.procs + + # @测试步骤:3: 在CHILD2上运行一个进程 + { + while true; do :; done + } & + task_pid2=$! + echo $task_pid2 >"$CGROUP_TOPDIR"/$CHILD2/cgroup.procs + + # @测试步骤:4: 在CGROUP写入cgroup.kill + echo 1 >"$CGROUP_TOPDIR"/$CGROUP/cgroup.kill + + # @预期结果:1: CGROUP的cgroup.event中的populated字段为0 + populated=$(grep populated "$CGROUP_TOPDIR"/$CGROUP/cgroup.events | awk '{print $2}') + assert_true [ "$populated" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid0" "$task_pid1" "$task_pid2" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD1000 + rmdir "$CGROUP_TOPDIR"/$CHILD100 + rmdir "$CGROUP_TOPDIR"/$CHILD10 + rmdir "$CGROUP_TOPDIR"/$CHILD01 + rmdir "$CGROUP_TOPDIR"/$CHILD00 + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CHILD1 + rmdir "$CGROUP_TOPDIR"/$CHILD2 + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-max-deep.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-max-deep.sh" new file mode 100755 index 0000000000000000000000000000000000000000..3bd4580d945f9e9809166d04f33c5cc9e797e7a0 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-max-deep.sh" @@ -0,0 +1,80 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240812-234221-157931352 +# @用例名称: cgroup-v2-max-deep +# @用例级别: 2 +# @用例标签: cgoup-v2 max deep +# @用例类型: 测试cgroup.max.deep接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-max-deep" +CHILD0="$CGROUP/child0" +CHILD00="$CHILD0/child0" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + + return 0 +} + +do_test() { + msg "this is do_test" + + # @测试步骤:1: 读取CGROUP的cgroup.max.descendants + max_descendants=$(cat "$CGROUP_TOPDIR"/$CGROUP/cgroup.max.descendants) + + # @预期结果:1: cgroup.max.descendants的值为max + assert_true [ "$max_descendants" = "max" ] + + # @测试步骤:2: 启用CGROUP的cgrou.max.descendants为1 + echo 1 > "$CGROUP_TOPDIR"/$CGROUP/cgroup.max.descendants + + # @测试步骤:3: 创建一个子cgroup + ret=0 + mkdir "$CGROUP_TOPDIR"/$CHILD0 || ret=-1 + + # @预期结果:2: 创建成功 + assert_true [ $ret -eq 0 ] + + # @测试步骤:4: 再创建一个子cgroup + ret=0 + mkdir "$CGROUP_TOPDIR"/$CHILD00|| ret=-1 + + # @预期结果:3: 创建失败 + assert_true [ $ret -eq -1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-max-descendants.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-max-descendants.sh" new file mode 100755 index 0000000000000000000000000000000000000000..aaefd3721b792f509f45b21edf48a0f80e2cb726 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-max-descendants.sh" @@ -0,0 +1,79 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240812-232817-897631780 +# @用例名称: cgroup-v2-max-descendants +# @用例级别: 2 +# @用例标签: cgroup-v2 max descendants +# @用例类型: 测试cgroup.max.descendants接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-max-descendants" +CHILD0="$CGROUP/child0" +CHILD1="$CGROUP/child1" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 读取CGROUP的cgroup.max.descendants + max_descendants=$(cat "$CGROUP_TOPDIR"/$CGROUP/cgroup.max.descendants) + + # @预期结果:1: cgroup.max.descendants的值为max + assert_true [ "$max_descendants" = "max" ] + + # @测试步骤:2: 启用CGROUP的cgrou.max.descendants为1 + echo 1 > "$CGROUP_TOPDIR"/$CGROUP/cgroup.max.descendants + + # @测试步骤:3: 创建一个子cgroup + ret=0 + mkdir "$CGROUP_TOPDIR"/$CHILD0 || ret=-1 + + # @预期结果:2: 创建成功 + assert_true [ $ret -eq 0 ] + + # @测试步骤:4: 再创建一个子cgroup + ret=0 + mkdir "$CGROUP_TOPDIR"/$CHILD1 || ret=-1 + + # @预期结果:3: 创建失败 + assert_true [ $ret -eq -1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-current.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-current.sh" new file mode 100755 index 0000000000000000000000000000000000000000..2376f8dbe9718628f8b1a4a3a418f53936641e72 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-current.sh" @@ -0,0 +1,112 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240806-235307-525430290 +# @用例名称: cgroup-v2-memory-current +# @用例级别: 1 +# @用例标签: cgroup-v2 memory current +# @用例类型: 测试memory.current接口文件,分配一些匿名内存和页缓存,查看memory.current的值 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-memory-current" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用memory控制器 + if ! check_string_in_file "memory" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用memory控制器" + fi + # @预置条件: 启用memory控制器 + echo "+memory" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 读取memory.current的值 + memory_current=$(cat "$CGROUP_TOPDIR"/$CGROUP/memory.current) + + # @预期结果:1: memory.current的值为0 + assert_true [ "$memory_current" -eq 0 ] + + # @测试步骤:2: 分配50MB匿名内存 + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 50M & + sleep 2 + + # @测试步骤:3: 读取memory.current的值 + total_memory_current=0 + for _ in $(seq 1 8); do + memory_current=$(cat "$CGROUP_TOPDIR"/$CGROUP/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + total_memory_current=$(echo "$memory_current + $total_memory_current" | bc) + sleep 1 + done + aver_memory_current=$(echo "$total_memory_current / 8" | bc) + msg "memory.current: $aver_memory_current MB" + sleep 3 + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + + # @预期结果:2: 在误差范围内,memory.current的值为50MB + TOLERANCE=$(echo "($aver_memory_current + 30) * 0.05" | bc) + diff=$((aver_memory_current - 50)) + abs_diff=${diff#-} + assert_true [ "$(echo "$abs_diff < $TOLERANCE" | bc)" -eq 1 ] + + # @测试步骤:4: 分配50MB页缓存 + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_pagecache 50M & + sleep 2 + + # @测试步骤:5: 读取memory.current的值 + total_memory_current=0 + for _ in $(seq 1 8); do + memory_current=$(cat "$CGROUP_TOPDIR"/$CGROUP/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + total_memory_current=$(echo "$memory_current + $total_memory_current" | bc) + sleep 1 + done + aver_memory_current=$(echo "$total_memory_current / 8" | bc) + msg "memory.current: $aver_memory_current MB" + sleep 3 + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + + # @预期结果:3: 在误差范围内,memory.current的值为50MB + TOLERANCE=$(echo "($aver_memory_current + 30) * 0.05" | bc) + diff=$((aver_memory_current - 50)) + abs_diff=${diff#-} + assert_true [ "$(echo "$abs_diff < $TOLERANCE" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-high-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-high-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..41a55f6fbc74911a3831302b2814935851e283f7 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-high-001.sh" @@ -0,0 +1,140 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240806-181220-908479593 +# @用例名称: cgroup-v2-memory-high-001 +# @用例级别: 1 +# @用例标签: cgroup-v2 memory high +# @用例类型: 测试memory.high接口文件,测试是否能有效控制匿名内存和页缓存所消耗的内存量 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-memory-high-001" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用memory控制器 + if ! check_string_in_file "memory" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用memory控制器" + fi + # @预置条件: 启用memory控制器 + echo "+memory" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 读取memory.high的值 + memory_high=$(cat "$CGROUP_TOPDIR"/$CGROUP/memory.high) + + # @预期结果:1: memory.high的值为max + assert_true [ "$memory_high" = "max" ] + + # @测试步骤:2: 关闭CGROUP中的swapping + echo 0 >"$CGROUP_TOPDIR"/$CGROUP/memory.swap.max + + # @测试步骤:3: 设置memory.high的值为30M + echo 30M >"$CGROUP_TOPDIR"/$CGROUP/memory.high + + # @测试步骤:4: 分配31MB匿名内存 + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 31M & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + sleep 2 + + # @预期结果:2: 分配成功 + pids=$(cat "$CGROUP_TOPDIR"/$CGROUP/cgroup.procs) + if [ -z "$pids" ]; then + is_alloc=-1 + else + is_alloc=0 + fi + assert_true [ "$is_alloc" -eq 0 ] + + kill -9 $task_pid + + # @测试步骤:5: 分配50MB页缓存 + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_pagecache 50M & + sleep 2 + + # @测试步骤:6: 获取memory.current + total_memory_current=0 + for _ in $(seq 1 8); do + memory_current=$(cat "$CGROUP_TOPDIR"/$CGROUP/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + total_memory_current=$(echo "$total_memory_current + $memory_current" | bc) + sleep 1 + done + aver_memory_current=$(echo "$total_memory_current / 8" | bc) + msg "average memory current: $aver_memory_current" + sleep 1 + + # @预期结果:3: memory.current小于50MB + assert_true [ "$aver_memory_current" -lt 50 ] + + # @测试步骤:7: 分配30MB页缓存 + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_pagecache 30M & + sleep 2 + + # @测试步骤:8: 获取memory.current + total_memory_current=0 + for _ in $(seq 1 8); do + memory_current=$(cat "$CGROUP_TOPDIR"/$CGROUP/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + total_memory_current=$(echo "$total_memory_current + $memory_current" | bc) + sleep 1 + done + aver_memory_current=$(echo "$total_memory_current / 8" | bc) + msg "average memory current: $aver_memory_current" + sleep 1 + + # @预期结果:4: 在误差允许范围内memory.current等于30MB + TOLERANCE=$(echo "($aver_memory_current + 30) * 0.05" | bc) + msg "tolerance: $TOLERANCE" + diff=$((aver_memory_current - 30)) + abs_diff=${diff#-} + assert_true [ "$(echo "$abs_diff < $TOLERANCE" | bc)" -eq 1 ] + + # @测试步骤:9: 获取CGROUP内存达到memory.high的次数 + high_cnt=$(grep "high" "$CGROUP_TOPDIR"/$CGROUP/memory.events | awk '{print $2}') + msg "high cnt: $high_cnt" + + # @预期结果:5: high_cnt大于0 + assert_true [ "$high_cnt" -gt "0" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-high-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-high-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..4148d6c97098dafd390f2d00bc3e5935f7a3bde6 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-high-002.sh" @@ -0,0 +1,103 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240806-191958-361673037 +# @用例名称: cgroup-v2-memory-high-002 +# @用例级别: 1 +# @用例标签: cgroup-v2 memory high +# @用例类型: 测试memory.high接口文件,测试是否能有效对内存的大量单次分配进行限制 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-memory-high-002" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用memory控制器 + if ! check_string_in_file "memory" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用memory控制器" + fi + # @预置条件: 启用memory控制器 + echo "+memory" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 读取memory.events的high字段和max字段 + high_cnt=$(grep "high" "$CGROUP_TOPDIR"/$CGROUP/memory.events | awk '{print $2}') + max_cnt=$(grep "max" "$CGROUP_TOPDIR"/$CGROUP/memory.events | awk '{print $2}') + msg "high_cnt: $high_cnt" + msg "max_cnt: $max_cnt" + + # @预期结果:1: high_cnt和max_cnt都不小于0 + assert_true [ "$high_cnt" -ge 0 ] + assert_true [ "$max_cnt" -ge 0 ] + + # @测试步骤:2: 关闭CGROUP中的swapping + echo 0 >"$CGROUP_TOPDIR"/$CGROUP/memory.swap.max + + # @测试步骤:3: 设置memory.high的值为30M + echo 10M >"$CGROUP_TOPDIR"/$CGROUP/memory.high + + # @测试步骤:4: 设置memory.max的值为140M + echo 140M >"$CGROUP_TOPDIR"/$CGROUP/memory.max + + # @测试步骤:5: 注册内存事件监控 + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/register_notify "$CGROUP_TOPDIR"/$CGROUP/cgroup.events & + + # @测试步骤:6: 单次分配100MB内存 + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon_mlock 120M & + task_pid=$! + echo "$task_pid" >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + sleep 12 + + # @测试步骤:7: 读取memory.events的high字段和max字段 + post_high_cnt=$(grep "high" "$CGROUP_TOPDIR"/$CGROUP/memory.events | awk '{print $2}') + post_max_cnt=$(grep "max" "$CGROUP_TOPDIR"/$CGROUP/memory.events | awk '{print $2}') + msg "post high_cnt: $post_high_cnt" + msg "post max_cnt: $post_max_cnt" + + # @预期结果:2: high_cnt和max_cnt都不小于0 + assert_true [ "$post_high_cnt" -ge 0 ] + assert_true [ "$post_max_cnt" -ge 0 ] + + # @预期结果:3: high_cnt增加,max_cnt不变 + assert_true [ "$post_high_cnt" -ne "$high_cnt" ] + assert_true [ "$post_max_cnt" -eq "$max_cnt" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid" + sleep 1 + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-low-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-low-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..e20299bbdaa4ba1ee4a4c5a612120ecf837a78bf --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-low-001.sh" @@ -0,0 +1,164 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240806-175358-337059818 +# @用例名称: cgroup-v2-memory-low-001 +# @用例级别: 1 +# @用例标签: cgroup-v2 memory low +# @用例类型: 测试memoruy.low接口文件,parent1/2的父cgroup设置的内存上限是200MB, parent2分配的内存为146MB, 不会占用parent1的memory.low保护的内存50MB +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-memory-low-001" +PARENT1="$CGROUP/parent1" +PARENT2="$CGROUP/parent2" +CHILD0="$PARENT1/child0" +CHILD1="$PARENT1/child1" +CHILD2="$PARENT1/child2" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + mkdir "$CGROUP_TOPDIR"/$PARENT1 + mkdir "$CGROUP_TOPDIR"/$PARENT2 + mkdir "$CGROUP_TOPDIR"/$CHILD0 + mkdir "$CGROUP_TOPDIR"/$CHILD1 + mkdir "$CGROUP_TOPDIR"/$CHILD2 + # @预置条件: 检查当前cgroup是否能启用memory控制器 + if ! check_string_in_file "memory" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用memory控制器" + fi + # @预置条件: 启用memory控制器 + echo "+memory" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + echo "+memory" >"$CGROUP_TOPDIR"/$CGROUP/cgroup.subtree_control || return 1 + echo "+memory" >"$CGROUP_TOPDIR"/$PARENT1/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 关闭系统上的所有交换空间 + echo 0 >"$CGROUP_TOPDIR"/$CGROUP/memory.swap.max + + # @测试步骤:2: 设置memory.max和memory.low + echo 200M >"$CGROUP_TOPDIR"/$CGROUP/memory.max + echo 50M >"$CGROUP_TOPDIR"/$PARENT1/memory.low + echo 75M >"$CGROUP_TOPDIR"/$CHILD0/memory.low + echo 25M >"$CGROUP_TOPDIR"/$CHILD1/memory.low + echo 0M >"$CGROUP_TOPDIR"/$CHILD2/memory.low + + # @测试步骤:3: 给PARENT1的三个子cgroup分配50MB内存 + echo $$ >"$CGROUP_TOPDIR"/$CHILD0/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_pagecache 50M & + echo $$ >"$CGROUP_TOPDIR"/$CHILD1/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_pagecache 50M & + echo $$ >"$CGROUP_TOPDIR"/$CHILD2/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_pagecache 50M & + sleep 1 # 确保子进程已经分配内存 + + # @测试步骤:4: 给PARENT2分配146MB内存 + echo $$ >"$CGROUP_TOPDIR"/$PARENT2/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 146M & + sleep 1 + + # @测试步骤:5: 检查内存使用情况 + parent1_memory=0 + chidl0_memory=0 + chidl1_memory=0 + chidl2_memory=0 + parent2_memory=0 + for _ in $(seq 1 8); do + memory_current=$(cat "$CGROUP_TOPDIR"/$PARENT1/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + parent1_memory=$(echo "$memory_current + $parent1_memory" | bc) + + memory_current=$(cat "$CGROUP_TOPDIR"/$CHILD0/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + chidl0_memory=$(echo "$memory_current + $chidl0_memory" | bc) + + memory_current=$(cat "$CGROUP_TOPDIR"/$CHILD1/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + chidl1_memory=$(echo "$memory_current + $chidl1_memory" | bc) + + memory_current=$(cat "$CGROUP_TOPDIR"/$CHILD2/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + chidl2_memory=$(echo "$memory_current + $chidl2_memory" | bc) + + memory_current=$(cat "$CGROUP_TOPDIR"/$PARENT2/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + parent2_memory=$(echo "$memory_current + $parent2_memory" | bc) + sleep 1 + done + aver_parent1_memory=$(echo "$parent1_memory / 8" | bc) + aver_chidl0_memory=$(echo "$chidl0_memory / 8" | bc) + aver_chidl1_memory=$(echo "$chidl1_memory / 8" | bc) + aver_chidl2_memory=$(echo "$chidl2_memory / 8" | bc) + aver_parent2_memory=$(echo "$parent2_memory / 8" | bc) + msg "parent1 memory average: $aver_parent1_memory" + msg "child0 memory average: $aver_chidl0_memory" + msg "child1 memory average: $aver_chidl1_memory" + msg "child2 memory average: $aver_chidl2_memory" + msg "parent2 memory average: $aver_parent2_memory" + sleep 3 + + # @预期结果:1: 在误差允许范围内,PARENT1的三个子cgroup分配的内存总和等于50MB + TOLERANCE=$(echo "($aver_parent1_memory + 50) * 0.05" | bc) + diff=$((aver_parent1_memory - 50)) + abs_diff=${diff#-} + assert_true [ "$(echo "$abs_diff < $TOLERANCE" | bc)" -eq 1 ] + + # @预期结果:2: 在误差允许范围内,CHILD0分配的内存等于25MB, CHILD1分配的内存等于25MB, CHILD2分配的内存等于0MB + TOLERANCE=$(echo "($aver_chidl0_memory + 29) * 0.2" | bc) + diff=$((aver_chidl0_memory - 29)) + abs_diff=${diff#-} + assert_true [ "$(echo "$abs_diff < $TOLERANCE" | bc)" -eq 1 ] + TOLERANCE=$(echo "($aver_chidl1_memory + 21) * 0.2" | bc) + diff=$((aver_chidl1_memory - 21)) + abs_diff=${diff#-} + assert_true [ "$(echo "$abs_diff < $TOLERANCE" | bc)" -eq 1 ] + assert_true [ "$aver_chidl2_memory" -le 3 ] + + # @预期结果:3: 在误差允许范围内,PARENT2分配的内存等于146MB + TOLERANCE=$(echo "($aver_parent2_memory + 146) * 0.05" | bc) + diff=$((aver_parent2_memory - 146)) + abs_diff=${diff#-} + assert_true [ "$(echo "$abs_diff < $TOLERANCE" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CHILD1 + rmdir "$CGROUP_TOPDIR"/$CHILD2 + rmdir "$CGROUP_TOPDIR"/$PARENT1 + rmdir "$CGROUP_TOPDIR"/$PARENT2 + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-low-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-low-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..e6cc6693523daac0bcfe4c8d5be33562c4821896 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-low-002.sh" @@ -0,0 +1,140 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240813-015314-638344032 +# @用例名称: cgroup-v2-memory-low-002 +# @用例级别: 1 +# @用例标签: cgroup-v2 memory low +# @用例类型: 测试memoruy.low接口文件,parent1/2的父cgroup设置的内存上限是200MB, parent2分配的内存为170MB, 会占用parent1的memory.low保护的内存50MB, 但是不会被kill,依然能分配 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-memory-low-001" +PARENT1="$CGROUP/parent1" +PARENT2="$CGROUP/parent2" +CHILD0="$PARENT1/child0" +CHILD1="$PARENT1/child1" +CHILD2="$PARENT1/child2" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + mkdir "$CGROUP_TOPDIR"/$PARENT1 + mkdir "$CGROUP_TOPDIR"/$PARENT2 + mkdir "$CGROUP_TOPDIR"/$CHILD0 + mkdir "$CGROUP_TOPDIR"/$CHILD1 + mkdir "$CGROUP_TOPDIR"/$CHILD2 + # @预置条件: 检查当前cgroup是否能启用memory控制器 + if ! check_string_in_file "memory" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用memory控制器" + fi + # @预置条件: 启用memory控制器 + echo "+memory" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + echo "+memory" >"$CGROUP_TOPDIR"/$CGROUP/cgroup.subtree_control || return 1 + echo "+memory" >"$CGROUP_TOPDIR"/$PARENT1/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 关闭系统上的所有交换空间 + echo 0 >"$CGROUP_TOPDIR"/$CGROUP/memory.swap.max + + # @测试步骤:2: 设置memory.max和memory.low + echo 200M >"$CGROUP_TOPDIR"/$CGROUP/memory.max + echo 50M >"$CGROUP_TOPDIR"/$PARENT1/memory.low + echo 75M >"$CGROUP_TOPDIR"/$CHILD0/memory.low + echo 25M >"$CGROUP_TOPDIR"/$CHILD1/memory.low + echo 0M >"$CGROUP_TOPDIR"/$CHILD2/memory.low + + # @测试步骤:3: 给PARENT1的三个子cgroup分配50MB内存 + echo $$ >"$CGROUP_TOPDIR"/$CHILD0/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_pagecache 50M & + echo $$ >"$CGROUP_TOPDIR"/$CHILD1/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_pagecache 50M & + echo $$ >"$CGROUP_TOPDIR"/$CHILD2/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_pagecache 50M & + sleep 1 # 确保子进程已经分配内存 + + # @测试步骤:4: 给PARENT2分配170MB内存 + echo $$ >"$CGROUP_TOPDIR"/$PARENT2/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 170M & + sleep 1 + + # @测试步骤:5: 检查内存使用情况 + parent1_memory=0 + parent2_memory=0 + for _ in $(seq 1 8); do + memory_current=$(cat "$CGROUP_TOPDIR"/$PARENT1/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + parent1_memory=$(echo "$memory_current + $parent1_memory" | bc) + + memory_current=$(cat "$CGROUP_TOPDIR"/$PARENT2/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + parent2_memory=$(echo "$memory_current + $parent2_memory" | bc) + sleep 1 + done + aver_parent1_memory=$(echo "$parent1_memory / 8" | bc) + aver_parent2_memory=$(echo "$parent2_memory / 8" | bc) + msg "parent1 memory average: $aver_parent1_memory" + msg "parent2 memory average: $aver_parent2_memory" + sleep 3 + + # @预期结果:1: 在误差允许范围内,PARENT1的三个子cgroup分配的内存总和等于30MB + TOLERANCE=$(echo "($aver_parent1_memory + 30) * 0.1" | bc) + diff=$((aver_parent1_memory - 30)) + abs_diff=${diff#-} + assert_true [ "$(echo "$abs_diff < $TOLERANCE" | bc)" -eq 1 ] + + # @预期结果:2: 在误差允许范围内,PARENT2分配的内存等于170MB + TOLERANCE=$(echo "($aver_parent2_memory + 170) * 0.05" | bc) + diff=$((aver_parent2_memory - 170)) + abs_diff=${diff#-} + assert_true [ "$(echo "$abs_diff < $TOLERANCE" | bc)" -eq 1 ] + + # @预期结果:4: 检查low事件次数大于0 + low_cnt=$(grep "low" "$CGROUP_TOPDIR"/$PARENT1/memory.events | awk '{print $2}') + assert_true [ "$low_cnt" -gt 0 ] + + # @预期结果:5: 检查PARENT2的oom_kill事件次数等于0 + oom_kill_cnt=$(grep "oom_kill" "$CGROUP_TOPDIR"/$PARENT2/memory.events | awk 'NR==1 {print $2}') + assert_true [ "$oom_kill_cnt" -ge 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CHILD1 + rmdir "$CGROUP_TOPDIR"/$CHILD2 + rmdir "$CGROUP_TOPDIR"/$PARENT1 + rmdir "$CGROUP_TOPDIR"/$PARENT2 + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-max.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-max.sh" new file mode 100755 index 0000000000000000000000000000000000000000..7aadd78f9b08c9459ef746a9390f078e28228a72 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-max.sh" @@ -0,0 +1,127 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240805-225552-969242515 +# @用例名称: cgroup-v2-memory-max +# @用例级别: 1 +# @用例标签: cgroup-v2 memory max +# @用例类型: 测试memory.max接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-memory-max" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用memory控制器 + if ! check_string_in_file "memory" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用memory控制器" + fi + # @预置条件: 启用memory控制器 + echo "+memory" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 读取memory.max的值 + memory_max=$(cat "$CGROUP_TOPDIR"/$CGROUP/memory.max) + + # @预期结果:1: memory.max的值为max + assert_true [ "$memory_max" = "max" ] + + # @测试步骤:2: 关闭CGROUP中的swapping + echo 0 >"$CGROUP_TOPDIR"/$CGROUP/memory.swap.max + + # @测试步骤:3: 设置memory.max的值为30M + echo 30M >"$CGROUP_TOPDIR"/$CGROUP/memory.max + + # @测试步骤:4: 分配100MB匿名内存 + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 200M & + echo $! >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + sleep 2 + + # @预期结果:2: 分配失败 + pids=$(cat "$CGROUP_TOPDIR"/$CGROUP/cgroup.procs) + if [ -z "$pids" ]; then + is_alloc=-1 + else + is_alloc=0 + fi + assert_false [ "$is_alloc" -eq 0 ] + + # @测试步骤:5: 分配50MB页缓存 + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_pagecache 50M & + sleep 2 + + # @测试步骤:6: 获取memory.current + total_memory_current=0 + for _ in $(seq 1 8); do + memory_current=$(cat "$CGROUP_TOPDIR"/$CGROUP/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + total_memory_current=$(echo "$total_memory_current + $memory_current" | bc) + sleep 1 + done + aver_memory_current=$(echo "$total_memory_current / 8" | bc) + msg "aver memory current: $aver_memory_current" + sleep 1 + + # @预期结果:3: 在误差允许范围内,memory.current的值等于30MB + TOLERANCE=$(echo "($aver_memory_current + 30) * 0.05" | bc) + msg "tolerance: $TOLERANCE" + diff=$((aver_memory_current - 30)) + abs_diff=${diff#-} + assert_true [ "$(echo "$abs_diff < $TOLERANCE" | bc)" -eq 1 ] + + # @测试步骤:7: 获取CGROUP内存达到memory.max的次数 + max_cnt=$(grep "max" "$CGROUP_TOPDIR"/$CGROUP/memory.events.local | awk '{print $2}') + msg "max cnt: $max_cnt" + + # @预期结果:1: max_cnt大于0 + assert_true [ "$max_cnt" -gt "0" ] + + # @测试步骤:8: 读取memory.peak + if [ ! -f "$CGROUP_TOPDIR"/$CGROUP/memory.peak ]; then + return 0 + else + memory_peak=$(cat "$CGROUP_TOPDIR"/$CGROUP/memory.peak) + memory_peak=$(echo "$memory_peak / 1024 / 1024" | bc) + # @预期结果:2: memory.peak的值等于memory.max + assert_true [ "$memory_peak" -eq 30 ] + fi + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-min-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-min-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..068e5cff70b223254ed2727db82ad75f65146c6c --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-min-001.sh" @@ -0,0 +1,169 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240806-100136-390417533 +# @用例名称: cgroup-v2-memory-min-001 +# @用例级别: 1 +# @用例标签: cgroup-v2 memory min +# @用例类型: 测试memoruy.min接口文件,parent1/2的父cgroup设置的内存上限是200MB, parent2分配的内存为143MB, 不会占用parent1的memory.min保护的内存50MB +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +# CGROUP +# / \ +# PARENT1 PARENT2 +# / | \ +# CHILD0 CHILD1 CHILD2 +CGROUP="cgroup-v2-memory-min-001" +PARENT1="$CGROUP/parent1" +PARENT2="$CGROUP/parent2" +CHILD0="$PARENT1/child0" +CHILD1="$PARENT1/child1" +CHILD2="$PARENT1/child2" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + mkdir "$CGROUP_TOPDIR"/$PARENT1 + mkdir "$CGROUP_TOPDIR"/$PARENT2 + mkdir "$CGROUP_TOPDIR"/$CHILD0 + mkdir "$CGROUP_TOPDIR"/$CHILD1 + mkdir "$CGROUP_TOPDIR"/$CHILD2 + # @预置条件: 检查当前cgroup是否能启用memory控制器 + if ! check_string_in_file "memory" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用memory控制器" + fi + # @预置条件: 启用memory控制器 + echo "+memory" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + echo "+memory" >"$CGROUP_TOPDIR"/$CGROUP/cgroup.subtree_control || return 1 + echo "+memory" >"$CGROUP_TOPDIR"/$PARENT1/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 关闭系统上的所有交换空间 + echo 0 >"$CGROUP_TOPDIR"/$CGROUP/memory.swap.max + + # @测试步骤:2: 设置memory.max和memory.min + echo 200M >"$CGROUP_TOPDIR"/$CGROUP/memory.max + echo 50M >"$CGROUP_TOPDIR"/$PARENT1/memory.min + echo 75M >"$CGROUP_TOPDIR"/$CHILD0/memory.min + echo 25M >"$CGROUP_TOPDIR"/$CHILD1/memory.min + echo 0M >"$CGROUP_TOPDIR"/$CHILD2/memory.min + + # @测试步骤:3: 给PARENT1的三个子cgroup分配50MB内存 + echo $$ >"$CGROUP_TOPDIR"/$CHILD0/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_pagecache 50M & + echo $$ >"$CGROUP_TOPDIR"/$CHILD1/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_pagecache 50M & + echo $$ >"$CGROUP_TOPDIR"/$CHILD2/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_pagecache 50M & + sleep 1 # 确保子进程已经分配内存 + + # @测试步骤:4: 给PARENT2分配143MB内存 + echo $$ >"$CGROUP_TOPDIR"/$PARENT2/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 143M & + sleep 1 + + # @测试步骤:5: 检查内存使用情况 + parent1_memory=0 + chidl0_memory=0 + chidl1_memory=0 + chidl2_memory=0 + parent2_memory=0 + for _ in $(seq 1 8); do + memory_current=$(cat "$CGROUP_TOPDIR"/$PARENT1/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + parent1_memory=$(echo "$memory_current + $parent1_memory" | bc) + + memory_current=$(cat "$CGROUP_TOPDIR"/$CHILD0/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + chidl0_memory=$(echo "$memory_current + $chidl0_memory" | bc) + + memory_current=$(cat "$CGROUP_TOPDIR"/$CHILD1/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + chidl1_memory=$(echo "$memory_current + $chidl1_memory" | bc) + + memory_current=$(cat "$CGROUP_TOPDIR"/$CHILD2/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + chidl2_memory=$(echo "$memory_current + $chidl2_memory" | bc) + + memory_current=$(cat "$CGROUP_TOPDIR"/$PARENT2/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + parent2_memory=$(echo "$memory_current + $parent2_memory" | bc) + sleep 1 + done + aver_parent1_memory=$(echo "$parent1_memory / 8" | bc) + aver_chidl0_memory=$(echo "$chidl0_memory / 8" | bc) + aver_chidl1_memory=$(echo "$chidl1_memory / 8" | bc) + aver_chidl2_memory=$(echo "$chidl2_memory / 8" | bc) + aver_parent2_memory=$(echo "$parent2_memory / 8" | bc) + msg "parent1 memory average: $aver_parent1_memory" + msg "child0 memory average: $aver_chidl0_memory" + msg "child1 memory average: $aver_chidl1_memory" + msg "child2 memory average: $aver_chidl2_memory" + msg "parent2 memory average: $aver_parent2_memory" + sleep 3 + + # @预期结果:1: 在误差允许范围内,PARENT1的三个子cgroup分配的内存总和等于50MB + TOLERANCE=$(echo "($aver_parent1_memory + 50) * 0.05" | bc) + diff=$((aver_parent1_memory - 50)) + abs_diff=${diff#-} + assert_true [ "$(echo "$abs_diff < $TOLERANCE" | bc)" -eq 1 ] + + # @预期结果:2: 在误差允许范围内,CHILD0分配的内存等于25MB, CHILD1分配的内存等于25MB, CHILD2分配的内存等于0MB + TOLERANCE=$(echo "($aver_chidl0_memory + 29) * 0.2" | bc) + diff=$((aver_chidl0_memory - 29)) + abs_diff=${diff#-} + assert_true [ "$(echo "$abs_diff <= $TOLERANCE" | bc)" -eq 1 ] + TOLERANCE=$(echo "($aver_chidl1_memory + 21) * 0.2" | bc) + diff=$((aver_chidl1_memory - 21)) + abs_diff=${diff#-} + assert_true [ "$(echo "$abs_diff <= $TOLERANCE" | bc)" -eq 1 ] + assert_true [ "$aver_chidl2_memory" -le 5 ] + + # @预期结果:3: 在误差允许范围内,PARENT2分配的内存等于143MB + TOLERANCE=$(echo "($aver_parent2_memory + 143) * 0.05" | bc) + diff=$((aver_parent2_memory - 143)) + abs_diff=${diff#-} + assert_true [ "$(echo "$abs_diff <= $TOLERANCE" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CHILD1 + rmdir "$CGROUP_TOPDIR"/$CHILD2 + rmdir "$CGROUP_TOPDIR"/$PARENT1 + rmdir "$CGROUP_TOPDIR"/$PARENT2 + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-min-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-min-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..2b40699c42ad94ca85c54bee1c45322f2490f539 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-min-002.sh" @@ -0,0 +1,137 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240813-014222-140891925 +# @用例名称: cgroup-v2-memory-min-002 +# @用例级别: 1 +# @用例标签: cgroup-v2 memory min +# @用例类型: 测试memoruy.min接口文件,parent1/2的父cgroup设置的内存上限是200MB, parent2分配的内存为170MB, 会占用parent1的memory.min保护的内存50MB,因此会被kill +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +# CGROUP +# / \ +# PARENT1 PARENT2 +# / | \ +# CHILD0 CHILD1 CHILD2 +CGROUP="cgroup-v2-memory-min-002" +PARENT1="$CGROUP/parent1" +PARENT2="$CGROUP/parent2" +CHILD0="$PARENT1/child0" +CHILD1="$PARENT1/child1" +CHILD2="$PARENT1/child2" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + mkdir "$CGROUP_TOPDIR"/$PARENT1 + mkdir "$CGROUP_TOPDIR"/$PARENT2 + mkdir "$CGROUP_TOPDIR"/$CHILD0 + mkdir "$CGROUP_TOPDIR"/$CHILD1 + mkdir "$CGROUP_TOPDIR"/$CHILD2 + # @预置条件: 检查当前cgroup是否能启用memory控制器 + if ! check_string_in_file "memory" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用memory控制器" + fi + # @预置条件: 启用memory控制器 + echo "+memory" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + echo "+memory" >"$CGROUP_TOPDIR"/$CGROUP/cgroup.subtree_control || return 1 + echo "+memory" >"$CGROUP_TOPDIR"/$PARENT1/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + # @测试步骤:1: 关闭系统上的所有交换空间 + echo 0 >"$CGROUP_TOPDIR"/$CGROUP/memory.swap.max + + # @测试步骤:2: 设置memory.max和memory.min + echo 200M >"$CGROUP_TOPDIR"/$CGROUP/memory.max + echo 50M >"$CGROUP_TOPDIR"/$PARENT1/memory.min + echo 75M >"$CGROUP_TOPDIR"/$CHILD0/memory.min + echo 25M >"$CGROUP_TOPDIR"/$CHILD1/memory.min + echo 0M >"$CGROUP_TOPDIR"/$CHILD2/memory.min + + # @测试步骤:3: 给PARENT1的三个子cgroup分配50MB内存 + echo $$ >"$CGROUP_TOPDIR"/$CHILD0/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_pagecache 50M & + echo $$ >"$CGROUP_TOPDIR"/$CHILD1/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_pagecache 50M & + echo $$ >"$CGROUP_TOPDIR"/$CHILD2/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_pagecache 50M & + sleep 1 # 确保子进程已经分配内存 + + # @测试步骤:4: 给PARENT2分配170MB内存 + echo $$ >"$CGROUP_TOPDIR"/$PARENT2/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 170M & + sleep 1 + + # @测试步骤:5: 检查内存使用情况 + parent1_memory=0 + parent2_memory=0 + for _ in $(seq 1 8); do + memory_current=$(cat "$CGROUP_TOPDIR"/$PARENT1/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + parent1_memory=$(echo "$memory_current + $parent1_memory" | bc) + + memory_current=$(cat "$CGROUP_TOPDIR"/$PARENT2/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + parent2_memory=$(echo "$memory_current + $parent2_memory" | bc) + sleep 1 + done + aver_parent1_memory=$(echo "$parent1_memory / 8" | bc) + aver_parent2_memory=$(echo "$parent2_memory / 8" | bc) + msg "parent1 memory average: $aver_parent1_memory" + msg "parent2 memory average: $aver_parent2_memory" + sleep 3 + + # @预期结果:1: 在误差允许范围内,PARENT1的三个子cgroup分配的内存总和等于50MB + TOLERANCE=$(echo "($aver_parent1_memory + 50) * 0.05" | bc) + diff=$((aver_parent1_memory - 50)) + abs_diff=${diff#-} + assert_true [ "$(echo "$abs_diff <= $TOLERANCE" | bc)" -eq 1 ] + + # @预期结果:2: 在误差允许范围内,PARENT2分配的内存等于0MB + assert_true [ "$aver_parent2_memory" -le 5 ] + + # @预期结果:3: 检查PARENT2的oom事件次数大于0 + oom_kill_cnt=$(grep "oom_kill" "$CGROUP_TOPDIR"/$PARENT2/memory.events | awk 'NR==1 {print $2}') + assert_true [ "$oom_kill_cnt" -gt 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CHILD1 + rmdir "$CGROUP_TOPDIR"/$CHILD2 + rmdir "$CGROUP_TOPDIR"/$PARENT1 + rmdir "$CGROUP_TOPDIR"/$PARENT2 + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-oom-events.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-oom-events.sh" new file mode 100755 index 0000000000000000000000000000000000000000..cc6bd47dd5c7b7ab160233569e6962b086da3d74 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-oom-events.sh" @@ -0,0 +1,91 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240807-132326-618850104 +# @用例名称: cgroup-v2-memory-oom-events +# @用例级别: 2 +# @用例标签: cgroup-v2 memory oom-events +# @用例类型: 测试memory.events中的oom和oom_kill事件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-memory-oom-events" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用memory控制器 + if ! check_string_in_file "memory" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用memory控制器" + fi + # @预置条件: 启用memory控制器 + echo "+memory" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置memory.max为30M + echo 30M >"$CGROUP_TOPDIR"/$CGROUP/memory.max + + # @测试步骤:2: 关闭CGROUP中的swapping + echo 0 >"$CGROUP_TOPDIR"/$CGROUP/memory.swap.max + + # @测试步骤:3: 分配100MB匿名内存 + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 200M & + echo $! >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + sleep 2 + + # @预期结果:1: 分配失败 + pids=$(cat "$CGROUP_TOPDIR"/$CGROUP/cgroup.procs) + if [ -z "$pids" ]; then + is_alloc=-1 + else + is_alloc=0 + fi + assert_false [ "$is_alloc" -eq 0 ] + + # @测试步骤:4: 读取memory.events中的oom字段 + oom_cnt=$(cat "$CGROUP_TOPDIR"/$CGROUP/memory.events | grep oom | awk 'NR==1 {print $2}') + msg "oom_cnt: $oom_cnt" + + # @预期结果:2: oom_cnt的值为1 + assert_true [ "$oom_cnt" -eq 1 ] + + # @测试步骤:5: 读取memory.events中的oom_kill字段 + oom_kill_cnt=$(cat "$CGROUP_TOPDIR"/$CGROUP/memory.events | grep oom_kill | awk '{print $2}') + msg "oom_kill_cnt: $oom_kill_cnt" + + # @预期结果:3: oom_kill_cnt的值为1 + assert_true [ "$oom_kill_cnt" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-oom-group-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-oom-group-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..1d2a1acbfa24e11e557e45ec19ab529b6d2d2b1b --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-oom-group-001.sh" @@ -0,0 +1,114 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240806-203339-406928857 +# @用例名称: cgroup-v2-memory-oom-group-001 +# @用例级别: 2 +# @用例标签: cgroup-v2 memory oom group +# @用例类型: 测试memory.oom.group接口文件,分配匿名内存达到oom限制,检查子cgroup进程是否被kill +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-memory-oom-group-001" +CHILD="$CGROUP/child" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + mkdir "$CGROUP_TOPDIR"/$CHILD + # @预置条件: 检查当前cgroup是否能启用memory控制器 + if ! check_string_in_file "memory" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用memory控制器" + fi + # @预置条件: 启用memory控制器 + echo "+memory" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + echo "+memory" >"$CGROUP_TOPDIR"/$CGROUP/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置CHILD的内存限制为50M + echo 50M >"$CGROUP_TOPDIR"/$CHILD/memory.max + + # @测试步骤:2: 关闭CHILD的swapping + echo 0 >"$CGROUP_TOPDIR"/$CHILD/memory.swap.max + + # @测试步骤:3: 启用CHILDE的oom.group + echo 1 >"$CGROUP_TOPDIR"/$CHILD/memory.oom.group + + # @测试步骤:4: 在CHILD中分配两个1MB匿名内存 + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 1M & + echo $! >"$CGROUP_TOPDIR"/$CHILD/cgroup.procs + sleep 1 + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 1M & + echo $! >"$CGROUP_TOPDIR"/$CHILD/cgroup.procs + sleep 1 + + # @测试步骤:5: 在CHILD分配超出memory.max的匿名内存 + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 200M & + echo $! >"$CGROUP_TOPDIR"/$CHILD/cgroup.procs + sleep 1 + + # @预期结果:1: CHILD中的进程都被kill + pids=$(cat "$CGROUP_TOPDIR"/$CGROUP/cgroup.procs) + if [ -z "$pids" ]; then + is_killed=0 + else + is_killed=-1 + fi + assert_true [ "$is_killed" -eq 0 ] + + # @测试步骤:6: 获取CHILD的memory.events中的oom_kill + oom_kill_cnt=$(grep "oom_kill" "$CGROUP_TOPDIR"/$CHILD/memory.events | awk '{print $2}') + + # @预期结果:2: CHILD的oom_kill_cnt大于0 + assert_true [ "$oom_kill_cnt" -gt "0" ] + + # @测试步骤:7: 获取PARENT的memory.events中的oom_kill + oom_kill_cnt=$(grep "oom_kill" "$CGROUP_TOPDIR"/$CGROUP/memory.events | awk '{print $2}') + + # @预期结果:3: PARENT的oom_kill_cnt大于0 + assert_true [ "$oom_kill_cnt" -gt "0" ] + + # @测试步骤:8: 获取CGROUP的oom_group_kill + oom_group_kill_cnt=$(grep "oom_group_kill" "$CGROUP_TOPDIR"/$CGROUP/memory.events | awk '{print $2}') + if [ -z "$oom_group_kill_cnt" ]; then + return 0 + else + # @预期结果:4: oom_group_kill_cnt为1 + assert_true [ "$oom_group_kill_cnt" -eq 1 ] + fi + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-oom-group-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-oom-group-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..76323e393ad47ddb2221c7c474e4029ae139a38c --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-oom-group-002.sh" @@ -0,0 +1,113 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240806-212056-208652807 +# @用例名称: cgroup-v2-memory-oom-group-002 +# @用例级别: 2 +# @用例标签: cgroup-v2 memory oom group +# @用例类型: 测试memory.oom.group接口文件,分配匿名内存达到oom限制,检查父cgroup和子cgroup进程是否被kill +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-memory-oom-group-002" +CHILD="$CGROUP/child" + +tc_setup() { + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + mkdir "$CGROUP_TOPDIR"/$CHILD + # @预置条件: 检查当前cgroup是否能启用memory控制器 + if ! check_string_in_file "memory" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用memory控制器" + fi + # @预置条件: 启用memory控制器 + echo "+memory" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置PARENT的内存限制为80M + echo 80M >"$CGROUP_TOPDIR"/$CGROUP/memory.max + + # @测试步骤:2: 关闭PARENT的swapping + echo 0 >"$CGROUP_TOPDIR"/$CGROUP/memory.swap.max + + # @测试步骤:3: 启用PARENT的oom.group + echo 1 >"$CGROUP_TOPDIR"/$CGROUP/memory.oom.group + + # @测试步骤:4: 在PARENT中分配60MB匿名内存 + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 60M & + echo $! >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + sleep 1 + + # @测试步骤:5: 在CHILD中分配两个1MB匿名内存 + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 1M & + echo $! >"$CGROUP_TOPDIR"/$CHILD/cgroup.procs + sleep 1 + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 1M & + echo $! >"$CGROUP_TOPDIR"/$CHILD/cgroup.procs + sleep 1 + + # @测试步骤:6: 在CHILD分配超出memory.max的匿名内存 + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 500M & + echo $! >"$CGROUP_TOPDIR"/$CHILD/cgroup.procs + sleep 1 + + # @预期结果:1: CHILD中的进程都被kill + pids=$(cat "$CGROUP_TOPDIR"/$CHILD/cgroup.procs) + if [ -z "$pids" ]; then + is_killed=0 + else + is_killed=-1 + fi + assert_true [ "$is_killed" -eq 0 ] + + # @预期结果:2: PARENT中的进程都被kill + pids=$(cat "$CGROUP_TOPDIR"/$CGROUP/cgroup.procs) + if [ -z "$pids" ]; then + is_killed=0 + else + is_killed=-1 + fi + assert_true [ "$is_killed" -eq 0 ] + + # @测试步骤:7: 获取CGROUP的oom_group_kill + oom_group_kill_cnt=$(grep "oom_group_kill" "$CGROUP_TOPDIR"/$CGROUP/memory.events | awk '{print $2}') + if [ -z "$oom_group_kill_cnt" ]; then + return 0 + else + # @预期结果:4: oom_group_kill_cnt为1 + assert_true [ "$oom_group_kill_cnt" -eq 1 ] + fi + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-oom-group-003.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-oom-group-003.sh" new file mode 100755 index 0000000000000000000000000000000000000000..67740a0a912491c76282a8df9c31f53e30624ce3 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-oom-group-003.sh" @@ -0,0 +1,109 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240806-212858-982022706 +# @用例名称: cgroup-v2-memory-oom-group-003 +# @用例级别: 2 +# @用例标签: cgroup-v2 memory oom group +# @用例类型: 测试memory.oom.group接口文件,分配匿名内存达到oom限制,检查除了设置OOM_SCORE_ADJ_MIN的进程外,其他进程是否被kill +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-memory-oom-group-003" +OOM_SCORE_ADJ_MIN=-1000 + +tc_setup() { + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用memory控制器 + if ! check_string_in_file "memory" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用memory控制器" + fi + # @预置条件: 启用memory控制器 + echo "+memory" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置CGROUP的内存限制为50MB + echo 50M >"$CGROUP_TOPDIR"/$CGROUP/memory.max + + # @测试步骤:2: 关闭CGROUP的swapping + echo 0 >"$CGROUP_TOPDIR"/$CGROUP/memory.swap.max + + # @测试步骤:3: 启用CGROUP的oom.group + echo 1 >"$CGROUP_TOPDIR"/$CGROUP/memory.oom.group + + # @测试步骤:4: 在CGROUP中分配1MB匿名内存 + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 1M & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + sleep 1 + + # @测试步骤:5: 设置进程task_pid的oom_score_adj为OOM_SCORE_ADJ_MIN + echo $OOM_SCORE_ADJ_MIN >"/proc/$task_pid/oom_score_adj" + + # @测试步骤:6: 在CGROUP中分配1MB匿名内存 + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 1M & + echo $! >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + sleep 1 + + # @测试步骤:7: 在CGROUP中分配超出memory.max的匿名内存 + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 200M & + echo $! >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + sleep 1 + + # @测试步骤:8: 获取CGROUP的oom_kill + oom_kill_cnt=$(grep "oom_kill" "$CGROUP_TOPDIR"/$CGROUP/memory.events | awk '{print $2}') + msg "oom kill cnt: $oom_kill_cnt" + + # @预期结果:1: oom_kill_cnt为3 + assert_true [ "$oom_kill_cnt" -eq 3 ] + + # @测试步骤:9: 获取CGROUP的oom_group_kill + oom_group_kill_cnt=$(grep "oom_group_kill" "$CGROUP_TOPDIR"/$CGROUP/memory.events | awk '{print $2}') + if [ -z "$oom_group_kill_cnt" ]; then + echo "Warning: oom_group_kill count not found in $CGROUP_TOPDIR/$CGROUP/memory.events" + else + # @预期结果:4: oom_group_kill_cnt为1 + assert_true [ "$oom_group_kill_cnt" -eq 1 ] + fi + + # @测试步骤:10: 尝试kill有OOM_SCORE_ADJ_MIN的进程, 进程task_pid被kill + ret=0 + kill -9 $task_pid || ret=-1 + + # @预期结果:3: 进程task_pid被kill + assert_true [ "$ret" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + sleep 1 + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-pressure.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-pressure.sh" new file mode 100755 index 0000000000000000000000000000000000000000..bf571ae67969380aea68d1860a1ef1643a64b32f --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-pressure.sh" @@ -0,0 +1,98 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240807-205257-782673483 +# @用例名称: cgroup-v2-memory-pressure +# @用例级别: 2 +# @用例标签: cgroup-v2 memory pressure +# @用例类型: 测试memory.pressure接口文件,设置内存压力通知 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-memory-pressure" +TMP_FILE=$(mktemp) + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用memory控制器 + if ! check_string_in_file "memory" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用memory控制器" + fi + # @预置条件: 启用memory控制器 + echo "+memory" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 启用cgroup.pressure + echo 1 >"$CGROUP_TOPDIR"/$CGROUP/cgroup.pressure || return 1 + + # @测试步骤:2: 设置memory.high为50MB + echo 50M >"$CGROUP_TOPDIR"/$CGROUP/memory.high + + # @测试步骤:3: 关闭CGROUP上的memory.swap.max + echo 0 >"$CGROUP_TOPDIR"/$CGROUP/memory.swap.max + + # @测试步骤:4: 注册触发器 + stdbuf -oL "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/pressure_listener "$CGROUP_TOPDIR"/$CGROUP/memory.pressure &>"$TMP_FILE" & + + # @测试步骤:5: 运行两个30MB的匿名分配进程 + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 30M & + sleep 2 + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 30M & + sleep 2 + + # @测试步骤:6: 读取memor.pressure文件 + memory_pressure=$(cat "$CGROUP_TOPDIR"/$CGROUP/memory.pressure) + avg10=$(echo "$memory_pressure" | awk 'NR==1 {for(i=1;i<=NF;i++) if ($i ~ /^avg10=/) {split($i, a, "="); print a[2]}}') + msg "avg10: $avg10" + sleep 8 + + # @预期结果:1: avg10值应该大于0 + assert_true [ "$(echo "$avg10 > 0" | bc)" -eq 1 ] + + # @预期结果:2: 触发器应该被触发 + is_trigered=-1 + if grep -q "event triggered" "$TMP_FILE"; then + is_trigered=0 + fi + assert_true [ "$is_trigered" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-reclaim-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-reclaim-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..32f343651a195380c2f37aface807310c1a0a316 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-reclaim-001.sh" @@ -0,0 +1,101 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240806-193843-997660285 +# @用例名称: cgroup-v2-memory-reclaim-001 +# @用例级别: 2 +# @用例标签: cgroup-v2 memory reclaim +# @用例类型: 测试memory.reclaim接口文件,回收page cache +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-memory-reclaim-001" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用memory控制器 + if ! check_string_in_file "memory" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用memory控制器" + fi + # @预置条件: 启用memory控制器 + echo "+memory" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 关闭CGROUP的swapping + echo 0 >"$CGROUP_TOPDIR"/$CGROUP/memory.swap.max + + # @测试步骤:2: 运行一个分配50M页缓存内存的进程 + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_pagecache 50M & + task_pid=$! + sleep 1 + + # @测试步骤:3: 计算回收前的内存 + before_reclaim=0 + for _ in $(seq 1 5); do + memory_current=$(cat "$CGROUP_TOPDIR"/$CGROUP/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + before_reclaim=$(echo " $before_reclaim + $memory_current" | bc) + sleep 1 + done + aver_before_reclaim=$(echo "$before_reclaim / 5" | bc) + + # @测试步骤:4: 主动回收内存 + echo "40M" >"$CGROUP_TOPDIR"/$CGROUP/memory.reclaim || return 1 + + # @测试步骤:5: 计算回收后的内存 + after_reclaim=0 + for _ in $(seq 1 4); do + memory_current=$(cat "$CGROUP_TOPDIR"/$CGROUP/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + after_reclaim=$(echo " $after_reclaim + $memory_current" | bc) + sleep 1 + done + aver_after_reclaim=$(echo "$after_reclaim / 4" | bc) + sleep 3 + + # @预期结果:1: 在误差范围内回收了内存40MB + diff=$(echo "$aver_before_reclaim - $aver_after_reclaim" | bc) + msg "diff: $diff" + diff_max=45 + diff_min=35 + assert_true [ "$diff" -gt $diff_min ] + assert_true [ "$diff" -lt $diff_max ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + kill -9 "$task_pid" + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-reclaim-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-reclaim-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..d2d39761e3289ac5e44b1bd59ff70d3e3b335e54 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-reclaim-002.sh" @@ -0,0 +1,99 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240806-202710-043353562 +# @用例名称: cgroup-v2-memory-reclaim-002 +# @用例级别: 2 +# @用例标签: cgroup-v2 memory reclaim +# @用例类型: 测试memory.reclaim接口文件,回收匿名内存 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-memory-reclaim-002" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用memory控制器 + if ! check_string_in_file "memory" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用memory控制器" + fi + # @预置条件: 启用memory控制器 + echo "+memory" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 运行一个分配50M匿名内存的进程 + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 50M & + task_pid=$! + sleep 1 + + # @测试步骤:2: 计算回收前的内存 + before_reclaim=0 + for _ in $(seq 1 5); do + memory_current=$(cat "$CGROUP_TOPDIR"/$CGROUP/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + before_reclaim=$(echo " $before_reclaim + $memory_current" | bc) + sleep 1 + done + aver_before_reclaim=$(echo "$before_reclaim / 5" | bc) + + # @测试步骤:3: 主动回收内存 + echo "40M" >"$CGROUP_TOPDIR"/$CGROUP/memory.reclaim || return 1 + + # @测试步骤:4: 计算回收后的内存 + after_reclaim=0 + for _ in $(seq 1 4); do + memory_current=$(cat "$CGROUP_TOPDIR"/$CGROUP/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + after_reclaim=$(echo " $after_reclaim + $memory_current" | bc) + sleep 1 + done + aver_after_reclaim=$(echo "$after_reclaim / 4" | bc) + sleep 3 + + # @预期结果:1: 在误差范围内回收了内存40MB + diff=$(echo "$aver_before_reclaim - $aver_after_reclaim" | bc) + msg "diff: $diff" + diff_max=45 + diff_min=35 + assert_true [ "$diff" -gt $diff_min ] + assert_true [ "$diff" -lt $diff_max ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell进程移出cgroup + kill -9 "$task_pid" + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-swap-high.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-swap-high.sh" new file mode 100755 index 0000000000000000000000000000000000000000..c4858d22f6275f31fc145f39ef736a80c1a25be7 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-swap-high.sh" @@ -0,0 +1,128 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240807-191722-246340813 +# @用例名称: cgroup-v2-memory-swap-high +# @用例级别: 1 +# @用例标签: cgroup-v2 memory swap high +# @用例类型: 测试memory.swap.high接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-memory-swap-high" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用memory控制器 + if ! check_string_in_file "memory" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用memory控制器" + fi + # @预置条件: 启用memory控制器 + echo "+memory" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + # @预置条件: 查看系统是否启用了swapping + if [ -z "$(swapon --show)" ]; then + skip_test "系统未启用swap或没有swapfile" + fi + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 读取memory.swap.high的值 + memory_swap_high=$(cat "$CGROUP_TOPDIR"/$CGROUP/memory.swap.high) + + # @预期结果:1: memory.swap.high的值为max + assert_true [ "$memory_swap_high" = "max" ] + + # @测试步骤:2: 设置memory.swap.high为30M + echo 30M >"$CGROUP_TOPDIR"/$CGROUP/memory.swap.high + + # @测试步骤:3: 设置memory.high为30M + echo 30M >"$CGROUP_TOPDIR"/$CGROUP/memory.high + + # @测试步骤:4: 分配31M匿名内存的进程 + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 200M & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + sleep 2 + + # @预期结果:2: 分配成功 + pids=$(cat "$CGROUP_TOPDIR"/$CGROUP/cgroup.procs) + if [ -z "$pids" ]; then + is_alloc=-1 + else + is_alloc=0 + fi + assert_true [ "$is_alloc" -eq 0 ] + kill -9 $task_pid + + # @测试步骤:5: 分配50M匿名内存的进程 + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 50M & + sleep 2 + + # @测试步骤:6: 获取CGROUP的memory.current和memory.swap.current + total_memory_current=0 + total_memory_swap_current=0 + for _ in $(seq 1 8); do + memory_current=$(cat "$CGROUP_TOPDIR"/$CGROUP/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + total_memory_current=$(echo "$total_memory_current + $memory_current" | bc) + memory_swap_current=$(cat "$CGROUP_TOPDIR"/$CGROUP/memory.swap.current) + memory_swap_current=$(echo "$memory_swap_current / 1024 / 1024" | bc) + total_memory_swap_current=$(echo "$total_memory_swap_current + $memory_swap_current" | bc) + sleep 1 + done + aver_memory_current=$(echo "$total_memory_current / 8" | bc) + aver_memory_swap_current=$(echo "$total_memory_swap_current / 8" | bc) + msg "average memory current: $aver_memory_current" + msg "average memory current: $aver_memory_swap_current" + sleep 1 + + # @预期结果:3: 在误差允许范围内,memory.current等于30MB, memory.current+memory.swap.current等于50MB + TOLERANCE=$(echo "($aver_memory_current + 30) * 0.1" | bc) + diff=$((aver_memory_current - 30)) + abs_diff=${diff#-} + assert_true [ "$aver_memory_current" -ne 0 ] + assert_true [ "$(echo "$abs_diff < $TOLERANCE" | bc)" -eq 1 ] + + TOLERANCE=$(echo "($aver_memory_current + $aver_memory_swap_current + 50) * 0.03" | bc) + diff=$((aver_memory_current + aver_memory_swap_current - 50)) + abs_diff=${diff#-} + assert_true [ "$aver_memory_current" -ne 0 ] + assert_true [ "$(echo "$abs_diff < $TOLERANCE" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-swap-max.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-swap-max.sh" new file mode 100755 index 0000000000000000000000000000000000000000..af2b7454f4438ae0b8570e06c3a190e51ba94223 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-swap-max.sh" @@ -0,0 +1,135 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240806-224039-790267806 +# @用例名称: cgroup-v2-memory-swap-max +# @用例级别: 2 +# @用例标签: cgroup-v2 memory swap max +# @用例类型: 测试memory.swap.max接口文件 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-memory-swap-max" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用memory控制器 + if ! check_string_in_file "memory" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用memory控制器" + fi + # @预置条件: 启用memory控制器 + echo "+memory" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + # @预置条件: 查看系统是否启用了swapping + if [ -z "$(swapon --show)" ]; then + skip_test "系统未启用swap或没有swapfile" + fi + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置memory.swap.max为30M + echo 30M >"$CGROUP_TOPDIR"/$CGROUP/memory.swap.max + + # @测试步骤:2: 设置memory.max为30M + echo 30M >"$CGROUP_TOPDIR"/$CGROUP/memory.max + + # @测试步骤:3: 分配31M匿名内存的进程 + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 200M & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + sleep 5 + + # @预期结果:1: 分配失败 + pids=$(cat "$CGROUP_TOPDIR"/$CGROUP/cgroup.procs) + if [ -z "$pids" ]; then + is_alloc=-1 + else + is_alloc=0 + fi + assert_false [ "$is_alloc" -eq 0 ] + + # @测试步骤:4: 获取CGROUP的momory.events中的oom + oom_cnt=$(grep "oom" "$CGROUP_TOPDIR"/$CGROUP/memory.events | awk 'NR==1 {print $2}') + msg "oom: $oom_cnt" + + # @预期结果:2: oom大于0 + assert_true [ "$oom_cnt" -gt 0 ] + + # @测试步骤:5: 获取CGROUP的memory.events中的oom_kill + oom_kill_cnt=$(grep "oom_kill" "$CGROUP_TOPDIR"/$CGROUP/memory.events | awk '{print $2}') + msg "oom_kill: $oom_kill_cnt" + + # @预期结果:3: oom_kill大于0 + assert_true [ "$oom_kill_cnt" -gt 0 ] + + # @测试步骤:6: 分配50MB匿名内存的进程 + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 50M & + sleep 2 + + # @测试步骤:7: 获取CGROUP的memory.current和memory.swap.current + totol_memory_current=0 + totol_swap_current=0 + for _ in $(seq 1 8); do + memory_current=$(cat "$CGROUP_TOPDIR"/$CGROUP/memory.current) + memory_current=$(echo "$memory_current / 1024 / 1024" | bc) + totol_memory_current=$(echo "$memory_current + $totol_memory_current" | bc) + swap_current=$(cat "$CGROUP_TOPDIR"/$CGROUP/memory.swap.current) + swap_current=$(echo "$swap_current / 1024 / 1024" | bc) + totol_swap_current=$(echo "$swap_current + $totol_swap_current" | bc) + sleep 1 + done + aver_memory_current=$(echo "$totol_memory_current / 8" | bc) + aver_swap_current=$(echo "$totol_swap_current / 8" | bc) + msg "memory.current: $aver_memory_current" + msg "memory.swap.current: $aver_swap_current" + sleep 3 + + # @预期结果:4: 在误差允许范围内,memory.current等于30MB, memory.current+memory.swap.current等于50MB + TOLERANCE=$(echo "($aver_memory_current + 30) * 0.1" | bc) + diff=$((aver_memory_current - 30)) + abs_diff=${diff#-} + assert_true [ "$aver_memory_current" -ne 0 ] + assert_true [ "$(echo "$abs_diff < $TOLERANCE" | bc)" -eq 1 ] + + TOLERANCE=$(echo "($aver_memory_current + $aver_swap_current + 50) * 0.03" | bc) + diff=$((aver_memory_current + aver_swap_current - 50)) + abs_diff=${diff#-} + assert_true [ "$aver_memory_current" -ne 0 ] + assert_true [ "$(echo "$abs_diff < $TOLERANCE" | bc)" -eq 1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将shell移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-zswap.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-zswap.sh" new file mode 100755 index 0000000000000000000000000000000000000000..6348b29a2c7af58d423ac3e6e8a280a3f2d9f4f1 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-memory-zswap.sh" @@ -0,0 +1,107 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240807-200055-083750426 +# @用例名称: cgroup-v2-memory-zswap +# @用例级别: 2 +# @用例标签: cgroup-v2 memory zswap +# @用例类型: 测试memory.zswap.max和memory.zswap.current接口文件, 达到限制不会触发写回操作 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-memory-zswap" + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用memory控制器 + if ! check_string_in_file "memory" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用memory控制器" + fi + # @预置条件: 启用memory控制器 + echo "+memory" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + # @预置条件: 查看系统是否启用了zswap + enabled=$(cat /sys/module/zswap/parameters/enabled) + if [ "$enabled" = 'N' ]; then + skip_test "系统未启用zswap" + fi + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置memory.max为1M + echo 1M >"$CGROUP_TOPDIR"/$CGROUP/memory.max + + # @测试步骤:2: 设置memory.zswap.max为10K + echo 10K >"$CGROUP_TOPDIR"/$CGROUP/memory.zswap.max || return 1 + + # @测试步骤:3: 获取当前zswap已经写回的页数 + written_back_before=$(cat /sys/kernel/debug/zswap/written_back_pages) + msg "written_back_before: $written_back_before" + + # @测试步骤:4: 分配10M匿名内存的进程 + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + "$TST_TS_TOPDIR"/tst_lib/cgroup_util/bin/alloc_anon 10M & + + # @测试步骤:5: 获取memory.zswap.current的值 + total_memory_zswap_current=0 + for _ in $(seq 1 10); do + memory_zswap_current=$(cat /sys/fs/cgroup/$CGROUP/memory.zswap.current) + memory_zswap_current=$(echo "$memory_zswap_current / 1024" | bc) + total_memory_zswap_current=$(echo "$total_memory_zswap_current + $memory_zswap_current" | bc) + sleep 1 + done + aver_memory_zswap_current=$(echo "$total_memory_zswap_current / 10" | bc) + msg "aver_memory_zswap_current: $aver_memory_zswap_current KB" + + # @预期结果:1: memory.zswap.current大于0 + assert_true [ "$(echo "$aver_memory_zswap_current > 0" | bc)" -eq 1 ] + + # @测试步骤:6: 获取当前zswap已经写回的页数 + written_back_after=$(cat /sys/kernel/debug/zswap/written_back_pages) + msg "written_back_after: $written_back_after" + + # @预期结果:2: 之前写回和现在写回的页数相等 + assert_true [ "$written_back_before" -eq "$written_back_after" ] + + # @测试步骤:7: 获取memory.stat中的zswapped字段 + zswapped=$(grep "zswapped" "$CGROUP_TOPDIR"/$CGROUP/memory.stat | awk '{print $2}') + msg "zswapped: $zswapped" + + # @预期结果:3: zswapped字段大于0 + assert_true [ "$zswapped" -gt 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将当前shell移出cgroup + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-pids-max-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-pids-max-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..85c78090c5d4dd9ae504ca524813712ce38f8ccc --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-pids-max-001.sh" @@ -0,0 +1,86 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240808-114347-394098494 +# @用例名称: cgroup-v2-pids-max-001 +# @用例级别: 1 +# @用例标签: cgroup-v2 pids max +# @用例类型: 测试pids.max接口文件, 进程数超过限制 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-pids-max-001" +TMP_FILE=$(mktemp) + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用pids控制器 + if ! check_string_in_file "pids" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用pids控制器" + fi + # @预置条件: 启用io控制器 + echo "+pids" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置pids.max为2 + echo 2 >"$CGROUP_TOPDIR"/$CGROUP/pids.max + + # @测试步骤:2: 将当前shell加入cgroup + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + + # @测试步骤:3: 运行两个子进程 + (echo "Here's some processes for you." | cat) &>"$TMP_FILE" + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + + # @测试步骤:4: 获取超过最大进程数的次数 + fail_cnt=$(grep max "$CGROUP_TOPDIR"/$CGROUP/pids.events | awk '{print $2}') + msg "fail cnt: $fail_cnt" + + # @预期结果:1: fail cnt大于0 + assert_true [ "$fail_cnt" -gt 0 ] + + # @测试步骤:5: 获取最大进程数 + if [ ! -f "$CGROUP_TOPDIR"/$CGROUP/pids.peak ]; then + return 0 + else + peak_cnt=$(cat "$CGROUP_TOPDIR"/$CGROUP/pids.peak) + # @预期结果:2: 最大进程数为2 + assert_true [ "$peak_cnt" -eq 2 ] + fi + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-pids-max-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-pids-max-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..8969447d3ca11d03e733fc0c377088279468514f --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-pids-max-002.sh" @@ -0,0 +1,80 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240808-114351-356194752 +# @用例名称: cgroup-v2-pids-max-002 +# @用例级别: 2 +# @用例标签: cgroup-v2 pids max +# @用例类型: 测试pids.max控制文件, 进程数不超过限制 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-pids-max-002" +TMP_FILE=$(mktemp) + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + # @预置条件: 检查当前cgroup是否能启用pids控制器 + if ! check_string_in_file "pids" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用pids控制器" + fi + # @预置条件: 启用io控制器 + echo "+pids" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置pids.max为2 + echo 2 >"$CGROUP_TOPDIR"/$CGROUP/pids.max + + # @测试步骤:2: 将当前shell加入cgroup + echo $$ >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs + + # @测试步骤:3: 运行进程并获取pid.current + pid_num=$(cat "$CGROUP_TOPDIR"/$CGROUP/pids.current) + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + + # @测试步骤:4: 获取超过最大进程数的次数 + fail_cnt=$(grep max "$CGROUP_TOPDIR"/$CGROUP/pids.events | awk '{print $2}') + msg "fail cnt: $fail_cnt" + + # @预期结果:1: pid_num为2 + assert_true [ "$pid_num" -eq 2 ] + assert_true [ "$fail_cnt" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将当前shell从cgroup中移除 + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-pids-max-003.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-pids-max-003.sh" new file mode 100755 index 0000000000000000000000000000000000000000..e5d2f8206dcc5ffac05ace4dbc3cfc2469bc0a4d --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-pids-max-003.sh" @@ -0,0 +1,92 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240808-114352-529042314 +# @用例名称: cgroup-v2-pids-max-003 +# @用例级别: 3 +# @用例标签: cgroup-v2 pids max +# @用例类型: 测试pids的层次结构 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-pids-max-003" +CHILD0="$CGROUP/child0" +TMP_FILE=$(mktemp) + +tc_setup() { + msg "this is tc_setup" + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + mkdir "$CGROUP_TOPDIR"/$CHILD0 + # @预置条件: 检查当前cgroup是否能启用pids控制器 + if ! check_string_in_file "pids" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "当前cgroup不能启用pids控制器" + fi + # @预置条件: 启用io控制器 + echo "+pids" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + echo "+pids" >"$CGROUP_TOPDIR"/$CGROUP/cgroup.subtree_control || return 1 + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置pids.max为2 + echo 2 >"$CGROUP_TOPDIR"/$CGROUP/pids.max + + # @测试步骤:2: 获取CHILD0的pids.max + pid_max=$(cat "$CGROUP_TOPDIR"/$CHILD0/pids.max) + + # @预期结果:1: CHILD0的pids.max为max + assert_true [ "$pid_max" = "max" ] + + # @测试步骤:3: 将当前shell加入CHILD0 + echo $$ >"$CGROUP_TOPDIR"/$CHILD0/cgroup.procs + + # @测试步骤:4: 运行了两个子进程 + (echo "Here's some processes for you." | cat) &>"$TMP_FILE" + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + + # @测试步骤:5: 获取超过最大进程数的次数 + fail_cnt=$(grep max "$CGROUP_TOPDIR"/$CHILD0/pids.events | awk '{print $2}') + + # @预期结果:2: 运行失败 + if grep -q "Resource temporarily unavailable" "$TMP_FILE"; then + assert_true [ "$fail_cnt" -gt 0 ] + else + return 1 + fi + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 将当前shell从cgroup中移除 + echo $$ >"$CGROUP_TOPDIR"/cgroup.procs + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CGROUP + # @清理工作: 删除临时文件 + rm "$TMP_FILE" + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-populated.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-populated.sh" new file mode 100755 index 0000000000000000000000000000000000000000..1eb80f6e23974fbbbfda40cb1e61b7e0dc07e35c --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-populated.sh" @@ -0,0 +1,99 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240810-005006-336461552 +# @用例名称: cgroup-v2-populated +# @用例级别: 1 +# @用例标签: cgroup-v2 populated +# @用例类型: 测试cgroup.events中的populated字段 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +# CGROUP +# | +# CHILD0 +# / \ +# CHILD00 CHILD01 +CGROUP="cgroup-v2-type-001" +CHILD0="$CGROUP/child0" +CHILD00="$CHILD0/child0" +CHILD01="$CHILD0/child1" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + mkdir "$CGROUP_TOPDIR"/$CHILD0 + mkdir "$CGROUP_TOPDIR"/$CHILD00 + mkdir "$CGROUP_TOPDIR"/$CHILD01 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 运行一个进程并将其放入CHILD00 + { + while true; do :; done + } & + task_pid=$! + echo $task_pid >"$CGROUP_TOPDIR"/$CHILD00/cgroup.procs + + # @预测结果:1: CGROUP, CHILD0, CHILD00的populated字段为1,CHILD01的populated字段为0 + populated=$(grep populated "$CGROUP_TOPDIR"/$CGROUP/cgroup.events | awk '{print $2}') + assert_true [ "$populated" -eq 1 ] + populated=$(grep populated "$CGROUP_TOPDIR"/$CHILD0/cgroup.events | awk '{print $2}') + assert_true [ "$populated" -eq 1 ] + populated=$(grep populated "$CGROUP_TOPDIR"/$CHILD00/cgroup.events | awk '{print $2}') + assert_true [ "$populated" -eq 1 ] + populated=$(grep populated "$CGROUP_TOPDIR"/$CHILD01/cgroup.events | awk '{print $2}') + assert_true [ "$populated" -eq 0 ] + + # @测试步骤:2: 将进程迁移到root cgroup + echo $task_pid >"$CGROUP_TOPDIR"/cgroup.procs + + # @预期结果:1: 四个cgroup的populated字段为0 + populated=$(grep populated "$CGROUP_TOPDIR"/$CGROUP/cgroup.events | awk '{print $2}') + assert_true [ "$populated" -eq 0 ] + populated=$(grep populated "$CGROUP_TOPDIR"/$CHILD0/cgroup.events | awk '{print $2}') + assert_true [ "$populated" -eq 0 ] + populated=$(grep populated "$CGROUP_TOPDIR"/$CHILD00/cgroup.events | awk '{print $2}') + assert_true [ "$populated" -eq 0 ] + populated=$(grep populated "$CGROUP_TOPDIR"/$CHILD01/cgroup.events | awk '{print $2}') + assert_true [ "$populated" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD01 + rmdir "$CGROUP_TOPDIR"/$CHILD00 + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-subtree_control-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-subtree_control-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..7d170636e0d2b93f5672bb2a35ae6aa12e74891a --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-subtree_control-001.sh" @@ -0,0 +1,80 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240810-000034-129698018 +# @用例名称: cgroup-v2-subtree_control-001 +# @用例级别: 1 +# @用例标签: cgroup-v2 subtree_control +# @用例类型: 测试cgroup.subtree_control接口文件,不能够在domain cgroup中加入进程在启用了subtree_control的cgroup中 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-subtree_control-001" +CHILD0="$CGROUP/child0" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + mkdir "$CGROUP_TOPDIR"/$CHILD0 + # @预置条件: 检查当前cgroup是否能启用memory控制器 + if ! check_string_in_file "memory" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "根cgroup不能启用memory控制器" + fi + # @预置条件: 启用memory控制器 + echo "+memory" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 启用CGROUP的subtree_control的memory + echo "+memory" >"$CGROUP_TOPDIR"/$CGROUP/cgroup.subtree_control + + # @测试步骤:2: 运行一个进程 + { + while true; do :; done + } & + task_pid=$! + + # @测试步骤:3: 写入CGROUP的cgroup.procs + ret=0 + echo $task_pid >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs || ret=-1 + + # @预期结果:1: 写入失败 + assert_true [ "$ret" -eq -1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-subtree_control-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-subtree_control-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..6daa6a6ba634481277a9e4090e4491843d57ce2b --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-subtree_control-002.sh" @@ -0,0 +1,72 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240810-000036-358265138 +# @用例名称: cgroup-v2-subtree_control-002 +# @用例级别: 1 +# @用例标签: cgroup-v2 subtree_control +# @用例类型: 测试cgroup.subtree_control接口文件,子cgroup的subtree_control只能包含父cgroup的subtree_control +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-subtree_control-002" +CHILD0="$CGROUP/child0" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + mkdir "$CGROUP_TOPDIR"/$CHILD0 + # @预置条件: 检查当前cgroup是否能启用memory控制器 + if ! check_string_in_file "memory" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "根cgroup不能启用memory控制器" + fi + # @预置条件: 启用memory控制器 + echo "+memory" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 检查CGROUP的subtree_control为空 + assert_true [ -z "$(cat "$CGROUP_TOPDIR"/$CGROUP/cgroup.subtree_control)" ] + + # @测试步骤:2: 启用CHILD0的subtree_control的memory + ret=0 + echo "+memory" >"$CGROUP_TOPDIR"/$CHILD0/cgroup.subtree_control || ret=-1 + + # @预期结果:1: 启用失败 + assert_true [ "$ret" -eq -1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @测试清理: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-subtree_control-003.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-subtree_control-003.sh" new file mode 100755 index 0000000000000000000000000000000000000000..5a24cfb7299213fed5e7e5056374850742192012 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-subtree_control-003.sh" @@ -0,0 +1,75 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240810-000037-405402992 +# @用例名称: cgroup-v2-subtree_control-003 +# @用例级别: 1 +# @用例标签: cgroup-v2 subtree_control +# @用例类型: 测试cgroup.subtree_control接口文件, 不能禁用父cgroup的subtree_control因为子cgroup的subtree_control包含父cgroup的subtree_control +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-subtree_control-003" +CHILD0="$CGROUP/child0" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + mkdir "$CGROUP_TOPDIR"/$CHILD0 + # @预置条件: 检查当前cgroup是否能启用memory控制器 + if ! check_string_in_file "memory" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "根cgroup不能启用memory控制器" + fi + # @预置条件: 启用memory控制器 + echo "+memory" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 启用CGROUP的subtree_control的memory + echo "+memory" >"$CGROUP_TOPDIR"/$CGROUP/cgroup.subtree_control + + # @测试步骤:2: 启用CHILD0的subtree_control的memory + echo "+memory" >"$CGROUP_TOPDIR"/$CHILD0/cgroup.subtree_control + + # @测试步骤:3: 禁用CGROUP的subtree_control的memory + ret=0 + echo "-memory" >"$CGROUP_TOPDIR"/$CGROUP/cgroup.subtree_control || ret=-1 + + # @预期结果:1: 禁用失败 + assert_true [ "$ret" -eq -1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-subtree_control-004.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-subtree_control-004.sh" new file mode 100755 index 0000000000000000000000000000000000000000..06deb0ea306c48364a726f156f6bbe2bcfe7c977 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-subtree_control-004.sh" @@ -0,0 +1,84 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240810-002148-359999787 +# @用例名称: cgroup-v2-subtree_control-004 +# @用例级别: 2 +# @用例标签: cgroup-v2 subtree_control +# @用例类型: 测试cgroup.subtree_control接口文件, 在threaded cgroup能够加入线程在启用了subtree_control的cgroup中 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-subtree_control-001" +CHILD0="$CGROUP/child0" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + mkdir "$CGROUP_TOPDIR"/$CHILD0 + # @预置条件: 检查当前cgroup是否能启用cpu控制器 + if ! check_string_in_file "memory" "$CGROUP_TOPDIR/cgroup.controllers"; then + skip_test "根cgroup不能启用memory控制器" + fi + # @预置条件: 启用cpu控制器 + echo "+memory" >"$CGROUP_TOPDIR"/cgroup.subtree_control || return 1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 修改CGROUP和CHILD0的类型 + echo "threaded" >"$CGROUP_TOPDIR"/$CGROUP/cgroup.type + echo "threaded" >"$CGROUP_TOPDIR"/$CHILD0/cgroup.type + + # @测试步骤:2: 启用CGROUP的subtree_control的cpu + echo "+cpu" >"$CGROUP_TOPDIR"/$CGROUP/cgroup.subtree_control + + # @测试步骤:3: 运行一个线程 + { + while true; do :; done + } & + task_pid=$! + + # @测试步骤:4: 写入CGROUP的cgroup.procs + ret=0 + echo $task_pid >"$CGROUP_TOPDIR"/$CGROUP/cgroup.procs || ret=-1 + + # @预期结果:1: 写入成功 + assert_true [ "$ret" -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-type-001.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-type-001.sh" new file mode 100755 index 0000000000000000000000000000000000000000..5214eb63ddfdb9d2212f14922025e7ff6b976df9 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-type-001.sh" @@ -0,0 +1,65 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240810-003655-734736228 +# @用例名称: cgroup-v2-type-001 +# @用例级别: 1 +# @用例标签: cgroup-v2 type +# @用例类型: 测试cgroup.type接口文件,当子cgroup设置为threaded时,父cgroup自动设置为domain threaded +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-type-001" +CHILD0="$CGROUP/child0" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + mkdir "$CGROUP_TOPDIR"/$CHILD0 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 设置CHILD0的type为threaded + echo "threaded" >"$CGROUP_TOPDIR"/$CHILD0/cgroup.type + + # @测试步骤:2: 获取CGROUP的type + type=$(cat "$CGROUP_TOPDIR"/$CGROUP/cgroup.type) + + # @预期结果:1: CGROUP的type为domain threaded + assert_true [ "$type" = "domain threaded" ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-type-002.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-type-002.sh" new file mode 100755 index 0000000000000000000000000000000000000000..1b257d6e21be51ffa86e825db865719e9ae9d453 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/testcase/cgroup-v2-type-002.sh" @@ -0,0 +1,83 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20240810-003658-663844108 +# @用例名称: cgroup-v2-type-002 +# @用例级别: 2 +# @用例标签: cgroup-v2 type +# @用例类型: 测试cgroup.type接口文件, 测试层次结构约束 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +[ -z "$CGROUP_TOPDIR" ] && { + CGROUP_TOPDIR="/sys/fs/cgroup" + export CGROUP_TOPDIR +} +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +# shellcheck source=/dev/null +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 +############################################################################### + +CGROUP="cgroup-v2-type-001" +CHILD0="$CGROUP/child0" +CHILD1="$CHILD0/child1" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 检查cgroup版本是否为cgroup v2 + if ! check_cgroup_version_is_v2; then + skip_test "cgroup版本不是v2" + fi + + # @预置条件: 创建cgroup + mkdir "$CGROUP_TOPDIR"/$CGROUP + mkdir "$CGROUP_TOPDIR"/$CHILD0 + mkdir "$CGROUP_TOPDIR"/$CHILD1 + + return 0 +} + +do_test() { + msg "this is do_test" + # @测试步骤:1: 启用CHILD0的type为threaded + echo "threaded" >"$CGROUP_TOPDIR"/$CHILD0/cgroup.type + + # @测试步骤:2: 获取CHILD1的type + type=$(cat "$CGROUP_TOPDIR"/$CHILD1/cgroup.type) + + # @预期结果:1: CHILD1的type为domain invalid + assert_true [ "$type" = "domain invalid" ] + + # @测试步骤:3: 运行一个进程 + { + while true; do :; done + } & + task_pid=$! + + # @测试步骤:4: 将进程加入CHILD1 + ret=0 + echo $task_pid >"$CGROUP_TOPDIR"/$CHILD1/cgroup.procs || ret=-1 + + # @预期结果:2: 将进程加入CHILD1失败 + assert_true [ $ret -eq -1 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + # @清理工作: 清理后台进程 + kill -9 "$task_pid" + # @清理工作: 删除cgroup + rmdir "$CGROUP_TOPDIR"/$CHILD1 + rmdir "$CGROUP_TOPDIR"/$CHILD0 + rmdir "$CGROUP_TOPDIR"/$CGROUP + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/Makefile" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/Makefile" new file mode 100644 index 0000000000000000000000000000000000000000..171b10b3fca6452dc7565ebc7b613ae163de0e86 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/Makefile" @@ -0,0 +1,20 @@ +export TST_TS_TOPDIR ?= $(shell pwd)/.. +include $(TST_TS_TOPDIR)/Makefile.common +ALL_SRC := $(wildcard *.c) +ALL_OBJ := $(patsubst %.c,%.o,$(ALL_SRC)) +LIB_STATIC := libtscommon.a +CFLAGS += + +all: $(LIB_STATIC) + +$(LIB_STATIC): $(ALL_OBJ) + ar -rc $(LIB_STATIC) $(ALL_OBJ) + +$(ALL_OBJ):%.o:%.c + $(CC) $(CFLAGS) -c $^ -o $@ + +clean: + rm -rfv $(LIB_STATIC) $(ALL_OBJ) + +cleanall: clean + rm -rfv __pycache__ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/Makefile" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/Makefile" new file mode 100644 index 0000000000000000000000000000000000000000..db52efa78978804e41b087601643a3e121e6d0bc --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/Makefile" @@ -0,0 +1,21 @@ +SRC_DIR := . +BIN_DIR := ./bin +CC := gcc +CFLAGS := -O2 + +SRC_FILES := $(wildcard $(SRC_DIR)/*.c) +BIN_FILES := $(patsubst $(SRC_DIR)/%.c,$(BIN_DIR)/%,$(SRC_FILES)) + +# 目标文件 +all: $(BIN_FILES) + +$(BIN_DIR)/%: $(SRC_DIR)/%.c | $(BIN_DIR) + $(CC) $(CFLAGS) -o $@ $< + +$(BIN_DIR): + mkdir -p $(BIN_DIR) + +clean: + rm -rf $(BIN_DIR) + +.PHONY: all clean \ No newline at end of file diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/alloc_anon.c" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/alloc_anon.c" new file mode 100644 index 0000000000000000000000000000000000000000..9bfd16e9f70910271df616af58e0a41bdbb6f60c --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/alloc_anon.c" @@ -0,0 +1,56 @@ +#include +#include +#include +#include + +#define PAGE_SIZE 4096 // 页大小 + +// 分配匿名内存并初始化 +int alloc_anon(size_t mb) { + size_t size = mb * 1024 * 1024; + char *buf; + char *ptr; + + // 分配内存 + buf = malloc(size); + if (buf == NULL) { + perror("malloc 失败"); + return -1; + } + + // 初始化分配的内存 + memset(buf, 0, size); + + // 访问内存以确保它正在被使用 + for (ptr = buf; ptr < buf + size; ptr += PAGE_SIZE) { + *ptr = 0; + } + + printf("成功分配 %zu MB内存.\n", mb); + + sleep(10); + + // 释放内存 + free(buf); + return 0; +} + +int main(int argc, char *argv[]) { + if (argc != 2) { + fprintf(stderr, "用法: %s \n", argv[0]); + return EXIT_FAILURE; + } + + size_t mb = atoi(argv[1]); + if (mb == 0) { + fprintf(stderr, "无效的内存大小: %s\n", argv[1]); + return EXIT_FAILURE; + } + + // 分配内存 + if (alloc_anon(mb) != 0) { + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/alloc_anon_mlock.c" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/alloc_anon_mlock.c" new file mode 100644 index 0000000000000000000000000000000000000000..cb88ec183a3cae3bce41ea24425d6b2aa45ce6d5 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/alloc_anon_mlock.c" @@ -0,0 +1,57 @@ +// 启用GNU扩展 +#define _GNU_SOURCE + +#include +#include +#include +#include + +#define PAGE_SIZE 4096 // 页大小 + +// 单次分配大量匿名内存 +int alloc_anon_mlock(size_t mb) { + size_t size = mb * 1024 * 1024; + void *buf; + + // 使用mmap分配内存 + buf = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (buf == MAP_FAILED) { + perror("mmap 失败"); + return -1; + } + + if (mlock(buf, size) != 0) { + perror("mlock 失败"); + return -1; + } + + sleep(1); + + if (munmap(buf, size) != 0) { + perror("munmap 失败"); + return -1; + } + + return 0; +} + +int main(int argc, char *argv[]) { + if (argc != 2) { + fprintf(stderr, "用法: %s \n", argv[0]); + return EXIT_FAILURE; + } + + size_t mb = atoi(argv[1]); + if (mb == 0) { + fprintf(stderr, "无效的内存大小: %s\n", argv[1]); + return EXIT_FAILURE; + } + + // 分配内存 + if (alloc_anon_mlock(mb) != 0) { + return EXIT_FAILURE; + } + + printf("成功分配 %zu MB内存.\n", mb); + return EXIT_SUCCESS; +} \ No newline at end of file diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/alloc_hugepage.c" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/alloc_hugepage.c" new file mode 100644 index 0000000000000000000000000000000000000000..6c150b5b7cf73bd9396178187a27f4b38b5e3917 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/alloc_hugepage.c" @@ -0,0 +1,73 @@ +#include +#include +#include +#include +#include + +#define FILE_NAME "/mnt/huge/hugepagefile" +#define PROTECTION (PROT_READ | PROT_WRITE) +#define ADDR (void *)(0x0UL) +#define FLAGS (MAP_SHARED) + +size_t size = 0; + +static void write_bytes(char *addr) +{ + unsigned long i; + + for (i = 0; i < size; i++) + *(addr + i) = (char)i; +} + +static int read_bytes(char *addr) +{ + unsigned long i; + + for (i = 0; i < size; i++) + if (*(addr + i) != (char)i) { + printf("Mismatch at %lu\n", i); + return 1; + } + return 0; +} + +int main(int argc, char *argv[]) +{ + if (argc != 3) { + fprintf(stderr, "用法: %s \n", argv[0]); + exit(1); + } + + int hugepage_count = atoi(argv[1]); + int hugepage_size = atoi(argv[2]); + size = hugepage_count * hugepage_size * 1024 * 1024UL; + + void *addr; + int fd, ret; + fd = open(FILE_NAME, O_CREAT | O_RDWR, 0755); + if (fd < 0) { + perror("打开文件失败"); + exit(1); + } + + // 申请hugepage内存 + addr = mmap(ADDR, size, PROTECTION, FLAGS, fd, 0); + if (addr == MAP_FAILED) { + perror("mmap"); + unlink(FILE_NAME); + exit(1); + } + + printf("内存映射起始地址: %p\n", addr); + write_bytes(addr); + ret = read_bytes(addr); + + sleep(5); + + // 释放hugepage内存 + munmap(addr, size); + close(fd); + unlink(FILE_NAME); + + return ret; +} \ No newline at end of file diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/alloc_hugepage_rsvd.c" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/alloc_hugepage_rsvd.c" new file mode 100644 index 0000000000000000000000000000000000000000..e9c5ec7bfdea96a6a839c455275910029ece7a1f --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/alloc_hugepage_rsvd.c" @@ -0,0 +1,51 @@ +#include +#include +#include +#include +#include + +#define FILE_NAME "/mnt/huge/hugepagefile" +#define PROTECTION (PROT_READ | PROT_WRITE) +#define ADDR (void *)(0x0UL) +#define FLAGS (MAP_SHARED) + +size_t size = 0; + +int main(int argc, char *argv[]) +{ + if (argc != 3) { + fprintf(stderr, "用法: %s \n", argv[0]); + exit(1); + } + + int hugepage_count = atoi(argv[1]); + int hugepage_size = atoi(argv[2]); + size = hugepage_count * hugepage_size * 1024 * 1024UL; + + void *addr; + int fd, ret; + fd = open(FILE_NAME, O_CREAT | O_RDWR, 0755); + if (fd < 0) { + perror("打开文件失败"); + exit(1); + } + + // 申请hugepage内存 + addr = mmap(ADDR, size, PROTECTION, FLAGS, fd, 0); + if (addr == MAP_FAILED) { + perror("mmap"); + unlink(FILE_NAME); + exit(1); + } + + printf("内存映射起始地址: %p\n", addr); + + sleep(5); + + // 释放hugepage内存 + munmap(addr, size); + close(fd); + unlink(FILE_NAME); + + return 0; +} \ No newline at end of file diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/alloc_pagecache.c" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/alloc_pagecache.c" new file mode 100644 index 0000000000000000000000000000000000000000..63b4418ebbde586d32ee823b43a40c9b3f53fe6f --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/alloc_pagecache.c" @@ -0,0 +1,86 @@ +// 启用GNU扩展 +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include + +#define PAGE_SIZE 4096 // 页大小 + +// 通过调整文件大小和读取文件来分配页面缓存 +int alloc_pagecache(int fd, size_t size) { + char buf[PAGE_SIZE]; + struct stat st; + int i; + + // 获取文件装填 + if (fstat(fd, &st)) { + perror("fstat 失败"); + return -1; + } + + // 增加文件大小 + size += st.st_size; + if (ftruncate(fd, size)) { + perror("ftruncate 失败"); + return -1; + } + + // 读取文件分配页缓存 + for (i = 0; i < size; i += sizeof(buf)) { + if (read(fd, buf, sizeof(buf)) < 0) { + perror("read 失败"); + return -1; + } + } + + return 0; +} + +// 创建临时文件并分配页面缓存 +int create_temp_file_and_allocate(size_t size_mb) { + int fd; + + // 创建临时我呢见 + fd = open(".", O_TMPFILE | O_RDWR | O_EXCL, 0644); + if (fd < 0) { + perror("open 失败"); + return -1; + } + + // 分配页缓存 + if (alloc_pagecache(fd, size_mb * 1024 * 1024)) { + close(fd); + return -1; + } + + printf("成功分配 %zu MB 页缓存.\n", size_mb); + + sleep(10); + + // 释放文件 + close(fd); + return 0; +} + +int main(int argc, char *argv[]) { + if (argc != 2) { + fprintf(stderr, "用法: %s \n", argv[0]); + return EXIT_FAILURE; + } + + size_t size_mb = atoi(argv[1]); + if (size_mb == 0) { + fprintf(stderr, "无效的内存大小: %s\n", argv[1]); + return EXIT_FAILURE; + } + + if (create_temp_file_and_allocate(size_mb)) { + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/cgroup_event_listener.c" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/cgroup_event_listener.c" new file mode 100644 index 0000000000000000000000000000000000000000..f416b54974c5c51417fb8d344b261ecc04e4b7d2 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/cgroup_event_listener.c" @@ -0,0 +1,86 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define USAGE_STR "Usage: cgroup_event_listener " + +int main(int argc, char **argv) +{ + int efd = -1; // eventfd 文件描述符 + int cfd = -1; // 控制文件的文件描述符 + int event_control = -1;// cgroup.event_control 文件的文件描述符 + char event_control_path[4096]; // 存储 cgroup.event_control 文件路径的缓冲区 + char line[256]; // 存储写入 cgroup.event_control 文件的字符串 + int ret; + + // 检查命令行参数数量是否正确 + if (argc != 3) + errx(1, "%s", USAGE_STR); + + // 打开控制文件 + cfd = open(argv[1], O_RDONLY); + if (cfd == -1) + err(1, "Cannot open %s", argv[1]); + + // 构建 cgroup.event_control 文件的路径 + ret = snprintf(event_control_path, 4096, "%s/cgroup.event_control", + dirname(argv[1])); + if (ret >= 256) + errx(1, "Path to cgroup.event_control is too long"); + + // 打开 cgroup.event_control 文件 + event_control = open(event_control_path, O_WRONLY); + if (event_control == -1) + err(1, "Cannot open %s", event_control_path); + + // 创建 eventfd + efd = eventfd(0, 0); + if (efd == -1) + err(1, "eventfd() failed"); + + // 构建写入 cgroup.event_control 文件的字符串 + ret = snprintf(line, 63, "%d %d %s", efd, cfd, argv[2]); + if (ret >= 256) + errx(1, "Arguments string is too long"); + + // 将字符串写入 cgroup.event_control 文件 + ret = write(event_control, line, strlen(line) + 1); + if (ret == -1) + err(1, "Cannot write to cgroup.event_control"); + + while (1) { + uint64_t result; + + // 从 eventfd 读取事件 + ret = read(efd, &result, sizeof(result)); + if (ret == -1) { + if (errno == EINTR) + continue; + err(1, "Cannot read from eventfd"); + } + assert(ret == sizeof(result)); + + // 检查 cgroup.event_control 文件是否仍然可写 + ret = access(event_control_path, W_OK); + if ((ret == -1) && (errno == ENOENT)) { + puts("The cgroup seems to have removed."); + break; + } + + if (ret == -1) + err(1, "cgroup.event_control is not accessible any more"); + + // 打印事件信息 + printf("%s %s: crossed\n", argv[1], argv[2]); + } + + return 0; +} \ No newline at end of file diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/pressure_listener.c" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/pressure_listener.c" new file mode 100644 index 0000000000000000000000000000000000000000..84b5c73739da4fdcdf35a042d82928821d412b0d --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/pressure_listener.c" @@ -0,0 +1,60 @@ +#include +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + if (argc != 2) + { + printf("用法: %s \n", argv[0]); + return 1; + } + + const char *file_path = argv[1]; + const char trig[] = "some 500000 1000000"; + struct pollfd fds; + int n; + + fds.fd = open(file_path, O_RDWR | O_NONBLOCK); + if (fds.fd < 0) + { + printf("%s open 错误: %s\n", file_path, strerror(errno)); + return 1; + } + fds.events = POLLPRI; + + if (write(fds.fd, trig, strlen(trig) + 1) < 0) + { + printf("%s write 错误: %s\n", file_path, strerror(errno)); + return 1; + } + + while (1) + { + n = poll(&fds, 1, -1); + if (n < 0) + { + printf("poll error: %s\n", strerror(errno)); + return 1; + } + if (fds.revents & POLLERR) + { + printf("got POLLERR, event source is gone\n"); + return 0; + } + if (fds.revents & POLLPRI) + { + printf("event triggered!\n"); + } + else + { + printf("unknown event received: 0x%x\n", fds.revents); + return 1; + } + } + + return 0; +} \ No newline at end of file diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/register_notify.c" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/register_notify.c" new file mode 100644 index 0000000000000000000000000000000000000000..2486119f6c5a0838b8bcab97747f4bb67e0a059f --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/cgroup_util/register_notify.c" @@ -0,0 +1,75 @@ +#include +#include +#include +#include +#include +#include +#include + +int prepare_for_wait(const char *filepath) { + int fd, ret; + + fd = inotify_init1(0); + if (fd == -1) { + return -1; + } + + ret = inotify_add_watch(fd, filepath, IN_MODIFY); + if (ret == -1) { + perror("inotify_add_watch"); + close(fd); + return -1; + } + + return fd; +} + +int monitor_file(int fd) { + int ret = -1; + struct pollfd pfd = { + .fd = fd, + .events = POLLIN, + }; + + while (1) { + // 最多等待10s来检测事件 + ret = poll(&pfd, 1, 10000); + + if (ret == -1) { + if (errno == EINTR) { + continue; + } + perror("poll"); + break; + } + + if (ret > 0 && pfd.revents & POLLIN) { + ret = 0; + break; + } + } + return ret; +} + +int main(int argc, char *argv[]) { + if (argc != 2) { + fprintf(stderr, "用法: %s \n", argv[0]); + return EXIT_FAILURE; + } + + const char *filepath = argv[1]; + int fd; + + fd = prepare_for_wait(filepath); + if (fd == -1) { + fprintf(stderr, "开启inotify失败.\n"); + return EXIT_FAILURE; + } + + sleep(1); + printf("正在监听文件: %s\n", filepath); + monitor_file(fd); + + close(fd); + return EXIT_SUCCESS; +} diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/other_common.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/other_common.sh" new file mode 100644 index 0000000000000000000000000000000000000000..14b5a1dfbfe4897282092d302dd13e1920ffc719 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/other_common.sh" @@ -0,0 +1,152 @@ +#!/bin/bash + +# 检查是否以root用户运行 +is_root() { + if [ "$EUID" -ne 0 ]; then + return 1 + fi + return 0 +} + +# 检查是否安装了dd工具 +is_dd_installed() { + if ! command -v dd &> /dev/null; then + return 1 + fi + return 0 +} + +# 检查是否安装了tc工具 +is_tc_installed() { + if ! command -v tc &> /dev/null; then + return 1 + fi + return 0 +} + +# 检查是否安装了iperf3工具 +is_iperf3_installed() { + if ! command -v iperf3 &> /dev/null; then + return 1 + fi + return 0 +} + +# 检查是否安装了perf工具 +is_perf_installed() { + if ! command -v perf &> /dev/null; then + return 1 + fi + return 0 +} + +# 检查是否安装了numactl工具 +is_numactl_installed() { + if ! command -v numactl &> /dev/null; then + return 1 + fi + return 0 +} + +# 检查是否安装了numastat工具 +is_numastat_installed() { + if ! command -v numastat &> /dev/null; then + return 1 + fi + return 0 +} + +# 检查是否安装了mpstat命令 +is_sysstat_installed() { + if ! command -v mpstat &> /dev/null; then + return 1 + fi + return 0 +} + +# 检查是否安装了bc命令 +is_bc_installed() { + if ! command -v bc &> /dev/null; then + return 1 + fi + return 0 +} + +# 检查cgroup版本是否为cgroup v1 +check_cgroup_version_is_v1() { + if [ "$(stat -fc %T "$CGROUP_TOPDIR")" = "tmpfs" ]; then + return 0 + else + return 1 + fi +} +# 检查cgroup版本是否为cgroup v2 +check_cgroup_version_is_v2() { + if [ "$(stat -fc %T "$CGROUP_TOPDIR")" = "cgroup2fs" ]; then + return 0 + else + return 1 + fi +} + +# 检查文件中是否包含指定字符串 +check_string_in_file() { + local string="$1" + local file="$2" + + if grep -q "$string" "$file"; then + return 0 + else + return 1 + fi +} + +# 获取cgroup可用的cpu列表 +get_online_cpu_list() { + local file_path=$1 + local cpu_effective + local cpu_list=() + + cpu_effective=$(cat "$file_path") + + # 提取所有 CPU 序号 + IFS=',' read -r -a ranges <<< "$cpu_effective" + for range in "${ranges[@]}"; do + if [[ $range =~ ^[0-9]+-[0-9]+$ ]]; then + # 处理范围格式,如 "0-1" + IFS='-' read -r start end <<< "$range" + for ((i=start; i<=end; i++)); do + cpu_list+=("$i") + done + else + # 处理单个 CPU 序号,如 "4" + cpu_list+=("$range") + fi + done + + # 返回 cpu_list 数组 + echo "${cpu_list[@]}" +} + +# 获取cgroup可用的mem列表 +get_online_mem_list() { + local file_path=$1 + local mem_effective + local mem_list=() + + mem_effective=$(cat "$file_path") + + IFS=',' read -r -a ranges <<< "$mem_effective" + for range in "${ranges[@]}"; do + if [[ $range =~ ^[0-9]+-[0-9]+$ ]]; then + IFS='-' read -r start end <<< "$range" + for ((i=start; i<=end; i++)); do + mem_list+=("$i") + done + else + mem_list+=("$range") + fi + done + + echo "${mem_list[@]}" +} \ No newline at end of file diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/ts_common.c" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/ts_common.c" new file mode 100644 index 0000000000000000000000000000000000000000..b65caf6f1c17ff37deebd1c16cdc2fe9c362faad --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/ts_common.c" @@ -0,0 +1,23 @@ +// 测试套自定义公共函数库 +#include "common.h" +#include "ts_common.h" + +int ts_setup(void) { + msg("this is ts_setup"); + return 0; +} + +int tc_setup_common(int argc, char **argv) { + msg("this is tc_setup_common"); + return 0; +} + +int tc_teardown_common(int argc, char **argv) { + msg("this is tc_teardown_common"); + return 0; +} + +int ts_teardown(void) { + msg("this is ts_teardown"); + return 0; +} diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/ts_common.h" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/ts_common.h" new file mode 100644 index 0000000000000000000000000000000000000000..9ed2c5f83c433140bd772eb8c673132df2760066 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/ts_common.h" @@ -0,0 +1,6 @@ +#ifndef __TS_COMMON_H__ +#define __TS_COMMON_H__ + +// 测试套自定义头文件内容 + +#endif // __TS_COMMON_H__ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/ts_common.py" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/ts_common.py" new file mode 100644 index 0000000000000000000000000000000000000000..5b60299e25b059fdb5dc6707cc9fa380c8763ab3 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/ts_common.py" @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +# coding: utf-8 +# Desc: 测试套公共模块 +import abc +import os.path +import sys + +sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')) +from tst_common.lib.common import TestCase + + +class MyTestCase(TestCase): + """ + 本测试套内的Python用例需要继承此类 + """ + + def tc_setup_common(self, *args): + """ + 所有Python用例执行tc_setup函数前会先执行本函数 + :param args: + :return: + """ + self.msg("this is tc_setup_common") + + @abc.abstractmethod + def do_test(self, *args): + pass + + def tc_teardown_common(self, *args): + """ + 所有Python用例执行tc_teardown函数后会执行本函数 + :param args: + :return: + """ + self.msg("this is tc_teardown_common") diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/ts_common.sh" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/ts_common.sh" new file mode 100644 index 0000000000000000000000000000000000000000..c0a7f51c57001834dc84e7883922bf35b02da539 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/ts_common.sh" @@ -0,0 +1,42 @@ +#!/bin/bash +# 测试套公共函数 +# 约定: +# 1、以下划线"_"开头的函数和变量用例不能直接调用 +# 2、环境变量全大写,全局变量加上"g_"前置,局部变量统一加"local"修饰 + +# source自己定义的其他公共函数 +source "${TST_TS_TOPDIR}/tst_lib/other_common.sh" || exit 1 + +ts_setup() { + msg "this is ts_setup" + return 0 +} + +tc_setup_common() { + msg "this is tc_setup_common" + # 检查是否是ROOT用户 + if ! is_root; then + msg "错误原因:脚本需要 root 权限运行, 尝试在root shell环境下运行" + return 1 + fi + # 检查是否开启了CONFIG_CGROUPS + if ! grep -q CONFIG_CGROUPS=y /boot/config-"$(uname -r)"; then + msg "错误原因: CONFIG_CGROUPS 配置未开启" + return 1 + fi + # 检查是否安装了bc工具 + if ! is_bc_installed; then + msg "错误原因: 未安装bc工具" + return 1 + fi +} + +tc_teardown_common() { + msg "this is tc_teardown_common" + return 0 +} + +ts_teardown() { + msg "this is ts_teardown" + return 0 +} diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/ts_setup" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/ts_setup" new file mode 100755 index 0000000000000000000000000000000000000000..2f7aaaf2ac6439e24ea61cc85b48eb95a56541d9 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/ts_setup" @@ -0,0 +1,13 @@ +#!/bin/bash +# Time: 2022-04-19 22:44:25 +# Desc: ts_setup +[ -z "$TST_TS_TOPDIR" ] && export TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" + +ts_setup() { + # 测试套setup脚本,在这里增加setup操作 + msg "this is ts_setup" + return 0 +} + +ts_setup diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/ts_teardown" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/ts_teardown" new file mode 100755 index 0000000000000000000000000000000000000000..324080fe7b09842c383f9ba3d8585741a3b75d64 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tst_lib/ts_teardown" @@ -0,0 +1,13 @@ +#!/bin/bash +# Time: 2022-04-19 22:44:25 +# Desc: ts_teardown +[ -z "$TST_TS_TOPDIR" ] && export TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" + +ts_teardown() { + # 测试套teardown脚本,在这里增加teardown操作 + msg "this is ts_teardown" + return 0 +} + +ts_teardown diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tsuite" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tsuite" new file mode 120000 index 0000000000000000000000000000000000000000..d7009e55a826436c7a6549fb48cc1d33e7abd1eb --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/tsuite" @@ -0,0 +1 @@ +tst_common/tsuite \ No newline at end of file diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\344\275\277\347\224\250\346\226\207\346\241\243.md" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\344\275\277\347\224\250\346\226\207\346\241\243.md" new file mode 100644 index 0000000000000000000000000000000000000000..aee34d7b367b93b491cd8fc35aa464b73b208322 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\344\275\277\347\224\250\346\226\207\346\241\243.md" @@ -0,0 +1,214 @@ +# tst-cgroup测试套使用文档 + +## 运行测试 + +### 克隆到本地 + +```bash +git clone -b hmt-issue https://gitee.com/LINGYUNXINGZHE/contributor_rhino-bird.git +``` + +### 进入到tst-cgroup目录下载子模块 + +``` +git submodule add https://gitee.com/opencloudos-stream/test-suite-base.git tst_common +``` + +### 安装必要的工具 + +```bash +bash install_package.sh +``` + +### 编译cgroup util中的程序 + +在tst_lib/cgroup_util目录下输入 `make` 命令编译程序,生成的可执行文件在tst_lib/cgroup_util/bin中 + +### 运行单个测试用例 + +在根目录下,以root权限运行 + +```bash +sudo ./tsuite run testcase/$TESTCACE +``` + +`TESTCASE` 是具体的测试用例名称 + +### 运行整个测试套 + +在根目录下,以root权限运行 + +```bash +sudo ./tsuite run +``` + +运行结果在logs/.ts.sysdir/run.result文件中 + +## 操作指南 + +### 切换cgroup版本 + +切换到cgroup v1,在/etc/default/grub的GRUB_CMDLINE_LINUX添加`systemd.unified_cgroup_hierarchy=0` + +切换到cgroup v1,在/etc/default/grub的GRUB_CMDLINE_LINUX添加`systemd.unified_cgroup_hierarchy=1` + +然后更新配置: + +```bash +sudo grub2-mkconfig -o /boot/grub2/grub.cfg +``` + +### 启用zswap + +以下测试用例需要启用系统的zswap: + +- cgroup-v2-memory-zswap + +修改方式:在/etc/default/grub的GRUB_CMDLINE_LINUX添加`zswap.enabled=1` + +然后更新配置: + +```bash +sudo grub2-mkconfig -o /boot/grub2/grub.cfg +``` + +### 在qemu上测试 + +以下测试用例需要在有两个NUMA节点及以上的系统中测试: + +- cgroup-v1-cpuset-mems +- cgroup-v1-cpuset-mem_exclusive +- cgroup-v1-cpuset-memory_migrate-001 +- cgroup-v1-cpuset-memory_migrate-002 +- cgroup-v1-cpuset-memory_spread_page-001 +- cgroup-v1-cpuset-memory_spread_page-002 +- cgroup-v2-cpuset-mems + +OpenCloudOS 8:下载qcow2镜像格式 + +```bash +qemu-system-x86_64 -machine q35 \ +-smp 8,sockets=2,cores=4,threads=1 \ +-m 8G \ +-cpu host \ +-enable-kvm \ +-drive file=OpenCloudOS-8.8-5.4.119-20.0009.29-20230817.1028-x86_64.qcow2,format=qcow2 \ +-object memory-backend-ram,size=4G,id=ram-node0 \ +-object memory-backend-ram,size=4G,id=ram-node1 \ +-numa node,nodeid=0,cpus=0-3,memdev=ram-node0 \ +-numa node,nodeid=1,cpus=4-7,memdev=ram-node1 \ +-net nic -net user,hostfwd=tcp::2222-:22 \ +-vnc :0 +``` + +OpenCloudOS 9: 下载minimal镜像格式 + +```bash +qemu-img create -f qcow2 OpenCloudOS9 20G +``` + +```bash +qemu-system-x86_64 -machine q35 \ +-smp 8,sockets=2,cores=4,threads=1 \ +-m 8G \ +-cpu host \ +-enable-kvm \ +-drive file=OpenCloudOS9,format=qcow2 \ +-cdrom OpenCloudOS-9.2-x86_64-minimal.iso \ +-object memory-backend-ram,size=4G,id=ram-node0 \ +-object memory-backend-ram,size=4G,id=ram-node1 \ +-numa node,nodeid=0,cpus=0-3,memdev=ram-node0 \ +-numa node,nodeid=1,cpus=4-7,memdev=ram-node1 \ +-net nic -net user,hostfwd=tcp::2222-:22 \ +-vnc :0 +``` + +OpenCloudOS Stream 23: 下载minimal镜像格式 + +```bash +qemu-img create -f qcow2 OpenCloudOS-Stream-23 20G +``` + +```bash +qemu-system-x86_64 -machine q35 \ +-smp 8,sockets=2,cores=4,threads=1 \ +-m 8G \ +-cpu host \ +-enable-kvm \ +-drive file=OpenCloudOS-Stream-23,format=qcow2 \ +-cdrom OpenCloudOS-Stream-23-20240304-minimal-x86_64.iso \ +-object memory-backend-ram,size=4G,id=ram-node0 \ +-object memory-backend-ram,size=4G,id=ram-node1 \ +-numa node,nodeid=0,cpus=0-3,memdev=ram-node0 \ +-numa node,nodeid=1,cpus=4-7,memdev=ram-node1 \ +-net nic -net user,hostfwd=tcp::2222-:22 \ +-vnc :0 +``` + +### 切换hugepage大小 + +以下测试用例需要修改系统hugepage默认大小: + +- cgroup-v1-hugetlb-limit_in_bytes-003 +- cgroup-v1-hugetlb-limit_in_bytes-004 +- cgroup-v1-hugetlb-rsvd-limit_in_bytes-003 +- cgroup-v1-hugetlb-rsvd-limit_in_bytes-004 +- cgroup-v2-hugetlb-max-003 +- cgroup-v2-hugetlb-max-004 +- cgroup-v2-hugetlb-rsvd-max-003 +- cgroup-v2-hugetlb-rsvd-max-004 + +修改方式:在/etc/default/grub的GRUB_CMDLINE_LINUX添加`default_hugepagesz=1G hugepagesz=1G` + +然后更新配置: + +```bash +sudo grub2-mkconfig -o /boot/grub2/grub.cfg +``` + +### 设置swapfile + +创建一个空文件: + +``` +sudo fallocate -l 4G /swapfile +``` + +设置正确的权限: + +``` +sudo chmod 600 /swapfile +``` + +格式化为swap: + +``` +sudo mkswap /swapfile +``` + +启用Swap文件: + +``` +sudo swapon /swapfile +``` + +永久启用: + +``` +echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab +``` + +## 其他 + +### 添加新的测试用例 + +```bash +./tsuite new case sh|c|py cgroup-v1-cpuset-cpus-001 +``` + +### 显示所有测试用例 + +```bash +./tsuite list +``` + diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813154623977.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813154623977.png" new file mode 100644 index 0000000000000000000000000000000000000000..b709c18e007abba92fa494979659a0b8ec651af8 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813154623977.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813154831524.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813154831524.png" new file mode 100644 index 0000000000000000000000000000000000000000..c001eb7f15c400d43350e32a6163eac48af553d0 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813154831524.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813154844123.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813154844123.png" new file mode 100644 index 0000000000000000000000000000000000000000..c001eb7f15c400d43350e32a6163eac48af553d0 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813154844123.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813154921611.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813154921611.png" new file mode 100644 index 0000000000000000000000000000000000000000..15f7619790b2f8bbb30aad82760f83e788c46a69 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813154921611.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813155138963.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813155138963.png" new file mode 100644 index 0000000000000000000000000000000000000000..ce2e44351b12d50cfb4a5a8f799d7cc6ddd81895 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813155138963.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813155220037.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813155220037.png" new file mode 100644 index 0000000000000000000000000000000000000000..8b64b7ca2fe05e236100f49cea60d44ee4ba0284 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813155220037.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813155239339.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813155239339.png" new file mode 100644 index 0000000000000000000000000000000000000000..6d47afcae755a5591aad60f7f8f5b98688520077 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813155239339.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813155303515.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813155303515.png" new file mode 100644 index 0000000000000000000000000000000000000000..4a947c51e40b91be62a7888b7b751f156b1064a9 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813155303515.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813161618198.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813161618198.png" new file mode 100644 index 0000000000000000000000000000000000000000..5dfb907fa78f9c2fcf1b503c9262ed5209f3ef2c Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813161618198.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813163729651.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813163729651.png" new file mode 100644 index 0000000000000000000000000000000000000000..71f2f53325892be2a5549ba97cbcce5330cffdb3 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813163729651.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813164446290.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813164446290.png" new file mode 100644 index 0000000000000000000000000000000000000000..86054156bb385d83550aacfbbab5e05d153086e2 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813164446290.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813164459881.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813164459881.png" new file mode 100644 index 0000000000000000000000000000000000000000..f0fe10fc47b6f164b178440bc915952e06b145b3 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813164459881.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813164512233.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813164512233.png" new file mode 100644 index 0000000000000000000000000000000000000000..1eb2f5e28565e0635947b27091fa35bc3bc1d481 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813164512233.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813164526945.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813164526945.png" new file mode 100644 index 0000000000000000000000000000000000000000..26b97eb88e36190e6e2a905efb105053c2a456f4 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813164526945.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813175813489.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813175813489.png" new file mode 100644 index 0000000000000000000000000000000000000000..69b8d2bd81d042679a94db39e863f9298f42c040 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813175813489.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813175842360.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813175842360.png" new file mode 100644 index 0000000000000000000000000000000000000000..c2415fd5c5d888b28a8ea47b61792013f91e968c Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813175842360.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813175902750.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813175902750.png" new file mode 100644 index 0000000000000000000000000000000000000000..a3000c7973f2f4136ec8ba0bd2e88ec4c525ff64 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813175902750.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813180012630.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813180012630.png" new file mode 100644 index 0000000000000000000000000000000000000000..d766a73561d004d8a92f655aa89bdd33430850b2 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813180012630.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813180101765.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813180101765.png" new file mode 100644 index 0000000000000000000000000000000000000000..db09c233b6d76a8896d5fc244733fde5408feade Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813180101765.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813180113229.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813180113229.png" new file mode 100644 index 0000000000000000000000000000000000000000..db09c233b6d76a8896d5fc244733fde5408feade Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813180113229.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813192619397.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813192619397.png" new file mode 100644 index 0000000000000000000000000000000000000000..876da4cc6b0263b14e7f1ff1f64ad2cd9a8b5a54 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813192619397.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813192641081.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813192641081.png" new file mode 100644 index 0000000000000000000000000000000000000000..9ea2493793c88a7f32ed9168e7e304c58625e55c Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813192641081.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813193042254.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813193042254.png" new file mode 100644 index 0000000000000000000000000000000000000000..51fa8ccc46e0cb4876b6d9c29cedcc2270b94229 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813193042254.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813212218088.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813212218088.png" new file mode 100644 index 0000000000000000000000000000000000000000..c84d8cfd70d7230eef099ef0efa8947c1cb43bff Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813212218088.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813213901996.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813213901996.png" new file mode 100644 index 0000000000000000000000000000000000000000..8b0267e8a4c698abbcf2c8f6d0d00f656a22b738 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813213901996.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813215939420.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813215939420.png" new file mode 100644 index 0000000000000000000000000000000000000000..3b906a63ead6a589bcadb29d5aac7ca55205a731 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813215939420.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813220134010.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813220134010.png" new file mode 100644 index 0000000000000000000000000000000000000000..bcb5ff30f9e22d768487547b8adb8220ecfad93c Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813220134010.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813220144401.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813220144401.png" new file mode 100644 index 0000000000000000000000000000000000000000..bcb5ff30f9e22d768487547b8adb8220ecfad93c Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813220144401.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813222209839.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813222209839.png" new file mode 100644 index 0000000000000000000000000000000000000000..7d4ae17a2873d2dc813f60ab6137e337a81ad6b0 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813222209839.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813222236560.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813222236560.png" new file mode 100644 index 0000000000000000000000000000000000000000..48ea08097903d7df2e91ef98bf9ae2783dc571fa Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813222236560.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813222250409.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813222250409.png" new file mode 100644 index 0000000000000000000000000000000000000000..c7ae99526de5691b1d1ed45fbd06f39734ffe4fa Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813222250409.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813222437274.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813222437274.png" new file mode 100644 index 0000000000000000000000000000000000000000..c73bb5e025ccea80929991a2f08f49284db3e97b Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813222437274.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813233107878.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813233107878.png" new file mode 100644 index 0000000000000000000000000000000000000000..c401c3681139137dc4194440fd9b304e7c4a052d Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813233107878.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813233120405.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813233120405.png" new file mode 100644 index 0000000000000000000000000000000000000000..1393b311594bf7c347adb6f2817456aba6923c8d Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813233120405.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813233137341.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813233137341.png" new file mode 100644 index 0000000000000000000000000000000000000000..2180624456a5401b68a5abf2978c9adcd18d71ea Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813233137341.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813233208725.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813233208725.png" new file mode 100644 index 0000000000000000000000000000000000000000..ab3e7df82719ca74d3a609521dfc050730a0a363 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813233208725.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813233232772.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813233232772.png" new file mode 100644 index 0000000000000000000000000000000000000000..863eddafff78dff6c39b186bac00f9e6bbe5abd2 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240813233232772.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814102516235.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814102516235.png" new file mode 100644 index 0000000000000000000000000000000000000000..3a4d53c5bc337150e27d400e83839d209ba5ef5f Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814102516235.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814102535908.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814102535908.png" new file mode 100644 index 0000000000000000000000000000000000000000..faa833f04db38f221d859dc4eca95d7d2d4d941c Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814102535908.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814102549259.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814102549259.png" new file mode 100644 index 0000000000000000000000000000000000000000..8236b450428faca7d4db4d39fbfeaa5c112403a2 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814102549259.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814102626444.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814102626444.png" new file mode 100644 index 0000000000000000000000000000000000000000..73ed26810d2309cea8a75657292f8c4e3e2e8638 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814102626444.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814102723332.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814102723332.png" new file mode 100644 index 0000000000000000000000000000000000000000..4ade93476fdddf9e9a353f6b3d08f0599ed1f6fd Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814102723332.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814102741707.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814102741707.png" new file mode 100644 index 0000000000000000000000000000000000000000..b77b47a762b4b88e72adad953b39a8b1fc041bcc Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814102741707.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814102757182.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814102757182.png" new file mode 100644 index 0000000000000000000000000000000000000000..d8b952d4ffa583123f4938f948ecedc84df0a15c Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814102757182.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814103735716.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814103735716.png" new file mode 100644 index 0000000000000000000000000000000000000000..497f28cc7a3da2f5d0a249172929c6418541cc8f Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814103735716.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814105728307.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814105728307.png" new file mode 100644 index 0000000000000000000000000000000000000000..9efd938ad553314eaddef56d6306a0fc11918f14 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814105728307.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814111432108.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814111432108.png" new file mode 100644 index 0000000000000000000000000000000000000000..40e43c8c833500c2a1c58ebb249bb201a197e6e2 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814111432108.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814111439428.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814111439428.png" new file mode 100644 index 0000000000000000000000000000000000000000..eca697c3006593ac413b9b253aaa8d88042c7352 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814111439428.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814111452398.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814111452398.png" new file mode 100644 index 0000000000000000000000000000000000000000..73c9a374602c6ec4c05e01feebaf862fc22df2b2 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814111452398.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814111510069.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814111510069.png" new file mode 100644 index 0000000000000000000000000000000000000000..d10d3d9fe1dc7d0b5062c51ee9671e1aff199589 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814111510069.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814121157863.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814121157863.png" new file mode 100644 index 0000000000000000000000000000000000000000..b3819d8638aad4b73b43dffd86f669b0cd7297c8 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814121157863.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814121312911.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814121312911.png" new file mode 100644 index 0000000000000000000000000000000000000000..c8de8663a5c48dbd33efce6f07280bd7cda272e8 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814121312911.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814121333373.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814121333373.png" new file mode 100644 index 0000000000000000000000000000000000000000..08c486a2a04f37d678e9b203a3bba29d0cfa44cf Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814121333373.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814121353069.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814121353069.png" new file mode 100644 index 0000000000000000000000000000000000000000..50141ddf2c5de5d4a23f988e6cce8b69a8a63672 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814121353069.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814121500396.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814121500396.png" new file mode 100644 index 0000000000000000000000000000000000000000..599fe7afeaefab570b061a06bf2b41ef96bad434 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814121500396.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814131958155.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814131958155.png" new file mode 100644 index 0000000000000000000000000000000000000000..d3ebfaf26475c09398885fe7031b70033a185811 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814131958155.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132028781.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132028781.png" new file mode 100644 index 0000000000000000000000000000000000000000..2192eeca8e218120934de0ef3f7b78bf43a26bcb Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132028781.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132039205.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132039205.png" new file mode 100644 index 0000000000000000000000000000000000000000..32d010cdad4cc79aaefd69da2a76479bc7ce6ed1 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132039205.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132044757.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132044757.png" new file mode 100644 index 0000000000000000000000000000000000000000..32d010cdad4cc79aaefd69da2a76479bc7ce6ed1 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132044757.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132114591.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132114591.png" new file mode 100644 index 0000000000000000000000000000000000000000..5d2b753928a0da8aa6a683628568afd7f7a9c95f Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132114591.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132156950.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132156950.png" new file mode 100644 index 0000000000000000000000000000000000000000..0c3d8d16ad12342381105e0426ce88640b37ce95 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132156950.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132225566.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132225566.png" new file mode 100644 index 0000000000000000000000000000000000000000..c19655644087038f41a995f1ffe4c4fcb8a169cc Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132225566.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132303942.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132303942.png" new file mode 100644 index 0000000000000000000000000000000000000000..60029c861423ec496c35c67f2d6db4683c7787da Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132303942.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132330534.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132330534.png" new file mode 100644 index 0000000000000000000000000000000000000000..e670397f8292531b501bad0d182b9530d2d95198 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132330534.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132333013.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132333013.png" new file mode 100644 index 0000000000000000000000000000000000000000..e670397f8292531b501bad0d182b9530d2d95198 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814132333013.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814133111776.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814133111776.png" new file mode 100644 index 0000000000000000000000000000000000000000..2c08fb6dbcc21028b832c970f089b17b1c01bb58 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814133111776.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814133152422.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814133152422.png" new file mode 100644 index 0000000000000000000000000000000000000000..beeb85e0b8a9f0299306589f9ee2a5c3750bc731 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814133152422.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814133153525.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814133153525.png" new file mode 100644 index 0000000000000000000000000000000000000000..beeb85e0b8a9f0299306589f9ee2a5c3750bc731 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814133153525.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814133210805.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814133210805.png" new file mode 100644 index 0000000000000000000000000000000000000000..72ff0a204e22ebe1d5ba2e936df5d4901910c18b Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814133210805.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814133229822.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814133229822.png" new file mode 100644 index 0000000000000000000000000000000000000000..94f6775ee577202bf572923f9a3ead59941ad974 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814133229822.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814133340510.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814133340510.png" new file mode 100644 index 0000000000000000000000000000000000000000..5baace3bafcf684f88ae6b1050117749993e2295 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814133340510.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814133341911.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814133341911.png" new file mode 100644 index 0000000000000000000000000000000000000000..5baace3bafcf684f88ae6b1050117749993e2295 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814133341911.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814134324218.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814134324218.png" new file mode 100644 index 0000000000000000000000000000000000000000..62d096253bc485797cd238aa49cf4f46b723cbdc Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814134324218.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814134339407.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814134339407.png" new file mode 100644 index 0000000000000000000000000000000000000000..ddf2bc5b4df5401000548e165c3d03635e2cb37e Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814134339407.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814134349799.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814134349799.png" new file mode 100644 index 0000000000000000000000000000000000000000..31035e3f923153d774935647a341bc365ff5b0bb Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814134349799.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814141530725.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814141530725.png" new file mode 100644 index 0000000000000000000000000000000000000000..ff239f43b9546c39e21526d913500ecb2a6a37ad Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814141530725.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814141912888.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814141912888.png" new file mode 100644 index 0000000000000000000000000000000000000000..179b69e91c3d96a4b42963847437a616762b4e79 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814141912888.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814142044608.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814142044608.png" new file mode 100644 index 0000000000000000000000000000000000000000..9a79ed57b12851d7c7b54e91dde5860cb3720d75 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814142044608.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814142222974.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814142222974.png" new file mode 100644 index 0000000000000000000000000000000000000000..a86d477ca1e37b83c224ba507a36ac4bb843f60e Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814142222974.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814142241006.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814142241006.png" new file mode 100644 index 0000000000000000000000000000000000000000..3bfaaacfc7950a163061374ab9e3952a44734d06 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814142241006.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814142314782.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814142314782.png" new file mode 100644 index 0000000000000000000000000000000000000000..d37ad3e725838496be8b185f0009006c826c6ec1 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814142314782.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814142348511.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814142348511.png" new file mode 100644 index 0000000000000000000000000000000000000000..35234377e72de470d3f2be8c6c1fd19660105c78 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814142348511.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814143135644.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814143135644.png" new file mode 100644 index 0000000000000000000000000000000000000000..8a25b80f87e5cd6ee2b1efc5dddfb8f25ae625c7 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814143135644.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814143203487.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814143203487.png" new file mode 100644 index 0000000000000000000000000000000000000000..0f847808ac13ef9d9015e9f3d8d3a668827d42aa Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814143203487.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814143213079.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814143213079.png" new file mode 100644 index 0000000000000000000000000000000000000000..d052df498465646a291b46b4f3281b1a4d78f680 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814143213079.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151255325.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151255325.png" new file mode 100644 index 0000000000000000000000000000000000000000..5a655ceb819322904004cbcdbdf2358848070303 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151255325.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151409352.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151409352.png" new file mode 100644 index 0000000000000000000000000000000000000000..c457cfb56c9728ec4251c436d73c9b5bc8f47688 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151409352.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151416375.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151416375.png" new file mode 100644 index 0000000000000000000000000000000000000000..0b0bd41cc8f66411fd3bdb44ac5797a838c679e4 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151416375.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151440881.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151440881.png" new file mode 100644 index 0000000000000000000000000000000000000000..b4341643e5df469e141cb01696032f6d8b2dfb2a Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151440881.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151456351.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151456351.png" new file mode 100644 index 0000000000000000000000000000000000000000..c97eae964d1d7d5c7684fe7c5e3863c5222a9912 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151456351.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151522526.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151522526.png" new file mode 100644 index 0000000000000000000000000000000000000000..f3b5d5f4a10364335c01953880baba2376c4c0b5 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151522526.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151819447.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151819447.png" new file mode 100644 index 0000000000000000000000000000000000000000..ab12a7999c95117cc456e0cb6cf79dc0587a08f6 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151819447.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151841682.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151841682.png" new file mode 100644 index 0000000000000000000000000000000000000000..54658052d699cdcf2a9c98ae26ed17f055b74ed6 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814151841682.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814152225938.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814152225938.png" new file mode 100644 index 0000000000000000000000000000000000000000..24d6101faeb72783cf9c0f4b65a6c044a15e21ce Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814152225938.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814152233304.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814152233304.png" new file mode 100644 index 0000000000000000000000000000000000000000..7bf29db30bc3d2c01a352f33d97a65b8cf3149ad Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814152233304.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814152237975.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814152237975.png" new file mode 100644 index 0000000000000000000000000000000000000000..7bf29db30bc3d2c01a352f33d97a65b8cf3149ad Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814152237975.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814152247856.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814152247856.png" new file mode 100644 index 0000000000000000000000000000000000000000..d6f5bf3b19554844ac1faf105619abb92c8e2242 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814152247856.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814152259054.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814152259054.png" new file mode 100644 index 0000000000000000000000000000000000000000..74ad25160563f4bad47435f6b43be6e652f85866 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814152259054.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814153132555.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814153132555.png" new file mode 100644 index 0000000000000000000000000000000000000000..813b6fcd458b482d6c0ea89b3b768d1ac6b2b8d0 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814153132555.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814153748435.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814153748435.png" new file mode 100644 index 0000000000000000000000000000000000000000..8d448beedbf7cbea891d834daf3909ff6a2e6a2d Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814153748435.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814154750773.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814154750773.png" new file mode 100644 index 0000000000000000000000000000000000000000..fe8ad771e56430a8a3126d0d2a83aa0eb4d24aa9 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814154750773.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814155032448.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814155032448.png" new file mode 100644 index 0000000000000000000000000000000000000000..98242c4ea66dafdb3b009cc899886d8294cd1e41 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814155032448.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814155051387.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814155051387.png" new file mode 100644 index 0000000000000000000000000000000000000000..8cab0ad7de1fa266d95cc1772e434399b6988ad6 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814155051387.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814155628208.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814155628208.png" new file mode 100644 index 0000000000000000000000000000000000000000..6ea22b17d55f592e2755d8b555d1fa5e8c5192de Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814155628208.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814155752495.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814155752495.png" new file mode 100644 index 0000000000000000000000000000000000000000..bb1e4f6663ee98cfca690359f3206ff81cce61a7 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814155752495.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814155915955.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814155915955.png" new file mode 100644 index 0000000000000000000000000000000000000000..3ff7167d2f7d61b192ed1678fbb922a73c256a54 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814155915955.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814155933002.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814155933002.png" new file mode 100644 index 0000000000000000000000000000000000000000..3c57f7716ce05602aac6f6f9c5bdc84ee61f9674 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814155933002.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814155949999.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814155949999.png" new file mode 100644 index 0000000000000000000000000000000000000000..463486ceed7d6071ab4c7764bd03944b5a2c94ae Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814155949999.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814160924162.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814160924162.png" new file mode 100644 index 0000000000000000000000000000000000000000..611272cf17d00ede548d2e0a7ae39a4564418cf6 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814160924162.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814161512867.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814161512867.png" new file mode 100644 index 0000000000000000000000000000000000000000..f08dc58a5b1c9522d3fb023c57a33d613916856f Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814161512867.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814162257363.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814162257363.png" new file mode 100644 index 0000000000000000000000000000000000000000..bd28af97faf28ffa35da050ddcc5dcc6ab50d357 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814162257363.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814162307489.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814162307489.png" new file mode 100644 index 0000000000000000000000000000000000000000..7ddc95bcf7e7bf23521ac767f85848b9f3f9a2ea Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814162307489.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814162842038.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814162842038.png" new file mode 100644 index 0000000000000000000000000000000000000000..333896f612f80bb98a87e02c483224db8df38c90 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814162842038.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814181022711.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814181022711.png" new file mode 100644 index 0000000000000000000000000000000000000000..84a39b1fcc295f139bd3420cc9db8f883f1de2ca Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814181022711.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814181059810.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814181059810.png" new file mode 100644 index 0000000000000000000000000000000000000000..46f03dd490e8d995ec8449ca2a1accd3eee7f35f Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814181059810.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814181112081.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814181112081.png" new file mode 100644 index 0000000000000000000000000000000000000000..314be534bdf959db31a420e28be932a3c14f201a Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814181112081.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814181155186.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814181155186.png" new file mode 100644 index 0000000000000000000000000000000000000000..a3efc9e693c3c16bf8ab0408a308998f87505cb7 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814181155186.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814181927733.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814181927733.png" new file mode 100644 index 0000000000000000000000000000000000000000..77278a2dc71ba9e316d61d2c02ba0d7a992d07e1 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814181927733.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182020730.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182020730.png" new file mode 100644 index 0000000000000000000000000000000000000000..a5472af45e5e650a64a8e7127fb9173a1fb8b9c6 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182020730.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182034409.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182034409.png" new file mode 100644 index 0000000000000000000000000000000000000000..c72b18f742c0db8329b46f59ec466f4624d2ce11 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182034409.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182050676.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182050676.png" new file mode 100644 index 0000000000000000000000000000000000000000..037f997f2acae7401257b71126a0e9a9b1df56ca Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182050676.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182512346.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182512346.png" new file mode 100644 index 0000000000000000000000000000000000000000..cd4dfc87bfd16e3e864b993dbdbdb0f0d1cb3a81 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182512346.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182522372.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182522372.png" new file mode 100644 index 0000000000000000000000000000000000000000..cd4dfc87bfd16e3e864b993dbdbdb0f0d1cb3a81 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182522372.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182535354.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182535354.png" new file mode 100644 index 0000000000000000000000000000000000000000..19512ed995c33d6f551da977126be867a6ae28dc Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182535354.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182547603.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182547603.png" new file mode 100644 index 0000000000000000000000000000000000000000..73d2af5d1e48735116a1bd913e99689b6cf0aca4 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182547603.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182606386.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182606386.png" new file mode 100644 index 0000000000000000000000000000000000000000..deaf9d74249c818214bd3abebcf956d3641ed5f4 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182606386.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182618283.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182618283.png" new file mode 100644 index 0000000000000000000000000000000000000000..b1f7ea21bec391d14e252df27ec86428e88287e4 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814182618283.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814183418474.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814183418474.png" new file mode 100644 index 0000000000000000000000000000000000000000..475e203e4966a58e277221907db2f93c21e6e06b Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814183418474.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814184416348.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814184416348.png" new file mode 100644 index 0000000000000000000000000000000000000000..dd5ff89dcbb27cb5f30106c20d1dec6bb2decab7 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814184416348.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814184809027.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814184809027.png" new file mode 100644 index 0000000000000000000000000000000000000000..bf45da8d726bc352f0567fe06b9bd7e84e8d3130 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814184809027.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814184815898.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814184815898.png" new file mode 100644 index 0000000000000000000000000000000000000000..59270b2f04d50904fa5fce3371d407fc0b8b0f01 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814184815898.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814185220725.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814185220725.png" new file mode 100644 index 0000000000000000000000000000000000000000..821fec04e3e88356da339ab4629b00f549e9044b Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814185220725.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814185236668.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814185236668.png" new file mode 100644 index 0000000000000000000000000000000000000000..40f442f2dd778d821cb8a7ed18ab52e08b191f5a Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814185236668.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814185415242.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814185415242.png" new file mode 100644 index 0000000000000000000000000000000000000000..ed7834b5a5b6eb8ee06cb3e8225b8ba4564b639c Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814185415242.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814185448434.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814185448434.png" new file mode 100644 index 0000000000000000000000000000000000000000..2bd9a21a67de898f71e13eb328c549838783589a Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814185448434.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814185502940.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814185502940.png" new file mode 100644 index 0000000000000000000000000000000000000000..432e56a7ac98fda5c20ab330ae78d4c84cd8e622 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814185502940.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814185505769.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814185505769.png" new file mode 100644 index 0000000000000000000000000000000000000000..432e56a7ac98fda5c20ab330ae78d4c84cd8e622 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814185505769.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814190419664.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814190419664.png" new file mode 100644 index 0000000000000000000000000000000000000000..a63c91d1b5599302184859a39057cb597b7a1e8e Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814190419664.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814222204119.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814222204119.png" new file mode 100644 index 0000000000000000000000000000000000000000..07609ec5bcb6829635b8bfdfb42d7b4d0cc22785 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814222204119.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814222221561.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814222221561.png" new file mode 100644 index 0000000000000000000000000000000000000000..68f4010b56df2ad60ce0bf6bd1a3fe775cff7d72 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814222221561.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814225750443.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814225750443.png" new file mode 100644 index 0000000000000000000000000000000000000000..ad518c15e9a2fd690b9fe3df6d46f6cb7ed0d795 Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814225750443.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814225759870.png" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814225759870.png" new file mode 100644 index 0000000000000000000000000000000000000000..47ef3b9285ea801997ae6a6937897bb8ba686aaf Binary files /dev/null and "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.assets/image-20240814225759870.png" differ diff --git "a/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.md" "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.md" new file mode 100644 index 0000000000000000000000000000000000000000..7804fd8d984eaa7fa69348a806be9bee9653c3c8 --- /dev/null +++ "b/\344\270\212\346\211\213issue_\344\275\234\345\223\201\346\226\207\344\273\266\345\244\271/\351\273\204\351\223\255\346\266\233-\351\252\214\350\257\201Linux_Kernel_Cgroup_V1\345\222\214V2\345\220\204\345\255\220\346\250\241\345\235\227\347\232\204\345\212\237\350\203\275/tst-cgroup/\346\265\213\350\257\225\346\212\245\345\221\212.md" @@ -0,0 +1,1547 @@ +# 测试环境 + +**OpenCloudOS 8:** + +腾讯云:2cpu 2G,NUMA节点为1,x86架构 + +本地qemu:8cpu 8G NUMA节点为2, 镜像是OpencloudOS8.8的qcow2格式镜像,x86架构 + +**OpenCloudOS 9:** + +腾讯云:2cpu 2G,NUMA节点为1,x86架构 + +本地qemu:8cpu 8G NUMA节点为2,镜像是OpencloudOS9.2的Minimal格式镜像,x86架构 + +**OpenCloudOS Stream 23:** + +本地qemu:8cpu 8G NUMA节点为2,镜像是OpencloudOS Stream 23的Minimal格式镜像,x86架构 + +# cgroup version1 + +## blkio + +主要是限制cgroup对IO的使用,两种控制策略,weight和throttling。 + +### weight策略 + +**需要开启的内核配置:** + +- CONFIG_BLK_CGROUP + +**接口文件:** + +- **blkio.bfq.weight:** 读写文件。指定每个cgroup组的权重。这是组在所有设备上的默认权重,除非被blkio.bfq.weight_device覆盖。目前允许的范围是1到1000 + +- **blkio.bfq.weight_device:** 读写文件。指定每个cgroup中每个设备的权重,覆盖blkio.bfq.weight + +- **blkio.bfq.io_service_bytes:** 只读文件。cgroup传输到磁盘/从磁盘传输的字节数 + +- **blkio.bfq.io_serviced:** 只读文件。cgroup向磁盘发出的 IO(bio)数量。 + +**测试用例:** + +- **cgroup-v1-blkio-bfq-weight:** 测试接口文件blkio.bfq.weight。 +- **cgroup-v1-blkio-bfq-weight_device:** 测试接口文件blkio.bfq.weight_device。 + +### throttling策略 + +**需要开启内核配置:** + +- CONFIG_BLK_CGROUP +- CONFIG_BLK_DEV_THROTTLING + +**接口文件:** + +- **blkio.throttle.read_bps_device:** 读写文件。设置从设备读取速率的上限。单位是`byets/s` +- **blkio.throttle.write_bps_device:** 读写文件。设置对设备的写速率上限。单位是`byets/s` +- **blkio.throttle.read_iops_device:** 读写文件。设置从设备读取速率的上限。单位是`IO/s` +- **blkio.throttle.write_iops_device:** 读写文件。设置对设备的写速率上限。单位是`IO/s` +- **bklio.throttle.io_service_bytes:** 只读文件。记录自从cgroup创建以来,对于每种操作的已完成的向磁盘传输/从磁盘传输的字节数。 +- **blkio.throttle.io_serviced:** 只读文件。记录自从cgroup创建以来,对于每种操作的已完成的I/O操作数。 + +**测试用例:** + +- **cgroup-v1-blkio-throttle-read_bps_device:** 测试接口文件blkio.throttle.read_bps_device +- **cgroup-v1-blkio-throttle-write_bps_device:** 测试接口文件blkio.throttle.write_bps_device +- **cgroup-v1-blkio-throttle-read_iops_device:** 测试接口文件blkio.throttle.read_iops_device +- **cgroup-v1-blkio-throttle-write_iops_device:** 测试接口文件blkio.throttle.write_iops_device + +### 层次结构 + +throttling实现了层次结构支持,但只有root cgroup启用了sane_behavior选项才启用了throttling层次结构。如果没有启用,则实际上会将所有cgroup视为同一级别。目前这是一个开发选项,尚未公开 + +### 测试结果 + +**OpenCloudOS 8:** + +腾讯云: + +![image-20240813154623977](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813154623977.png) + +本地qemu: + +![image-20240813233107878](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813233107878.png) + +**OpenCloudOS 9:** + +腾讯云: + +![image-20240814131958155](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814131958155.png) + +本地qemu: + +![image-20240814151255325](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814151255325.png) + +cgroup-v1-blkio-throttle-write_bps_device和cgroup-v1-blkio-throttle-write_iops_device测试用例测试失败,原因不明,不能正常地限制硬盘写速度 + +**OpenCloudOS Stream 23:** + +本地qemu: + +![image-20240814181022711](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814181022711.png) + +cgroup-v1-blkio-throttle-write_bps_device和cgroup-v1-blkio-throttle-write_iops_device测试用例测试失败,不能正常地限制硬盘写速度 + +## cpu + +主要是限制cgroup对CPU的使用,两种控制策略,权重比例设置和周期使用时间上限。 + +### CPU使用周期使用时间上限 + +**接口文件:** + +- **cpu.cfs_period_us:** 读写文件。规定CPU的时间周期(微秒),最大值是1s,最小值是1000微妙。 +- **cpu.cfs_quota_us:** 读写文件。在单位时间内(即cpu.cfs_period_us设定值)可用的CPU最大时间(单位是微秒)。cpu.cfs_quota_us值可以大于cpu.cfs_period_us的值,例如在一个双CPU的系统内,想要一个cgroup内的进程充分地利用2个CPU,可以设定cpu.cfs_quota_us为200000及cpu.cfs_period_us为100000 +- **cpu.stat: ** 只读文件。统计信息,包含: + - nr_periods:经历了几个cfs_period_us周期 + - nr_throttled:task被限制的次数 + - throtled_time:表示task被限制的总时长 + +**测试用例:** + +- **cgroup-v1-cpu-cfs-001:** 测试cpu.cfs_period_us和cpu.cfs_quota_us接口文件,cfs_quota_us小于cfs_period_us的情况 +- **cgroup-v1-cpu-cfs-002:** 测试cpu.cfs_period_us和cpu.cfs_quota_us接口文件,cfs_quota_us是cfs_period_us两倍的情况 + +### 权重比例设定CPU的分配 + +**接口文件:** + +- **cpu.shares:** 读写文件。CPU比重分配,通过一个整数的数值调节cgroup所占用的CPU时间。 + +**测试用例: ** + +- **cgroup-v1-cpu-shares:** 测试cpu.shares接口文件 + +### 测试结果 + +**OpenCloudOS 8:** + +腾讯云: + +![image-20240813154844123](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813154844123.png) +![image-20240813155220037](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813155220037.png) + +本地qemu: + +![image-20240813233120405](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813233120405.png) +![image-20240813233137341](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813233137341.png) + +**OpenCloudOS 9:** + +腾讯云: + +![image-20240814132028781](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814132028781.png) +![image-20240814132044757](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814132044757.png) + +本地qemu: + +![image-20240814151409352](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814151409352.png) +![image-20240814151416375](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814151416375.png) + +**OpenCloudOS Stream 23:** + +本地qemu: + +![image-20240814181059810](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814181059810.png) +![image-20240814181112081](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814181112081.png) + +## cpuacct + +显示cgroup中任务所使用的CPU资源 + +**需要开启的内核配置:** + +- CONFIG_CGROUP_CPUACCT + +**接口文件:** + +- **cpuacct.stat:** 只读文件。报告cgroup的所有任务使用的用户和内核CPU时间,单位为USER_HZ +- **cpuacct.usage:** 只读文件。记录该cgroup中所有进程的CPU使用总时间,以纳秒为单位 +- **cpuacct.usage_percpu:** 只读文件。记录该cgroup中所有进程在每个CPU上的使用时间,以纳秒为单位 +- **cpuacct.usage_user:** 只读文件。报告一个cgroup中所有任务使用用户态CPU的总时间,以纳秒为单位 +- **cpuacct.usage_percpu_user:** 只读文件。报告一个cgroup中所有任务在每个CPU上使用用户态CPU的时间,以纳秒为单位 +- **cpuacct.usage_sys:** 只读文件。报告一个cgroup中所有任务在CPU上使用内核态CPU的时间,以纳秒为单位 +- **cpuacct.usage_percpu_sys:** 只读文件。报告一个cgroup中所有任务在每个CPU上使用内核态CPU的时间 +- **cpuacct.usage_all:** 只读文件。详细输出文件cpuacct.usage_percpu_user和cpuacct.usage_percpu_sys的内容 + +**测试用例:** + +- **cgroup-v1-cpuacct-stat:** 测试cpuacct.stat接口文件 +- **cgroup-v1-cpuacct-usage:** 测试cpuacct.usage接口文件 +- **cgroup-v1-cpuacct-usage_percpu:** 测试cpuacct.usage_percpu接口文件 +- **cgroup-v1-cpuacct-usage_user:** 测试cpuacct.usage_user接口文件 +- **cgroup-v1-cpuacct-usage_percpu_user:** 测试cpuacct.usage_percpu_user接口文件 +- **cgroup-v1-cpuacct-usage_sys:** 测试cpuacct.usage_sys接口文件 +- **cgroup-v1-cpuacct-usage_percpu_sys:** 测试cpuacct.usage_percpu_sys接口文件 +- **cgroup-v1-cpuacct-usage_all:** 测试cpuacct.usage_all接口文 + +**测试结果:** + +**OpenCloudOS 8:** + +腾讯云: + +![image-20240813154921611](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813154921611.png) + +cgroup-v1-cpuacct-usage_all、cgroup-v1-cpuacct-usage_percpu_sys和cgroup-v1-cpuacct-usage_sys测试用例失败,原因是这些接口文件不能正确统计cpu内核态使用时间 + +本地qemu: + +![image-20240813233232772](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813233232772.png) + +cgroup-v1-cpuacct-usage_all、cgroup-v1-cpuacct-usage_percpu_sys和cgroup-v1-cpuacct-usage_sys测试用例失败,原因是这些接口文件不能正确统计cpu内核态使用时间 + +**OpenCloudOS 9:** + +腾讯云: + +![image-20240814132114591](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814132114591.png) + +本地qemu: + +![image-20240814151440881](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814151440881.png) + +**OpenCloudOS Stream 23:** + +本地qemu: + +![image-20240814181155186](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814181155186.png) + +## cpuset + +为cgroup分配指定的CPU和内存节点 + +以下规则使用每个cgroup: + +- 它的 CPU 和内存节点必须是其父级的子集。 +- 除非其父级被标记为exclusive,否则它不能被标记为exclusive。 +- 如果其 CPU 或内存是独占的,则它们可能不会与任何兄弟cgroup重叠 +- 必须指定当前cgroup的cpuset.mems和cpuset.cpus,才能将进程移入当前cgroup + +### cpu相关 + +**接口文件:** + +- **cpuset.cpus:** 读写文件。允许cgroup中的进程使用的CPU列表。 +- **cpuset.effective_cpus:** 只读文件。显示了当前cgroup中实际可用于分配给进程的CPU核心列表,它考虑了上级cgroup的限制和当前cgroup的cpuset.cpus配置,从而提供了一个最终的、实际可用的CPU核心集合 +- **cpuset.cpu_exclusive:** 读写文件。cgroup是否独占cpuset.cpus中分配的cpu。默认值为0,表示共享;1表示独占。如果设置为1,其他cgroup内的cpuset.cpus值不能包含有该cpuset.cpus内的值 +- **cpuset.sched_load_balance:** 读写文件。cgroup的cpu压力是否会被平均到cpuset中的多个cpu上。默认值1,启用负载均衡;0表示禁用。注意:如果任意上级cgroup中启用负载均衡,则在cgroup中设定这个标签没有任何效果,因为已经在较高一级cgroup中处理了负载均衡。因此,要在cgroup中禁用负载平衡,还要在每个上级cgroup中禁用负载平衡。 + +**测试用例:** + +- **cgroup-v1-cpuset-cpus:** 测试cpuset.cpus接口文件 +- **cgroup-v1-cpuset-cpu_exclusive:** 测试cpu_exclusive接口文件 +- **cgroup-v1-cpuset-sched_load_balance:** 测试cpuset.sched_load_balance接口文件 + +### memory相关 + +**接口文件:** + +- **cpuset.mems:** 读写文件。允许cgroup中的进程使用的内存节点列表。 +- **cpuset.effective_mems:** 只读文件。显示当前cgroup中实际可用于分配给进程的内存节点列表,同样考虑了上级cgroup的限制和当前cgrouop的cpuset.mems配置 +- **cpuset.mem_exclusive:** 读写文件。是否独占memory。默认值0表示共享,1表示独占。如果设置为1,其他cgroup内的cpuset.mems值不能包含有该cpuset.mems内的值 +- **cpuset.memory_migrate: * 读写文件。用来指定当cpuset.mems中的值更改时是否应该讲内存中的页迁移到新节点。默认情况下是0表示禁止内存迁移,且页就保留在原来分配的节点中,即使在cpuset.mems中现已不再指定这个节点。如果设置为1,则该系统会将页迁移到由cpuset.mems指定的新参数中的内存节点中。 +- **cpuset.memory_spread_page:** 读写文件。如果被设置了,将该cpuset中进程上下文是申请的page cache平均分布到cpuset中的各个节点中。默认值是0表示不启用。设置为1表示启用 + +**测试用例:** + +- **cgroup-v1-cpuset-mems:** 测试cpuset.mems接口文件 +- **cgroup-v1-cpuset-mem_exclusive:** 测试cpuset.mem_exclusive接口文件 +- **cgroup-v1-cpuset-memory_migrate-001:** 测试memory_migrate接口文件, 测试启用内存迁移 +- **cgroup-v1-cpuset-memory_migrate-002:** 测试memory_migrate接口文件, 测试不启用内存迁移 +- **cgroup-v1-cpuset-memory_spread_page-001:** 测试cpuset.memory_spread_page接口文件,测试不将page cache平均分布道各个节点中 +- **cgroup-v1-cpuset-memory_spread_page-002:** 测试cpuset.memory_spread_page接口文件,测试将page cache平均分布道各个节点中 + +### 测试结果 + +**OpenCloudOS 8:** + +腾讯云: + +![image-20240813155138963](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813155138963.png) + +部分测试用例需要系统有两个numa节点及以上,所以跳过测试 + +本地qemu: + +![image-20240814102516235](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814102516235.png) + +**OpenCloudOS 9:** + +腾讯云: + +![image-20240814132156950](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814132156950.png) + +部分测试用例需要系统有两个numa节点及以上,所以跳过测试 + +本地qemu: + +![image-20240814151456351](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814151456351.png) + +**OpenCloudOS Stream 23:** + +本地qemu: + +![image-20240814181927733](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814181927733.png) + +cgroup-v1-cpuset-cpu_exclusive测试失败,cpuset.cpu_exclusive无法发挥正常作用,无法独占cpu + +## devices + +来跟踪和执行对设备文件的打开和关闭限制。设备cgroup为每个cgroup关联一个设备接入白名单,白名单有四个字段: + +- type:a(all), c(char), b(block) +- 主设备号 +- 副设备号 +- 访问权限(r ,w, m(mknod)) + +**需要开启的内核配置:** + +- CONFIG_CGROUP_DEVICE + +**层次结构:** devices控制器通过确保子cgroup永远不会拥有比其父cgroup更多的访问权限来维护层次结构。每次将条目写入cgroup的devices.deny文件时,它的所有子cgroup都会从白名单中删除该条目,并且所有本地设置的白名单条目都会被重新评估。如果某个本地设置的白名单条目提供了比父cgroup更多的访问权限,它将从白名单中删除 + +**接口文件:** + +- **devices.allow:** 读写文件。允许访问的设备。文件包含4个字段:type(设备类型),major(主设备号),minor(次设备号),access(访问方式) +- **devices.deny:** 读写文件。禁止访问的设备,格式如devices.allow +- **devices.list:** 只读文件。显示目前允许被访问的设备列表 + +**测试用例:** + +- **cgroup-v1-devices-001:** 测试devices.allow接口文件和devices.deny接口文件 +- **cgroup-v1-devices-002:** 测试deivces的层级结构 + +**测试结果:** + +**OpenCloudOS 8:** + +腾讯云: + +![image-20240813155239339](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813155239339.png) + +本地qemu: + +![image-20240814102535908](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814102535908.png) + +**OpenCloudOS 9:** + +腾讯云: + +![image-20240814132225566](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814132225566.png) + +本地qemu: + +![image-20240814151522526](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814151522526.png) + +**OpenCloudOS Stream 23: ** + +本地qemu: + +![image-20240814182020730](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814182020730.png) + +## freezer + +可以启动和停止cgroup中的task + +**需要开启的内核配置:** + +- CONFIG_CGROUP_FREEZER + +**注意事项:** + +- 挂起进程时,会连同子进程一同挂起 +- 不能将进程移动到处于FROZEN状态的cgroup中 +- 只有FROZEN状态和THAWED状态可以被写进freezer.state中,FREEZING状态则不能,只能读取它 +- root cgroup是不可冻结的 + +**接口文件:** + +- **freezer.state: ** 读写文件 + - cgroup的三种状态 + - FROZEN:挂起该cgroup中的任务 + - FREEZING:该系统正在挂起该cgroup中的任务 + - THAWED:已经恢复该cgroup中的任务 + - 当被读取时,返回该group的有效状态(也就是上面三种状态)。这是自己和父cgroup状态的结合。如果有FREEZING,则cgroup的状态为FREEZING + - 当属于cgroup及其子cgroup所有任务被冻结时,cgroup转换为FROZEN。注意,当一个新任务被添加到cgroup或它的子cgroup中,cgroup会从FROZEN状态恢复到FREZING状态,直到新任务被冻结 + - 写入时,设置cgroup的self-state。允许两个值:FROZEN和THAWED。如果写了FROZEN,则cgroup和它的所有子cgroup一起进入FROZEN状态 + - 如果写入THAWED,则cgroup的self-state更改为THAWED。注意,如果父cgroup状态仍处于FROZEN,则有效状态可能不会被更改为THAWED。如果cgroup的有效状态变为THAWED,则由于cgroup而冻结的所有子cgroup将离开FROZEN状态 +- **freezer.self_freezing: ** 只读文件。显示self-state。如果是0,则为THAWED状态;否则为1。如果最后一次写入了FORZEN,这个值为1 +- **freezer.parent_freezing: ** 只读文件。显示parent-state。如果cgroup的父cgroup不是FROZEN,则为0;否则为1 + +**测试用例: ** + +- **cgroup-v1-freezer-001:** 测试freezer的正常使用,即停止task和再次启动task +- **cgroup-v1-freezer-002:** 测试freezer的层次结构 + +**测试结果:** + +**OpenCloud 8:** + +腾讯云: + +![image-20240813155303515](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813155303515.png) + +本地qemu: + +![image-20240814102549259](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814102549259.png) + +**OpenCloud 9:** + +腾讯云: + +![image-20240814132303942](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814132303942.png) + +本地qemu: + +![image-20240814151819447](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814151819447.png) + +**OpenCloud Stream 23:** + +本地qemu: + +![image-20240814182034409](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814182034409.png) + +## hugetlb + +允许限制cgroup的hugepage使用量和hugepage预留。 + +**需要的内核配置:** + +- CONFIG_CGROUP_HUGETLB +- CONFIG_HUGETLB_PAGE +- CONFIG_HUGETLBFS + +### hugepage使用量 + +**接口文件:** + +- **hugetlb.2MB.limit_in_bytes:** 读写文件。设置hugepage大小为2MB的hugepage使用量限制 +- **hugetlb.1GB.limit_in_bytes:** 读写文件。设置hugepage大小为1GB的hugepage使用量限制 +- **hugetlb.2MB.max_usage_in_bytes:** 只读文件。显示hugepage大小为2MB最大hugepages使用记录 +- **hugetlb.1GB.max_usage_in_bytes:** 只读文件。显示hugepage大小为1GB最大hugepages使用记录 +- **hugetlb.2MB.usage_in_bytes:** 只读文件。显示hugepages大小为2MB的hugepage的当前使用量 +- **hugetlb.1GB.usage_in_bytes:** 只读文件。显示hugepages大小为1GB的hugepage的当前使用量 +- **hugetlb.2MB.failcnt:** 只读文件。显示hugepage大小为2MB由于hugepage使用限制导致的分配失败 +- **hugetlb.1GB.failcnt:** 只读文件。显示hugepage大小为1GB由于hugepage使用限制导致的分配失败 + +**测试用例:** + +- **cgropu-v1-hugetlb-limit_in_bytes-001:** 测试hugetlb.2MB.limit_in_bytes接口文件,超过限制 +- **cgroup-v1-hugetlb-limit_in_bytes-002:** 测试hugetlb.2MB.limit_in_bytes接口文件, 不超过限制 +- **cgroup-v1-hugetlb-limit_in_bytes-003:** 测试hugetlb.1GB.limit_in_bytes接口文件,超过限制 +- **cgroup-v1-hugetlb-limit_in_bytes-004:** 测试hugetlb.1GB.limit_in_bytes接口文件, 不超过限制 + +### hugepage预留 + +**接口文件:** + +- **hugetlb.2MB.rsvd.limit_in_bytes:** 读写文件。设置hugepage大小为2MB的hugepage预留限制 +- **hugetlb.1GB.rsvd.limit_in_bytes:** 读写文件。设置hugepage大小为1GB的hugepage预留限制 +- **hugetlb.2MB.rsvd.max_usage_in_bytes:** 只读文件。显示hugepage大小为2MB最大hugepages预留记录 +- **hugetlb.1GB.rsvd.max_usage_in_bytes:** 只读文件。显示hugepage大小为1GB最大hugepages预留记录 +- **hugetlb.2MB.rsvd.usage_in_bytes:** 只读文件。显示hugepages大小为2MB的hugepage的当前预留量 +- **hugetlb.1GB.rsvd.usage_in_bytes:** 只读文件。显示hugepages大小为1GB的hugepage的当前预留量 +- **hugetlb.2MB.rsvd.failcnt:** 只读文件。显示hugepage大小为2MB由于hugepage预留限制导致的分配失败 +- **hugetlb.1GB.rsvd.failcnt:** 只读文件。显示hugepage大小为1GB由于hugepage预留限制导致的分配失败 + +**测试用例:** + +- **cgropu-v1-hugetlb-rsvd-limit_in_bytes-001:** 测试hugetlb.2MB.rsvd.limit_in_bytes接口文件,超过限制 +- **cgroup-v1-hugetlb-rsvd-limit_in_bytes-002:** 测试hugetlb.2MB.rsvd.limit_in_bytes接口文件, 不超过限制 +- **cgroup-v1-hugetlb-rsvd-limit_in_bytes-003:** 测试hugetlb.1GB.rsvd.limit_in_bytes接口文件,超过限制 +- **cgroup-v1-hugetlb-rsvd-limit_in_bytes-004:** 测试hugetlb.1GB.rsvd.limit_in_bytes接口文件, 不超过限制 + +### 测试结果 + +**OpenCloudOS 8:** + +腾讯云: + +![image-20240813161618198](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813161618198.png) + +跳过的测试是需要在hugepage大小为1G的情况下测试,而rsvd测试失败是因为系统hugetlb.\.rsvd.limit_in_bytes接口文件。 + +本地qemu: + +![image-20240814102626444](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814102626444.png) + +rsvd测试失败是因为系统hugetlb.\.rsvd.limit_in_bytes接口文件。 + +修改hugepage大小为1G后测试:(系统内存至少有8G) + +![image-20240814105728307](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814105728307.png) + +**OpenCloudOS 9:** + +腾讯云: + +![image-20240814132333013](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814132333013.png) + +本地qemu: + +![image-20240814151841682](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814151841682.png) + +修改hugepage大小为1G后测试: + +![image-20240814153748435](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814153748435.png) + +**OpenCloudOS Stream 23:** + +本地qemu: + +![image-20240814182050676](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814182050676.png) + +修改hugepage大小为1G后测试: + +![image-20240814183418474](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814183418474.png) + +## memory + +主要是限制cgroup所能使用的内存上限 + +**需要的内核配置:** + +- CONFIG_MEMCG +- CONFIG_SWAP + +**接口文件:** + +- **memory.usage_in_bytes:** 只读文件。显示当前内存使用情况,单位为字节 +- **memory.memsw.usage_in_bytes:** 只读文件。显示当前内存+交换的使用情况,单位为字节 +- **memory.max_uasge_in_bytes:** 只读文件。显示记录的最大内存使用量,单位为字节 +- **memory.memsw.max_usage_in_bytes:** 只读文件。显示记录的最大内存+交换使用量,单位为字节 +- **memory.failcnt:** 只读文件。显示内存达到memory.limit_in_bytes设定的限制值的次数 +- **memory.memsw.failcnt:** 只读文件。显示内存+swap空间限制达到在memory.memsw.limit_in_bytes设定的值的次数 +- **memory.limit_in_bytes:** 读写文件。设定最大的内存使用量(包括文件缓存),可以加单位(k/K, m/M, g/G)不加单位默认为bytes。不能限制root cgroup。写入-1删除现有的限制 +- **memory.soft_limit_in_bytes:** 读写文件。和memory.limit_in_bytes的差异是,这个限制并不会阻止进程使用超过限额的内存,只是在系统内存不足时,会优先回收超过限额的进程占用的内存,使之向限定值靠拢。该值应小于memory.limit_in_bytes设定值 +- **memory.memsw.limit_in_bytes:** 读写文件。设定最大的内存+swap的用量之和。可以加单位(k/K, m/M, g/G)不加单位默认为bytes。不能限制根cgroup。写入-1删除现有的限制 +- **memory.force_empty:** 只写文件。当写入0时,清空该group的所有内存页。该选项只有在当前group没有tasks才可以使用。删除cgroup前请使用memory.force_empty以避免将不再使用的页面缓存移动到它的上级cgroup中 +- **memory.swappiness:** 读写文件。将内核倾向设定为换出这个cgroup中任务所使用的进程内存,而不是从页缓冲中再生页面。这也是在/proc/sys/vm/swappiness中设定的使用同一方法为整个系统设定的内核倾向。默认值为60,低于这个值会降低内核换出进程内存的倾向,将其设定为0则完成不会为cgroup中的任务换出进程内存。高于这个值将提高内核换出进程内存的倾向,等于100时内核将开始换出作为这个cgroup中进程的地址空间的一部分页面。不能更改一下群组的swappniess:根cgroup,它使用在/proc/sys/vm/swappiness中设定的swappiness。 +- **cgroup.event_control:** 只写文件。event_fd()的接口 +- **memory.pressure_level:** 读写文件。设置内存压力通知。压力级别通知用于监控内存分配成本;基于压力,应用程序可以实现不同的内存资源管理策略。 +- **memory.oom_control:** 读写文件。当进程出现Out of Memory时,是否进行kill操作。默认值0,表示kill;设置为1时,进程将进入睡眠状态,等待内存充足时被唤醒 + - oom_kill_disable:当设置为0时,表示在这个cgroup内存不足时,OOM killer是启用的,可以杀死大量占用内存的进程来释放内存;当值为1时,表示禁用OOM killer,即使内存不足也不会自动杀死进程 + - under_oom:当值为0时,表示当前没有OOM条件发生在这个cgroup中;当值为1时,表示这个cgroup目前正处于oom状态,即系统已经检测到内存不足的情况,并可能正在尝试杀死一些进程来释放内存 + - oom_kill:这个字段显示了由于OOM条件而被杀死的进程数量。每次OOM killer杀死cgroup中的一个进程时,这个计数器就会增加 + +**测试用例:** + +- **cgroup-v1-memory-limit_in_bytes:** 测试memory.limit_in_bytes接口文件,使用了memory.max_uasge_in_bytes和memory.failcnt接口文件 +- **cgroup-v1-memory-soft_limit_in_bytes:** 测试memory.soft_limit_in_bytes控制文件 +- **cgroup-v1-memory-memsw-limit_in_byte:** 测试memory.memsw.limit_in_bytes接口文件,使用了memory.memsw.max_uasge_in_bytes和memory.memsw.failcnt接口文件 +- **cgroup-v1-memory-swappiness-001:** 测试memory.swappiness控制文件,当swappiness为0时,内存不会被交换到swap空间 +- **cgroup-v1-memory-swappiness-002:** 测试memory.swappiness控制文件,当swappiness为100时,内存会被交换到swap空间 +- **cgroup-v1-memory-pressure_level:** 测试memory.pressure_level控制文件,设置内存压力通知 +- **cgroup-v1-memory-oom_control-001:** 测试memory.oom_control接口文件,默认是启用状态 +- **cgroup-v1-memory-oom_control-002:** 测试memory.oom_control接口文件,禁用oom_control + +**测试结果:** + +**OpenCloudOS 8:** + +腾讯云: + +![image-20240814160924162](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814160924162.png) + +cgroup-v1-memory-swappiness-001/002测试跳过的原因是系统没有设置swapfile + +本地qemu: + +![image-20240814103735716](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814103735716.png) + +**OpenCloudOS 9:** + +腾讯云: + +![image-20240814162842038](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814162842038.png) + +cgroup-v1-memory-swappiness-001/002测试跳过的原因是系统没有设置swapfile + +本地qemu: + +![image-20240814153132555](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814153132555.png) + +**OpenCloudOS Stream 23:** + +本地qemu: + +![image-20240814182522372](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814182522372.png) + +## net_cls + +使用等级标识符(classid)标记网络数据包,可允许linux流量控制程 + +序(traffic controller, tc)识别从具体cgroup中生成的数据包,为来自不同cgroup的报文分配不同的优先级 + +**需要开启的内核配置:** + +- CONFIG_CGROUP_NET_CLASSID + +**接口文件:** + +- **net_cls.classid:** 读写文件。包含一个说明流量控制句柄的十六进制的值,初始值为0。。这些句柄的格式为0xAAAABBBB,其中AAAA是十六进制主设备号,BBBB是十六进制副设备号。 + +**测试用例:** + +- **cgroup-v1-net_cls-001:** 测试设置带宽限制的情况 +- **cgroup-v1-net_cls-002:** 测试不设置带宽限制的情况 + +**测试结果:** + +**OpenCloudOS 8:** + +腾讯云: + +![image-20240813164446290](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813164446290.png) + +本地qemu: + +![image-20240814102723332](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814102723332.png) + +**OpenCloudOS 9:** + +腾讯云: + +![image-20240814133153525](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814133153525.png) + +本地qemu: + +![image-20240814152225938](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814152225938.png) + +**OpenCloudOS Stream 23:** + +本地qemu: + +![image-20240814182535354](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814182535354.png) + +## net_prio + +允许设置各种应用程序产生的网络流量的优先级 + +**需要开启的内核配置:** + +- CONFIG_CGROUP_NET_PRIO + +**接口文件:** + +- **net_prio.ifpriomap:** 读写文件。该文件包含分配给来自该组进程的流量的优先级映射。这些流量从不同的接口流出系统。 + +**测试用例:** + +- **cgroup-v1-net_prio:** 测试net_prio.ifpriomap是否能成功设置 + +**测试结果:** + +**OpenCloudOS 8:** + +腾讯云: + +![image-20240813164459881](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813164459881.png) + +本地qemu: + +![image-20240814102741707](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814102741707.png) + +**OpenCloudOS 9:** + +腾讯云: + +![image-20240814133210805](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814133210805.png) + +本地qemu: + +![image-20240814152237975](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814152237975.png) + +**OpenCloudOS Stream 23:** + +本地qemu: + +![image-20240814182547603](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814182547603.png) + +## perf_event + +该层级中的所有cgroup可以使用perf工具对这些进程和线程监控,没有可供调节的参数 + +**测试用例:** + +- **cgroup-v1-perf_event:** 测试使用perf监控cgroup + +**测试结果:** + +**OpenCloudOS 8:** + +腾讯云: + +![image-20240813164512233](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813164512233.png) + +本地qemu: + +![image-20240814102757182](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814102757182.png) + +**OpenCloudOS 9:** + +腾讯云: + +![image-20240814133229822](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814133229822.png) + +本地qemu: + +![image-20240814152247856](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814152247856.png) + +**OpenCloudOS Stream 23:** + +本地qemu: + +![image-20240814182606386](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814182606386.png) + +## pids + +允许cgroup在达到一定限制后阻止任何新任务被fork()或clone() + +**需要开启的内核配置:** + +- CONFIG_CGROUP_PIDS + +**接口文件:** + +- **pids.max:** 读写文件。设置最大任务数,不能在root cgroup中使用。默认值是max +- **pids.current:** 只读文件。目前cgroup运行的任务数,pids.current有可鞥大于pids.max,通过设置pids.max小于pids.current实现,但是不可能通过fork和clone实现 +- **pids.events:** 只读文件。包含事件计数器: + - max: 由于自身或父cgroup达到限制,cgroup 中 fork 失败的次数 + +**测试用例: ** + +- **cgroup-v1-pids-001:** 测试pids.max控制文件, 进程数超过限制 +- **cgroup-v1-pids-002:** 测试pids.max控制文件, 进程数不超过限制 +- **cgroup-v1-pids-003:** 测试层次结构 + +**测试结果:** + +**OpenCloudOS 8:** + +腾讯云: + +![image-20240813164526945](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813164526945.png) + +本地qemu: + +![image-20240814141530725](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814141530725.png) + +**OpenCloudOS 9:** + +腾讯云: + +![image-20240814133341911](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814133341911.png) + +本地qemu: + +![image-20240814152259054](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814152259054.png) + +**OpenCloudOS Stream 23:** + +本地qemu: + +![image-20240814182618283](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814182618283.png) + +# cgroup version2 + +## 核心接口文件 + +### cgroup.type + +存在于非root cgroup上的读写单值文件 + +读取时,表示该cgroup当前的类型,可以是下列值之一: + +- domain:正常有效的域cgroup +- domain threaded:作为线程子树根的线程域cgroup +- domain invalid:处于无效状态的cgroup,无法填充或启用控制器,可能允许其成为线程cgroup +- threaded:线程cgroup,是线程子树的成员 + +通过将threaded写入此文件,可以将cgroup转变为线程cgroup + +### cgroup.controllers + +所有cgroup上都存在的只读空格分隔值文件 + +它显示了cgroup可用的所有控制器的空格分隔值列表。控制器没有排序 + +### cgroup.subtree_control + +所有cgroup上都存在的可读写空格分隔值文件。初始为空 + +读取时,它会显示以空格分割的控制器列表,这些控制器被启用来控制从cgroup到其子组的资源分配 + +可以写入以空格分隔的带有+或-前缀的控制器列表来启用或禁用控制器。带有+前缀的控制器名称将启用该控制器,带有-前缀的控制器名称将禁用该控制器。如果控制器在列表中出现多次,则最后一个有效。当指定多个启用和禁用操作时,要么全部成功,要么全部失败 + +### cgroup.event + +存在于非root cgroup上的只读平键文件。定义了以下条目。除非另有说明,否则此文件中的值更改会生成文件修改事件 + +- populated:如果cgroup或其他后代包含任何活动进程,则为1;否则为0 +- frozen:如果cgroup被冻结,则为1;否则为0 + +### cgroup.max.descendants + +读写单值文件。默认值为"max" + +允许的最大后代cgroup数量。如果实际后代数量相等或更大,则在层次结构中创建新cgroup的尝试将失败 + +### cgroup.max.deep + +读写单值文件。默认值为max + +当前cgroup下允许的最大下降深度。如果实际下降深度等于或大于该值,则尝试创建新的子cgroup将失败 + +### cgroup.freeze + +存在于非root cgroup中的读写单值文件。允许的值为0和1。默认值为0 + +将1写入文件会导致cgroup及其所有后代cgroup被冻结。这意味着所有附属进程都将停止,直到cgroup明确解冻后才会运行。cgroup的冻结可能需要一些时间;此操作完成后,cgroup.events控制文件中的frozen值将更新为1,并发出相应的通知 + +cgroup可以通过其自身设置或任何祖先cgroup的设置进行解冻。如果任何父cgroup被解冻,则cgroup将保持冻结状态 + +冻结cgroup中的进程可以通过致命信号终止。它们还可以进入和离开冻结cgroup;要么通过用户的明确移动,要么冻结cgroup与fork()竞争。如果将进程移动到冻结cgroup,它将停止,如果将进程移出冻结cgroup,它将变为运行状态 + +cgroup的冻结状态不会影响任何cgroup树操作;可以删除冻结的cgroup,也可以创建新的子cgroup + +### cgroup.kill + +存在于非root cgroup中的只写单值文件。唯一允许的值是1 + +将1写入文件会导致cgroup及其所有后代cgroup被终止。这意味着受影响的cgroup树种的所有进程都将通过SIGKILL终止 + +### cgroup.pressure + +允许值为0和1的读写单值文件。默认值为1 + +向文件写入0将禁用cgroup PSI记。向文件写入1将重新启用cgroup PSI。 + +此控制属性不是分层的,因此在cgroup中禁用或启用PSI不会影响后代中的PSI,并且不需要通过来自root cgroup传递启用 + +### 测试用例 + +- **cgroup-v2-type-001:** 测试cgroup.type接口文件,当子cgroup设置为threaded时,父cgroup自动设置为domain threaded +- **cgroup-v2-type-002:** 测试cgroup.type接口文件, 测试层次结构约束 +- **cgroup-v2-subtree_control-001:** 测试cgroup.subtree_control接口文件,在启用了subtree_control的cgroup中,不能够在domain cgroup中加入进程, +- **cgroup-v2-subtree_control-002:** 测试cgroup.subtree_control接口文件,子cgroup的subtree_control只能包含父cgroup的subtree_control +- **cgroup-v2-subtree_control-003:** 测试cgroup.subtree_control接口文件, 不能禁用父cgroup的subtree_control因为子cgroup的subtree_control包含父cgroup的subtree_control +- **cgroup-v2-subtree_control-004:** 测试cgroup.subtree_control接口文件, 在threaded cgroup能够加入线程在启用了subtree_control的cgroup中 +- **cgroup-v2-populated:** 测试cgroup.events中的populated字段 +- **cgroup-v2-max-descendants:** 测试cgroup.max.descendants接口文件 +- **cgroup-v2-max-deep:** 测试cgroup.max.deep接口文件 +- **cgroup-v2-freeze-001:** 测试cgroup.freeze接口文件 +- **cgroup-v2-freeze-002:** 测试cgroup.freeze接口文件, 测试层次结构 +- **cgroup-v2-freeze-003:** 测试cgroup.freeze接口文件, 测试层次结构,测试如果将进程移动到冻结cgroup,它将停止 +- **cgroup-v2-freeze-004:** 测试cgroup.freeze接口文件, 测试层次结构,测试cgroup的冻结状态不会影响任何cgroup树操作 +- **cgroup-v2-freeze-005:** 测试cgroup.freeze接口文件, 测试迁移的情况 +- **cgroup-v2-kill-001:** 测试cgroup.kill接口文件 +- **cgroup-v2-kill-002:** 测试cgroup.kill接口文件, 测试层次结构 + +### 测试结果 + +**OpenCloudOS 8:** + +腾讯云: + +![image-20240813175902750](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813175902750.png) +![image-20240813180012630](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813180012630.png) +![image-20240813180113229](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813180113229.png) + +cgroup-v2-kill-001/002测试用例失败原因是不存在cgroup.kill这个接口文件 + +本地qemu: + +![image-20240814111432108](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814111432108.png) +![image-20240814111439428](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814111439428.png) +![image-20240814111452398](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814111452398.png) +![image-20240814111510069](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814111510069.png) + +cgroup-v2-kill-001/002测试用例失败原因是不存在cgroup.kill这个接口文件 + +**OpenCloudOS 9:** + +腾讯云: + +![image-20240814134324218](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814134324218.png) +![image-20240814134339407](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814134339407.png) +![image-20240814134349799](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814134349799.png) + +本地qemu: + +![image-20240814154750773](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814154750773.png) +![image-20240814222204119](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814222204119.png) +![image-20240814222221561](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814222221561.png) + +**OpenCloudOS Stream 23:** + +本地qemu: + +![image-20240814184416348](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814184416348.png) +![image-20240814225750443](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814225750443.png) +![image-20240814225759870](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814225759870.png) + +## 控制器接口文件 + +### CPU + +CPU控制器调节CPU周期的分配,为普通调度策略实现权重和绝对带宽限制模型。 + +所有接口文件的时间长度均以微妙为单位 + +#### cpu.stat + +只读平键文件。无论控制器是否启用,此文件都存在 + +它始终报告以下三个统计数据: + +- usage_usec:CPU使用时间 +- user_usec:CPU用户态时间 +- system_usec:CPU内核态时间 + +当控制器启用时,还有以下五个统计数据: + +- nr_periods:调度周期的总数 +- nr_throttled:进程被限制(throttled)的次数 +- throttled_usec:进程被限制的总时间 +- nr_bursts:发生的burst事件的次数。burst事件是指在短时间内CPU使用率突然增加的情况 +- burst_usec:burst事件的总时间 + +#### cpu.weight + +存在于非root cgroup上的读写单值文件。默认值为100 + +对于非空闲组(cpu.idle = 0),权重在范围内[1, 10000] + +如果cgroup已配置为SCHED_IDLE(cpu.idle = 1),则权重将显示为0 + +#### cpu.weight.nice + +存在于非root cgroup上的读写单值文件。默认值为0 + +nice值的范围是[-20, 19] + +此接口文件是cpu.weight的替代接口,允许使用 nice(2)使用的相同值读取和设置权重。由于nice值的范围较小,粒度较粗,因此读取的值是当前权重的最接近近似值 + +nice(2)是一个系统调用,用于设置进程的优先级,优先级决定了进程在系统资源(特别是CPU时间)分配中的优先顺序。nice值的范围通常是从-20到19,值越小表示越高优先级 + +#### cpu.max + +存在于非root cgroup上的读写双值文件。默认值为" max 100000" + +最大带宽限制。其格式如下: + +```bash +$MAX $PERIOD +``` + +表示该组在每个\$PERIOD期间最多可以消费\$MAX。\$MAX中的max表示没有限制,如果只写一个数字,则更新\$MAX + +#### cpu.max.burst + +存在于非root cgroup上的读写单值文件。默认值为0 + +burst范围在[0, $MAX]内,这里的MAS是cpu.max中定义的 + +#### cpu.pressure + +读写嵌套键文件。显示CPU的压力失速信息 + +#### cpu.idle + +存在于非root cgroup上的读写单值文件。默认值为0 + +这是cgroup中每个任务的SCHD_IDLE调度策略的模拟。将此值设置为1将使cgroup的调度策略成为SCHED_IDLE。cgroup中的线程将保留其自己的相对优先级,但cgroup本身将被视为相对于其他同类而言优先级非常低 + +#### 测试用例 + +- **cgroup-v2-cpu-stat:** 测试cpu.stat接口文件 +- **cgroup-v2-cpu-weight-001:** 测试cpu.weight接口文件 +- **cgroup-v2-cpu-weight-002:** 测试cpu.weight接口文件,测试层次结构 +- **cgroup-v2-cpu-weight-nice-001:** 测试cpu.weight.nice接口文件 +- **cgroup-v2-cpu-weight-nice-002:** 测试cpu.weight.nice接口文件, 测试层次结构 +- **cgroup-v2-cpu-max:** 测试cpu.max接口文件 +- **cgroup-v2-cpu-max-burst-001:** 测试cpu.max.burst接口文件,设置限制,并设置burst时间 +- **cgroup-v2-cpu-max-burst-002:** 测试cpu.max.burst接口文件,设置限制,不设置burst时间 +- **cgroup-v2-cpu-pressure:** 测试cpu.pressure接口文件,设置CPU压力通知 +- **cgroup-v2-cpu-idle-001:** 测试cpu.idle接口文件,设置SCHD_IDLE调度策略 +- **cgroup-v2-cpu-idle-002:** 测试cpu.idle接口文件,不设置SCHD_IDLE调度策略 + +#### 测试结果 + +**OpenCloudOS 8:** + +腾讯云: + +![image-20240813193042254](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813193042254.png) +![image-20240813192641081](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813192641081.png) + +cgroup-v2-cpu-idle-001和cgroup-v2-cpu-max-burst-001测试失败的原因是不存在cpu.idle和cpu.burst.max这两个接口文件 +cgroup-v2-cpu-pressure测试失败的原因是没有cpu.pressure这个接口文件。 + +本地qemu: + +![image-20240814143203487](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814143203487.png) +![image-20240814143213079](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814143213079.png) + +cgroup-v2-cpu-idle-001和cgroup-v2-cpu-max-burst-001测试失败的原因是不存在cpu.idle和cpu.burst.max这两个接口文件 +cgroup-v2-cpu-pressure测试失败的原因是没有cpu.pressure这个接口文件。 + +**OpenCloudOS 9:** + +腾讯云: + +![image-20240814162257363](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814162257363.png) +![image-20240814162307489](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814162307489.png) + +本地qemu: + +![image-20240814155032448](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814155032448.png) +![image-20240814155051387](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814155051387.png) + +**OpenCloudOS Stream 23:** + +本地qemu: + +![image-20240814184809027](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814184809027.png) +![image-20240814184815898](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814184815898.png) + +### memory + +memory控制器调节内存的分配。内存是有效状态的,并实现限制和保护模型。 + +所有内存量均以字节为单位。如果写入的值为与PAGE_SIZE对齐,则读回该值可能会向上舍入为最接近的PAGE_SIZE倍数 + +#### memory.current + +存在于非root cgroup上的只读单值文件 + +该cgroup及其后代当前正在使用的内存总量 + +#### memory.min + +存在于非root cgroup上的读写单值文件。默认值为0 + +硬内存保护。如果cgroup的内存使用量在其有效最小边界内,则在任何情况下都不会回收该cgroup的内存。如果没有可用的不受保护的可回收内存,则会调用OOM终止程序。如果超过出有效最小边界(或有效低边界,如果有效低边界更高),则会按超额比例回收页面,从而减少超额较小的回收压力 + +如果memory cgroup中没有进程, 则会忽略其memory.min + +#### memory.low + +存在于非root cgroup上的读写单值文件。默认值为0 + +尽力保护内存,如果cgroup的内存使用量在其有效低边界内,则除非未受保护的cgroup中没有可回收内存,否则不会回收该cgroup的内存。如果超出有效低边界(或有效最小边界,如果有效最小边界更高),则会根据超额部分按比例回收页面,从而减少超额部分的回收压力 + +#### memory.high + +存在于非root cgroup上的读写单值文件。默认值为max + +内存使用限制,如果cgroup的使用量超出上限,则cgroup的进程将受到限制,并承受巨大的回收压力 + +超过上限不会调用OOM终止程序,在极端情况下可能会突破限制。在外部进程监控受限cgroup以缓解沉重的回收压力的情况下,应使用上限 + +#### memory.max + +存在于非root cgroup上的读写单值文件。默认值为max + +内存使用硬限制。这是限制cgroup内存使用的主要机制。如果cgroup的内存使用量达到此限制且无法降低,则会在cgroup中调用OOM killer。在某些情况下, 使用量可能会暂时超过限制 + +#### memory.peak + +存在于非root cgroup上的只读单值文件。自cgroup创建以来,记录的cgroup及其后代的最大内存使用量 + +#### memory.reclaim + +所有cgroup都存在的只写文件 + +这是一个在目标cgroup中触发内存回收的简单接口 + +#### memory.oom.group + +存在于非root cgroup上的读写单值文件。默认值为0 + +确定OOM终止程序是否应将cgroup视为不可分割的工作负载。如果设置,则属于该cgroup或其后代(如果内存cgroup不是叶cgroup)的所有任务都会一起终止或根本不终止。这可用于避免部分终止以保证工作负载的完整性 + +具有OOM保护(oom_score_adj设置为-1000)的任务被视为异常,并且永远不会被终止 + +如果在cgroup中调用OOM终止程序,它将不会终止该cgroup之外的任何任务,无论父cgroup的memory.oom,group值如何 + +#### memory.events + +存在于非root cgroup上的只读平键文件。定义了以下条目: + +- low:尽管cgroup的使用率低于低限,但由于内存压力过大而被回收的次数。 +- high:由于超出高内存边界,cgroup的进程被限制以执行直接内存回收的次数。 +- max:cgroup的内存使用量即将超过最大边界的次数。如果直接回收无法降低内存使用量,则cgroup会进入oom状态 +- oom:cgroup内存使用量达到限制且分配即将失败的次数。如果不将oom killer视为一个选项,则不会引发此事件 +- oom_kill:属于此cgroup的被任何类型的OOM终止程序终止的进程数 +- oom_group_kill:发生组oom的次数(OpenCloud8没有此字段) + +memory.events.local:与memory.events类似,但文件中的字段是cgroup本地的,即不是分层的。在此文件上生成的文件修改仅反映本地事件 + +#### memory.swap.current + +存在于非root cgroup上的只读单值文件 + +该cgroup及其后代当前正在使用的交换总量 + +#### memory.swap.high + +存在于非root cgroup上的读写单值文件。默认值为max + +此限制标志着cgroup的不可逆转点。它并非设置用于管理工作负载在正常运行期间进行的交换量。与memory.swap.max相比,后者进制交换量超过设定值,但只要其他内存可以回收,cgroup就可以不受阻碍地继续运行 + +#### memory.swap.peak + +存在于非root cgroup上的只读单值文件 + +自cgroup创建以来,记录的cgroup及其后代的最大交换使用情况 + +#### memory.swap.max + +存在于非root cgroup上的读写单值文件,默认值为max + +交换使用硬限制。如果cgroup的交换使用量达到此限制,则不会将cgroup的匿名内存换出 + +#### memory.swap.events + +存在于非root cgroup上的只读平键文件。定义了以下条目。除非另有说明,否则此文件中的值更改会生成文件修改事件 + +- high:cgroup的交换使用量超出高阈值的次数 +- max:cgroup的交换使用量即将超出最大边界且交换分配失败的次数 +- fail:由于系统范围内的交换空间用尽或最大限制而导致交换分配失败的次数 + +当在当前使用率下减少时,现有的交换条目将逐渐被回收,并且交换使用率可能在较长时间内保持高于限制,着减少了对工作负载和内存管理的影响 + +#### memory.zswap.current + +存在于非root cgroup上只读单值文件 + +zswap压缩后端消耗的内存总量 + +#### memory.zswap.max + +存在于非root cgroup上的读写单值文件。默认值为max + +zswap使用硬限制。如果cgroup的zswap池达到此限制,它将拒绝在现有条目故障恢复或写入磁盘之前接受任何存储 + +#### memory.pressure + +只读的嵌套键文件。显示内存的压力失速信息。 + +#### 测试用例 + +- **cgroup-v2-memory-current:** 测试memory.current接口文件,分配一些匿名内存和页缓存,查看memory.current的值 +- **cgroup-v2-memory-min-001:** 测试memoruy.min接口文件,parent1/2的父cgroup设置的内存上限是200MB, parent2分配的内存为146MB, 不会占用parent1的memory.min保护的内存50MB +- **cgroup-v2-memory-min-002:** 测试memoruy.min接口文件,parent1/2的父cgroup设置的内存上限是200MB, parent2分配的内存为170MB, 会占用parent1的memory.min保护的内存50MB,因此会被kill +- **cgroup-v2-memory-low-001:** 测试memoruy.low接口文件,parent1/2的父cgroup设置的内存上限是200MB, parent2分配的内存为146MB, 不会占用parent1的memory.low保护的内存50MB +- **cgroup-v2-memory-low-002:** 测试memoruy.low接口文件,parent1/2的父cgroup设置的内存上限是200MB, parent2分配的内存为170MB, 会占用parent1的memory.low保护的内存50MB, 但是不会被kill,依然能分配 +- **cgroup-v2-memory-high-001:** 测试memory.high接口文件,测试是否能有效控制匿名内存和页缓存所消耗的内存量 +- **cgroup-v2-memory-high-002:** 测试memory.high接口文件,测试是否能有效对内存的大量单次分配进行限制 +- **cgroup-v2-memory-max:** 测试memory.max接口文件 +- **cgroup-v2-memory-reclaim-001:** 测试memory.reclaim接口文件,回收page cache +- **cgroup-v2-memory-reclaim-002:** 测试memory.reclaim接口文件,回收匿名内存 +- **cgroup-v2-memory-oom-group-001:** 测试memory.oom.group接口文件,分配匿名内存达到oom限制,检查子cgroup进程是否被kill +- **cgroup-v2-memory-oom-group-002:** 测试memory.oom.group接口文件,分配匿名内存达到oom限制,检查父cgroup和子cgroup进程是否被kill +- **cgroup-v2-memory-oom-group-003:** 测试memory.oom.group接口文件,分配匿名内存达到oom限制,检查除了设置OOM_SCORE_ADJ_MIN的进程外,其他进程是否被kill +- **cgroup-v2-memory-oom-events:** 测试memory.events中的oom和oom_kill事件 +- **cgroup-v2-memory-swap-high:** 测试memory.swap.high和memory.swap.current接口文件 +- **cgroup-v2-memory-swap-max:** 测试memory.swap.max接口文件 +- **cgroup-v2-memory-zswap:** 测试memory.zswap.max和memory.zswap.current接口文件, 达到限制不会触发写回操作 +- **cgroup-v2-memory-pressure:** 测试memory.pressure接口文件,设置内存压力通知 + +#### 测试结果 + +**OpenCloudOS 8:** + +腾讯云: + +![image-20240813215939420](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813215939420.png) + +cgroup-v2-memory-pressure测试用例失败的原因是没有cgroup.preesure接口文件 + +cgroup-v2-memory-reclaim-001/2测试用例失败的原因是没有memory.reclaim接口文件 + +cgroup-v2-memory-swap-high/max测试用例跳过的原因是没有swapfile + +cgroup-v2-memory-zswap测试用例失败的原因是没有memory.zswap.max接口文件 + +本地qemu: + +![image-20240814142044608](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814142044608.png) + +cgroup-v2-memory-pressure测试用例失败的原因是没有cgroup.preesure接口文件 + +cgroup-v2-memory-reclaim-001/2测试用例失败的原因是没有memory.reclaim接口文件 + +cgroup-v2-memory-swap-high/max测试用例失败的原因是没有memory.swap.high接口文件 + +**OpenCloudOS 9:** + +腾讯云: + +![image-20240814141912888](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814141912888.png) + +cgroup-v2-memory-reclaim-002测试用例失败的原因是没有不能正常回收匿名内存,当分配匿名内存时,无法写入memory.reclaim接口文件 +cgroup-v2-memory-zswap测试用例失败的原因,推测是无法正常使用zswap,尽管设定了zswap.max的值,但是分配的内存还是会被kill掉,无法利用到zswap + +本地qemu: + +![image-20240814155628208](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814155628208.png) + +仍然是cgroup-v2-memory-zswap测试用例测试失败 + +**OpenCloudOS Stream 23:** + +本地qemu: + +![image-20240814185220725](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814185220725.png) + +### IO + +io控制器控制io资源的分配,此控制器可实现基于权重和绝对带宽或IOPS限制的分配 + +#### io.stat + +只读的嵌套键文件 + +行由\$MAJ:\$MIN设备编号键控,且无序。定义了以下嵌套键: + +| 字段 | 含义 | +| ------ | ------------ | +| rbytes | 读取的字节数 | +| wbytes | 写入的字节数 | +| rios | 读取IO数量 | +| wios | 写IO次数 | +| dbytes | 丢弃的字节数 | +| dios | 丢弃IO数 | + +#### io.weight + +存在于非 root cgroup 上的读写平键文件。默认值为“default 100”。 + +第一行是应用于设备的默认权重,没有特定的覆盖。其余的覆盖由 \$MAJ:\$MIN 设备编号键入且无序。权重在 [1, 10000] 范围内,指定 cgroup 相对于其同级可以使用的相对 IO 时间量。 + +可以通过写入“default \$WEIGHT”或简单的“​\$WEIGHT”来更新默认权重。可以通过写入“\$MAJ:\$MIN ​\$WEIGHT”来设置覆盖,并通过写入“​\$MAJ:\$MIN default”来取消设置。 + +注意:需要先在root cgroup启用特定设备的io.cost.qos,才能将设备填充到io.weight,例如: + + ```bash +ehco "8:0 enabled=1 ctrl=auto" > io.cost.qos + ``` + +#### io.max + +存在于非 root cgroup 上的读写嵌套键文件。 + +基于 BPS 和 IOPS 的 IO 限制。行由 \$MAJ:\$MIN 设备编号键控且无序。定义了以下嵌套键: + +| 字段 | 含义 | +| ----- | ---------------------- | +| rbps | 每秒最大读取字节数 | +| wbps | 每秒最大写入字节数 | +| riops | 每秒最大读取 IO 操作数 | +| wiops | 每秒最大写入 IO 操作数 | + +写入时,可以以任意顺序指定任意数量的嵌套键值对。可以指定“max”作为值来删除特定限制。如果多次指定相同的键,则结果不确定。 + +#### io.pressure + +只读的嵌套键文件,显示 IO 的压力失速信息。 + +#### 测试用例 + +- **cgroup-v2-io-weight:** 测试io.weight接口文件 +- **cgroup-v2-io-max-001:** 测试io.max接口文件的rbps +- **cgroup-v2-io-max-002:** 测试io.max接口文件的wbps +- **cgroup-v2-io-max-003:** 测试io.max接口文件的riops +- **cgroup-v2-io-max-004:** 测试io.max接口文件的wiops、 +- **cgroup-v2-io-pressure:** 测试io.pressure接口文件,设置io压力通知 + +#### 测试结果 + +**OpenCloudOS 8:** + +腾讯云: + +![image-20240813220144401](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813220144401.png) + +cgroup-v2-io-pressure测试用例失败的原因是没有cgroup.preesure接口文件 + +本地qemu: + +![image-20240814121312911](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814121312911.png) + +cgroup-v2-io-pressure测试用例失败的原因是没有cgroup.preesure接口文件 + +**OpenCloudOS 9:** + +腾讯云: + +![image-20240814142222974](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814142222974.png) + +本地qemu: + +![image-20240814155752495](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814155752495.png) + +同样是跟上面的cgroup v1中的cgroup-v1-blkio-throttle-write_bps_device和cgroup-v1-blkio-throttle-write_iops_device测试用例一样,不能正常限制写硬盘速率。 + +**OpenCloudOS Stream 23:** + +本地qemu: + +![image-20240814185236668](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814185236668.png) + +同上,不能正常限制写硬盘速率。 + +### PID + +允许cgroup在达到一定限制后阻止任何新任务被fork()或clone() + +**接口文件:** + +- pids.max:存在于非 root cgroup 上的读写单值文件。默认值为“max”。进程数量的硬性限制。 +- pids.current:存在于非 root cgroup 上的只读单值文件。cgroup 及其后代中当前的进程数。 +- pids.peak:存在于非 root cgroup 上的只读单值文件。该 cgroup 及其后代进程数曾达到的最大值。 +- pids.events:存在于非 root cgroup 上的只读平键文件。除非另有说明,否则此文件中的值更改会生成文件修改事件。定义了以下条目: + - max:cgroup 的总进程数达到 pids.max 限制的次数 +- pids.events.local:与 pids.events 类似,但文件中的字段是 cgroup 本地的,即不是分层的。在此文件上生成的文件修改事件仅反映本地事件。 + +pids.current > pids.max 是可能的,这可以通过将限制设置为小于 pids.current 或将足够多的进程附加到 cgroup 以使 pids.current 大于 pids.max 来实现。但是,不可能通过 fork() 或 clone() 违反 cgroup PID 策略。 + +**测试用例:** + +- **cgroup-v2-pids-max-001:** 测试pids.max接口文件, 进程数超过限制 +- **cgroup-v2-pids-max-002:** 测试pids.max控制文件, 进程数不超过限制 +- **cgroup-v2-pids-max-003:** 测试pids的层次结构 + +**测试结果:** + +**OpenCloudOS 8:** + +腾讯云: + +![image-20240813222209839](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813222209839.png) + +本地qemu: + +![image-20240814121333373](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814121333373.png) + +**OpenCloudOS 9:** + +腾讯云: + +![image-20240814142241006](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814142241006.png) + +本地qemu: + +![image-20240814155915955](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814155915955.png) + +**OpenCloudOS Stream 23:** + +本地qemu: + +![image-20240814185415242](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814185415242.png) + +### cpuset + +“cpuset”控制器提供了一种机制,用于将任务的 CPU 和内存节点放置限制为仅任务当前 cgroup 中的 cpuset 接口文件中指定的资源。这在大型 NUMA 系统中尤其有用,在这些系统中,将作业放置在适当大小的系统子集上,并仔细放置处理器和内存以减少跨节点内存访问和争用,可以提高整体系统性能。 + +“cpuset” 控制器是分层的。这意味着控制器不能使用其父级中不允许的 CPU 或内存节点。 + +#### cpuset.cpus + +存在于非 root cpuset 启用的 cgroup 上的读写多值文件。 + +它列出了此 cgroup 内的任务所请求的 CPU。但实际授予的 CPU 列表受其父级施加的限制,可能与请求的 CPU 不同。 + +CPU 编号是用逗号分隔的数字或范围,例如:0,3-4 + +空值表示 cgroup 使用与具有非空“cpuset.cpus”的最近的 cgroup 祖先相同的设置,如果未找到任何可用 CPU,则使用所有可用的 CPU。 + +“cpuset.cpus” 的值保持不变直到下次更新,不会受到任何 CPU 热插拔事件的影响。 + +#### cpuset.cpus.effective + +所有启用 cpuset 的 cgroup 上都存在的只读多值文件。 + +它列出了此 cgroup 的父级实际授予其的在线 CPU。这些 CPU 允许由当前 cgroup 中的任务使用。 + +如果“cpuset.cpus”为空,“cpuset.cpus.effective”文件将显示父 cgroup 中可供此 cgroup 使用的所有 CPU。否则,它应该是“cpuset.cpus”的子集,除非“cpuset.cpus”中列出的 CPU 均无法授予。在这种情况下,它将被视为空的“cpuset.cpus”。 + +其值会受到CPU热插拔事件的影响。 + +#### cpuset.cpus.partition + +这个文件可以被设置为root或member,主要功能是用来设置当前的cgroup是不是作为一个独立的scheduling domain进行调度。这个功能其实就是可以理解为,在root模式下,所有分配给当前cgroup的cpu都是独占这些cpu的,而member模式则可以在多个cgroup之间共享这些cpu。设置为root将使当前cgroup使用的cpu从上级cgroup的cpuset.cpus.effective列表中拿走,即上一级不能使用这个被独占的CPU了。设置为root后,如果这个cgroup有下一级的cgroup,这个cgroup也将不能再切换回member状态。在这种模式下,上一级的cgroup不可以把自己所有的cpu都分配给其下一级的cgroup,其自身至少给自己留一个cpu + +设置为root需要当前cgroup符合以下条件: + +- cpuset.cpus中设置不为空且设置的cpu list中的cpu都是独立的。就是说这些cpu不会共享给其他平级cgroup +- 上一级cgroup是partion root配置 +- 当前cgroup的cpuset.cpus作为集合是上一级cgroup的cpuset.cpus.effective集合的子集 +- 下一级cgroup没有启用cpuset资源隔离 + +#### cpuset.mems + +存在于非 root cpuset 启用的 cgroup 上的读写多值文件。 + +它列出了此 cgroup 内的任务所请求的内存节点。但实际授予的内存节点列表受其父级施加的限制,可能与请求的内存节点不同。 + +内存节点号是用逗号分隔的数字或范围。例如:0-1,3 + +空值表示 cgroup 使用与最近的 cgroup 祖先相同的设置 + +“cpuset.mems” 的值保持不变直到下次更新,不会受到任何内存节点热插拔事件的影响。 + +如果“cpuset.mems”当前正在使用指定节点之外的内存,则将 cgroup 内的任务的内存迁移到指定节点。 + +这种内存迁移是有代价的。迁移可能不完整,可能会遗留一些内存页。因此,建议在将新任务生成到 cpuset 之前正确设置“cpuset.mems”。即使需要使用活动任务更改“cpuset.mems”,也不应该频繁进行。 + +#### cpuset.mems.effective + +所有启用 cpuset 的 cgroup 上都存在的只读多值文件。 + +它列出了此 cgroup 的父级实际授予其的在线内存节点。这些内存节点允许由当前 cgroup 内的任务使用。 + +如果“cpuset.mems”为空,则显示父 cgroup 中可供此 cgroup 使用的所有内存节点。否则,它应该是“cpuset.mems”的子集,除非“cpuset.mems”中列出的任何内存节点都无法授予。在这种情况下,它将被视为空的“cpuset.mems”。 + +其值会受到内存节点热插拔事件的影响。 + +#### 测试用例 + +- **cgroup-v2-cpuset-cpus:** 测试cpuset.cpus和cpuset.cpus.effetive接口文件 +- **cgroup-v2-cpuset-cpus-partition:** 测试cpuset.cpus.patition接口文件 +- **cgroup-v2-cpuset-mems:** 测试cpuset.mems和cpuset.mems.effetive接口文件 + +#### 测试结果 + +**OpenCloudOS 8:** + +腾讯云: + +![image-20240813222250409](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813222250409.png) + +cgroup-v2-cpuset-cpus-partition测试用例要在2个以上cpu才能测试,因为root cgroup始终要占有一个cpu + +cgroup-v2-cpuset-mems测试用例需要在2个及以上NUMA节点才能测试 + +本地qemu: + +![image-20240814121353069](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814121353069.png) + +**OpenCloudOS 9:** + +腾讯云: + +![image-20240814142314782](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814142314782.png) + +cgroup-v2-cpuset-cpus-partition测试用例要在2个以上cpu才能测试,因为root cgroup始终要占有一个cpu + +cgroup-v2-cpuset-mems测试用例需要在2个及以上NUMA节点才能测试 + +本地qemu: + +![image-20240814155933002](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814155933002.png) + +**OpenCloudOS Stream 23:** + +本地qemu: + +![image-20240814185448434](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814185448434.png) + +### hugetlb + +HugeTLB 控制器允许限制每个控制组的 HugeTLB 使用情况,并在页面错误期间强制执行控制器限制。 + +**接口文件:** + +- **hugetlb.2MB.max:** 读写文件。设置hugepage大小为2MB的hugepage使用量限制 +- **hugetlb.1GB.max:** 读写文件。设置hugepage大小为1GB的hugepage使用量限制 +- **hugetlb.2MB.current:** 只读文件。显示hugepages大小为2MB的hugepage的当前使用量 +- **hugetlb.1GB.current:** 只读文件。显示hugepages大小为1GB的hugepage的当前使用量 +- **hugetlb.2MB.rsvd.max:** 读写文件。设置hugepage大小为2MB的hugepage预留限制 +- **hugetlb.1GB.rsvd.max:** 读写文件。设置hugepage大小为1GB的hugepage预留限制 +- **hugetlb.2MB.rsvd.current:** 只读文件。显示hugepages大小为2MB的hugepage的当前预留量 +- **hugetlb.1GB.rsvd.current:** 只读文件。显示hugepages大小为1GB的hugepage的当前预留量 +- **hugetlb..2MB.events:** 存在于非 root cgroup 上的只读平键文件,包含以下字段: + - max:由于 HugeTLB 限制导致分配失败的次数 +- **hugetlb.1GB.events:** 存在于非 root cgroup 上的只读平键文件,包含以下字段: + - max:由于 HugeTLB 限制导致分配失败的次数 + +**测试用例:** + +- **cgroup-v2-hugetlb-max-001:** 测试hugetlb.2MB.max接口文件,超过限制 +- **cgroup-v2-hugetlb-max-002:** 测试hugetlb.2MB.max接口文件, 不超过限制 +- **cgroup-v2-hugetlb-max-003:** 测试hugetlb.1GB.max接口文件, 超过限制 +- **cgroup-v2-hugetlb-max-004:** 测试hugetlb.1GB.max接口文件, 不超过限制 +- **cgroup-v2-hugetlb-rsvd-max-001:** 测试hugetlb.2MB.rsvd.max接口文件,超过限制 +- **cgroup-v2-hugetlb-rsvd-max-002:** 测试hugetlb.2MB.rsvd.max接口文件,不超过限制 +- **cgroup-v2-hugetlb-rsvd-max-003:** 测试hugetlb.1GB.rsvd.max接口文件, 超过限制 +- **cgroup-v2-hugetlb-rsvd-max-004:** 测试hugetlb.1GB.rsvd.max接口文件, 不超过限制 + +**测试结果: ** + +**OpenCloudOS 8:** + +腾讯云: + +![image-20240813222437274](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240813222437274.png) + +都跳过测试的原因:不能启用hugetlb控制器,即root cgroup 的cgroup.control没有包含该控制器 + +本地qemu: + +![image-20240814121500396](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814121500396.png) + +都跳过测试的原因:不能启用hugetlb控制器,即root cgroup 的cgroup.control没有包含该控制器 + +**OpenCloudOS 9:** + +腾讯云: + +![image-20240814142348511](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814142348511.png) + +本地qemu: + +![image-20240814155949999](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814155949999.png) + +修改hugepage大小为1G后测试: + +![image-20240814161512867](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814161512867.png) + +cgroup-v2-hugetlb-max-003/004测试失败,即hugetlb.1GB.max没有正常发挥效果 + +**OpenCloudOS Stream 23:** + +本地qemu: + +![image-20240814185505769](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814185505769.png) + +修改hugepage大小为1G后测试: + +![image-20240814190419664](%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.assets/image-20240814190419664.png) + +cgroup-v2-hugetlb-max-003/004测试失败,即hugetlb.1GB.max没有正常发挥效果 +