diff --git a/lisa/_assets/binaries/arm64/README.pahole b/lisa/_assets/binaries/arm64/README.pahole new file mode 100644 index 0000000000000000000000000000000000000000..c8495b9e49d473d4cd097cfffa0e79b22740dd48 --- /dev/null +++ b/lisa/_assets/binaries/arm64/README.pahole @@ -0,0 +1,597 @@ +Sources of pahole available at: +Git commit: d7e83320c320048a948e1230598cc3ae80f24960 +Git repository: https://github.com/douglas-raillard-arm/pahole.git + + +Build host info: + +NAME="Alpine Linux" +ID=alpine +VERSION_ID=3.18.3 +PRETTY_NAME="Alpine Linux v3.18" +HOME_URL="https://alpinelinux.org/" +BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues" + + +Build recipe: + +export ARCH=arm64 +export LISA_ARCH_ASSETS=/lisa/_assets/binaries/arm64 +export LISA_HOME='' +#! /bin/bash + +ALPINE_VERSION=v3.18 +ALPINE_BUILD_DEPENDENCIES=(bash gcc git make cmake musl-dev zlib-static bzip2-static libelf-static libbpf-dev musl-obstack-dev argp-standalone linux-headers xz-static zstd-static) +BROKEN_CROSS_COMPILATION=1 + + +# See $LISA_HOME/tools/recipes/pahole.manifest.yaml for instructions on how to build the "lisa" branch + +download() { + #git clone https://git.kernel.org/pub/scm/devel/pahole/pahole.git + git clone https://github.com/douglas-raillard-arm/pahole.git + git -C pahole checkout lisa +} + +build() { + cd pahole + + mkdir build + ( + cd build + cmake \ + -DSTATIC_LINK=ON \ + -DCMAKE_BUILD_TYPE=Release \ + .. \ + && + make pahole + ) && + strip build/pahole +} + +install() { + cp -v pahole/build/pahole "$LISA_ARCH_ASSETS/pahole" + + source "$LISA_HOME/tools/recipes/utils.sh" + install_readme pahole pahole COPYING +} + + +The sources were distributed under the following licence (content of pahole/COPYING): + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, 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 Lesser 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 Street, 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 Lesser General +Public License instead of this License. + + +The sources were compiled with musl-libc (content of COPYRIGHT): + +musl as a whole is licensed under the following standard MIT license: + +---------------------------------------------------------------------- +Copyright © 2005-2020 Rich Felker, et al. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +---------------------------------------------------------------------- + +Authors/contributors include: + +A. Wilcox +Ada Worcester +Alex Dowad +Alex Suykov +Alexander Monakov +Andre McCurdy +Andrew Kelley +Anthony G. Basile +Aric Belsito +Arvid Picciani +Bartosz Brachaczek +Benjamin Peterson +Bobby Bingham +Boris Brezillon +Brent Cook +Chris Spiegel +Clément Vasseur +Daniel Micay +Daniel Sabogal +Daurnimator +David Carlier +David Edelsohn +Denys Vlasenko +Dmitry Ivanov +Dmitry V. Levin +Drew DeVault +Emil Renner Berthing +Fangrui Song +Felix Fietkau +Felix Janda +Gianluca Anzolin +Hauke Mehrtens +He X +Hiltjo Posthuma +Isaac Dunham +Jaydeep Patil +Jens Gustedt +Jeremy Huntwork +Jo-Philipp Wich +Joakim Sindholt +John Spencer +Julien Ramseier +Justin Cormack +Kaarle Ritvanen +Khem Raj +Kylie McClain +Leah Neukirchen +Luca Barbato +Luka Perkov +M Farkas-Dyck (Strake) +Mahesh Bodapati +Markus Wichmann +Masanori Ogino +Michael Clark +Michael Forney +Mikhail Kremnyov +Natanael Copa +Nicholas J. Kain +orc +Pascal Cuoq +Patrick Oppenlander +Petr Hosek +Petr Skocik +Pierre Carrier +Reini Urban +Rich Felker +Richard Pennington +Ryan Fairfax +Samuel Holland +Segev Finer +Shiz +sin +Solar Designer +Stefan Kristiansson +Stefan O'Rear +Szabolcs Nagy +Timo Teräs +Trutz Behn +Valentin Ochs +Will Dietz +William Haddon +William Pitcock + +Portions of this software are derived from third-party works licensed +under terms compatible with the above MIT license: + +The TRE regular expression implementation (src/regex/reg* and +src/regex/tre*) is Copyright © 2001-2008 Ville Laurikari and licensed +under a 2-clause BSD license (license text in the source files). The +included version has been heavily modified by Rich Felker in 2012, in +the interests of size, simplicity, and namespace cleanliness. + +Much of the math library code (src/math/* and src/complex/*) is +Copyright © 1993,2004 Sun Microsystems or +Copyright © 2003-2011 David Schultz or +Copyright © 2003-2009 Steven G. Kargl or +Copyright © 2003-2009 Bruce D. Evans or +Copyright © 2008 Stephen L. Moshier or +Copyright © 2017-2018 Arm Limited +and labelled as such in comments in the individual source files. All +have been licensed under extremely permissive terms. + +The ARM memcpy code (src/string/arm/memcpy.S) is Copyright © 2008 +The Android Open Source Project and is licensed under a two-clause BSD +license. It was taken from Bionic libc, used on Android. + +The AArch64 memcpy and memset code (src/string/aarch64/*) are +Copyright © 1999-2019, Arm Limited. + +The implementation of DES for crypt (src/crypt/crypt_des.c) is +Copyright © 1994 David Burren. It is licensed under a BSD license. + +The implementation of blowfish crypt (src/crypt/crypt_blowfish.c) was +originally written by Solar Designer and placed into the public +domain. The code also comes with a fallback permissive license for use +in jurisdictions that may not recognize the public domain. + +The smoothsort implementation (src/stdlib/qsort.c) is Copyright © 2011 +Valentin Ochs and is licensed under an MIT-style license. + +The x86_64 port was written by Nicholas J. Kain and is licensed under +the standard MIT terms. + +The mips and microblaze ports were originally written by Richard +Pennington for use in the ellcc project. The original code was adapted +by Rich Felker for build system and code conventions during upstream +integration. It is licensed under the standard MIT terms. + +The mips64 port was contributed by Imagination Technologies and is +licensed under the standard MIT terms. + +The powerpc port was also originally written by Richard Pennington, +and later supplemented and integrated by John Spencer. It is licensed +under the standard MIT terms. + +All other files which have no copyright comments are original works +produced specifically for use as part of this library, written either +by Rich Felker, the main author of the library, or by one or more +contibutors listed above. Details on authorship of individual files +can be found in the git version control history of the project. The +omission of copyright and license comments in each file is in the +interest of source tree size. + +In addition, permission is hereby granted for all public header files +(include/* and arch/*/bits/*) and crt files intended to be linked into +applications (crt/*, ldso/dlstart.c, and arch/*/crt_arch.h) to omit +the copyright notice and permission notice otherwise required by the +license, and to use these files without any requirement of +attribution. These files include substantial contributions from: + +Bobby Bingham +John Spencer +Nicholas J. Kain +Rich Felker +Richard Pennington +Stefan Kristiansson +Szabolcs Nagy + +all of whom have explicitly granted such permission. + +This file previously contained text expressing a belief that most of +the files covered by the above exception were sufficiently trivial not +to be subject to copyright, resulting in confusion over whether it +negated the permissions granted in the license. In the spirit of +permissive licensing, and of not having licensing issues being an +obstacle to adoption, that text has been removed. diff --git a/lisa/_assets/binaries/arm64/pahole b/lisa/_assets/binaries/arm64/pahole index 209e0721e190710aa6e664601876c588694180aa..e4cfac49a23b06e08955ba5e52e37bd5dd0d7c7c 100755 Binary files a/lisa/_assets/binaries/arm64/pahole and b/lisa/_assets/binaries/arm64/pahole differ diff --git a/lisa/_assets/binaries/armeabi/README.pahole b/lisa/_assets/binaries/armeabi/README.pahole new file mode 100644 index 0000000000000000000000000000000000000000..d9322dda2e72d46cf75adec67bab25ee077ae0a8 --- /dev/null +++ b/lisa/_assets/binaries/armeabi/README.pahole @@ -0,0 +1,597 @@ +Sources of pahole available at: +Git commit: d7e83320c320048a948e1230598cc3ae80f24960 +Git repository: https://github.com/douglas-raillard-arm/pahole.git + + +Build host info: + +NAME="Alpine Linux" +ID=alpine +VERSION_ID=3.18.3 +PRETTY_NAME="Alpine Linux v3.18" +HOME_URL="https://alpinelinux.org/" +BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues" + + +Build recipe: + +export ARCH=armeabi +export LISA_ARCH_ASSETS=/lisa/_assets/binaries/armeabi +export LISA_HOME='' +#! /bin/bash + +ALPINE_VERSION=v3.18 +ALPINE_BUILD_DEPENDENCIES=(bash gcc git make cmake musl-dev zlib-static bzip2-static libelf-static libbpf-dev musl-obstack-dev argp-standalone linux-headers xz-static zstd-static) +BROKEN_CROSS_COMPILATION=1 + + +# See $LISA_HOME/tools/recipes/pahole.manifest.yaml for instructions on how to build the "lisa" branch + +download() { + #git clone https://git.kernel.org/pub/scm/devel/pahole/pahole.git + git clone https://github.com/douglas-raillard-arm/pahole.git + git -C pahole checkout lisa +} + +build() { + cd pahole + + mkdir build + ( + cd build + cmake \ + -DSTATIC_LINK=ON \ + -DCMAKE_BUILD_TYPE=Release \ + .. \ + && + make pahole + ) && + strip build/pahole +} + +install() { + cp -v pahole/build/pahole "$LISA_ARCH_ASSETS/pahole" + + source "$LISA_HOME/tools/recipes/utils.sh" + install_readme pahole pahole COPYING +} + + +The sources were distributed under the following licence (content of pahole/COPYING): + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, 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 Lesser 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 Street, 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 Lesser General +Public License instead of this License. + + +The sources were compiled with musl-libc (content of COPYRIGHT): + +musl as a whole is licensed under the following standard MIT license: + +---------------------------------------------------------------------- +Copyright © 2005-2020 Rich Felker, et al. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +---------------------------------------------------------------------- + +Authors/contributors include: + +A. Wilcox +Ada Worcester +Alex Dowad +Alex Suykov +Alexander Monakov +Andre McCurdy +Andrew Kelley +Anthony G. Basile +Aric Belsito +Arvid Picciani +Bartosz Brachaczek +Benjamin Peterson +Bobby Bingham +Boris Brezillon +Brent Cook +Chris Spiegel +Clément Vasseur +Daniel Micay +Daniel Sabogal +Daurnimator +David Carlier +David Edelsohn +Denys Vlasenko +Dmitry Ivanov +Dmitry V. Levin +Drew DeVault +Emil Renner Berthing +Fangrui Song +Felix Fietkau +Felix Janda +Gianluca Anzolin +Hauke Mehrtens +He X +Hiltjo Posthuma +Isaac Dunham +Jaydeep Patil +Jens Gustedt +Jeremy Huntwork +Jo-Philipp Wich +Joakim Sindholt +John Spencer +Julien Ramseier +Justin Cormack +Kaarle Ritvanen +Khem Raj +Kylie McClain +Leah Neukirchen +Luca Barbato +Luka Perkov +M Farkas-Dyck (Strake) +Mahesh Bodapati +Markus Wichmann +Masanori Ogino +Michael Clark +Michael Forney +Mikhail Kremnyov +Natanael Copa +Nicholas J. Kain +orc +Pascal Cuoq +Patrick Oppenlander +Petr Hosek +Petr Skocik +Pierre Carrier +Reini Urban +Rich Felker +Richard Pennington +Ryan Fairfax +Samuel Holland +Segev Finer +Shiz +sin +Solar Designer +Stefan Kristiansson +Stefan O'Rear +Szabolcs Nagy +Timo Teräs +Trutz Behn +Valentin Ochs +Will Dietz +William Haddon +William Pitcock + +Portions of this software are derived from third-party works licensed +under terms compatible with the above MIT license: + +The TRE regular expression implementation (src/regex/reg* and +src/regex/tre*) is Copyright © 2001-2008 Ville Laurikari and licensed +under a 2-clause BSD license (license text in the source files). The +included version has been heavily modified by Rich Felker in 2012, in +the interests of size, simplicity, and namespace cleanliness. + +Much of the math library code (src/math/* and src/complex/*) is +Copyright © 1993,2004 Sun Microsystems or +Copyright © 2003-2011 David Schultz or +Copyright © 2003-2009 Steven G. Kargl or +Copyright © 2003-2009 Bruce D. Evans or +Copyright © 2008 Stephen L. Moshier or +Copyright © 2017-2018 Arm Limited +and labelled as such in comments in the individual source files. All +have been licensed under extremely permissive terms. + +The ARM memcpy code (src/string/arm/memcpy.S) is Copyright © 2008 +The Android Open Source Project and is licensed under a two-clause BSD +license. It was taken from Bionic libc, used on Android. + +The AArch64 memcpy and memset code (src/string/aarch64/*) are +Copyright © 1999-2019, Arm Limited. + +The implementation of DES for crypt (src/crypt/crypt_des.c) is +Copyright © 1994 David Burren. It is licensed under a BSD license. + +The implementation of blowfish crypt (src/crypt/crypt_blowfish.c) was +originally written by Solar Designer and placed into the public +domain. The code also comes with a fallback permissive license for use +in jurisdictions that may not recognize the public domain. + +The smoothsort implementation (src/stdlib/qsort.c) is Copyright © 2011 +Valentin Ochs and is licensed under an MIT-style license. + +The x86_64 port was written by Nicholas J. Kain and is licensed under +the standard MIT terms. + +The mips and microblaze ports were originally written by Richard +Pennington for use in the ellcc project. The original code was adapted +by Rich Felker for build system and code conventions during upstream +integration. It is licensed under the standard MIT terms. + +The mips64 port was contributed by Imagination Technologies and is +licensed under the standard MIT terms. + +The powerpc port was also originally written by Richard Pennington, +and later supplemented and integrated by John Spencer. It is licensed +under the standard MIT terms. + +All other files which have no copyright comments are original works +produced specifically for use as part of this library, written either +by Rich Felker, the main author of the library, or by one or more +contibutors listed above. Details on authorship of individual files +can be found in the git version control history of the project. The +omission of copyright and license comments in each file is in the +interest of source tree size. + +In addition, permission is hereby granted for all public header files +(include/* and arch/*/bits/*) and crt files intended to be linked into +applications (crt/*, ldso/dlstart.c, and arch/*/crt_arch.h) to omit +the copyright notice and permission notice otherwise required by the +license, and to use these files without any requirement of +attribution. These files include substantial contributions from: + +Bobby Bingham +John Spencer +Nicholas J. Kain +Rich Felker +Richard Pennington +Stefan Kristiansson +Szabolcs Nagy + +all of whom have explicitly granted such permission. + +This file previously contained text expressing a belief that most of +the files covered by the above exception were sufficiently trivial not +to be subject to copyright, resulting in confusion over whether it +negated the permissions granted in the license. In the spirit of +permissive licensing, and of not having licensing issues being an +obstacle to adoption, that text has been removed. diff --git a/lisa/_assets/binaries/armeabi/pahole b/lisa/_assets/binaries/armeabi/pahole index 1355aba9a021fa65f3a9753e6db9ee952edbbcdd..6aa2f76773c4c2732a767a71a7d6430cf6cf2203 100755 Binary files a/lisa/_assets/binaries/armeabi/pahole and b/lisa/_assets/binaries/armeabi/pahole differ diff --git a/lisa/_assets/binaries/x86_64/README.pahole b/lisa/_assets/binaries/x86_64/README.pahole new file mode 100644 index 0000000000000000000000000000000000000000..1a5781160334eb80de4548b55604abe95264a130 --- /dev/null +++ b/lisa/_assets/binaries/x86_64/README.pahole @@ -0,0 +1,598 @@ +Sources of pahole available at: +Git commit: d7e83320c320048a948e1230598cc3ae80f24960 +Git repository: https://github.com/douglas-raillard-arm/pahole.git + + +Build host info: + +NAME="Alpine Linux" +ID=alpine +VERSION_ID=3.18.3 +PRETTY_NAME="Alpine Linux v3.18" +HOME_URL="https://alpinelinux.org/" +BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues" + + +Build recipe: + +export ARCH=x86_64 +export LISA_ARCH_ASSETS=/lisa/_assets/binaries/x86_64 +export LISA_HOME='' +#! /bin/bash + +ALPINE_VERSION=v3.18 +ALPINE_BUILD_DEPENDENCIES=(bash gcc git make cmake musl-dev zlib-static bzip2-static libelf-static libbpf-dev musl-obstack-dev argp-standalone linux-headers xz-static zstd-static) +BROKEN_CROSS_COMPILATION=1 + + +# See $LISA_HOME/tools/recipes/pahole.manifest.yaml for instructions on how to build the "lisa" branch + +download() { + #git clone https://git.kernel.org/pub/scm/devel/pahole/pahole.git + git clone https://github.com/douglas-raillard-arm/pahole.git + git -C pahole checkout lisa +} + +build() { + cd pahole + + mkdir build + ( + cd build + cmake \ + -DSTATIC_LINK=ON \ + -DCMAKE_BUILD_TYPE=Release \ + .. \ + && + make pahole + ) && + strip build/pahole +} + +install() { + cp -v pahole/build/pahole "$LISA_ARCH_ASSETS/pahole" + + source "$LISA_HOME/tools/recipes/utils.sh" + set -e + install_readme pahole pahole COPYING +} + + +The sources were distributed under the following licence (content of pahole/COPYING): + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, 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 Lesser 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 Street, 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 Lesser General +Public License instead of this License. + + +The sources were compiled with musl-libc (content of COPYRIGHT): + +musl as a whole is licensed under the following standard MIT license: + +---------------------------------------------------------------------- +Copyright © 2005-2020 Rich Felker, et al. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +---------------------------------------------------------------------- + +Authors/contributors include: + +A. Wilcox +Ada Worcester +Alex Dowad +Alex Suykov +Alexander Monakov +Andre McCurdy +Andrew Kelley +Anthony G. Basile +Aric Belsito +Arvid Picciani +Bartosz Brachaczek +Benjamin Peterson +Bobby Bingham +Boris Brezillon +Brent Cook +Chris Spiegel +Clément Vasseur +Daniel Micay +Daniel Sabogal +Daurnimator +David Carlier +David Edelsohn +Denys Vlasenko +Dmitry Ivanov +Dmitry V. Levin +Drew DeVault +Emil Renner Berthing +Fangrui Song +Felix Fietkau +Felix Janda +Gianluca Anzolin +Hauke Mehrtens +He X +Hiltjo Posthuma +Isaac Dunham +Jaydeep Patil +Jens Gustedt +Jeremy Huntwork +Jo-Philipp Wich +Joakim Sindholt +John Spencer +Julien Ramseier +Justin Cormack +Kaarle Ritvanen +Khem Raj +Kylie McClain +Leah Neukirchen +Luca Barbato +Luka Perkov +M Farkas-Dyck (Strake) +Mahesh Bodapati +Markus Wichmann +Masanori Ogino +Michael Clark +Michael Forney +Mikhail Kremnyov +Natanael Copa +Nicholas J. Kain +orc +Pascal Cuoq +Patrick Oppenlander +Petr Hosek +Petr Skocik +Pierre Carrier +Reini Urban +Rich Felker +Richard Pennington +Ryan Fairfax +Samuel Holland +Segev Finer +Shiz +sin +Solar Designer +Stefan Kristiansson +Stefan O'Rear +Szabolcs Nagy +Timo Teräs +Trutz Behn +Valentin Ochs +Will Dietz +William Haddon +William Pitcock + +Portions of this software are derived from third-party works licensed +under terms compatible with the above MIT license: + +The TRE regular expression implementation (src/regex/reg* and +src/regex/tre*) is Copyright © 2001-2008 Ville Laurikari and licensed +under a 2-clause BSD license (license text in the source files). The +included version has been heavily modified by Rich Felker in 2012, in +the interests of size, simplicity, and namespace cleanliness. + +Much of the math library code (src/math/* and src/complex/*) is +Copyright © 1993,2004 Sun Microsystems or +Copyright © 2003-2011 David Schultz or +Copyright © 2003-2009 Steven G. Kargl or +Copyright © 2003-2009 Bruce D. Evans or +Copyright © 2008 Stephen L. Moshier or +Copyright © 2017-2018 Arm Limited +and labelled as such in comments in the individual source files. All +have been licensed under extremely permissive terms. + +The ARM memcpy code (src/string/arm/memcpy.S) is Copyright © 2008 +The Android Open Source Project and is licensed under a two-clause BSD +license. It was taken from Bionic libc, used on Android. + +The AArch64 memcpy and memset code (src/string/aarch64/*) are +Copyright © 1999-2019, Arm Limited. + +The implementation of DES for crypt (src/crypt/crypt_des.c) is +Copyright © 1994 David Burren. It is licensed under a BSD license. + +The implementation of blowfish crypt (src/crypt/crypt_blowfish.c) was +originally written by Solar Designer and placed into the public +domain. The code also comes with a fallback permissive license for use +in jurisdictions that may not recognize the public domain. + +The smoothsort implementation (src/stdlib/qsort.c) is Copyright © 2011 +Valentin Ochs and is licensed under an MIT-style license. + +The x86_64 port was written by Nicholas J. Kain and is licensed under +the standard MIT terms. + +The mips and microblaze ports were originally written by Richard +Pennington for use in the ellcc project. The original code was adapted +by Rich Felker for build system and code conventions during upstream +integration. It is licensed under the standard MIT terms. + +The mips64 port was contributed by Imagination Technologies and is +licensed under the standard MIT terms. + +The powerpc port was also originally written by Richard Pennington, +and later supplemented and integrated by John Spencer. It is licensed +under the standard MIT terms. + +All other files which have no copyright comments are original works +produced specifically for use as part of this library, written either +by Rich Felker, the main author of the library, or by one or more +contibutors listed above. Details on authorship of individual files +can be found in the git version control history of the project. The +omission of copyright and license comments in each file is in the +interest of source tree size. + +In addition, permission is hereby granted for all public header files +(include/* and arch/*/bits/*) and crt files intended to be linked into +applications (crt/*, ldso/dlstart.c, and arch/*/crt_arch.h) to omit +the copyright notice and permission notice otherwise required by the +license, and to use these files without any requirement of +attribution. These files include substantial contributions from: + +Bobby Bingham +John Spencer +Nicholas J. Kain +Rich Felker +Richard Pennington +Stefan Kristiansson +Szabolcs Nagy + +all of whom have explicitly granted such permission. + +This file previously contained text expressing a belief that most of +the files covered by the above exception were sufficiently trivial not +to be subject to copyright, resulting in confusion over whether it +negated the permissions granted in the license. In the spirit of +permissive licensing, and of not having licensing issues being an +obstacle to adoption, that text has been removed. diff --git a/lisa/_assets/binaries/x86_64/pahole b/lisa/_assets/binaries/x86_64/pahole index 774a0adb4fff80bf85ce216a6a237471d3de3167..f2c963cd83232611085f7f4d2b1b606a13c56d12 100755 Binary files a/lisa/_assets/binaries/x86_64/pahole and b/lisa/_assets/binaries/x86_64/pahole differ diff --git a/lisa/_assets/kmodules/lisa/Makefile b/lisa/_assets/kmodules/lisa/Makefile index eaa75c3654ecb339012cc64ec92416ad1745e13e..f1c1011160829a8896d117e3ff2562f65051bc68 100644 --- a/lisa/_assets/kmodules/lisa/Makefile +++ b/lisa/_assets/kmodules/lisa/Makefile @@ -15,6 +15,11 @@ # limitations under the License. # +# This would break the IN_TREE_BUILD detection +ifeq ($(KBUILD_ABS_SRCTREE),1) +$(error KBUILD_ABS_SRCTREE=1 is not handled by the lisa module +endif + ifeq ($(srctree),.) IN_TREE_BUILD := 0 else @@ -63,14 +68,14 @@ ifneq ($(KERNELRELEASE),) LISA_KMOD_NAME ?= lisa obj-m := $(LISA_KMOD_NAME).o -$(LISA_KMOD_NAME)-y := main.o tp.o wq.o features.o pixel6.o private_types.o +$(LISA_KMOD_NAME)-y := main.o tp.o wq.o features.o pixel6.o introspection_data.o # -fno-stack-protector is needed to possibly undefined __stack_chk_guard symbol ccflags-y := "-I$(MODULE_SRC)" -std=gnu11 -fno-stack-protector -Wno-declaration-after-statement # Ensure we get appropriate debug info so that pahole can work on the object # file regardless of the kernel config. -CFLAGS_private_types.o := -g3 -gno-split-dwarf -gdwarf -fno-eliminate-unused-debug-types +CFLAGS_introspection_data.o := -g3 -gno-split-dwarf -gdwarf -fno-eliminate-unused-debug-types FEATURES_LDS := features.lds GENERATED := $(MODULE_OBJ)/generated @@ -80,6 +85,7 @@ $(GENERATED): SYMBOL_NAMESPACES_H := $(GENERATED)/symbol_namespaces.h MODULE_VERSION_H := $(GENERATED)/module_version.h +KALLSYMS := $(GENERATED)/kallsyms # in-tree build ifeq ($(IN_TREE_BUILD),1) @@ -90,38 +96,38 @@ ldflags-y += -T $(srctree)/$(obj)/$(FEATURES_LDS) # out-of-tree build else -PRIVATE_TYPES_H := $(GENERATED)/private_types.h +INTROSPECTION_DATA_H := $(GENERATED)/introspection_data.h ldflags-y += -T $(M)/$(FEATURES_LDS) -clean-files := $(PRIVATE_TYPES_H) $(SYMBOL_NAMESPACES_H) $(MODULE_VERSION_H) +clean-files := $(GENERATED) PRIVATE_TYPES_TXT := $(MODULE_SRC)/private_types.txt # Can be either a kernel image built with DWARF debug info, or the BTF blob # found at /sys/kernel/btf/vmlinux _BTF_VMLINUX := $(MODULE_SRC)/vmlinux -_DWARF_VMLINUX := $(KERNEL_SRC)/vmlinux -_SYNTHETIC_VMLINUX := $(MODULE_OBJ)/private_types.o +_REAL_VMLINUX := $(KERNEL_SRC)/vmlinux +_SYNTHETIC_VMLINUX := $(MODULE_OBJ)/introspection_data.o ifeq ("$(wildcard $(_BTF_VMLINUX))","") ifeq ($(IN_TREE_BUILD),1) VMLINUX := $(_SYNTHETIC_VMLINUX) else - VMLINUX := $(_DWARF_VMLINUX) + VMLINUX := $(_REAL_VMLINUX) endif else VMLINUX := $(_BTF_VMLINUX) endif -PRIVATE_TYPES_H_TYPE_PREFIX := KERNEL_PRIVATE_ - -python_env: - python3 -m pip install -r $(MODULE_SRC)/requirements.txt +UNUSED_KERNEL_PRIVATE_TYPES_PREFIX := KERNEL_PRIVATE_ -.PHONY: python_env +VENV := $(MODULE_OBJ)/venv +$(VENV): + python3 -m venv $(VENV) + . $(VENV)/bin/activate && python3 -m pip install --upgrade pip setuptools wheel && python3 -m pip install -r $(MODULE_SRC)/requirements.txt -$(PRIVATE_TYPES_H): $(GENERATED) $(PRIVATE_TYPES_TXT) $(VMLINUX) python_env +$(INTROSPECTION_DATA_H): $(GENERATED) $(KALLSYMS) $(PRIVATE_TYPES_TXT) $(VMLINUX) $(VENV) # Some options are not upstream (yet) but they have all be published on the # dwarves mailing list # @@ -139,20 +145,30 @@ $(PRIVATE_TYPES_H): $(GENERATED) $(PRIVATE_TYPES_TXT) $(VMLINUX) python_env # that was not explicitly asked for. This avoids conflicting with type # definitions that would come from public kernel headers, while still allowing # easy attribute access. - pahole -F btf,dwarf -E --suppress_force_paddings --show_only_data_members --skip_missing --expand_types_once -C "file://$(PRIVATE_TYPES_TXT)" "$(VMLINUX)" > $(MODULE_OBJ)/_header + pahole -F btf,dwarf -E --compile --suppress_force_paddings --show_only_data_members --skip_missing --expand_types_once -C "file://$(PRIVATE_TYPES_TXT)" "$(VMLINUX)" > $(MODULE_OBJ)/_header -# Rename all defined types to include the prefix - sed "s/\(struct\|union\|enum\)\s*\([a-zA-Z0-9_]\+\)/\1 $(PRIVATE_TYPES_H_TYPE_PREFIX)\2/g" -i $(MODULE_OBJ)/_header -# Create a sed script to rename back to initial state the types that we explicitly asked for - sed -n "s@\(.*\)@s/\\\(struct\\\|union\\\|enum\\\)\\\s*$(PRIVATE_TYPES_H_TYPE_PREFIX)\1/\\\1 \\1/;@gp" "$(PRIVATE_TYPES_TXT)" | sed -f - -i $(MODULE_OBJ)/_header +# Create a header with all the types we can for introspection purposes. This +# will not be included in any of the module sources, so all we care about is +# that pycparser can parse it. Specifically, some types may be re-defined with +# incompatible definitions. This is expected as various drivers use the same +# struct names. + pahole -F btf,dwarf -E --expand_types_once --suppress_force_paddings --suppress_aligned_attribute --suppress_packed --show_only_data_members --compile --fixup_silly_bitfields "$(VMLINUX)" > $(MODULE_OBJ)/_full_header # Strip comments to avoid matching them with the sed regex. "$(CC)" -P -E - < $(MODULE_OBJ)/_header > $(MODULE_OBJ)/_header_no_comment -# Create forward declaration of every type +# Create forward declaration of every type to ensure the header can be parsed correctly. sed -r -n 's/.*(struct|union|enum) ([0-9a-zA-Z_]*) .*/\1 \2;/p' $(MODULE_OBJ)/_header_no_comment | sort -u > $(MODULE_OBJ)/_fwd_decl + +# Rename all the kernel private types we are not directly interested in to avoid any clash + cat $(MODULE_OBJ)/_fwd_decl $(MODULE_OBJ)/_header_no_comment > $(MODULE_OBJ)/_header + . $(VENV)/bin/activate && python3 $(MODULE_SRC)/introspect_header.py --header $(MODULE_OBJ)/_header --type-prefix $(UNUSED_KERNEL_PRIVATE_TYPES_PREFIX) --non-renamed-types $(PRIVATE_TYPES_TXT) > $(MODULE_OBJ)/_renamed_header + # Create type introspection macros - python3 $(MODULE_SRC)/introspect_header.py $(MODULE_OBJ)/_header >> $(MODULE_OBJ)/_fwd_decl - cat $(MODULE_OBJ)/_fwd_decl $(MODULE_OBJ)/_header > $@ + . $(VENV)/bin/activate && python3 $(MODULE_SRC)/introspect_header.py --header $(MODULE_OBJ)/_full_header --introspect --kallsyms $(KALLSYMS) --kernel-features $(MODULE_SRC)/kernel_features.json >> $(MODULE_OBJ)/_introspection_header + +# Build the final header + printf '#pragma once\n' > $@ + cat $(MODULE_OBJ)/_introspection_header $(MODULE_OBJ)/_renamed_header >> $@ # cat $@ # out-of-tree build @@ -168,16 +184,23 @@ endif # There does not seem to be any other source for the info in e.g. sysfs or # procfs, so we rely on that hack for now. $(SYMBOL_NAMESPACES_H): $(GENERATED) - find "$(KERNEL_SRC)" '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 sed -n 's/MODULE_IMPORT_NS([^;]*;/\0/p' | sort -u > $@ + printf '#pragma once\n' > $@ + find "$(KERNEL_SRC)" '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 sed -n 's/MODULE_IMPORT_NS([^;]*;/\0/p' | sort -u >> $@ echo "MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);" >> $@ $(MODULE_VERSION_H): $(GENERATED) - printf "#ifndef _MODULE_VERSION_H\n#define _MODULE_VERSION_H\n#define LISA_MODULE_VERSION \"" > $@ - export LC_ALL=C && (cd $(MODULE_SRC) && sha1sum -- *.c *.h) | sort | sha1sum | cut -d' ' -f1 | tr -d '\n' >> $@ - printf "\"\n#endif\n" >> $@ + printf '#pragma once\n' > $@ + printf "#define LISA_MODULE_VERSION \"" >> $@ + export LC_ALL=C && (cd $(MODULE_SRC) && find -type f '(' -name '*.c' -or -name '*.h' -or -name '*.txt' -or -name '*.json' -or -name '*.py' -or -name '*.lds' -or -name 'Makefile' -or -name 'vmlinux' -or -name 'kallsyms' ')' -and -not -path './generated/*' | xargs sha1sum) | sort | sha1sum | cut -d' ' -f1 | tr -d '\n' >> $@ + printf "\"\n" >> $@ + + +$(KALLSYMS): $(GENERATED) + cat $(MODULE_SRC)/kallsyms > $@ || $(NM) $(_REAL_VMLINUX) > $@ || touch $@ + # Make all object files depend on the generated sources -$(addprefix $(MODULE_OBJ)/,$($(LISA_KMOD_NAME)-y)): $(PRIVATE_TYPES_H) $(SYMBOL_NAMESPACES_H) $(MODULE_VERSION_H) +$(addprefix $(MODULE_OBJ)/,$($(LISA_KMOD_NAME)-y)): $(INTROSPECTION_DATA_H) $(SYMBOL_NAMESPACES_H) $(MODULE_VERSION_H) # Non-Kbuild part else diff --git a/lisa/_assets/kmodules/lisa/ftrace_events.h b/lisa/_assets/kmodules/lisa/ftrace_events.h index e71d6961fa86c3fe5607961aaeb69c393f3cc9f9..8c6ad7a6a55154e2e06c7272b525ece3bf361ab2 100644 --- a/lisa/_assets/kmodules/lisa/ftrace_events.h +++ b/lisa/_assets/kmodules/lisa/ftrace_events.h @@ -17,16 +17,17 @@ #include "sched_helpers.h" -#if LINUX_VERSION_CODE <= KERNEL_VERSION(5,6,0) +#if HAS_MEMBER(struct, sched_avg, runnable_load_avg) #define RBL_LOAD_ENTRY rbl_load #define RBL_LOAD_MEMBER runnable_load_avg #define RBL_LOAD_STR "rbl_load" -#else +#elif HAS_MEMBER(struct, sched_avg, runnable_avg) #define RBL_LOAD_ENTRY runnable #define RBL_LOAD_MEMBER runnable_avg #define RBL_LOAD_STR "runnable" #endif +#if HAS_KERNEL_FEATURE(CFS_PELT) TRACE_EVENT(lisa__sched_pelt_cfs, TP_PROTO(int cpu, char *path, const struct sched_avg *avg), @@ -37,7 +38,9 @@ TRACE_EVENT(lisa__sched_pelt_cfs, __field( int, cpu ) __array( char, path, PATH_SIZE ) __field( unsigned long, load ) +#if HAS_KERNEL_FEATURE(SCHED_AVG_RBL) __field( unsigned long, RBL_LOAD_ENTRY ) +#endif __field( unsigned long, util ) __field( unsigned long long, update_time ) ), @@ -46,16 +49,29 @@ TRACE_EVENT(lisa__sched_pelt_cfs, __entry->cpu = cpu; strlcpy(__entry->path, path, PATH_SIZE); __entry->load = avg->load_avg; +#if HAS_KERNEL_FEATURE(SCHED_AVG_RBL) __entry->RBL_LOAD_ENTRY = avg->RBL_LOAD_MEMBER; +#endif __entry->util = avg->util_avg; __entry->update_time = avg->last_update_time; ), - TP_printk("cpu=%d path=%s load=%lu " RBL_LOAD_STR "=%lu util=%lu update_time=%llu", - __entry->cpu, __entry->path, __entry->load, - __entry->RBL_LOAD_ENTRY,__entry->util, __entry->update_time) + TP_printk( + "cpu=%d path=%s load=%lu util=%lu update_time=%llu" +#if HAS_KERNEL_FEATURE(SCHED_AVG_RBL) + " " RBL_LOAD_STR "=%lu" +#endif + , + __entry->cpu, __entry->path, __entry->load, + __entry->util, __entry->update_time +#if HAS_KERNEL_FEATURE(SCHED_AVG_RBL) + ,__entry->RBL_LOAD_ENTRY +#endif + ) ); +#endif +#if HAS_TYPE(struct, sched_avg) DECLARE_EVENT_CLASS(lisa__sched_pelt_rq_template, TP_PROTO(int cpu, const struct sched_avg *avg), @@ -65,7 +81,9 @@ DECLARE_EVENT_CLASS(lisa__sched_pelt_rq_template, TP_STRUCT__entry( __field( int, cpu ) __field( unsigned long, load ) +#if HAS_KERNEL_FEATURE(SCHED_AVG_RBL) __field( unsigned long, RBL_LOAD_ENTRY ) +#endif __field( unsigned long, util ) __field( unsigned long long, update_time ) ), @@ -73,28 +91,47 @@ DECLARE_EVENT_CLASS(lisa__sched_pelt_rq_template, TP_fast_assign( __entry->cpu = cpu; __entry->load = avg->load_avg; +#if HAS_KERNEL_FEATURE(SCHED_AVG_RBL) __entry->RBL_LOAD_ENTRY = avg->RBL_LOAD_MEMBER; +#endif __entry->util = avg->util_avg; __entry->update_time = avg->last_update_time; ), - TP_printk("cpu=%d load=%lu " RBL_LOAD_STR "=%lu util=%lu update_time=%llu", - __entry->cpu, __entry->load, - __entry->RBL_LOAD_ENTRY,__entry->util, __entry->update_time) + TP_printk( + "cpu=%d load=%lu util=%lu update_time=%llu" +#if HAS_KERNEL_FEATURE(SCHED_AVG_RBL) + " " RBL_LOAD_STR "=%lu" +#endif + , + __entry->cpu, __entry->load, + __entry->util, __entry->update_time +#if HAS_KERNEL_FEATURE(SCHED_AVG_RBL) + ,__entry->RBL_LOAD_ENTRY +#endif + ) ); +#endif +#if HAS_KERNEL_FEATURE(RT_PELT) DEFINE_EVENT(lisa__sched_pelt_rq_template, lisa__sched_pelt_rt, TP_PROTO(int cpu, const struct sched_avg *avg), TP_ARGS(cpu, avg)); +#endif +#if HAS_KERNEL_FEATURE(DL_PELT) DEFINE_EVENT(lisa__sched_pelt_rq_template, lisa__sched_pelt_dl, TP_PROTO(int cpu, const struct sched_avg *avg), TP_ARGS(cpu, avg)); +#endif +#if HAS_KERNEL_FEATURE(IRQ_PELT) DEFINE_EVENT(lisa__sched_pelt_rq_template, lisa__sched_pelt_irq, TP_PROTO(int cpu, const struct sched_avg *avg), TP_ARGS(cpu, avg)); +#endif +#if HAS_KERNEL_FEATURE(SE_PELT) TRACE_EVENT(lisa__sched_pelt_se, TP_PROTO(int cpu, char *path, char *comm, int pid, const struct sched_avg *avg), @@ -107,7 +144,9 @@ TRACE_EVENT(lisa__sched_pelt_se, __array( char, comm, TASK_COMM_LEN ) __field( int, pid ) __field( unsigned long, load ) +#if HAS_KERNEL_FEATURE(SCHED_AVG_RBL) __field( unsigned long, RBL_LOAD_ENTRY ) +#endif __field( unsigned long, util ) __field( unsigned long long, update_time ) ), @@ -118,16 +157,29 @@ TRACE_EVENT(lisa__sched_pelt_se, strlcpy(__entry->comm, comm, TASK_COMM_LEN); __entry->pid = pid; __entry->load = avg->load_avg; +#if HAS_KERNEL_FEATURE(SCHED_AVG_RBL) __entry->RBL_LOAD_ENTRY = avg->RBL_LOAD_MEMBER; +#endif __entry->util = avg->util_avg; __entry->update_time = avg->last_update_time; ), - TP_printk("cpu=%d path=%s comm=%s pid=%d load=%lu " RBL_LOAD_STR "=%lu util=%lu update_time=%llu", - __entry->cpu, __entry->path, __entry->comm, __entry->pid, - __entry->load, __entry->RBL_LOAD_ENTRY,__entry->util, __entry->update_time) + TP_printk( + "cpu=%d path=%s comm=%s pid=%d load=%lu util=%lu update_time=%llu" +#if HAS_KERNEL_FEATURE(SCHED_AVG_RBL) + " " RBL_LOAD_STR "=%lu" +#endif + , + __entry->cpu, __entry->path, __entry->comm, __entry->pid, + __entry->load, __entry->util, __entry->update_time +#if HAS_KERNEL_FEATURE(SCHED_AVG_RBL) + ,__entry->RBL_LOAD_ENTRY +#endif + ) ); +#endif +#if HAS_KERNEL_FEATURE(SCHED_OVERUTILIZED) TRACE_EVENT(lisa__sched_overutilized, TP_PROTO(int overutilized, char *span), @@ -147,8 +199,9 @@ TRACE_EVENT(lisa__sched_overutilized, TP_printk("overutilized=%d span=0x%s", __entry->overutilized, __entry->span) ); +#endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0) +#if HAS_KERNEL_FEATURE(RQ_NR_RUNNING) TRACE_EVENT(lisa__sched_update_nr_running, TP_PROTO(int cpu, int change, unsigned int nr_running), @@ -169,7 +222,9 @@ TRACE_EVENT(lisa__sched_update_nr_running, TP_printk("cpu=%d change=%d nr_running=%d", __entry->cpu, __entry->change, __entry->nr_running) ); +#endif +#if HAS_KERNEL_FEATURE(SE_UTIL_EST) TRACE_EVENT(lisa__sched_util_est_se, TP_PROTO(int cpu, char *path, char *comm, int pid, @@ -201,7 +256,9 @@ TRACE_EVENT(lisa__sched_util_est_se, __entry->cpu, __entry->path, __entry->comm, __entry->pid, __entry->enqueued, __entry->ewma, __entry->util) ); +#endif +#if HAS_KERNEL_FEATURE(CFS_UTIL_EST) TRACE_EVENT(lisa__sched_util_est_cfs, TP_PROTO(int cpu, char *path, const struct sched_avg *avg), @@ -230,8 +287,7 @@ TRACE_EVENT(lisa__sched_util_est_cfs, ); #endif -#ifdef CONFIG_UCLAMP_TASK - +#if HAS_KERNEL_FEATURE(SE_UCLAMP) TRACE_EVENT_CONDITION(lisa__uclamp_util_se, TP_PROTO(bool is_task, struct task_struct *p, struct rq *rq), @@ -253,9 +309,9 @@ TRACE_EVENT_CONDITION(lisa__uclamp_util_se, TP_fast_assign( __entry->pid = p->pid; memcpy(__entry->comm, p->comm, TASK_COMM_LEN); - __entry->cpu = lisa_rq_cpu(rq); + __entry->cpu = rq_cpu(rq); __entry->util_avg = p->se.avg.util_avg; - __entry->uclamp_avg = uclamp_rq_util_with(rq, p->se.avg.util_avg, NULL); + __entry->uclamp_avg = uclamp_rq_util_with(rq, p->se.avg.util_avg); __entry->uclamp_min = rq->uclamp[UCLAMP_MIN].value; __entry->uclamp_max = rq->uclamp[UCLAMP_MAX].value; ), @@ -266,7 +322,12 @@ TRACE_EVENT_CONDITION(lisa__uclamp_util_se, __entry->util_avg, __entry->uclamp_avg, __entry->uclamp_min, __entry->uclamp_max) ); +#else +#define trace_lisa__uclamp_util_se(is_task, p, rq) while(false) {} +#define trace_lisa__uclamp_util_se_enabled() (false) +#endif +#if HAS_KERNEL_FEATURE(CFS_UCLAMP) TRACE_EVENT_CONDITION(lisa__uclamp_util_cfs, TP_PROTO(bool is_root, struct rq *rq, struct cfs_rq *cfs_rq), @@ -284,9 +345,9 @@ TRACE_EVENT_CONDITION(lisa__uclamp_util_cfs, ), TP_fast_assign( - __entry->cpu = lisa_rq_cpu(rq); + __entry->cpu = rq_cpu(rq); __entry->util_avg = cfs_rq->avg.util_avg; - __entry->uclamp_avg = uclamp_rq_util_with(rq, cfs_rq->avg.util_avg, NULL); + __entry->uclamp_avg = uclamp_rq_util_with(rq, cfs_rq->avg.util_avg); __entry->uclamp_min = rq->uclamp[UCLAMP_MIN].value; __entry->uclamp_max = rq->uclamp[UCLAMP_MAX].value; ), @@ -297,13 +358,11 @@ TRACE_EVENT_CONDITION(lisa__uclamp_util_cfs, __entry->uclamp_min, __entry->uclamp_max) ); #else -#define trace_lisa__uclamp_util_se(is_task, p, rq) while(false) {} -#define trace_lisa__uclamp_util_se_enabled() false #define trace_lisa__uclamp_util_cfs(is_root, cpu, cfs_rq) while(false) {} -#define trace_lisa__uclamp_util_cfs_enabled() false -#endif /* CONFIG_UCLAMP_TASK */ +#define trace_lisa__uclamp_util_cfs_enabled() (false) +#endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,10,0) && (defined(CONFIG_ARM64) || defined(CONFIG_ARM)) +#if HAS_KERNEL_FEATURE(RQ_CAPACITY) TRACE_EVENT(lisa__sched_cpu_capacity, TP_PROTO(struct rq *rq), diff --git a/lisa/_assets/kmodules/lisa/introspect_header.py b/lisa/_assets/kmodules/lisa/introspect_header.py index 0152e979fcd28c080a54b02d28dfa9ce12f5cd09..0f4e2e64a098d5025ed0a57314d1edb0dad75c1f 100755 --- a/lisa/_assets/kmodules/lisa/introspect_header.py +++ b/lisa/_assets/kmodules/lisa/introspect_header.py @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -# Copyright (C) 2019, Arm Limited and contributors. +# Copyright (C) 2023, Arm Limited and contributors. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. @@ -18,76 +18,375 @@ # +import abc +import copy import itertools import argparse import subprocess from collections import namedtuple +import functools +import json +import re -from pycparser import c_parser, c_ast +from pycparser import c_ast +from pycparserext.ext_c_parser import GnuCParser +from pycparserext.ext_c_generator import GnuCGenerator -class TypeMember(namedtuple('TypeMember', ['type_name', 'member_name'])): +class Record(abc.ABC): + @abc.abstractmethod def make_define(self): - return f'#define _TYPE_HAS_MEMBER_{self.type_name}___{self.member_name}' + pass - @property - def printable(self): - return self.type_name and self.member_name + +class TypeMemberRecord(namedtuple('TypeMemberRecord', ['type_kind', 'type_name', 'member_name']), Record): + def make_define(self): + return f'#define _TYPE_HAS_MEMBER_{self.type_kind}_{self.type_name}_LISA_SEPARATOR_{self.member_name} 1' -class TypeExists(namedtuple('TypeExists', ['type_name'])): +class TypeExistsRecord(namedtuple('TypeExistsRecord', ['type_kind', 'type_name']), Record): def make_define(self): - return f'#define _TYPE_EXISTS_{self.type_name}' + return f'#define _TYPE_EXISTS_{self.type_kind}_{self.type_name} 1' - @property - def printable(self): - return bool(self.type_name) -def expand_typ(typ): - if isinstance(typ, c_ast.TypeDecl): - return expand_typ(typ.type) - else: - return [typ] - -def resolve_typ(typ): - if isinstance(typ, (c_ast.Struct, c_ast.Union)): - children = typ.decls or [] - children_typs = [ - child.type - for child in children +class TypedefMemo: + def __init__(self, types): + self.complete_memo = {} + self.resolved = {} + + # Seed the memo so that we know complete type defintions when typedef + # is created based on a forward definition. + def walk(typ): + self.register_complete(typ) + self.resolve_typ(typ) + + for typ in types: + walk(typ) + + @staticmethod + def _get_key(typ): + if isinstance(typ, (c_ast.Struct, c_ast.Union, c_ast.Enum)): + return (typ.__class__, typ.name) + else: + raise ValueError('unhandled type') + + @staticmethod + def _is_complete(typ): + if isinstance(typ, (c_ast.Struct, c_ast.Union)): + return typ.decls is not None + elif isinstance(typ, c_ast.Enum): + return typ.values is not None + else: + return True + + def register_complete(self, typ): + try: + key = self._get_key(typ) + except ValueError: + return + else: + # Only memoize complete definitions, i.e. not forward definitions + if self._is_complete(typ): + self.complete_memo[key] = typ + + def get_complete(self, typ): + try: + key = self._get_key(typ) + except ValueError: + return typ + else: + return self.complete_memo.get(key, typ) + + + def resolve_typ(self, typ): + try: + return self.resolved[typ] + except KeyError: + pass + + recurse = self.resolve_typ + + if isinstance(typ, (c_ast.Struct, c_ast.Union)): + def expand_child(decl): + typ = decl.type + # An struct/union anonymous member inside a struct/union is + # expanded in its parent. + if decl.name is None: + _, _, children, children_typs = recurse(typ) + return (children, list(children_typs) + [typ]) + else: + return ([decl], [typ.type]) + + name = typ.name + children = typ.decls + + if children: + children, children_typs = map(itertools.chain.from_iterable, zip(*map(expand_child, children))) + else: + children = [] + children_typs = [] + + if isinstance(typ, c_ast.Struct): + kind = 'struct' + elif isinstance(typ, c_ast.Union): + kind = 'union' + else: + raise ValueError(f'Unhandled type: {typ}') + + elif isinstance(typ, c_ast.Enum): + children = typ.values or [] + children_typs = [] + name = typ.name + kind = 'enum' + elif isinstance(typ, c_ast.Typedef): + name = typ.name + # Typedef is refering to a type by name, so look the full definition of + # that type + child_typ = self.get_complete(typ.type.type) + _, _, children, children_typs = recurse(child_typ) + kind = 'typedef' + else: + return (None, None, [], []) + + res = (kind, name, tuple(children), tuple(children_typs)) + self.resolved[typ] = res + return res + + +def make_records(memo, types): + + def recurse_multi(types): + return itertools.chain.from_iterable( + map(recurse, types) + ) + + visited = set() + def recurse(typ): + if typ in visited: + return tuple() + else: + visited.add(typ) + + kind, name, children, children_typs = memo.resolve_typ(typ) + return itertools.chain( + ( + TypeExistsRecord(type_kind=kind, type_name=name), + ) if name else tuple(), + ( + TypeMemberRecord(type_kind=kind, type_name=name, member_name=child.name) + for child in children + if name and child.name + ), + recurse_multi(children_typs) + ) + + return recurse_multi(types) + + +def introspect_header(ast): + assert isinstance(ast, c_ast.FileAST) + + def expand_decl(node): + if isinstance(node, c_ast.Decl): + return node.type + else: + return node + + types = [ + expand_decl(node) + for node in ast + ] + + memo = TypedefMemo(types) + records = make_records(memo, types) + return itertools.chain( + ( + '#define _TYPE_INTROSPECTION_INFO_AVAILABLE 1', + ), + ( + record.make_define() + for record in records + ), + ) + + +class TypeRenameVisitor(c_ast.NodeVisitor): + def __init__(self, type_prefix, non_renamed): + self.type_prefix = type_prefix + self.names = { + name: name + for name in (non_renamed or []) + } + + def _rename(self, name): + if name: + try: + return self.names[name] + except KeyError: + new = f'{self.type_prefix}{name}' + self.names[name] = new + return new + else: + return name + + def visit_IdentifierType(self, node): + node.names = [ + self.names.get(name, name) + for name in node.names ] - name = typ.name - elif isinstance(typ, c_ast.Enum): - children = typ.values or [] - children_typs = [] - name = typ.name - elif isinstance(typ, c_ast.TypeDecl): - name = typ.declname - _, children, children_typs = resolve_typ(typ.type) - else: - raise ValueError('Unhandled type') - return (name, children, children_typs) + def visit_Typedef(self, node): + def rename_decl(node, name): + if isinstance(node, c_ast.TypeDecl): + node.declname = name + else: + # Go through layers of PtrDecl, ArrayDecl etc + return rename_decl(node.type, name) + new = self._rename(node.name) + node.name = new + rename_decl(node.type, new) + self.visit(node.type) -def walk_type(typ): - try: - name, children, children_typs = resolve_typ(typ) - except ValueError: - return [] + def visit_Enum(self, node): + node.name = self._rename(node.name) + if node.values is not None: + self.visit(node.values) + + def visit_Enumerator(self, node): + node.name = self._rename(node.name) + + def _visit_StructUnion(self, node): + node.name = self._rename(node.name) + # Not a forward decl + if node.decls is not None: + self.visit(node.decls) + + def visit_Struct(self, node): + self._visit_StructUnion(node) + + def visit_Union(self, node): + self._visit_StructUnion(node) + + # pycparserext types added by: + # https://github.com/inducer/pycparserext/pull/76 + visit_EnumExt = visit_Enum + visit_StructExt = visit_Struct + visit_UnionExt = visit_Union + visit_EnumeratorExt = visit_Enumerator + +def rename_types(ast, type_prefix, non_renamed): + ast = copy.deepcopy(ast) + TypeRenameVisitor(type_prefix, non_renamed).visit(ast) + code = GnuCGenerator().visit(ast) + return code + + +def process_header(path, introspect, type_prefix, non_renamed_types): + with open(path, 'r') as f: + header = f.read() + + if non_renamed_types: + with open(non_renamed_types, 'r') as f: + non_renamed_types = [name.strip() for name in f.read().splitlines()] else: - children_typs = itertools.chain.from_iterable(map(expand_typ, children_typs)) + non_renamed_types = [] + + # Remove comments and the non-standard GNU C extensions that pycparser cannot + # process + cmd = ['cpp', '-P', '-'] + res = subprocess.run(cmd, input=header, capture_output=True, text=True, check=True) + header = res.stdout + + parser = GnuCParser() + ast = parser.parse(header, filename=path) + + return itertools.chain( + introspect_header(ast) if introspect else [], + [rename_types(ast, type_prefix, non_renamed_types)] if type_prefix else [], + ) + +class SymbolRecord(namedtuple('SymbolRecord', ['name']), Record): + def make_define(self): + return f'#define _SYMBOL_EXISTS_{self.name} 1' + + +def process_kallsyms(path): + with open(path, 'r') as f: + kallsyms = f.read() + + def make_record(addr, code, name): + # Uppercase codes are for STB_GLOBAL symbols, i.e. exported symbols. + if code.isupper() and name.isidentifier(): + return SymbolRecord(name=name).make_define() + else: + return None + + records = itertools.starmap( + make_record, + ( + line.split(maxsplit=2) + for line in kallsyms.splitlines() + if line + ) + ) + records = set(record for record in records if record) + + if records: return itertools.chain( - [ - TypeExists(type_name=name) - ], + records, ( - TypeMember(type_name=name, member_name=child.name) - for child in children + '#define _SYMBOL_INTROSPECTION_INFO_AVAILABLE 1', ), - itertools.chain.from_iterable(map(walk_type, children_typs)) ) + # If the file is empty, we assume there is no kallsyms available + else: + return [] + + +def process_kernel_features(path): + with open(path, 'r') as f: + features = json.load(f) + + # Macros cannot be recursive, so we expand them manually. + def expand(value): + def replace(m): + name = m.group(1) + name = name.strip() + value = features[name] + expanded = expand(value) + return f'({expanded})' + + return re.sub(r'HAS_KERNEL_FEATURE\(([a-zA-Z0-9_]+)\)', replace, value) + + features = { + name: expand(value) + for name, value in features.items() + } + + features = list(features.items()) + names, values = zip(*features) + + names = ', '.join( + f'"{name}"' + for name in names + ) + names = f'#define __KERNEL_FEATURE_NAMES {names}' + + values = ', '.join( + f'({value})' + for value in values + ) + values = f'#define __KERNEL_FEATURE_VALUES {values}' + + return itertools.chain( + (names, values), + ( + f'#define _KERNEL_HAS_FEATURE_{name} ({value})' + for name, value in features + ) + ) def main(): @@ -96,43 +395,31 @@ def main(): of types. """) - parser.add_argument('header', help='C header file to parse') + parser.add_argument('--header', help='C header file to parse') + parser.add_argument('--introspect', action='store_true', help='Create introspection macros for the given --header or --kallsyms') - args = parser.parse_args() - with open(args.header, 'r') as f: - header = f.read() - - # Remove comments and the non-standard GNU C extensions that pycparser cannot - # process - cmd = ['cpp', '-P', '-D__attribute__(x)=', '-'] - res = subprocess.run(cmd, input=header, capture_output=True, text=True, check=True) - header = res.stdout + parser.add_argument('--type-prefix', help='Add the given prefix to the types found in --header and dump the resulting renamed header') + parser.add_argument('--non-renamed-types', help='File containing list of type names that will not be renamed by --type-prefix') + parser.add_argument('--kallsyms', help='kallsyms content to parse') + parser.add_argument('--kernel-features', help='JSON list of kernel features') - parser = c_parser.CParser() - node = parser.parse(header, filename=args.header) + args = parser.parse_args() - assert isinstance(node, c_ast.FileAST) + if args.type_prefix and not args.header: + parser.error('--header is required if --type-prefix is used') - types = [ - _node.type - for _node in node - if isinstance(_node, (c_ast.Decl, c_ast.Typedef, c_ast.TypeDecl)) - ] + out = [] + if args.header: + out.append(process_header(args.header, args.introspect, args.type_prefix, args.non_renamed_types)) - records = set(itertools.chain.from_iterable(map(walk_type, types))) - records = sorted( - record - for record in records - if record.printable - ) - macros = '\n'.join( - record.make_define() - for record in records - ) - print('#define _TYPE_INTROSPECTION_INFO_AVAILABLE') - print(macros) + if args.kallsyms and args.introspect: + out.append(process_kallsyms(args.kallsyms)) + if args.kernel_features: + out.append(process_kernel_features(args.kernel_features)) + for rec in sorted(set(itertools.chain.from_iterable(out))): + print(rec) if __name__ == '__main__': main() diff --git a/lisa/_assets/kmodules/lisa/introspection.h b/lisa/_assets/kmodules/lisa/introspection.h index d78f695d6d0170f94b10147ea68b604e7338ea6b..83d9ab62f57da9c0373ec2dceaece18f6d845114 100644 --- a/lisa/_assets/kmodules/lisa/introspection.h +++ b/lisa/_assets/kmodules/lisa/introspection.h @@ -2,9 +2,38 @@ #ifndef INTROSPECTION_H #define INTROSPECTION_H -#include +#include -#define HAS_TYPE(typ) ((defined(_TYPE_INTROSPECTION_INFO_AVAILABLE) && defined(_TYPE_EXISTS_##typ)) || (!defined(_TYPE_INTROSPECTION_INFO_AVAILABLE))) -#define HAS_MEMBER(typ, member) ((defined(_TYPE_INTROSPECTION_INFO_AVAILABLE) && defined(_TYPE_HAS_MEMBER_##typ##___##member)) || (!defined(_TYPE_INTROSPECTION_INFO_AVAILABLE))) + +// Inspired by the kernel IS_ENABLED() implementation. This works around the +// fact that the defined() operator only works in #if and #elif, but putting a +// layer of macro breaks it. +#define __ARG_PLACEHOLDER_1 0, +#define __take_second_arg(__ignored, val, ...) val +#define __is_defined(x) ___is_defined(x) +#define ___is_defined(val) ____is_defined(__ARG_PLACEHOLDER_##val) +#define ____is_defined(arg1_or_junk) __take_second_arg(arg1_or_junk 1, 0) + +#define IS_DEFINED(option) (__is_defined(option)) + + + +#ifdef _TYPE_INTROSPECTION_INFO_AVAILABLE +# define HAS_TYPE(kind, typ) IS_DEFINED(_TYPE_EXISTS_##kind##_##typ) +# define HAS_MEMBER(kind, typ, member) (HAS_TYPE(kind, typ) && IS_DEFINED(_TYPE_HAS_MEMBER_##kind##_##typ##_LISA_SEPARATOR_##member)) +#else +# warning "Type introspection information not available, HAS_TYPE() and HAS_MEMBER() will assume types and members exist" +# define HAS_TYPE(kind, typ) (1) +# define HAS_MEMBER(kind, typ, member) (1) +#endif + +#ifdef _SYMBOL_INTROSPECTION_INFO_AVAILABLE +# define HAS_SYMBOL(name) IS_DEFINED(_SYMBOL_EXISTS_##name) +#else +# warning "Symbol introspection information not available, HAS_SYMBOL() will assume all symbols exist" +# define HAS_SYMBOL(name) (1) +#endif + +#define HAS_KERNEL_FEATURE(name) (_KERNEL_HAS_FEATURE_##name) #endif /* INTROSPECTION_H */ diff --git a/lisa/_assets/kmodules/lisa/private_types.c b/lisa/_assets/kmodules/lisa/introspection_data.c similarity index 84% rename from lisa/_assets/kmodules/lisa/private_types.c rename to lisa/_assets/kmodules/lisa/introspection_data.c index 0d0639906af9b84472eef6951ee4280373964636..a8bb89b58259de09eeebbd92abbf5a16b11fd8ce 100644 --- a/lisa/_assets/kmodules/lisa/private_types.c +++ b/lisa/_assets/kmodules/lisa/introspection_data.c @@ -2,7 +2,7 @@ /* Include here headers containing the types listed in private_types.txt. * We process the debug info of the compiled object file like we would do * with the -BTF blob and generate the private_types.h header, which is then consumed the +BTF blob and generate the introspection_data.h header, which is then consumed the exact * same way as an out-of-tree build. This allows controlling the format of that * header for introspect_header.py. */ diff --git a/lisa/_assets/kmodules/lisa/kernel_features.json b/lisa/_assets/kmodules/lisa/kernel_features.json new file mode 100644 index 0000000000000000000000000000000000000000..9e8e3a69e1220a2855b812de6a777ee6bc5acabf --- /dev/null +++ b/lisa/_assets/kmodules/lisa/kernel_features.json @@ -0,0 +1,25 @@ + +{ + "RQ_CAPACITY": "HAS_MEMBER(struct, rq, cpu_capacity)", + "RQ_NR_RUNNING": "HAS_MEMBER(struct, rq, nr_running)", + + "CFS_PELT": "HAS_MEMBER(struct, cfs_rq, avg) && HAS_TYPE(struct, sched_avg)", + "CFS_UTIL_EST": "HAS_KERNEL_FEATURE(CFS_PELT) && HAS_MEMBER(struct, sched_avg, util_est)", + "CFS_UCLAMP": "IS_ENABLED(CONFIG_UCLAMP_TASK) && HAS_MEMBER(struct, rq, uclamp)", + + "SE_PELT": "HAS_TYPE(struct, sched_avg) && HAS_MEMBER(struct, sched_entity, avg)", + "SE_UCLAMP": "HAS_KERNEL_FEATURE(SE_PELT) && HAS_MEMBER(struct, uclamp_se, value)", + "SE_UTIL_EST": "HAS_KERNEL_FEATURE(SE_PELT) && HAS_MEMBER(struct, sched_avg, util_est)", + + "DL_PELT": "HAS_MEMBER(struct, rq, avg_dl)", + + "IRQ_PELT": "IS_ENABLED(CONFIG_HAVE_SCHED_AVG_IRQ) && HAS_MEMBER(struct, rq, avg_irq)", + + "RT_PELT": "HAS_MEMBER(struct, rq, avg_rt)", + + "SCHED_OVERUTILIZED": "HAS_MEMBER(struct, rq, rd) && HAS_MEMBER(struct, root_domain, overutilized)", + "SCHED_AUTOGROUP": "IS_ENABLED(CONFIG_SCHED_AUTOGROUP) && HAS_MEMBER(struct, task_group, autogroup)", + "SCHED_AVG_RBL": "HAS_MEMBER(struct, sched_avg, runnable_load_avg) || HAS_MEMBER(struct, sched_avg, runnable_avg)", + + "FILE_IO": "HAS_SYMBOL(kernel_read) && HAS_SYMBOL(kernel_write) && HAS_SYMBOL(filp_open)" +} \ No newline at end of file diff --git a/lisa/_assets/kmodules/lisa/main.c b/lisa/_assets/kmodules/lisa/main.c index a3d1b39427d7046d6ecb9edbe33a52e581d78bcf..8e556e6b2fb35c43426a7b76e8acb79f91d843d9 100644 --- a/lisa/_assets/kmodules/lisa/main.c +++ b/lisa/_assets/kmodules/lisa/main.c @@ -3,6 +3,7 @@ #include "main.h" #include "features.h" +#include "introspection.h" #include "generated/module_version.h" /* Import all the symbol namespaces that appear to be defined in the kernel * sources so that we won't trigger any warning @@ -32,6 +33,13 @@ static int __init modinit(void) { return -EPROTO; } + pr_info("Kernel features detected. This will impact the module features that are available:\n"); + const char *kernel_feature_names[] = {__KERNEL_FEATURE_NAMES}; + const bool kernel_feature_values[] = {__KERNEL_FEATURE_VALUES}; + for (size_t i=0; i < ARRAY_SIZE(kernel_feature_names); i++) { + pr_info(" %s: %s\n", kernel_feature_names[i], kernel_feature_values[i] ? "enabled" : "disabled"); + } + ret = init_features(features, features_len); if (ret) { diff --git a/lisa/_assets/kmodules/lisa/pixel6.c b/lisa/_assets/kmodules/lisa/pixel6.c index 142482b3f5faaae12c2cb3ceb75b3bfe144cb3e9..3fa924c628b77e3ff75d922f4faa8f61ae2025ae 100644 --- a/lisa/_assets/kmodules/lisa/pixel6.c +++ b/lisa/_assets/kmodules/lisa/pixel6.c @@ -9,6 +9,7 @@ #include "wq.h" #include "ftrace_events.h" #include "parsec.h" +#include "introspection.h" /* There is no point in setting this value to less than 8 times what is written * in usec to POWER_METER_RATE_FILE @@ -21,6 +22,8 @@ #define POWER_METER_SAMPLE_FILE_1 "/sys/bus/iio/devices/iio:device1/energy_value" #define POWER_METER_RATE_FILE_1 "/sys/bus/iio/devices/iio:device1/sampling_rate" +#if HAS_KERNEL_FEATURE(FILE_IO) + static PARSE_RESULT(int) parse_content(parse_buffer *); typedef struct sample { @@ -185,11 +188,6 @@ static int disable_p6_emeter(struct feature* feature) { return ret; }; - -DEFINE_FEATURE(event__lisa__pixel6_emeter, enable_p6_emeter, disable_p6_emeter); - - - /*********************************************** * Parser for the energy_value sysfs file format ***********************************************/ @@ -251,3 +249,18 @@ SEQUENCE(int, parse_content, ({ /* Parse all the following sample lines */ PARSE(parse_all_samples, 0); })) + +#else +#warning "event__lisa__pixel6_emeter feature will not be available due to kernel not exporting necessary symbols" +static int enable_p6_emeter(struct feature* feature) { + pr_err("The kernel does not export the required symbols for that feature"); + return 1; +} + +static int disable_p6_emeter(struct feature* feature) { + return 0; +} +#endif + + +DEFINE_FEATURE(event__lisa__pixel6_emeter, enable_p6_emeter, disable_p6_emeter); diff --git a/lisa/_assets/kmodules/lisa/requirements.txt b/lisa/_assets/kmodules/lisa/requirements.txt index dc1c9e101ad9ccd943b359338ef42c342ebc84a1..302be7e56f602cf0fbd40b4bcd3a8f882bbfeacf 100644 --- a/lisa/_assets/kmodules/lisa/requirements.txt +++ b/lisa/_assets/kmodules/lisa/requirements.txt @@ -1 +1,3 @@ -pycparser +# We need the __attribute__(()) support implemented in that pull request: +# https://github.com/inducer/pycparserext/pull/76 +https://github.com/douglas-raillard-arm/pycparserext/archive/lisa.zip diff --git a/lisa/_assets/kmodules/lisa/sched_helpers.h b/lisa/_assets/kmodules/lisa/sched_helpers.h index cc8b19ad90d4fd6cf6514cbcbb0fb037124c6aa8..48a90557f8373eed7c07c1a2de494801c2d8d449 100644 --- a/lisa/_assets/kmodules/lisa/sched_helpers.h +++ b/lisa/_assets/kmodules/lisa/sched_helpers.h @@ -2,65 +2,84 @@ #ifndef SCHED_HELPERS_H #define SCHED_HELPERS_H -/* Required for struct irq_work which is defined in struct root_domain */ -#include +#include +/* Required for some structs */ +#include #include -#include "generated/private_types.h" +#include "introspection.h" +#include "generated/introspection_data.h" -#ifdef CONFIG_FAIR_GROUP_SCHED + +#if HAS_TYPE(struct, cfs_rq) +# if defined(CONFIG_FAIR_GROUP_SCHED) && HAS_MEMBER(struct, cfs_rq, rq) static inline struct rq *rq_of(struct cfs_rq *cfs_rq) { return cfs_rq->rq; } -#define entity_is_task(se) (!se->my_q) -#else +# else static inline struct rq *rq_of(struct cfs_rq *cfs_rq) { return container_of(cfs_rq, struct rq, cfs); } -#define entity_is_task(se) 1 +# endif #endif + +#if HAS_MEMBER(struct, sched_entity, my_q) +# define entity_is_task(se) (!(se)->my_q) +#else +# define entity_is_task(se) (1) +#endif + + +#if HAS_TYPE(struct, rq) static inline int cpu_of(struct rq *rq) { -#ifdef CONFIG_SMP +# if defined(CONFIG_SMP) && HAS_MEMBER(struct, rq, cpu) return rq->cpu; -#else +# else return 0; -#endif +# endif } +#endif #define cap_scale(v, s) ((v)*(s) >> SCHED_CAPACITY_SHIFT) + +#if HAS_TYPE(struct, task_group) static inline bool task_group_is_autogroup(struct task_group *tg) { -#ifdef CONFIG_SCHED_AUTOGROUP +# if HAS_KERNEL_FEATURE(SCHED_AUTOGROUP) return !!tg->autogroup; -#else +# else return false; -#endif +# endif } +#endif +#if HAS_TYPE(struct, task_group) static int autogroup_path(struct task_group *tg, char *buf, int buflen) { -#ifdef CONFIG_SCHED_AUTOGROUP +# if HAS_KERNEL_FEATURE(SCHED_AUTOGROUP) && HAS_MEMBER(struct, autogroup, id) if (!task_group_is_autogroup(tg)) return 0; return snprintf(buf, buflen, "%s-%ld", "/autogroup", tg->autogroup->id); -#else +# else return 0; -#endif +# endif } +#endif + +#if HAS_TYPE(struct, rq) /* A cut down version of the original. @p MUST be NULL */ static __always_inline -unsigned long uclamp_rq_util_with(struct rq *rq, unsigned long util, - struct task_struct *p) +unsigned long uclamp_rq_util_with(struct rq *rq, unsigned long util) { -#ifdef CONFIG_UCLAMP_TASK +# if HAS_KERNEL_FEATURE(SE_UCLAMP) unsigned long min_util; unsigned long max_util; @@ -71,55 +90,62 @@ unsigned long uclamp_rq_util_with(struct rq *rq, unsigned long util, return min_util; return clamp(util, min_util, max_util); -#else +# else return util; -#endif +# endif } +#endif +#if HAS_TYPE(struct, cfs_rq) static inline void cfs_rq_tg_path(struct cfs_rq *cfs_rq, char *path, int len) { if (!path) return; -#ifdef CONFIG_FAIR_GROUP_SCHED +# if defined(CONFIG_FAIR_GROUP_SCHED) && HAS_MEMBER(struct, cfs_rq, tg) && HAS_MEMBER(struct, task_group, css) && HAS_MEMBER(struct, cgroup_subsys_state, cgroup) if (cfs_rq && task_group_is_autogroup(cfs_rq->tg)) autogroup_path(cfs_rq->tg, path, len); else if (cfs_rq && cfs_rq->tg->css.cgroup) cgroup_path((struct cgroup *)cfs_rq->tg->css.cgroup, path, len); else -#endif +# endif strlcpy(path, "(null)", len); } +#endif +#if HAS_TYPE(struct, sched_entity) static inline struct cfs_rq *get_group_cfs_rq(struct sched_entity *se) { -#ifdef CONFIG_FAIR_GROUP_SCHED +# if defined(CONFIG_FAIR_GROUP_SCHED) && HAS_MEMBER(struct, sched_entity, my_q) return se->my_q; -#else +# else return NULL; -#endif +# endif } static inline struct cfs_rq *get_se_cfs_rq(struct sched_entity *se) { -#ifdef CONFIG_FAIR_GROUP_SCHED +# if defined(CONFIG_FAIR_GROUP_SCHED) && HAS_MEMBER(struct, sched_entity, cfs_rq) return se->cfs_rq; -#else +# else return NULL; -#endif +# endif } +#endif -static inline const struct sched_avg *lisa_cfs_rq_avg(struct cfs_rq *cfs_rq) + +#if HAS_TYPE(struct, cfs_rq) +static inline const struct sched_avg *cfs_rq_avg(struct cfs_rq *cfs_rq) { -#ifdef CONFIG_SMP +# if HAS_KERNEL_FEATURE(CFS_PELT) return cfs_rq ? (struct sched_avg *)&cfs_rq->avg : NULL; -#else +# else return NULL; -#endif +# endif } -static inline char *lisa_cfs_rq_path(struct cfs_rq *cfs_rq, char *str, int len) +static inline char *cfs_rq_path(struct cfs_rq *cfs_rq, char *str, int len) { if (!cfs_rq) { if (str) @@ -132,66 +158,76 @@ static inline char *lisa_cfs_rq_path(struct cfs_rq *cfs_rq, char *str, int len) return str; } -static inline int lisa_cfs_rq_cpu(struct cfs_rq *cfs_rq) +static inline int cfs_rq_cpu(struct cfs_rq *cfs_rq) { return cfs_rq ? cpu_of(rq_of(cfs_rq)) : -1; } -static inline const struct sched_avg *lisa_rq_avg_rt(struct rq *rq) +#endif + +#if HAS_TYPE(struct, rq) +static inline const struct sched_avg *rq_avg_rt(struct rq *rq) { -#ifdef CONFIG_SMP +# if HAS_KERNEL_FEATURE(RT_PELT) return rq ? (struct sched_avg *)&rq->avg_rt : NULL; -#else +# else return NULL; -#endif +# endif } -static inline const struct sched_avg *lisa_rq_avg_dl(struct rq *rq) +static inline const struct sched_avg *rq_avg_dl(struct rq *rq) { -#ifdef CONFIG_SMP +# if HAS_KERNEL_FEATURE(DL_PELT) return rq ? (struct sched_avg *)&rq->avg_dl : NULL; -#else +# else return NULL; -#endif +# endif } -static inline const struct sched_avg *lisa_rq_avg_irq(struct rq *rq) +static inline const struct sched_avg *rq_avg_irq(struct rq *rq) { -#if defined(CONFIG_SMP) && defined(CONFIG_HAVE_SCHED_AVG_IRQ) +# if HAS_KERNEL_FEATURE(IRQ_PELT) return rq ? (struct sched_avg *)&rq->avg_irq : NULL; -#else +# else return NULL; -#endif +# endif } -static inline int lisa_rq_cpu(struct rq *rq) +static inline int rq_cpu(struct rq *rq) { return rq ? cpu_of(rq) : -1; } -static inline int lisa_rq_cpu_capacity(struct rq *rq) +static inline int rq_cpu_capacity(struct rq *rq) { return rq ? -#ifdef CONFIG_SMP +#if HAS_KERNEL_FEATURE(RQ_CAPACITY) rq->cpu_capacity -#else +# else SCHED_CAPACITY_SCALE -#endif +# endif : -1; } -static inline const struct cpumask *lisa_rd_span(struct root_domain *rd) +static inline int rq_nr_running(struct rq *rq) { -#ifdef CONFIG_SMP - return rd ? (struct cpumask *)rd->span : NULL; -#else - return NULL; -#endif +# if HAS_KERNEL_FEATURE(RQ_NR_RUNNING) + if (rq->nr_running) + return rq->nr_running; +# endif + return -1; } +#endif -static inline int lisa_rq_nr_running(struct rq *rq) +#if HAS_TYPE(struct, root_domain) +static inline const struct cpumask *rd_span(struct root_domain *rd) { - return rq ? rq->nr_running : -1; +# if defined(CONFIG_SMP) && HAS_MEMBER(struct, root_domain, span) + return rd ? (struct cpumask *)rd->span : NULL; +# else + return NULL; +# endif } +#endif -#endif /* SCHED_HELPERS */ +#endif /* SCHED_HELPERS_H */ diff --git a/lisa/_assets/kmodules/lisa/tp.c b/lisa/_assets/kmodules/lisa/tp.c index 240ab29988fa5bbe48a68aee60b78958b96616c7..a0e85b6e3a0b41e0d184f34e26908897d383b9fe 100644 --- a/lisa/_assets/kmodules/lisa/tp.c +++ b/lisa/_assets/kmodules/lisa/tp.c @@ -11,6 +11,7 @@ #include "wq.h" #include "tp.h" +#if HAS_KERNEL_FEATURE(CFS_PELT) static inline void _trace_cfs(struct cfs_rq *cfs_rq, void (*trace_event)(int, char*, const struct sched_avg*)) @@ -19,13 +20,16 @@ static inline void _trace_cfs(struct cfs_rq *cfs_rq, char path[PATH_SIZE]; int cpu; - avg = lisa_cfs_rq_avg(cfs_rq); - lisa_cfs_rq_path(cfs_rq, path, PATH_SIZE); - cpu = lisa_cfs_rq_cpu(cfs_rq); + avg = cfs_rq_avg(cfs_rq); + cfs_rq_path(cfs_rq, path, PATH_SIZE); + cpu = cfs_rq_cpu(cfs_rq); trace_event(cpu, path, avg); - } +} +#endif + +#if HAS_KERNEL_FEATURE(SE_PELT) static inline void _trace_se(struct sched_entity *se, void (*trace_event)(int, char*, char*, int, const struct sched_avg*)) @@ -38,8 +42,8 @@ static inline void _trace_se(struct sched_entity *se, pid_t pid; int cpu; - lisa_cfs_rq_path(gcfs_rq, path, PATH_SIZE); - cpu = lisa_cfs_rq_cpu(cfs_rq); + cfs_rq_path(gcfs_rq, path, PATH_SIZE); + cpu = cfs_rq_cpu(cfs_rq); p = gcfs_rq ? NULL : container_of(se, struct task_struct, se); comm = p ? p->comm : "(null)"; @@ -47,23 +51,29 @@ static inline void _trace_se(struct sched_entity *se, trace_event(cpu, path, comm, pid, &se->avg); } +#endif +#if HAS_KERNEL_FEATURE(CFS_PELT) static void sched_pelt_cfs_probe(void *feature, struct cfs_rq *cfs_rq) { _trace_cfs(cfs_rq, trace_lisa__sched_pelt_cfs); } DEFINE_TP_EVENT_FEATURE(lisa__sched_pelt_cfs, pelt_cfs_tp, sched_pelt_cfs_probe); +#endif +#if HAS_KERNEL_FEATURE(CFS_UCLAMP) static void uclamp_util_cfs_probe(void *feature, struct cfs_rq *cfs_rq) { bool __maybe_unused is_root_rq = ((struct cfs_rq *)&rq_of(cfs_rq)->cfs == cfs_rq); trace_lisa__uclamp_util_cfs(is_root_rq, rq_of(cfs_rq), cfs_rq); } DEFINE_TP_EVENT_FEATURE(lisa__uclamp_util_cfs, pelt_cfs_tp, uclamp_util_cfs_probe); +#endif +#if HAS_KERNEL_FEATURE(RT_PELT) static void sched_pelt_rt_probe(void *feature, struct rq *rq) { - const struct sched_avg *avg = lisa_rq_avg_rt(rq); - int cpu = lisa_rq_cpu(rq); + const struct sched_avg *avg = rq_avg_rt(rq); + int cpu = rq_cpu(rq); if (!avg) return; @@ -71,11 +81,13 @@ static void sched_pelt_rt_probe(void *feature, struct rq *rq) trace_lisa__sched_pelt_rt(cpu, avg); } DEFINE_TP_EVENT_FEATURE(lisa__sched_pelt_rt, pelt_rt_tp, sched_pelt_rt_probe); +#endif +#if HAS_KERNEL_FEATURE(DL_PELT) static void sched_pelt_dl_probe(void *feature, struct rq *rq) { - const struct sched_avg *avg = lisa_rq_avg_dl(rq); - int cpu = lisa_rq_cpu(rq); + const struct sched_avg *avg = rq_avg_dl(rq); + int cpu = rq_cpu(rq); if (!avg) return; @@ -83,11 +95,13 @@ static void sched_pelt_dl_probe(void *feature, struct rq *rq) trace_lisa__sched_pelt_dl(cpu, avg); } DEFINE_TP_EVENT_FEATURE(lisa__sched_pelt_dl, pelt_dl_tp, sched_pelt_dl_probe); +#endif +#if HAS_KERNEL_FEATURE(IRQ_PELT) static void sched_pelt_irq_probe(void *feature, struct rq *rq) { - const struct sched_avg *avg = lisa_rq_avg_irq(rq); - int cpu = lisa_rq_cpu(rq); + const struct sched_avg *avg = rq_avg_irq(rq); + int cpu = rq_cpu(rq); if (!avg) return; @@ -95,13 +109,17 @@ static void sched_pelt_irq_probe(void *feature, struct rq *rq) trace_lisa__sched_pelt_irq(cpu, avg); } DEFINE_TP_EVENT_FEATURE(lisa__sched_pelt_irq, pelt_irq_tp, sched_pelt_irq_probe); +#endif +#if HAS_KERNEL_FEATURE(SE_PELT) static void sched_pelt_se_probe(void *feature, struct sched_entity *se) { _trace_se(se, trace_lisa__sched_pelt_se); } DEFINE_TP_EVENT_FEATURE(lisa__sched_pelt_se, pelt_se_tp, sched_pelt_se_probe); +#endif +#if HAS_KERNEL_FEATURE(SE_UCLAMP) static void uclamp_util_se_probe(void *feature, struct sched_entity *se) { @@ -112,37 +130,44 @@ static void uclamp_util_se_probe(void *feature, struct sched_entity *se) rq_of(cfs_rq)); } DEFINE_TP_EVENT_FEATURE(lisa__uclamp_util_se, pelt_se_tp, uclamp_util_se_probe); +#endif +#if HAS_KERNEL_FEATURE(SCHED_OVERUTILIZED) static void sched_overutilized_probe(void *feature, struct root_domain *rd, bool overutilized) { if (trace_lisa__sched_overutilized_enabled()) { char span[SPAN_SIZE]; - cpumap_print_to_pagebuf(false, span, lisa_rd_span(rd)); + cpumap_print_to_pagebuf(false, span, rd_span(rd)); trace_lisa__sched_overutilized(overutilized, span); } } DEFINE_TP_EVENT_FEATURE(lisa__sched_overutilized, sched_overutilized_tp, sched_overutilized_probe); +#endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0) +#if HAS_KERNEL_FEATURE(RQ_NR_RUNNING) static void sched_update_nr_running_probe(void *feature, struct rq *rq, int change) { if (trace_lisa__sched_update_nr_running_enabled()) { - int cpu = lisa_rq_cpu(rq); - int nr_running = lisa_rq_nr_running(rq); + int cpu = rq_cpu(rq); + int nr_running = rq_nr_running(rq); trace_lisa__sched_update_nr_running(cpu, change, nr_running); } } DEFINE_TP_EVENT_FEATURE(lisa__sched_update_nr_running, sched_update_nr_running_tp, sched_update_nr_running_probe); +#endif +#if HAS_KERNEL_FEATURE(CFS_UTIL_EST) static void sched_util_est_cfs_probe(void *feature, struct cfs_rq *cfs_rq) { _trace_cfs(cfs_rq, trace_lisa__sched_util_est_cfs); } DEFINE_TP_EVENT_FEATURE(lisa__sched_util_est_cfs, sched_util_est_cfs_tp, sched_util_est_cfs_probe); +#endif +#if HAS_KERNEL_FEATURE(SE_UTIL_EST) static void sched_util_est_se_probe(void *feature, struct sched_entity *se) { _trace_se(se, trace_lisa__sched_util_est_se); @@ -150,7 +175,7 @@ static void sched_util_est_se_probe(void *feature, struct sched_entity *se) DEFINE_TP_EVENT_FEATURE(lisa__sched_util_est_se, sched_util_est_se_tp, sched_util_est_se_probe); #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,10,0) && (defined(CONFIG_ARM64) || defined(CONFIG_ARM)) +#if HAS_KERNEL_FEATURE(RQ_CAPACITY) static void sched_cpu_capacity_probe(void *feature, struct rq *rq) { trace_lisa__sched_cpu_capacity(rq); @@ -158,6 +183,7 @@ static void sched_cpu_capacity_probe(void *feature, struct rq *rq) DEFINE_TP_EVENT_FEATURE(lisa__sched_cpu_capacity, sched_cpu_capacity_tp, sched_cpu_capacity_probe); #endif + static int init_tp(struct feature *_) { return 0; diff --git a/lisa/_kmod.py b/lisa/_kmod.py index 7e625e863173d6576d1730184cd24ca7d1852cbf..5d23aa189c6656b3f6db42455276cbf87e62cee5 100644 --- a/lisa/_kmod.py +++ b/lisa/_kmod.py @@ -985,7 +985,7 @@ class _KernelBuildEnv(Loggable, SerializeViaConstructor): @classmethod - def _prepare_tree(cls, path, cc, abi, build_conf, apply_overlays, fixup_atomic_headers=False): + def _prepare_tree(cls, path, cc, abi, build_conf, apply_overlays): logger = cls.get_logger() path = Path(path) @@ -1025,38 +1025,35 @@ class _KernelBuildEnv(Loggable, SerializeViaConstructor): bind_paths = {path: path} def fixup_kernel_build_env(): - - if fixup_atomic_headers: - # TODO: re-assess - - # The headers in /sys/kheaders.tar.xz generated by - # CONFIG_IKHEADERS=y are broken since kernel/gen_kheaders.sh strip - # some comments from the file. KBuild then proceeds on checking the - # checksum and the check fails. This used to be a simple warning, - # but has now been turned into an error in recent kernels. - # We remove the SHA1 from the file so that the check is skipped. - with contextlib.suppress(FileNotFoundError): - def join(lines): - return b'\n'.join(lines) + b'\n' - - for _path in (path / 'include' / 'linux' / 'atomic').iterdir(): - content = _path.read_bytes() - lines = content.split(b'\n') - i, last_line = [(i, line) for (i, line) in enumerate(lines) if line][-1] - - if lines and last_line.lstrip().startswith(b'//'): - # Remove the last line, containing the sha1 - without_sha1 = copy.copy(lines) - del without_sha1[i] - without_sha1 = join(without_sha1) - sha1 = hashlib.sha1(without_sha1).hexdigest() - - # Update the sha1 - updated = copy.copy(lines) - updated[i] = b'// ' + sha1.encode('ascii') - updated = join(updated) - _path.write_bytes(updated) - + # TODO: re-assess + + # The headers in /sys/kheaders.tar.xz generated by + # CONFIG_IKHEADERS=y are broken since kernel/gen_kheaders.sh strip + # some comments from the file. KBuild then proceeds on checking the + # checksum and the check fails. This used to be a simple warning, + # but has now been turned into an error in recent kernels. + # We remove the SHA1 from the file so that the check is skipped. + with contextlib.suppress(FileNotFoundError): + def join(lines): + return b'\n'.join(lines) + + for _path in (path / 'include' / 'linux' / 'atomic').iterdir(): + content = _path.read_bytes() + lines = content.split(b'\n') + i, last_line = [(i, line) for (i, line) in enumerate(lines) if line][-1] + + if lines and last_line.lstrip().startswith(b'//'): + # Remove the last line, containing the sha1 + without_sha1 = copy.copy(lines) + del without_sha1[i] + without_sha1 = join(without_sha1) + sha1 = hashlib.sha1(without_sha1).hexdigest() + + # Update the sha1 + updated = copy.copy(lines) + updated[i] = b'// ' + sha1.encode('ascii') + updated = join(updated) + _path.write_bytes(updated) if build_conf['build-env'] == 'alpine': settings = build_conf['build-env-settings']['alpine'] @@ -1082,6 +1079,20 @@ class _KernelBuildEnv(Loggable, SerializeViaConstructor): else: cmd_cm = lambda cmds: nullcontext(cmds) + try: + config_path = os.environ['KCONFIG_CONFIG'] + except KeyError: + config_path = '.config' + + config_path = Path(config_path) + if not config_path.is_absolute(): + config_path = Path(path) / config_path + + try: + config_content = config_path.read_bytes() + except FileNotFoundError: + config_content = None + with cmd_cm(cmds) as _cmds: pre, post = _cmds logger.info(f'Preparing kernel tree for modules') @@ -1089,6 +1100,13 @@ class _KernelBuildEnv(Loggable, SerializeViaConstructor): if pre is not None: _subprocess_log(pre, logger=logger, level=logging.DEBUG) + # Ensure the configuration is available under .config, so that we + # can rely on that. Overlays can now be applied to override it if + # they need to. KCONFIG_CONFIG is set in _process_make_vars() to + # ".config" so that all make commands run with these settings. + if config_content: + (path / '.config').write_bytes(config_content) + # Apply the overlays before running make, so that it sees the # correct headers and conf etc apply_overlays() @@ -1126,6 +1144,10 @@ class _KernelBuildEnv(Loggable, SerializeViaConstructor): for k, v in make_vars.items() } + # Force the value of .config, and we ensure somewhere else that we will + # end up with the correct configuration there. + make_vars['KCONFIG_CONFIG'] = '.config' + try: arch = make_vars['ARCH'] except KeyError: @@ -1468,6 +1490,7 @@ class _KernelBuildEnv(Loggable, SerializeViaConstructor): target.cached_pull('/sys/kernel/kheaders.tar.xz', str(temp), via_temp=True, as_root=True) return { + # We can use .config as we control KCONFIG_CONFIG in _process_make_vars() FileOverlay.from_path(temp / 'config.gz', decompress=True): '.config', TarOverlay.from_path(temp / 'kheaders.tar.xz'): '.', } @@ -1475,7 +1498,6 @@ class _KernelBuildEnv(Loggable, SerializeViaConstructor): return _from_target_sources( configs=['CONFIG_IKHEADERS', 'CONFIG_IKCONFIG_PROC'], pull=pull, - fixup_atomic_headers=True, ) def from_proc_config(): @@ -1485,6 +1507,7 @@ class _KernelBuildEnv(Loggable, SerializeViaConstructor): def pull(target, temp): target.cached_pull('/proc/config.gz', str(temp), as_root=True) return { + # We can use .config as we control KCONFIG_CONFIG in _process_make_vars() FileOverlay.from_path(temp / 'config.gz', decompress=True): '.config', } @@ -1527,7 +1550,7 @@ class _KernelBuildEnv(Loggable, SerializeViaConstructor): logger.debug(f'Loaded kernel tree using loader {loader.__name__}') try: yield spec - except BaseException as e: + except Exception as e: cm.__exit__(type(e), e, e.__traceback__) raise else: @@ -1581,19 +1604,8 @@ class _KernelBuildEnv(Loggable, SerializeViaConstructor): """ logger = cls.get_logger() overlays = overlays or {} - build_conf, cc, abi = cls._resolve_conf(build_conf) - if tree_path: - try: - config = Path(tree_path, '.config').read_bytes() - except FileNotFoundError: - restore_config = lambda _: None - else: - restore_config = lambda path: path.write_bytes(config) - else: - restore_config = lambda _: None - def copy_filter(src, dst, remove_obj=False): return not ( (remove_obj and (src.suffix == '.o')) or @@ -1606,10 +1618,6 @@ class _KernelBuildEnv(Loggable, SerializeViaConstructor): ) def apply_overlays(path): - # Ensure .config is present if it was at the beginning, so that it - # survives make mrproper in _prepare_tree() - restore_config(path / '.config') - for overlay, dst in overlays.items(): logger.debug(f'Unpacking overlay {overlay} -> {dst}') overlay.write_to(os.path.join(path, dst)) @@ -1750,7 +1758,7 @@ class _KernelBuildEnv(Loggable, SerializeViaConstructor): for member in tar.getmembers() ) tar.extractall(extract_folder) - except BaseException: + except Exception: with contextlib.suppress(FileNotFoundError): shutil.rmtree(extract_folder, ignore_errors=True) raise @@ -1802,9 +1810,12 @@ class KmodSrc(Loggable): if name.endswith('.c') } - def _checksum(self, sources_only=False): - sources = self.code_files if sources_only else self.src - + @property + @memoized + def checksum(self): + """ + Checksum of the module's sources & Makefile. + """ def checksum(content): m = hashlib.sha1() content = content if isinstance(content, bytes) else content.encode('utf-8') @@ -1813,33 +1824,17 @@ class KmodSrc(Loggable): content = sorted( (checksum(content), name) - for name, content in sources.items() + for name, content in self.src.items() ) # Recreate the output of sha1sum over multiple files, and checksum # that. - return checksum( - '\n'.join( - f'{csum} {name}' - for csum, name in content - ) + '\n' - ) - - @property - @memoized - def checksum(self): - """ - Checksum of the module's sources & Makefile. - """ - return self._checksum(sources_only=False) + content = '\n'.join( + f'{csum} ./{name}' + for csum, name in content + ) + '\n' - @property - @memoized - def sources_checksum(self): - """ - Checksum of the module's sources. - """ - return self._checksum(sources_only=True) + return checksum(content) @property @memoized @@ -2415,6 +2410,9 @@ class LISAFtraceDynamicKmod(FtraceDynamicKmod): @classmethod def from_target(cls, target, **kwargs): + + extra = {} + path = Path(ASSETS_PATH) / 'kmodules' / 'lisa' btf_path = '/sys/kernel/btf/vmlinux' @@ -2427,9 +2425,16 @@ class LISAFtraceDynamicKmod(FtraceDynamicKmod): with open(f.name, 'rb') as f: btf = f.read() - extra = { - 'vmlinux': btf - } + extra['vmlinux'] = btf + + try: + kallsyms = target.read_value('/proc/kallsyms') + except TargetStableError: + pass + else: + extra['kallsyms'] = kallsyms.encode('utf-8') + + src = KmodSrc.from_path(path, extra=extra, name='lisa') return cls( target=target, @@ -2471,7 +2476,7 @@ class LISAFtraceDynamicKmod(FtraceDynamicKmod): kmod_params = kmod_params or {} - kmod_params['version'] = self.src.sources_checksum + kmod_params['version'] = self.src.checksum base_path, kmod_filename = guess_kmod_path() logger.debug(f'Looking for pre-installed {kmod_filename} module in {base_path}') diff --git a/setup.py b/setup.py index 1b0dcdfd761cd5012dcbaa79c7b73e7b4781f812..3185c901947d542c2d417fdc31d72f13bad0960e 100755 --- a/setup.py +++ b/setup.py @@ -164,7 +164,7 @@ if __name__ == "__main__": "cffi", # unshare syscall "typeguard", - "pycparser", # For the kernel module build + "pycparserext", # For the kernel module build ], extras_require=extras_require, diff --git a/tools/kmodules/lisa/introspection_data.c b/tools/kmodules/lisa/introspection_data.c new file mode 120000 index 0000000000000000000000000000000000000000..8c35601a8119e86d55b4feda23b89e829d5f671d --- /dev/null +++ b/tools/kmodules/lisa/introspection_data.c @@ -0,0 +1 @@ +../../../lisa/_assets/kmodules/lisa/introspection_data.c \ No newline at end of file diff --git a/tools/kmodules/lisa/kernel_features.json b/tools/kmodules/lisa/kernel_features.json new file mode 120000 index 0000000000000000000000000000000000000000..ba08761b4d830f5d79ee248edd1fc869cdd4d07c --- /dev/null +++ b/tools/kmodules/lisa/kernel_features.json @@ -0,0 +1 @@ +../../../lisa/_assets/kmodules/lisa/kernel_features.json \ No newline at end of file diff --git a/tools/recipes/pahole.manifest.yaml b/tools/recipes/pahole.manifest.yaml index 4b5007f839f523abc5d4279f6f818f80441f1706..a8cb37b740c08cc0045e893c9eabccde9683e5ae 100644 --- a/tools/recipes/pahole.manifest.yaml +++ b/tools/recipes/pahole.manifest.yaml @@ -22,6 +22,18 @@ rebase-conf: base: master tip: anon_struct + - + name: fix_const_nested + remote: github + base: master + tip: fix_const_nested + + - + name: fix_volatile_func_ptr + remote: github + base: master + tip: fix_volatile_func_ptr + remotes: github: url: https://github.com/douglas-raillard-arm/pahole.git