+# SPDX-FileCopyrightText: 2024 EfficiOS Inc.
+#
+# SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
+
.gitattributes export-ignore
.gitignore export-ignore
.gitreview export-ignore
+# SPDX-FileCopyrightText: 2024 EfficiOS Inc.
+#
+# SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
#
# NOTE! Don't add files that are generated in specific
# subdirectories here. Add them in the ".gitignore" file
+# SPDX-FileCopyrightText: 2024 EfficiOS Inc.
+#
+# SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
[gerrit]
host=review.lttng.org
port=29418
+# SPDX-FileCopyrightText: 2011-2021 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+#
+# SPDX-License-Identifier: CC-BY-SA-4.0
+
2021-04-23 (National Take a Chance (on me ?) Day) LTTng modules 2.13.0-rc1
* Set the 2.13 release codename and description
* Fix: LTTng-modules ABI ioctl wrong direction
+++ /dev/null
-LTTng Modules Kernel Tracer Coding Style
-
-The coding style used for this project follows the the Linux kernel
-guide lines. Please refer to:
-
-- Linux kernel Documentation/CodingStyle document for details,
-- Linux kernel scripts/checkpatch.pl for a script which verify the patch
- coding style.
-
-Mathieu Desnoyers, May 30, 2012
--- /dev/null
+<!--
+SPDX-FileCopyrightText: 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+
+SPDX-License-Identifier: CC-BY-SA-4.0
+-->
+
+# LTTng Modules Kernel Tracer Coding Style
+
+The coding style used for this project follows the the Linux kernel
+guide lines. Please refer to:
+
+- Linux kernel `Documentation/CodingStyle` document for details,
+- Linux kernel `scripts/checkpatch.pl` for a script which verify the patch
+ coding style.
+
+Mathieu Desnoyers, May 30, 2012
* LGPL-2.1 / GPL-2.0 dual-license
-The files contained within this package are licensed under
-LGPL-2.1 / GPL-2.0 dual-license (see LICENSES/LGPL-2.1 and LICENSES/GPL-2.0 for
+The files contained within this package are licensed under LGPL-2.1 / GPL-2.0
+dual-license (see LICENSES/LGPL-2.1-only.txt and LICENSES/GPL-2.0-only.txt for
details), except for files identified by the following sections.
* GPL-2.0 license
These files are licensed exclusively under the GPL-2.0 license. See
-LICENSES/GPL-2.0 for details.
+LICENSES/GPL-2.0-only.txt for details.
-lib/ringbuffer/ring_buffer_splice.c
-lib/ringbuffer/ring_buffer_mmap.c
-instrumentation/events/lttng-module/*.h
-wrapper/list.h
+src/lib/ringbuffer/ring_buffer_splice.c
+src/lib/ringbuffer/ring_buffer_mmap.c
+include/instrumentation/events/*.h
+include/wrapper/list.h
* MIT-style license
-These files are licensed under an MIT-style license. See LICENSES/MIT
+These files are licensed under an MIT-style license. See LICENSES/MIT.txt
for details.
include/lttng/prio_heap.h
include/lttng/bitfield.h
-include/lttng/filter-bytecode.h
-include/filter.h
-lib/prio_heap/lttng_prio_heap.c
-lttng-filter-interpreter.c
-lttng-filter-specialize.c
-lttng-filter-validator.c
-lttng-filter.c
+include/lttng/bytecode.h
+include/lttng/lttng-bytecode.h
+src/lib/prio_heap/lttng_prio_heap.c
+src/lttng-bytecode-interpreter.c
+src/lttng-bytecode-specialize.c
+src/lttng-bytecode-validator.c
+src/lttng-bytecode.c
--- /dev/null
+Creative Commons Attribution-ShareAlike 4.0 International
+
+ Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
+
+Using Creative Commons Public Licenses
+
+Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
+
+Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors.
+
+Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described.
+
+Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public.
+
+Creative Commons Attribution-ShareAlike 4.0 International Public License
+
+By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
+
+Section 1 – Definitions.
+
+ a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
+
+ b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
+
+ c. BY-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, approved by Creative Commons as essentially the equivalent of this Public License.
+
+ d. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
+
+ e. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
+
+ f. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
+
+ g. License Elements means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution and ShareAlike.
+
+ h. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
+
+ i. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
+
+ j. Licensor means the individual(s) or entity(ies) granting rights under this Public License.
+
+ k. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
+
+ l. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
+
+ m. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
+
+Section 2 – Scope.
+
+ a. License grant.
+
+ 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
+
+ A. reproduce and Share the Licensed Material, in whole or in part; and
+
+ B. produce, reproduce, and Share Adapted Material.
+
+ 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
+
+ 3. Term. The term of this Public License is specified in Section 6(a).
+
+ 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
+
+ 5. Downstream recipients.
+
+ A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
+
+ B. Additional offer from the Licensor – Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply.
+
+ C. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
+
+ 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
+
+ b. Other rights.
+
+ 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
+
+ 2. Patent and trademark rights are not licensed under this Public License.
+
+ 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties.
+
+Section 3 – License Conditions.
+
+Your exercise of the Licensed Rights is expressly made subject to the following conditions.
+
+ a. Attribution.
+
+ 1. If You Share the Licensed Material (including in modified form), You must:
+
+ A. retain the following if it is supplied by the Licensor with the Licensed Material:
+
+ i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
+
+ ii. a copyright notice;
+
+ iii. a notice that refers to this Public License;
+
+ iv. a notice that refers to the disclaimer of warranties;
+
+ v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
+
+ B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
+
+ C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
+
+ 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
+
+ 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
+
+ b. ShareAlike.In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.
+
+ 1. The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License.
+
+ 2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
+
+ 3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.
+
+Section 4 – Sui Generis Database Rights.
+
+Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
+
+ a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database;
+
+ b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and
+
+ c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
+For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
+
+Section 5 – Disclaimer of Warranties and Limitation of Liability.
+
+ a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
+
+ b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
+
+ c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
+
+Section 6 – Term and Termination.
+
+ a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
+
+ b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
+
+ 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
+
+ 2. upon express reinstatement by the Licensor.
+
+ c. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
+
+ d. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
+
+ e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
+
+Section 7 – Other Terms and Conditions.
+
+ a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
+
+ b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
+
+Section 8 – Interpretation.
+
+ a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
+
+ b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
+
+ c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
+
+ d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
+
+Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
+
+Creative Commons may be contacted at creativecommons.org.
--- /dev/null
+Creative Commons Legal Code
+
+CC0 1.0 Universal
+
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
+ HEREUNDER.
+
+Statement of Purpose
+
+The laws of most jurisdictions throughout the world automatically confer
+exclusive Copyright and Related Rights (defined below) upon the creator
+and subsequent owner(s) (each and all, an "owner") of an original work of
+authorship and/or a database (each, a "Work").
+
+Certain owners wish to permanently relinquish those rights to a Work for
+the purpose of contributing to a commons of creative, cultural and
+scientific works ("Commons") that the public can reliably and without fear
+of later claims of infringement build upon, modify, incorporate in other
+works, reuse and redistribute as freely as possible in any form whatsoever
+and for any purposes, including without limitation commercial purposes.
+These owners may contribute to the Commons to promote the ideal of a free
+culture and the further production of creative, cultural and scientific
+works, or to gain reputation or greater distribution for their Work in
+part through the use and efforts of others.
+
+For these and/or other purposes and motivations, and without any
+expectation of additional consideration or compensation, the person
+associating CC0 with a Work (the "Affirmer"), to the extent that he or she
+is an owner of Copyright and Related Rights in the Work, voluntarily
+elects to apply CC0 to the Work and publicly distribute the Work under its
+terms, with knowledge of his or her Copyright and Related Rights in the
+Work and the meaning and intended legal effect of CC0 on those rights.
+
+1. Copyright and Related Rights. A Work made available under CC0 may be
+protected by copyright and related or neighboring rights ("Copyright and
+Related Rights"). Copyright and Related Rights include, but are not
+limited to, the following:
+
+ i. the right to reproduce, adapt, distribute, perform, display,
+ communicate, and translate a Work;
+ ii. moral rights retained by the original author(s) and/or performer(s);
+iii. publicity and privacy rights pertaining to a person's image or
+ likeness depicted in a Work;
+ iv. rights protecting against unfair competition in regards to a Work,
+ subject to the limitations in paragraph 4(a), below;
+ v. rights protecting the extraction, dissemination, use and reuse of data
+ in a Work;
+ vi. database rights (such as those arising under Directive 96/9/EC of the
+ European Parliament and of the Council of 11 March 1996 on the legal
+ protection of databases, and under any national implementation
+ thereof, including any amended or successor version of such
+ directive); and
+vii. other similar, equivalent or corresponding rights throughout the
+ world based on applicable law or treaty, and any national
+ implementations thereof.
+
+2. Waiver. To the greatest extent permitted by, but not in contravention
+of, applicable law, Affirmer hereby overtly, fully, permanently,
+irrevocably and unconditionally waives, abandons, and surrenders all of
+Affirmer's Copyright and Related Rights and associated claims and causes
+of action, whether now known or unknown (including existing as well as
+future claims and causes of action), in the Work (i) in all territories
+worldwide, (ii) for the maximum duration provided by applicable law or
+treaty (including future time extensions), (iii) in any current or future
+medium and for any number of copies, and (iv) for any purpose whatsoever,
+including without limitation commercial, advertising or promotional
+purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
+member of the public at large and to the detriment of Affirmer's heirs and
+successors, fully intending that such Waiver shall not be subject to
+revocation, rescission, cancellation, termination, or any other legal or
+equitable action to disrupt the quiet enjoyment of the Work by the public
+as contemplated by Affirmer's express Statement of Purpose.
+
+3. Public License Fallback. Should any part of the Waiver for any reason
+be judged legally invalid or ineffective under applicable law, then the
+Waiver shall be preserved to the maximum extent permitted taking into
+account Affirmer's express Statement of Purpose. In addition, to the
+extent the Waiver is so judged Affirmer hereby grants to each affected
+person a royalty-free, non transferable, non sublicensable, non exclusive,
+irrevocable and unconditional license to exercise Affirmer's Copyright and
+Related Rights in the Work (i) in all territories worldwide, (ii) for the
+maximum duration provided by applicable law or treaty (including future
+time extensions), (iii) in any current or future medium and for any number
+of copies, and (iv) for any purpose whatsoever, including without
+limitation commercial, advertising or promotional purposes (the
+"License"). The License shall be deemed effective as of the date CC0 was
+applied by Affirmer to the Work. Should any part of the License for any
+reason be judged legally invalid or ineffective under applicable law, such
+partial invalidity or ineffectiveness shall not invalidate the remainder
+of the License, and in such case Affirmer hereby affirms that he or she
+will not (i) exercise any of his or her remaining Copyright and Related
+Rights in the Work or (ii) assert any associated claims and causes of
+action with respect to the Work, in either case contrary to Affirmer's
+express Statement of Purpose.
+
+4. Limitations and Disclaimers.
+
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
+ surrendered, licensed or otherwise affected by this document.
+ b. Affirmer offers the Work as-is and makes no representations or
+ warranties of any kind concerning the Work, express, implied,
+ statutory or otherwise, including without limitation warranties of
+ title, merchantability, fitness for a particular purpose, non
+ infringement, or the absence of latent or other defects, accuracy, or
+ the present or absence of errors, whether or not discoverable, all to
+ the greatest extent permissible under applicable law.
+ c. Affirmer disclaims responsibility for clearing rights of other persons
+ that may apply to the Work or any use thereof, including without
+ limitation any person's Copyright and Related Rights in the Work.
+ Further, Affirmer disclaims responsibility for obtaining any necessary
+ consents, permissions or other rights required for any use of the
+ Work.
+ d. Affirmer understands and acknowledges that Creative Commons is not a
+ party to this document and has no duty or obligation with respect to
+ this CC0 or use of the Work.
+++ /dev/null
-Valid-License-Identifier: GPL-2.0-only
-Valid-License-Identifier: GPL-2.0-or-later
-SPDX-URL: https://spdx.org/licenses/GPL-2.0.html
-Usage-Guide:
- To use this license in source code, put one of the following SPDX
- tag/value pairs into a comment according to the placement
- guidelines in the licensing rules documentation.
- For 'GNU General Public License (GPL) version 2 only' use:
- SPDX-License-Identifier: GPL-2.0-only
- For 'GNU General Public License (GPL) version 2 or any later version' use:
- SPDX-License-Identifier: GPL-2.0-or-later
-License-Text:
-
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU 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.
-\f
- 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.)
-\f
-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.
-\f
- 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.
-\f
- 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
-\f
- 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.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 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.
--- /dev/null
+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.
+
+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.
+
+ one line to give the program's name and an idea of what it does. Copyright (C) yyyy name of author
+
+ 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.
+
+signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice
+++ /dev/null
-Valid-License-Identifier: LGPL-2.1-only
-Valid-License-Identifier: LGPL-2.1-or-later
-SPDX-URL: https://spdx.org/licenses/LGPL-2.1.html
-Usage-Guide:
- To use this license in source code, put one of the following SPDX
- tag/value pairs into a comment according to the placement
- guidelines in the licensing rules documentation.
- For 'GNU Lesser General Public License (LGPL) version 2.1 only' use:
- SPDX-License-Identifier: LGPL-2.1-only
- For 'GNU Lesser General Public License (LGPL) version 2.1 or any later
- version' use:
- SPDX-License-Identifier: LGPL-2.1-or-later
-License-Text:
-
-GNU LESSER GENERAL PUBLIC LICENSE
-Version 2.1, February 1999
-
-Copyright (C) 1991, 1999 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.
-
-[This is the first released version of the Lesser GPL. It also counts as
-the successor of the GNU Library Public License, version 2, hence the
-version number 2.1.]
-
-Preamble
-
-The licenses for most software are designed to take away your freedom to
-share and change it. By contrast, the GNU General Public Licenses are
-intended to guarantee your freedom to share and change free software--to
-make sure the software is free for all its users.
-
-This license, the Lesser General Public License, applies to some specially
-designated software packages--typically libraries--of the Free Software
-Foundation and other authors who decide to use it. You can use it too, but
-we suggest you first think carefully about whether this license or the
-ordinary General Public License is the better strategy to use in any
-particular case, based on the explanations below.
-
-When we speak of free software, we are referring to freedom of use, 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 and use pieces of it in new free
-programs; and that you are informed that you can do these things.
-
-To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for you if
-you distribute copies of the library or if you modify it.
-
-For example, if you distribute copies of the library, whether gratis or for
-a fee, you must give the recipients all the rights that we gave you. You
-must make sure that they, too, receive or can get the source code. If you
-link other code with the library, you must provide complete object files to
-the recipients, so that they can relink them with the library after making
-changes to the library and recompiling it. And you must show them these
-terms so they know their rights.
-
-We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
-To protect each distributor, we want to make it very clear that there is no
-warranty for the free library. Also, if the library is modified by someone
-else and passed on, the recipients should know that what they have is not
-the original version, so that the original author's reputation will not be
-affected by problems that might be introduced by others.
-
-Finally, software patents pose a constant threat to the existence of any
-free program. We wish to make sure that a company cannot effectively
-restrict the users of a free program by obtaining a restrictive license
-from a patent holder. Therefore, we insist that any patent license obtained
-for a version of the library must be consistent with the full freedom of
-use specified in this license.
-
-Most GNU software, including some libraries, is covered by the ordinary GNU
-General Public License. This license, the GNU Lesser General Public
-License, applies to certain designated libraries, and is quite different
-from the ordinary General Public License. We use this license for certain
-libraries in order to permit linking those libraries into non-free
-programs.
-
-When a program is linked with a library, whether statically or using a
-shared library, the combination of the two is legally speaking a combined
-work, a derivative of the original library. The ordinary General Public
-License therefore permits such linking only if the entire combination fits
-its criteria of freedom. The Lesser General Public License permits more lax
-criteria for linking other code with the library.
-
-We call this license the "Lesser" General Public License because it does
-Less to protect the user's freedom than the ordinary General Public
-License. It also provides other free software developers Less of an
-advantage over competing non-free programs. These disadvantages are the
-reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
-For example, on rare occasions, there may be a special need to encourage
-the widest possible use of a certain library, so that it becomes a de-facto
-standard. To achieve this, non-free programs must be allowed to use the
-library. A more frequent case is that a free library does the same job as
-widely used non-free libraries. In this case, there is little to gain by
-limiting the free library to free software only, so we use the Lesser
-General Public License.
-
-In other cases, permission to use a particular library in non-free programs
-enables a greater number of people to use a large body of free
-software. For example, permission to use the GNU C Library in non-free
-programs enables many more people to use the whole GNU operating system, as
-well as its variant, the GNU/Linux operating system.
-
-Although the Lesser General Public License is Less protective of the users'
-freedom, it does ensure that the user of a program that is linked with the
-Library has the freedom and the wherewithal to run that program using a
-modified version of the Library.
-
-The precise terms and conditions for copying, distribution and modification
-follow. Pay close attention to the difference between a "work based on the
-library" and a "work that uses the library". The former contains code
-derived from the library, whereas the latter must be combined with the
-library in order to run.
-
-TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-0. This License Agreement applies to any software library or other program
- which contains a notice placed by the copyright holder or other
- authorized party saying it may be distributed under the terms of this
- Lesser General Public License (also called "this License"). Each
- licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
- prepared so as to be conveniently linked with application programs
- (which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work which
- has been distributed under these terms. A "work based on the Library"
- means either the Library or any derivative work under copyright law:
- that is to say, a work containing the Library or a portion of it, either
- verbatim or with modifications and/or translated straightforwardly into
- another language. (Hereinafter, translation is included without
- limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for making
- modifications to it. For a library, 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 library.
-
- Activities other than copying, distribution and modification are not
- covered by this License; they are outside its scope. The act of running
- a program using the Library is not restricted, and output from such a
- program is covered only if its contents constitute a work based on the
- Library (independent of the use of the Library in a tool for writing
- it). Whether that is true depends on what the Library does and what the
- program that uses the Library does.
-
-1. You may copy and distribute verbatim copies of the Library's complete
- 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
- distribute a copy of this License along with the Library.
-
- 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 Library or any portion of it,
- thus forming a work based on the Library, 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) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices stating
- that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no charge to
- all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a table
- of data to be supplied by an application program that uses the
- facility, other than as an argument passed when the facility is
- invoked, then you must make a good faith effort to ensure that, in
- the event an application does not supply such function or table, the
- facility still operates, and performs whatever part of its purpose
- remains meaningful.
-
- (For example, a function in a library to compute square roots has a
- purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must be
- optional: if the application does not supply it, the square root
- function must still compute square roots.)
-
- These requirements apply to the modified work as a whole. If
- identifiable sections of that work are not derived from the Library, 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 Library, 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 Library.
-
- In addition, mere aggregation of another work not based on the Library
- with the Library (or with a work based on the Library) on a volume of a
- storage or distribution medium does not bring the other work under the
- scope of this License.
-
-3. You may opt to apply the terms of the ordinary GNU General Public
- License instead of this License to a given copy of the Library. To do
- this, you must alter all the notices that refer to this License, so that
- they refer to the ordinary GNU General Public License, version 2,
- instead of to this License. (If a newer version than version 2 of the
- ordinary GNU General Public License has appeared, then you can specify
- that version instead if you wish.) Do not make any other change in these
- notices.
-
- Once this change is made in a given copy, it is irreversible for that
- copy, so the ordinary GNU General Public License applies to all
- subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of the
- Library into a program that is not a library.
-
-4. You may copy and distribute the Library (or a portion or derivative of
- it, under Section 2) in object code or executable form under the terms
- of Sections 1 and 2 above provided that you 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.
-
- If distribution of 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 satisfies the requirement to distribute the
- source code, even though third parties are not compelled to copy the
- source along with the object code.
-
-5. A program that contains no derivative of any portion of the Library, but
- is designed to work with the Library by being compiled or linked with
- it, is called a "work that uses the Library". Such a work, in isolation,
- is not a derivative work of the Library, and therefore falls outside the
- scope of this License.
-
- However, linking a "work that uses the Library" with the Library creates
- an executable that is a derivative of the Library (because it contains
- portions of the Library), rather than a "work that uses the
- library". The executable is therefore covered by this License. Section 6
- states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
- that is part of the Library, the object code for the work may be a
- derivative work of the Library even though the source code is
- not. Whether this is true is especially significant if the work can be
- linked without the Library, or if the work is itself a library. The
- threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data structure
- layouts and accessors, and small macros and small inline functions (ten
- lines or less in length), then the use of the object file is
- unrestricted, regardless of whether it is legally a derivative
- work. (Executables containing this object code plus portions of the
- Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
- distribute the object code for the work under the terms of Section
- 6. Any executables containing that work also fall under Section 6,
- whether or not they are linked directly with the Library itself.
-
-6. As an exception to the Sections above, you may also combine or link a
- "work that uses the Library" with the Library to produce a work
- containing portions of the Library, and distribute that work under terms
- of your choice, provided that the terms permit modification of the work
- for the customer's own use and reverse engineering for debugging such
- modifications.
-
- You must give prominent notice with each copy of the work that the
- Library is used in it and that the Library and its use are covered by
- this License. You must supply a copy of this License. If the work during
- execution displays copyright notices, you must include the copyright
- notice for the Library among them, as well as a reference directing the
- user to the copy of this License. Also, you must do one of these things:
-
- a) Accompany the work with the complete corresponding machine-readable
- source code for the Library including whatever changes were used in
- the work (which must be distributed under Sections 1 and 2 above);
- and, if the work is an executable linked with the Library, with the
- complete machine-readable "work that uses the Library", as object
- code and/or source code, so that the user can modify the Library and
- then relink to produce a modified executable containing the modified
- Library. (It is understood that the user who changes the contents of
- definitions files in the Library will not necessarily be able to
- recompile the application to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a copy
- of the library already present on the user's computer system, rather
- than copying library functions into the executable, and (2) will
- operate properly with a modified version of the library, if the user
- installs one, as long as the modified version is interface-compatible
- with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at least three
- years, to give the same user the materials specified in Subsection
- 6a, above, for a charge no more than the cost of performing this
- distribution.
-
- d) If distribution of the work is made by offering access to copy from a
- designated place, offer equivalent access to copy the above specified
- materials from the same place.
-
- e) Verify that the user has already received a copy of these materials
- or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the Library"
- must include any data and utility programs needed for reproducing the
- executable from it. However, as a special exception, the materials to be
- 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.
-
- It may happen that this requirement contradicts the license restrictions
- of other proprietary libraries that do not normally accompany the
- operating system. Such a contradiction means you cannot use both them
- and the Library together in an executable that you distribute.
-
-7. You may place library facilities that are a work based on the Library
- side-by-side in a single library together with other library facilities
- not covered by this License, and distribute such a combined library,
- provided that the separate distribution of the work based on the Library
- and of the other library facilities is otherwise permitted, and provided
- that you do these two things:
-
- a) Accompany the combined library with a copy of the same work based on
- the Library, uncombined with any other library facilities. This must
- be distributed under the terms of the Sections above.
-
- b) Give prominent notice with the combined library of the fact that part
- of it is a work based on the Library, and explaining where to find
- the accompanying uncombined form of the same work.
-
-8. You may not copy, modify, sublicense, link with, or distribute the
- Library except as expressly provided under this License. Any attempt
- otherwise to copy, modify, sublicense, link with, or distribute the
- Library 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.
-
-9. 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 Library or its derivative works. These actions are prohibited by law
- if you do not accept this License. Therefore, by modifying or
- distributing the Library (or any work based on the Library), you
- indicate your acceptance of this License to do so, and all its terms and
- conditions for copying, distributing or modifying the Library or works
- based on it.
-
-10. Each time you redistribute the Library (or any work based on the
- Library), the recipient automatically receives a license from the
- original licensor to copy, distribute, link with or modify the Library
- 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 with this License.
-
-11. 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 Library at all. For example, if a patent license
- would not permit royalty-free redistribution of the Library 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 Library.
-
- 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.
-
-12. If the distribution and/or use of the Library is restricted in certain
- countries either by patents or by copyrighted interfaces, the original
- copyright holder who places the Library 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.
-
-13. The Free Software Foundation may publish revised and/or new versions of
- the Lesser 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 Library
- 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 Library does not specify a license
- version number, you may choose any version ever published by the Free
- Software Foundation.
-
-14. If you wish to incorporate parts of the Library into other free
- programs whose distribution conditions are incompatible with these,
- 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
-
-15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
- FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
- OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
- PROVIDE THE LIBRARY "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 LIBRARY IS WITH
- YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
- NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-16. 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 LIBRARY 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 LIBRARY
- (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), 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 Libraries
-
-If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
-To apply these terms, attach the following notices to the library. 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.
-
-one line to give the library's name and an idea of what it does.
-Copyright (C) year name of author
-
-This library is free software; you can redistribute it and/or modify it
-under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation; either version 2.1 of the License, or (at
-your option) any later version.
-
-This library 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 Lesser General Public License
-for more details.
-
-You should have received a copy of the GNU Lesser General Public License
-along with this library; 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.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
-Yoyodyne, Inc., hereby disclaims all copyright interest in
-the library `Frob' (a library for tweaking knobs) written
-by James Random Hacker.
-
-signature of Ty Coon, 1 April 1990
-Ty Coon, President of Vice
-That's all there is to it!
--- /dev/null
+GNU LESSER GENERAL PUBLIC LICENSE
+
+Version 2.1, February 1999
+
+Copyright (C) 1991, 1999 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.
+
+[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.]
+
+Preamble
+
+The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users.
+
+This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below.
+
+When we speak of free software, we are referring to freedom of use, 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 and use pieces of it in new free programs; and that you are informed that you can do these things.
+
+To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it.
+
+For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights.
+
+We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library.
+
+To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others.
+
+Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license.
+
+Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs.
+
+When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library.
+
+We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances.
+
+For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License.
+
+In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system.
+
+Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library.
+
+The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run.
+
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you".
+
+A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables.
+
+The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".)
+
+"Source code" for a work means the preferred form of the work for making modifications to it. For a library, 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 library.
+
+Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does.
+
+1. You may copy and distribute verbatim copies of the Library's complete 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 distribute a copy of this License along with the Library.
+
+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 Library or any portion of it, thus forming a work based on the Library, 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) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful.
+
+(For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, 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 Library, 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 Library.
+
+In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
+
+3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices.
+
+Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy.
+
+This option is useful when you wish to copy part of the code of the Library into a program that is not a library.
+
+4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you 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.
+
+If distribution of 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 satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code.
+
+5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License.
+
+However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables.
+
+When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law.
+
+If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.)
+
+Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself.
+
+6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications.
+
+You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things:
+
+ a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy.
+
+For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be 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.
+
+It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute.
+
+7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above.
+
+ b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
+
+8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library 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.
+
+9. 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 Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it.
+
+10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library 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 with this License.
+
+11. 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 Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library 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 Library.
+
+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.
+
+12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library 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.
+
+13. The Free Software Foundation may publish revised and/or new versions of the Lesser 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 Library 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 Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation.
+
+14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, 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
+
+15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+16. 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 LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), 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 Libraries
+
+If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License).
+
+To apply these terms, attach the following notices to the library. 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.
+
+ one line to give the library's name and an idea of what it does.
+ Copyright (C) year name of author
+
+ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+
+ This library 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along with this library; 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.
+
+You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names:
+
+Yoyodyne, Inc., hereby disclaims all copyright interest in
+the library `Frob' (a library for tweaking knobs) written
+by James Random Hacker.
+
+signature of Ty Coon, 1 April 1990
+Ty Coon, President of Vice
+That's all there is to it!
+++ /dev/null
-Valid-License-Identifier: MIT
-SPDX-URL: https://spdx.org/licenses/MIT.html
-Usage-Guide:
- To use the MIT License put the following SPDX tag/value pair into a
- comment according to the placement guidelines in the licensing rules
- documentation:
- SPDX-License-Identifier: MIT
-License-Text:
-
-MIT License
-
-Copyright (c) <year> <copyright holders>
-
-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.
--- /dev/null
+MIT License
+
+Copyright (c) <year> <copyright holders>
+
+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.
# SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2010-2024 EfficiOS Inc.
ifneq ($(KERNELRELEASE),)
+<!--
+SPDX-FileCopyrightText: 2011-2024 EfficiOS Inc.
+
+SPDX-License-Identifier: CC-BY-SA-4.0
+-->
+
LTTng-modules
=============
--- /dev/null
+<!--
+SPDX-FileCopyrightText: 2020 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+
+SPDX-License-Identifier: CC-BY-SA-4.0
+-->
+
+# LTTng modules design
+
+by Mathieu Desnoyers
+June 30, 2020
+
+This document covers the high level design of lttng-modules.
+
+LTTng modules is a kernel tracer for the Linux kernel. It can be either
+loaded as a set of kernel modules, or built into a Linux kernel.
+
+Here are its key components:
+
+## LTTng modules ABI
+
+ Files:
+ - `src/lttng-abi.c`
+ - `include/lttng/abi.h`
+
+ This ABI consists of ioctls with code 0xF6. It extensively uses
+ anonymous file descriptors to represent the tracer "objects". Only
+ root is allowed to interact with those ioctls.
+
+
+## LTTng session, channels, contexts and events management
+
+ Files:
+ - `src/lttng-events.c`
+ - `include/lttng/lttng-events.h`
+
+ Current state about configured tracing sessions, channels, contexts
+ and events. The session, channel, context and event state is
+ manipulated through the LTTng modules ABI. A session contains 0 or
+ more channels, through which data is traced. A channel is associated
+ with an instance of a lib ring buffer client. Channels have 0 or more
+ events, which are associated to kernel instrumentation as event
+ sources.
+
+
+## lib ring buffer
+
+ Generic ring buffer library (kernel implementation). Note, there is
+ a very similar copy of this implementation within the lttng-ust
+ user-space tracer. The overall goal of this library is to support
+ both kernel and user-space tracing.
+
+ Files:
+ - `src/lib/ringbuffer/*`
+ - `include/ringbuffer/*`
+
+ Those include ring buffer ABI meant for consuming the buffer data
+ from user-space. It is implemented in:
+
+ - `src/lib/ringbuffer/ring_buffer_vfs.c` (open, release, poll, ioctl)
+ - `src/lib/ringbuffer/ring_buffer_mmap.c` (mmap)
+ - `src/lib/ringbuffer/ring_buffer_splice.c` (splice)
+ - `include/ringbuffer/vfs.h`: lib ring buffer ioctl commands (code 0xF6).
+
+ The ring buffer library can be configured to be used in various
+ use-cases by creating a specialized ring buffer "client" (template).
+ `include/ringbuffer/config.h` details the various configuration
+ parameters which are supported.
+
+
+## LTTng modules ring buffer clients
+
+ Files:
+ - `src/lttng-ring-buffer-client-discard.c`
+ - `src/lttng-ring-buffer-client-mmap-discard.c`
+ - `src/lttng-ring-buffer-client-mmap-overwrite.c`
+ - `src/lttng-ring-buffer-client-overwrite.c`
+ - `src/lttng-ring-buffer-metadata-client.c`
+ - `src/lttng-ring-buffer-metadata-mmap-client.c`
+ - `src/lttng-ring-buffer-client.h`
+ - `src/lttng-ring-buffer-metadata-client.h`
+
+ Those are the users of lib ring buffer, with specialized instances of
+ the ring buffer for each use-case supported by LTTng. Those are
+ hand-crafted templates in C. The fast-paths are inlined within each
+ client, and the slow paths are kept in the common library to minimize
+ code memory usage.
+
+
+## LTTng filter
+
+ The filter in lttng-modules is meant to quickly discard events which
+ do not match an expression. The expression parsing is all done in
+ userspace within lttng-tools. The filter is received by lttng-modules
+ as a bytecode. The frequent case for which a filter is optimized is to
+ discard most of the events. The filter operates on input arguments
+ received on the stack, before the ring buffer is touched.
+
+ Files:
+ - `include/lttng/filter-bytecode.h`: LTTng filter bytecode.
+ - `src/lttng-filter-validator.c`: Validation pass on bytecode reception
+ - `src/lttng-filter.c`: Filter linker code: link a bytecode onto a given
+ event (knowing its fields offsets).
+ - `src/lttng-filter-specialize.c`: Specialize the bytecode, transforming
+ generic instructions into
+ type-specific (faster) instructions.
+ - `src/lttng-filter-interpreter.c`: Bytecode interpreter, called by
+ instrumentation to filter events.
+
+## LTTng contexts
+
+ LTTng-modules supports the notion of "contexts" which can be attached either
+ to specific events or to all events in a channel. Those are additional
+ data which can be saved prior to the event payload, e.g. current
+ thread ID, process name, performance counters, and more.
+
+ Files:
+ - `src/lttng-context.c`: Context state associated to a channel or event,
+ and helpers.
+ - `src/lttng-context-*.c`: Implementation of all supported contexts:
+ callstack, cgroup-ns, cpu-id, egid, euid, gid, hostname,
+ interruptible, ipc-ns, migratable, mnt-ns, need-reschedule, net-ns,
+ nice, perf-counters, pid, pis-ns, ppid, preemptible, prio, procname,
+ sgid, suid, tid, uid, user-ns, uts-ns, vegid, veuid, vgid, vpid, vppid,
+ vsgid, vtid, vuid.
+
+
+## LTTng tracepoint instrumentation
+
+ The LTTng tracer attaches "probes" to kernel subsystems. A probe is a
+ set of tracepoint callbacks matching the tracepoint instrumentation
+ for a kernel subsystem. Each probe can be loaded separately.
+
+ Due to limitations in the kernel `TRACE_EVENT` macros, LTTng
+ implements its own `LTTNG_TRACEPOINT_EVENT` macros. It uses the
+ upstream kernel `TRACE_EVENT` macros only to validate the prototype
+ of its callbacks. Also, LTTng exposes an event field semantic which
+ matches what is exposed to user-space through /proc in the traces,
+ which requires different field layout implementation than what the
+ upstream kernel exposes to user-space.
+
+ Files:
+ - `src/lttng-tracepoint.c`: Mapping between tracepoint instrumentation and LTTng
+ events.
+ - `src/lttng-probes.c`: LTTng probes registry.
+ - `include/instrumentation/events/*`: LTTng tracepoint instrumentation
+ headers for all kernel subsystems.
+
+
+## LTTng system call instrumentation
+
+ The LTTng tracer gathers both input and output arguments from each
+ system call, for all supported architectures. This means the system
+ call probe callbacks read from user-space memory when needed.
+
+ Files:
+ - `src/lttng-syscalls.c`: LTTng system call instrumentation callbacks and
+ tables.
+ - `include/instrumentation/syscall/*`: generated and override system
+ call instrumentation headers.
+
+
+## LTTng statedump
+
+ Dump kernel state at trace start or when an explicit "statedump" is
+ requested. Useful to reconstruct the entire kernel state at
+ post-processing. Dumps: threads scheduling state, file
+ descriptor tables, interrupt handlers, network interfaces, block
+ devices, cpu topology. Also performs a "fence" on all CPUs to reach
+ a quiescent state on all CPUs before start and end of statedump.
+
+ Files:
+ - `src/lttng-statedump-impl.c`
+
+
+## LTTng tracker
+
+ User ID and Process ID trackers, for filtering of entire sessions
+ based on UID, GID, and PID.
+
+ Files:
+ - `src/lttng-tracker-id.c`
+
+
+## LTTng clock
+
+ Clock plugin registration. The clock used by the LTTng modules kernel
+ tracer can be overridden by a plugin module.
+
+ Files:
+ - `src/lttng-clock.c`
+ - `include/lttng/clock.h`
+++ /dev/null
-LTTng modules design
----------------------
-
-by Mathieu Desnoyers
-June 30, 2020
-
-This document covers the high level design of lttng-modules.
-
-LTTng modules is a kernel tracer for the Linux kernel. It can be either
-loaded as a set of kernel modules, or built into a Linux kernel.
-
-Here are its key components:
-
-* LTTng modules ABI
-
- Files:
- - src/lttng-abi.c
- - include/lttng/abi.h
-
- This ABI consists of ioctls with code 0xF6. It extensively uses
- anonymous file descriptors to represent the tracer "objects". Only
- root is allowed to interact with those ioctls.
-
-
-* LTTng session, channels, contexts and events management
- - src/lttng-events.c
- - include/lttng/lttng-events.h
-
- Current state about configured tracing sessions, channels, contexts
- and events. The session, channel, context and event state is
- manipulated through the LTTng modules ABI. A session contains 0 or
- more channels, through which data is traced. A channel is associated
- with an instance of a lib ring buffer client. Channels have 0 or more
- events, which are associated to kernel instrumentation as event
- sources.
-
-
-* lib ring buffer
-
- Generic ring buffer library (kernel implementation). Note, there is
- a very similar copy of this implementation within the lttng-ust
- user-space tracer. The overall goal of this library is to support
- both kernel and user-space tracing.
-
- Files:
- - src/lib/ringbuffer/*
- - include/ringbuffer/*
-
- Those include ring buffer ABI meant for consuming the buffer data
- from user-space. It is implemented in:
-
- - src/lib/ringbuffer/ring_buffer_vfs.c (open, release, poll, ioctl)
- - src/lib/ringbuffer/ring_buffer_mmap.c (mmap)
- - src/lib/ringbuffer/ring_buffer_splice.c (splice)
- - include/ringbuffer/vfs.h: lib ring buffer ioctl commands (code 0xF6).
-
- The ring buffer library can be configured to be used in various
- use-cases by creating a specialized ring buffer "client" (template).
- include/ringbuffer/config.h details the various configuration
- parameters which are supported.
-
-
-* LTTng modules ring buffer clients
-
- Files:
- - src/lttng-ring-buffer-client-discard.c
- - src/lttng-ring-buffer-client-mmap-discard.c
- - src/lttng-ring-buffer-client-mmap-overwrite.c
- - src/lttng-ring-buffer-client-overwrite.c
- - src/lttng-ring-buffer-metadata-client.c
- - src/lttng-ring-buffer-metadata-mmap-client.c
- - src/lttng-ring-buffer-client.h
- - src/lttng-ring-buffer-metadata-client.h
-
- Those are the users of lib ring buffer, with specialized instances of
- the ring buffer for each use-case supported by LTTng. Those are
- hand-crafted templates in C. The fast-paths are inlined within each
- client, and the slow paths are kept in the common library to minimize
- code memory usage.
-
-
-* LTTng filter
-
- The filter in lttng-modules is meant to quickly discard events which
- do not match an expression. The expression parsing is all done in
- userspace within lttng-tools. The filter is received by lttng-modules
- as a bytecode. The frequent case for which a filter is optimized is to
- discard most of the events. The filter operates on input arguments
- received on the stack, before the ring buffer is touched.
-
- Files:
- - include/lttng/filter-bytecode.h: LTTng filter bytecode.
- - src/lttng-filter-validator.c: Validation pass on bytecode reception
- - src/lttng-filter.c: Filter linker code: link a bytecode onto a given
- event (knowing its fields offsets).
- - src/lttng-filter-specialize.c: Specialize the bytecode, transforming
- generic instructions into
- type-specific (faster) instructions.
- - src/lttng-filter-interpreter.c: Bytecode interpreter, called by
- instrumentation to filter events.
-
-* LTTng contexts
-
- LTTng-modules supports the notion of "contexts" which can be attached either
- to specific events or to all events in a channel. Those are additional
- data which can be saved prior to the event payload, e.g. current
- thread ID, process name, performance counters, and more.
-
- Files:
- - src/lttng-context.c: Context state associated to a channel or event,
- and helpers.
- - src/lttng-context-*.c: Implementation of all supported contexts:
- callstack, cgroup-ns, cpu-id, egid, euid, gid, hostname,
- interruptible, ipc-ns, migratable, mnt-ns, need-reschedule, net-ns,
- nice, perf-counters, pid, pis-ns, ppid, preemptible, prio, procname,
- sgid, suid, tid, uid, user-ns, uts-ns, vegid, veuid, vgid, vpid, vppid,
- vsgid, vtid, vuid.
-
-
-* LTTng tracepoint instrumentation
-
- The LTTng tracer attaches "probes" to kernel subsystems. A probe is a
- set of tracepoint callbacks matching the tracepoint instrumentation
- for a kernel subsystem. Each probe can be loaded separately.
-
- Due to limitations in the kernel TRACE_EVENT macros, LTTng
- implements its own LTTNG_TRACEPOINT_EVENT macros. It uses the
- upstream kernel TRACE_EVENT macros only to validate the prototype
- of its callbacks. Also, LTTng exposes an event field semantic which
- matches what is exposed to user-space through /proc in the traces,
- which requires different field layout implementation than what the
- upstream kernel exposes to user-space.
-
- Files:
- src/lttng-tracepoint.c: Mapping between tracepoint instrumentation and LTTng
- events.
- src/lttng-probes.c: LTTng probes registry.
- include/instrumentation/events/*: LTTng tracepoint instrumentation
- headers for all kernel subsystems.
-
-
-* LTTng system call instrumentation
-
- The LTTng tracer gathers both input and output arguments from each
- system call, for all supported architectures. This means the system
- call probe callbacks read from user-space memory when needed.
-
- Files:
- - src/lttng-syscalls.c: LTTng system call instrumentation callbacks and
- tables.
- - include/instrumentation/syscall/*: generated and override system
- call instrumentation headers.
-
-
-* LTTng statedump
-
- Dump kernel state at trace start or when an explicit "statedump" is
- requested. Useful to reconstruct the entire kernel state at
- post-processing. Dumps: threads scheduling state, file
- descriptor tables, interrupt handlers, network interfaces, block
- devices, cpu topology. Also performs a "fence" on all CPUs to reach
- a quiescent state on all CPUs before start and end of statedump.
-
- Files:
- - src/lttng-statedump-impl.c
-
-
-* LTTng tracker
-
- User ID and Process ID trackers, for filtering of entire sessions
- based on UID, GID, and PID.
-
- Files:
- - src/lttng-tracker-id.c
-
-
-* LTTng clock
-
- Clock plugin registration. The clock used by the LTTng modules kernel
- tracer can be overridden by a plugin module.
-
- Files:
- - src/lttng-clock.c
- - include/lttng/clock.h
+++ /dev/null
-The first line of the "name" file is used to populate the "extra_version_name"
-modinfo key of each built module.
--- /dev/null
+<!--
+SPDX-FileCopyrightText: 2018 Michael Jeanson <mjeanson@efficios.com>
+
+SPDX-License-Identifier: CC-BY-SA-4.0
+-->
+
+The first line of the `name` file is used to populate the `extra_version_name`
+modinfo key of each built module.
+++ /dev/null
-The name of each file in this directory except this README will be used to
-populate a "extra_version_path" modinfo key for each built module.
--- /dev/null
+<!--
+SPDX-FileCopyrightText: 2018 Michael Jeanson <mjeanson@efficios.com>
+
+SPDX-License-Identifier: CC-BY-SA-4.0
+-->
+
+The name of each file in this directory except this README.md will be used to
+populate a `extra_version_path` modinfo key for each built module.
int8_t global_sum_step = counter->global_sum_step.s8;
res = *int_p;
- switch (sync) {
- case COUNTER_SYNC_PER_CPU:
+ switch (alloc) {
+ case COUNTER_ALLOC_PER_CPU:
{
do {
move_sum = 0;
old = res;
n = (int8_t) ((uint8_t) old + (uint8_t) v);
- if (unlikely(n > (int8_t) global_sum_step))
- move_sum = (int8_t) global_sum_step / 2;
- else if (unlikely(n < -(int8_t) global_sum_step))
- move_sum = -((int8_t) global_sum_step / 2);
- n -= move_sum;
+ if (unlikely(global_sum_step)) {
+ if (unlikely(n > (int8_t) global_sum_step))
+ move_sum = (int8_t) global_sum_step / 2;
+ else if (unlikely(n < -(int8_t) global_sum_step))
+ move_sum = -((int8_t) global_sum_step / 2);
+ n -= move_sum;
+ }
res = cmpxchg_local(int_p, old, n);
} while (old != res);
break;
}
- case COUNTER_SYNC_GLOBAL:
+ case COUNTER_ALLOC_GLOBAL:
{
do {
old = res;
int16_t global_sum_step = counter->global_sum_step.s16;
res = *int_p;
- switch (sync) {
- case COUNTER_SYNC_PER_CPU:
+ switch (alloc) {
+ case COUNTER_ALLOC_PER_CPU:
{
do {
move_sum = 0;
old = res;
n = (int16_t) ((uint16_t) old + (uint16_t) v);
- if (unlikely(n > (int16_t) global_sum_step))
- move_sum = (int16_t) global_sum_step / 2;
- else if (unlikely(n < -(int16_t) global_sum_step))
- move_sum = -((int16_t) global_sum_step / 2);
- n -= move_sum;
+ if (unlikely(global_sum_step)) {
+ if (unlikely(n > (int16_t) global_sum_step))
+ move_sum = (int16_t) global_sum_step / 2;
+ else if (unlikely(n < -(int16_t) global_sum_step))
+ move_sum = -((int16_t) global_sum_step / 2);
+ n -= move_sum;
+ }
res = cmpxchg_local(int_p, old, n);
} while (old != res);
break;
}
- case COUNTER_SYNC_GLOBAL:
+ case COUNTER_ALLOC_GLOBAL:
{
do {
old = res;
int32_t global_sum_step = counter->global_sum_step.s32;
res = *int_p;
- switch (sync) {
- case COUNTER_SYNC_PER_CPU:
+ switch (alloc) {
+ case COUNTER_ALLOC_PER_CPU:
{
do {
move_sum = 0;
old = res;
n = (int32_t) ((uint32_t) old + (uint32_t) v);
- if (unlikely(n > (int32_t) global_sum_step))
- move_sum = (int32_t) global_sum_step / 2;
- else if (unlikely(n < -(int32_t) global_sum_step))
- move_sum = -((int32_t) global_sum_step / 2);
- n -= move_sum;
+ if (unlikely(global_sum_step)) {
+ if (unlikely(n > (int32_t) global_sum_step))
+ move_sum = (int32_t) global_sum_step / 2;
+ else if (unlikely(n < -(int32_t) global_sum_step))
+ move_sum = -((int32_t) global_sum_step / 2);
+ n -= move_sum;
+ }
res = cmpxchg_local(int_p, old, n);
} while (old != res);
break;
}
- case COUNTER_SYNC_GLOBAL:
+ case COUNTER_ALLOC_GLOBAL:
{
do {
old = res;
int64_t global_sum_step = counter->global_sum_step.s64;
res = *int_p;
- switch (sync) {
- case COUNTER_SYNC_PER_CPU:
+ switch (alloc) {
+ case COUNTER_ALLOC_PER_CPU:
{
do {
move_sum = 0;
old = res;
n = (int64_t) ((uint64_t) old + (uint64_t) v);
- if (unlikely(n > (int64_t) global_sum_step))
- move_sum = (int64_t) global_sum_step / 2;
- else if (unlikely(n < -(int64_t) global_sum_step))
- move_sum = -((int64_t) global_sum_step / 2);
- n -= move_sum;
+ if (unlikely(global_sum_step)) {
+ if (unlikely(n > (int64_t) global_sum_step))
+ move_sum = (int64_t) global_sum_step / 2;
+ else if (unlikely(n < -(int64_t) global_sum_step))
+ move_sum = -((int64_t) global_sum_step / 2);
+ n -= move_sum;
+ }
res = cmpxchg_local(int_p, old, n);
} while (old != res);
break;
}
- case COUNTER_SYNC_GLOBAL:
+ case COUNTER_ALLOC_GLOBAL:
{
do {
old = res;
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2018 Michael Jeanson <mjeanson@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM 9p
+++ /dev/null
-* Workflow for updating patches from newer kernel:
-
-Pull the new headers from mainline kernel to this subdirectory.
-Update those headers to fix the lttng-modules instrumentation style.
-
-
-* Workflow to add new Tracepoint instrumentation to newer kernel,
- and add support for it into LTTng:
-
-a) instrument the kernel with new trace events headers. If you want that
- instrumentation distributed, you will have to push those changes into
- the upstream Linux kernel first,
-b) copy those headers into this subdirectory,
-c) look at a diff from other headers between mainline kernel version and
- those in this subdirectory, and use that as a recipe to alter the new
- headers copy.
-d) create a new file in probes/ for the new trace event header you added,
-e) add it to probes/Makefile,
-f) build, make modules_install,
-g) don't forget to load that new module too.
-
-Currently, LTTng policy is to only accept headers derived from trace
-event headers accepted into the Linux kernel upstream for tracepoints
-related to upstream kernel instrumentation.
--- /dev/null
+<!--
+SPDX-FileCopyrightText: 2011-2017 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+
+SPDX-License-Identifier: CC-BY-SA-4.0
+-->
+
+# Workflow for updating patches from newer kernel:
+
+Pull the new headers from mainline kernel to this subdirectory.
+Update those headers to fix the lttng-modules instrumentation style.
+
+
+# Workflow to add new Tracepoint instrumentation to newer kernel, and add support for it into LTTng:
+
+1. Instrument the kernel with new trace events headers. If you want that
+ instrumentation distributed, you will have to push those changes into
+ the upstream Linux kernel first,
+2. Copy those headers into this subdirectory,
+3. Look at a diff from other headers between mainline kernel version and
+ those in this subdirectory, and use that as a recipe to alter the new
+ headers copy.
+4. Create a new file in `src/probes/` for the new trace event header you added,
+5. Add it to `src/probes/Makefile`,
+6. Build, `make modules_install`,
+7. Don't forget to load that new module too.
+
+Currently, LTTng policy is to only accept headers derived from trace
+event headers accepted into the Linux kernel upstream for tracepoints
+related to upstream kernel instrumentation.
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#if !defined(LTTNG_TRACE_EXCEPTIONS_H) || defined(TRACE_HEADER_MULTI_READ)
#define LTTNG_TRACE_EXCEPTIONS_H
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#if !defined(LTTNG_TRACE_IRQ_VECTORS_H) || defined(TRACE_HEADER_MULTI_READ)
#define LTTNG_TRACE_IRQ_VECTORS_H
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2013 Mohamad Gebai <mohamad.gebai@polymtl.ca>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#if !defined(LTTNG_TRACE_KVM_MMU_H) || defined(TRACE_HEADER_MULTI_READ)
#define LTTNG_TRACE_KVM_MMU_H
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2013 Mohamad Gebai <mohamad.gebai@polymtl.ca>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#if !defined(LTTNG_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
#define LTTNG_TRACE_KVM_H
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Paul Woegerer <paul_woegerer@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM asoc
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM block
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Andrew Gabbasov <andrew_gabbasov@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM btrfs
)
#endif
-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,8,0))
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,11,0))
+
+LTTNG_TRACEPOINT_EVENT(btrfs_get_extent,
+
+ TP_PROTO(const struct btrfs_root *root, const struct btrfs_inode *inode,
+ const struct extent_map *map),
+
+ TP_ARGS(root, inode, map),
+
+ TP_FIELDS(
+ ctf_integer(u64, root_objectid, root->root_key.objectid)
+ ctf_integer(u64, ino, btrfs_ino(inode))
+ ctf_integer(u64, start, map->start)
+ ctf_integer(u64, len, map->len)
+ ctf_integer(unsigned int, flags, map->flags)
+ ctf_integer(int, refs, refcount_read(&map->refs))
+ ctf_integer(unsigned int, compress_type, extent_map_compression(map))
+ )
+)
+
+#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,8,0))
LTTNG_TRACEPOINT_EVENT(btrfs_get_extent,
)
#endif
-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,14,0) || \
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,10,0))
+LTTNG_TRACEPOINT_EVENT_CLASS(btrfs_delayed_tree_ref,
+
+ TP_PROTO(const struct btrfs_fs_info *fs_info,
+ const struct btrfs_delayed_ref_node *ref),
+
+ TP_ARGS(fs_info, ref),
+
+ TP_FIELDS(
+ ctf_array(u8, fsid, lttng_fs_info_fsid, BTRFS_UUID_SIZE)
+ ctf_integer(u64, bytenr, ref->bytenr)
+ ctf_integer(u64, num_bytes, ref->num_bytes)
+ ctf_integer(int, action, ref->action)
+ ctf_integer(u64, parent, ref->parent)
+ ctf_integer(u64, ref_root, ref->ref_root)
+ ctf_integer(int, level, ref->tree_ref.level)
+ ctf_integer(int, type, ref->type)
+ ctf_integer(u64, seq, ref->seq)
+ )
+)
+
+LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(btrfs_delayed_tree_ref,
+
+ add_delayed_tree_ref,
+
+ btrfs_add_delayed_tree_ref,
+
+ TP_PROTO(const struct btrfs_fs_info *fs_info,
+ const struct btrfs_delayed_ref_node *ref),
+
+ TP_ARGS(fs_info, ref)
+)
+
+LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(btrfs_delayed_tree_ref,
+
+ run_delayed_tree_ref,
+
+ btrfs_run_delayed_tree_ref,
+
+ TP_PROTO(const struct btrfs_fs_info *fs_info,
+ const struct btrfs_delayed_ref_node *ref),
+
+ TP_ARGS(fs_info, ref)
+)
+#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,14,0) || \
LTTNG_SLE_KERNEL_RANGE(4,4,73,5,0,0, 4,4,73,6,0,0) || \
LTTNG_SLE_KERNEL_RANGE(4,4,82,6,0,0, 4,4,82,7,0,0) || \
LTTNG_SLE_KERNEL_RANGE(4,4,92,6,0,0, 4,4,92,7,0,0) || \
)
#endif
-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,14,0) || \
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,10,0))
+LTTNG_TRACEPOINT_EVENT_CLASS(btrfs_delayed_data_ref,
+
+ TP_PROTO(const struct btrfs_fs_info *fs_info,
+ const struct btrfs_delayed_ref_node *ref),
+
+ TP_ARGS(fs_info, ref),
+
+ TP_FIELDS(
+ ctf_array(u8, fsid, lttng_fs_info_fsid, BTRFS_UUID_SIZE)
+ ctf_integer(u64, bytenr, ref->bytenr)
+ ctf_integer(u64, num_bytes, ref->num_bytes)
+ ctf_integer(int, action, ref->action)
+ ctf_integer(u64, parent, ref->parent)
+ ctf_integer(u64, ref_root, ref->ref_root)
+ ctf_integer(u64, owner, ref->data_ref.objectid)
+ ctf_integer(u64, offset, ref->data_ref.offset)
+ ctf_integer(int, type, ref->type)
+ ctf_integer(u64, seq, ref->seq)
+ )
+)
+
+LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(btrfs_delayed_data_ref,
+
+ add_delayed_data_ref,
+
+ btrfs_add_delayed_data_ref,
+
+ TP_PROTO(const struct btrfs_fs_info *fs_info,
+ const struct btrfs_delayed_ref_node *ref),
+
+ TP_ARGS(fs_info, ref)
+)
+
+LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(btrfs_delayed_data_ref,
+
+ run_delayed_data_ref,
+
+ btrfs_run_delayed_data_ref,
+
+ TP_PROTO(const struct btrfs_fs_info *fs_info,
+ const struct btrfs_delayed_ref_node *ref),
+
+ TP_ARGS(fs_info, ref)
+)
+
+#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,14,0) || \
LTTNG_SLE_KERNEL_RANGE(4,4,73,5,0,0, 4,4,73,6,0,0) || \
LTTNG_SLE_KERNEL_RANGE(4,4,82,6,0,0, 4,4,82,7,0,0) || \
LTTNG_SLE_KERNEL_RANGE(4,4,92,6,0,0, 4,4,92,7,0,0) || \
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Andrew Gabbasov <andrew_gabbasov@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM compaction
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2022 Rouven Czerwinski <r.czerwinski@pengutronix.de>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM dma_fence
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Andrew Gabbasov <andrew_gabbasov@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM ext4
)
#endif
-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,13,0))
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,11,0))
+LTTNG_TRACEPOINT_EVENT(ext4_da_reserve_space,
+ TP_PROTO(struct inode *inode, int nr_resv),
+
+ TP_ARGS(inode, nr_resv),
+
+ TP_FIELDS(
+ ctf_integer(dev_t, dev, inode->i_sb->s_dev)
+ ctf_integer(ino_t, ino, inode->i_ino)
+ ctf_integer(__u64, i_blocks, inode->i_blocks)
+ ctf_integer(__u64, nr_resv, nr_resv)
+ ctf_integer(int, reserved_data_blocks,
+ EXT4_I(inode)->i_reserved_data_blocks)
+ ctf_integer(TP_MODE_T, mode, inode->i_mode)
+ )
+)
+#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,13,0))
LTTNG_TRACEPOINT_EVENT(ext4_da_reserve_space,
TP_PROTO(struct inode *inode),
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Paul Woegerer <paul_woegerer@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM gpio
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2016 Simon Marchi <simon.marchi@ericsson.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM i2c
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM irq
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Paul Woegerer <paul_woegerer@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM jbd
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Paul Woegerer <paul_woegerer@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM jbd2
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Paul Woegerer <paul_woegerer@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM kmem
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#if !defined(LTTNG_TRACE_KVM_MAIN_H) || defined(TRACE_HEADER_MULTI_READ)
#define LTTNG_TRACE_KVM_MAIN_H
{ KVM_TRACE_MMIO_READ, "read" }, \
{ KVM_TRACE_MMIO_WRITE, "write" }
-
-#if (LTTNG_SLE_KERNEL_RANGE(4,4,121,92,92,0, 4,4,122,0,0,0) \
- || LTTNG_SLE_KERNEL_RANGE(4,4,131,94,0,0, 4,5,0,0,0,0))
-
-LTTNG_TRACEPOINT_EVENT(kvm_mmio,
- TP_PROTO(int type, int len, u64 gpa, u64 val),
- TP_ARGS(type, len, gpa, val),
-
- TP_FIELDS(
- ctf_integer(u32, type, type)
- ctf_integer(u32, len, len)
- ctf_integer(u64, gpa, gpa)
- ctf_integer(u64, val, val)
- )
-)
-
-#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,15,0) \
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,15,0) \
|| LTTNG_KERNEL_RANGE(4,14,14, 4,15,0) \
|| LTTNG_DEBIAN_KERNEL_RANGE(4,14,13,1,0, 4,15,0,0,0) \
|| LTTNG_KERNEL_RANGE(4,9,77, 4,10,0) \
- || LTTNG_KERNEL_RANGE(4,4,112, 4,5,0) \
+ || (LTTNG_KERNEL_RANGE(4,4,112, 4,5,0) \
+ && !(LTTNG_SLE_KERNEL_RANGE(4,4,121,92,92,0, 4,4,122,0,0,0) \
+ || LTTNG_SLE_KERNEL_RANGE(4,4,131,94,0,0, 4,5,0,0,0,0))) \
|| LTTNG_UBUNTU_KERNEL_RANGE(4,13,16,38, 4,14,0,0) \
|| LTTNG_DEBIAN_KERNEL_RANGE(4,9,65,3,0, 4,10,0,0,0) \
|| LTTNG_FEDORA_KERNEL_RANGE(4,14,13,300, 4,15,0,0))
ctf_integer(u32, type, type)
ctf_integer(u32, len, len)
ctf_integer(u64, gpa, gpa)
- ctf_sequence_hex(unsigned char, val, val, u32, len)
+ ctf_sequence_hex(unsigned char, val, val, u32, val != NULL ? len : 0)
)
)
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Paul Woegerer <paul_woegerer@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
#undef TRACE_SYSTEM
#define TRACE_SYSTEM lock
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM lttng_statedump
#define LTTNG_HAVE_STATEDUMP_CPU_TOPOLOGY
-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,7,0))
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,7,0) || \
+ LTTNG_RHEL_KERNEL_RANGE(5,14,0,452,0,0, 5,15,0,0,0,0))
LTTNG_TRACEPOINT_EVENT(lttng_statedump_cpu_topology,
TP_PROTO(struct lttng_kernel_session *session, struct cpuinfo_x86 *c),
TP_ARGS(session, c),
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM lttng_test
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM lttng
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Paul Woegerer <paul_woegerer@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM mm_vmscan
)
)
-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,7,0))
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,7,0) || \
+ LTTNG_RHEL_KERNEL_RANGE(5,14,0,427,16,1, 5,15,0,0,0,0))
LTTNG_TRACEPOINT_EVENT(mm_vmscan_lru_isolate,
TP_PROTO(int classzone_idx,
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Paul Woegerer <paul_woegerer@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
/*
* Because linux/module.h has tracepoints in the header, and ftrace.h
* eventually includes this file, define_trace.h includes linux/module.h
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Paul Woegerer <paul_woegerer@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM napi
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Paul Woegerer <paul_woegerer@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM net
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Paul Woegerer <paul_woegerer@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM power
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2017 Michael Jeanson <mjeanson@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#ifdef CONFIG_PREEMPTIRQ_EVENTS
#undef TRACE_SYSTEM
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Andrew Gabbasov <andrew_gabbasov@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM printk
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Andrew Gabbasov <andrew_gabbasov@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM random
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Andrew Gabbasov <andrew_gabbasov@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM rcu
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Andrew Gabbasov <andrew_gabbasov@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM regmap
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Paul Woegerer <paul_woegerer@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM regulator
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Andrew Gabbasov <andrew_gabbasov@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM rpc
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Andrew Gabbasov <andrew_gabbasov@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM rpm
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM sched
TP_PROTO(struct task_struct *tsk, u64 delay),
TP_ARGS(tsk, delay))
-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,8,0))
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,8,0) || \
+ LTTNG_RHEL_KERNEL_RANGE(5,14,0,452,0,0, 5,15,0,0,0,0))
/*
* Tracepoint for accounting runtime (time the task is executing
* on a CPU).
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Paul Woegerer <paul_woegerer@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM scsi
#define scsi_opcode_name(opcode) { opcode, #opcode }
-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,7,0) \
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,11,0))
+
+#define show_opcode_name(val) \
+ __print_symbolic(val, \
+ scsi_opcode_name(TEST_UNIT_READY), \
+ scsi_opcode_name(REZERO_UNIT), \
+ scsi_opcode_name(REQUEST_SENSE), \
+ scsi_opcode_name(FORMAT_UNIT), \
+ scsi_opcode_name(READ_BLOCK_LIMITS), \
+ scsi_opcode_name(REASSIGN_BLOCKS), \
+ scsi_opcode_name(INITIALIZE_ELEMENT_STATUS), \
+ scsi_opcode_name(READ_6), \
+ scsi_opcode_name(WRITE_6), \
+ scsi_opcode_name(SEEK_6), \
+ scsi_opcode_name(READ_REVERSE), \
+ scsi_opcode_name(WRITE_FILEMARKS), \
+ scsi_opcode_name(SPACE), \
+ scsi_opcode_name(INQUIRY), \
+ scsi_opcode_name(RECOVER_BUFFERED_DATA), \
+ scsi_opcode_name(MODE_SELECT), \
+ scsi_opcode_name(RESERVE), \
+ scsi_opcode_name(RELEASE), \
+ scsi_opcode_name(COPY), \
+ scsi_opcode_name(ERASE), \
+ scsi_opcode_name(MODE_SENSE), \
+ scsi_opcode_name(START_STOP), \
+ scsi_opcode_name(RECEIVE_DIAGNOSTIC), \
+ scsi_opcode_name(SEND_DIAGNOSTIC), \
+ scsi_opcode_name(ALLOW_MEDIUM_REMOVAL), \
+ scsi_opcode_name(SET_WINDOW), \
+ scsi_opcode_name(READ_CAPACITY), \
+ scsi_opcode_name(READ_10), \
+ scsi_opcode_name(WRITE_10), \
+ scsi_opcode_name(SEEK_10), \
+ scsi_opcode_name(POSITION_TO_ELEMENT), \
+ scsi_opcode_name(WRITE_VERIFY), \
+ scsi_opcode_name(VERIFY), \
+ scsi_opcode_name(SEARCH_HIGH), \
+ scsi_opcode_name(SEARCH_EQUAL), \
+ scsi_opcode_name(SEARCH_LOW), \
+ scsi_opcode_name(SET_LIMITS), \
+ scsi_opcode_name(PRE_FETCH), \
+ scsi_opcode_name(READ_POSITION), \
+ scsi_opcode_name(SYNCHRONIZE_CACHE), \
+ scsi_opcode_name(LOCK_UNLOCK_CACHE), \
+ scsi_opcode_name(READ_DEFECT_DATA), \
+ scsi_opcode_name(MEDIUM_SCAN), \
+ scsi_opcode_name(COMPARE), \
+ scsi_opcode_name(COPY_VERIFY), \
+ scsi_opcode_name(WRITE_BUFFER), \
+ scsi_opcode_name(READ_BUFFER), \
+ scsi_opcode_name(UPDATE_BLOCK), \
+ scsi_opcode_name(READ_LONG), \
+ scsi_opcode_name(WRITE_LONG), \
+ scsi_opcode_name(CHANGE_DEFINITION), \
+ scsi_opcode_name(WRITE_SAME), \
+ scsi_opcode_name(UNMAP), \
+ scsi_opcode_name(READ_TOC), \
+ scsi_opcode_name(LOG_SELECT), \
+ scsi_opcode_name(LOG_SENSE), \
+ scsi_opcode_name(XDWRITEREAD_10), \
+ scsi_opcode_name(MODE_SELECT_10), \
+ scsi_opcode_name(RESERVE_10), \
+ scsi_opcode_name(RELEASE_10), \
+ scsi_opcode_name(MODE_SENSE_10), \
+ scsi_opcode_name(PERSISTENT_RESERVE_IN), \
+ scsi_opcode_name(PERSISTENT_RESERVE_OUT), \
+ scsi_opcode_name(VARIABLE_LENGTH_CMD), \
+ scsi_opcode_name(REPORT_LUNS), \
+ scsi_opcode_name(MAINTENANCE_IN), \
+ scsi_opcode_name(MAINTENANCE_OUT), \
+ scsi_opcode_name(MOVE_MEDIUM), \
+ scsi_opcode_name(EXCHANGE_MEDIUM), \
+ scsi_opcode_name(READ_12), \
+ scsi_opcode_name(WRITE_12), \
+ scsi_opcode_name(WRITE_VERIFY_12), \
+ scsi_opcode_name(SEARCH_HIGH_12), \
+ scsi_opcode_name(SEARCH_EQUAL_12), \
+ scsi_opcode_name(SEARCH_LOW_12), \
+ scsi_opcode_name(READ_ELEMENT_STATUS), \
+ scsi_opcode_name(SEND_VOLUME_TAG), \
+ scsi_opcode_name(WRITE_LONG_2), \
+ scsi_opcode_name(READ_16), \
+ scsi_opcode_name(WRITE_16), \
+ scsi_opcode_name(VERIFY_16), \
+ scsi_opcode_name(WRITE_SAME_16), \
+ scsi_opcode_name(ZBC_OUT), \
+ scsi_opcode_name(ZBC_IN), \
+ scsi_opcode_name(SERVICE_ACTION_IN_16), \
+ scsi_opcode_name(READ_32), \
+ scsi_opcode_name(WRITE_32), \
+ scsi_opcode_name(WRITE_SAME_32), \
+ scsi_opcode_name(ATA_16), \
+ scsi_opcode_name(WRITE_ATOMIC_16), \
+ scsi_opcode_name(ATA_12))
+
+#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,7,0) \
|| LTTNG_SLE_KERNEL_RANGE(4,4,9,36,0,0, 4,5,0,0,0,0))
#define show_opcode_name(val) \
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM signal
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Paul Woegerer <paul_woegerer@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM skb
)
#endif
-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,17,0) \
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,11,0))
+LTTNG_TRACEPOINT_EVENT_MAP(kfree_skb,
+
+ skb_kfree,
+
+ TP_PROTO(struct sk_buff *skb, void *location,
+ enum skb_drop_reason reason, struct sock *rx_sk),
+
+ TP_ARGS(skb, location, reason, rx_sk),
+
+ TP_FIELDS(
+ ctf_integer_hex(void *, skbaddr, skb)
+ ctf_integer_hex(void *, location, location)
+ ctf_integer_network(unsigned short, protocol, skb->protocol)
+ ctf_enum(skb_drop_reason, uint8_t, reason, reason)
+ ctf_integer_hex(void *, rx_skaddr, rx_sk)
+ )
+)
+#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,17,0) \
|| LTTNG_KERNEL_RANGE(5,15,58, 5,16,0) \
|| LTTNG_RHEL_KERNEL_RANGE(5,14,0,70,0,0, 5,15,0,0,0,0) \
|| LTTNG_RHEL_KERNEL_RANGE(4,18,0,477,10,1, 4,19,0,0,0,0))
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Paul Woegerer <paul_woegerer@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM sock
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM timer
TP_ARGS(timer)
)
-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,8,0))
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,8,0) || \
+ LTTNG_RHEL_KERNEL_RANGE(5,14,0,457,0,0, 5,15,0,0,0,0))
/**
* timer_start - called when the timer is started
* @timer: pointer to struct timer_list
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Paul Woegerer <paul_woegerer@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM udp
#include <lttng/tracepoint-event.h>
#include <linux/udp.h>
+#include <lttng/kernel-version.h>
+
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,10,0))
+LTTNG_TRACEPOINT_ENUM(lttng_sk_family,
+ TP_ENUM_VALUES(
+ ctf_enum_value("AF_INET", AF_INET)
+ ctf_enum_value("AF_INET6", AF_INET6)
+ )
+)
+
+LTTNG_TRACEPOINT_EVENT(udp_fail_queue_rcv_skb,
+ TP_PROTO(int rc, struct sock *sk, struct sk_buff *skb),
+
+ TP_ARGS(rc, sk, skb),
+
+ TP_FIELDS(
+ ctf_integer(int, rc, rc)
+ ctf_integer(__u16, sport, ntohs(udp_hdr(skb)->source))
+ ctf_integer(__u16, dport, ntohs(udp_hdr(skb)->dest))
+ ctf_enum(lttng_sk_family, __u16, family, sk->sk_family)
+ /*
+ * The 'saddr' and 'daddr' fields from the upstream tracepoint
+ * are currently not extracted. It is recommended to use a
+ * tracepoint from the 'net' probe instead which includes all
+ * fields from the IP header.
+ */
+ )
+)
+#else
LTTNG_TRACEPOINT_EVENT(udp_fail_queue_rcv_skb,
TP_PROTO(int rc, struct sock *sk),
ctf_integer(__u16, lport, inet_sk(sk)->inet_num)
)
)
+#endif
#endif /* LTTNG_TRACE_UDP_H */
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2014 Wade Farnsworth <wade_farnsworth@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM v4l2
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Andrew Gabbasov <andrew_gabbasov@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM workqueue
-/* SPDX-License-Identifier: GPL-2.0-only */
+// SPDX-FileCopyrightText: 2012 Andrew Gabbasov <andrew_gabbasov@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only
+
#undef TRACE_SYSTEM
#define TRACE_SYSTEM writeback
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2022 EfficiOS Inc.
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
#ifndef CONFIG_UID16
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2022 EfficiOS Inc.
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
#define OVERRIDE_TABLE_32_mmap2
#endif /* CONFIG_COMPAT_OLD_SIGACTION */
#endif
+/*
+ * Override 'pipe' to set the output field 'fildes' to an array of 2 integers
+ * instead of the default integer pointer.
+ */
#define OVERRIDE_32_pipe
SC_LTTNG_TRACEPOINT_EVENT(pipe,
TP_PROTO(sc_exit(long ret,) int * fildes),
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2022 EfficiOS Inc.
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
/*
* this is a place-holder for arm64 integer syscall definition override.
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2022 EfficiOS Inc.
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
/*
* this is a place-holder for arm64 integer syscall definition override.
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
#ifdef CONFIG_X86_64
#include "x86-32-syscalls_integers.h"
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
#ifdef CONFIG_X86_64
#include "x86-32-syscalls_pointers.h"
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2012 Ralf Baechle <ralf@linux-mips.org>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
/*
* this is a place-holder for MIPS integer syscall definition override.
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2012 Ralf Baechle <ralf@linux-mips.org>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
#ifndef CREATE_SYSCALL_TABLE
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2012 Ralf Baechle <ralf@linux-mips.org>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
/*
* this is a place-holder for MIPS integer syscall definition override.
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2012 Ralf Baechle <ralf@linux-mips.org>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
#ifndef CREATE_SYSCALL_TABLE
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2013 Paul Woegerer <paul_woegerer@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
#ifndef CREATE_SYSCALL_TABLE
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2013 Paul Woegerer <paul_woegerer@mentor.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
#define OVERRIDE_TABLE_32_mmap2
#ifndef CREATE_SYSCALL_TABLE
+/*
+ * Override 'pipe' to set the output field 'fildes' to an array of 2 integers
+ * instead of the default integer pointer.
+ */
#define OVERRIDE_32_pipe
SC_LTTNG_TRACEPOINT_EVENT(pipe,
TP_PROTO(sc_exit(long ret,) int * fildes),
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
#ifdef CONFIG_X86_64
#include "x86-64-syscalls_integers.h"
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
#ifndef CREATE_SYSCALL_TABLE
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
#ifdef CONFIG_X86_64
#include "x86-64-syscalls_pointers.h"
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
#ifndef CREATE_SYSCALL_TABLE
)
)
+/*
+ * Override 'pipe2' to set the output field 'fildes' to an array of 2 integers
+ * instead of the default integer pointer.
+ */
#define OVERRIDE_32_pipe2
#define OVERRIDE_64_pipe2
SC_LTTNG_TRACEPOINT_EVENT(pipe2,
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
#if !defined(_TRACE_SYSCALLS_UNKNOWN_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_SYSCALLS_UNKNOWN_H
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2022 EfficiOS Inc.
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
#ifndef CONFIG_UID16
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2022 EfficiOS Inc.
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
#ifndef CREATE_SYSCALL_TABLE
#endif /* CONFIG_COMPAT_OLD_SIGACTION */
#endif
+/*
+ * Override 'pipe' to set the output field 'fildes' to an array of 2 integers
+ * instead of the default integer pointer.
+ */
#define OVERRIDE_32_pipe
#define OVERRIDE_64_pipe
SC_LTTNG_TRACEPOINT_EVENT(pipe,
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2022 EfficiOS Inc.
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
/*
* this is a place-holder for x86_64 integer syscall definition override.
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2022 EfficiOS Inc.
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
#ifndef CREATE_SYSCALL_TABLE
TP_code_post()
)
+/*
+ * Override 'pipe' to set the output field 'fildes' to an array of 2 integers
+ * instead of the default integer pointer.
+ */
#define OVERRIDE_64_pipe
SC_LTTNG_TRACEPOINT_EVENT(pipe,
TP_PROTO(sc_exit(long ret,) int * fildes),
} u;
};
+#define LTTNG_KERNEL_ABI_OLD_COUNTER_DIMENSION_MAX 4
+
+struct lttng_kernel_abi_old_counter_dimension {
+ uint64_t size;
+ uint64_t underflow_index;
+ uint64_t overflow_index;
+ uint8_t has_underflow;
+ uint8_t has_overflow;
+} __attribute__((packed));
+
+#define LTTNG_KERNEL_ABI_OLD_COUNTER_CONF_PADDING1 67
+struct lttng_kernel_abi_old_counter_conf {
+ uint32_t arithmetic; /* enum lttng_kernel_abi_counter_arithmetic */
+ uint32_t bitness; /* enum lttng_kernel_abi_counter_bitness */
+ uint32_t number_dimensions;
+ int64_t global_sum_step;
+ struct lttng_kernel_abi_old_counter_dimension dimensions[LTTNG_KERNEL_ABI_OLD_COUNTER_DIMENSION_MAX];
+ uint8_t coalesce_hits;
+ char padding[LTTNG_KERNEL_ABI_OLD_COUNTER_CONF_PADDING1];
+} __attribute__((packed));
+
+struct lttng_kernel_abi_old_counter_index {
+ uint32_t number_dimensions;
+ uint64_t dimension_indexes[LTTNG_KERNEL_ABI_OLD_COUNTER_DIMENSION_MAX];
+} __attribute__((packed));
+
+struct lttng_kernel_abi_old_counter_value {
+ int64_t value;
+ uint8_t underflow;
+ uint8_t overflow;
+} __attribute__((packed));
+
+#define LTTNG_KERNEL_ABI_OLD_COUNTER_READ_PADDING 32
+struct lttng_kernel_abi_old_counter_read {
+ struct lttng_kernel_abi_old_counter_index index;
+ int32_t cpu; /* -1 for global counter, >= 0 for specific cpu. */
+ struct lttng_kernel_abi_old_counter_value value; /* output */
+ char padding[LTTNG_KERNEL_ABI_OLD_COUNTER_READ_PADDING];
+} __attribute__((packed));
+
+#define LTTNG_KERNEL_ABI_OLD_COUNTER_AGGREGATE_PADDING 32
+struct lttng_kernel_abi_old_counter_aggregate {
+ struct lttng_kernel_abi_old_counter_index index;
+ struct lttng_kernel_abi_old_counter_value value; /* output */
+ char padding[LTTNG_KERNEL_ABI_OLD_COUNTER_AGGREGATE_PADDING];
+} __attribute__((packed));
+
+#define LTTNG_KERNEL_ABI_OLD_COUNTER_CLEAR_PADDING 32
+struct lttng_kernel_abi_old_counter_clear {
+ struct lttng_kernel_abi_old_counter_index index;
+ char padding[LTTNG_KERNEL_ABI_OLD_COUNTER_CLEAR_PADDING];
+} __attribute__((packed));
+
/* LTTng file descriptor ioctl */
#define LTTNG_KERNEL_ABI_OLD_SESSION _IO(0xF6, 0x40)
#define LTTNG_KERNEL_ABI_OLD_TRACER_VERSION \
#define LTTNG_KERNEL_ABI_OLD_ENABLE _IO(0xF6, 0x80)
#define LTTNG_KERNEL_ABI_OLD_DISABLE _IO(0xF6, 0x81)
+#define LTTNG_KERNEL_ABI_OLD_COUNTER \
+ _IOW(0xF6, 0x84, struct lttng_kernel_abi_old_counter_conf)
+
+/* Counter file descriptor ioctl ("old" 2.13 ABI) */
+#define LTTNG_KERNEL_ABI_OLD_COUNTER_READ \
+ _IOWR(0xF6, 0xC0, struct lttng_kernel_abi_old_counter_read)
+#define LTTNG_KERNEL_ABI_OLD_COUNTER_AGGREGATE \
+ _IOWR(0xF6, 0xC1, struct lttng_kernel_abi_old_counter_aggregate)
+#define LTTNG_KERNEL_ABI_OLD_COUNTER_CLEAR \
+ _IOW(0xF6, 0xC2, struct lttng_kernel_abi_old_counter_clear)
+
#endif /* _LTTNG_ABI_OLD_H */
uint32_t nr; /* For LTTNG_SYSCALL_MATCH_NR */
} __attribute__((packed));
+/*
+ * An immediate match requires that the requested event matches existing
+ * instrumentation when the ioctl is issued, whereas a lazy match does not
+ * have this constraint.
+ *
+ * Instrumentation default
+ * ---------------------------------------------------------------------------
+ * LTTNG_KERNEL_ABI_TRACEPOINT: lazy
+ * LTTNG_KERNEL_ABI_SYSCALL: lazy
+ * LTTNG_KERNEL_ABI_KPROBE: immediate
+ * LTTNG_KERNEL_ABI_KRETPROBE: immediate
+ * LTTNG_KERNEL_ABI_UPROBE: immediate
+ */
+enum lttng_kernel_abi_match_check {
+ LTTNG_KERNEL_ABI_MATCH_DEFAULT = 0,
+ LTTNG_KERNEL_ABI_MATCH_IMMEDIATE = 1,
+ LTTNG_KERNEL_ABI_MATCH_LAZY = 2,
+};
+
+/*
+ * Extended event parameters.
+ */
+struct lttng_kernel_abi_event_ext {
+ uint32_t len; /* length of this structure */
+
+ uint8_t match_check; /* enum lttng_kernel_abi_match_check */
+} __attribute__((packed));
+
/*
* For syscall tracing, name = "*" means "enable all".
*/
-#define LTTNG_KERNEL_ABI_EVENT_PADDING1 8
#define LTTNG_KERNEL_ABI_EVENT_PADDING2 LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32
struct lttng_kernel_abi_event {
char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN]; /* event name */
uint32_t instrumentation; /* enum lttng_kernel_abi_instrumentation */
uint64_t token; /* User-provided token */
- char padding[LTTNG_KERNEL_ABI_EVENT_PADDING1];
+ uint64_t event_ext; /* struct lttng_kernel_abi_event_ext */
/* Per instrumentation type configuration */
union {
char padding[LTTNG_KERNEL_ABI_EVENT_NOTIFIER_PADDING];
} __attribute__((packed));
-#define LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX 4
+#define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
+struct lttng_kernel_abi_event_notifier_notification {
+ uint64_t token;
+ uint16_t capture_buf_size;
+ char padding[LTTNG_KERNEL_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING];
+} __attribute__((packed));
+
+enum lttng_kernel_abi_key_token_type {
+ LTTNG_KERNEL_ABI_KEY_TOKEN_STRING = 0, /* arg: string_ptr. */
+ LTTNG_KERNEL_ABI_KEY_TOKEN_EVENT_NAME = 1, /* no arg. */
+ LTTNG_KERNEL_ABI_KEY_TOKEN_PROVIDER_NAME = 2, /* no arg. */
+};
enum lttng_kernel_abi_counter_arithmetic {
LTTNG_KERNEL_ABI_COUNTER_ARITHMETIC_MODULAR = 0,
LTTNG_KERNEL_ABI_COUNTER_BITNESS_64 = 1,
};
+struct lttng_kernel_abi_key_token {
+ uint32_t len; /* length of child structure. */
+ uint32_t type; /* enum lttng_kernel_abi_key_token_type */
+ /*
+ * The size of this structure is fixed because it is embedded into
+ * children structures.
+ */
+} __attribute__((packed));
+
+/* Length of this structure excludes the following string. */
+struct lttng_kernel_abi_key_token_string {
+ struct lttng_kernel_abi_key_token parent;
+ uint32_t string_len; /* string length (includes \0) */
+
+ /* Null-terminated string of length @string_len follows this structure. */
+} __attribute__((packed));
+
+/*
+ * token types event_name and provider_name don't have specific fields,
+ * so they do not need to derive their own specific child structure.
+ */
+
+struct lttng_kernel_abi_counter_map_descriptor {
+ uint32_t len; /* length of this structure. */
+
+ uint64_t descriptor_index; /* Descriptor index (input: [ 0 .. nr_descriptors - 1 ]) */
+
+ uint32_t dimension; /* Dimension indexed (output) */
+ uint64_t user_token; /* User-provided 64-bit token (output) */
+ uint64_t key_string; /*
+ * Pointer (input) to key string associated with this index
+ * (output). If key_string_len is smaller than the required
+ * space, the ioctl fails with -ENOSPC, storing the required
+ * string space into @key_string_len.
+ */
+ uint32_t key_string_len; /* Key string length (input/output, includes \0) */
+ uint64_t array_indexes; /*
+ * Pointer (input) to array of indexes within each dimension
+ * (output). There are @dimension values populated. Each
+ * element is of type uint64_t. If arrays_indexes_len is
+ * smaller than @dimension, the ioctl fails with -ENOSPC,
+ * storing the required array index length into
+ * @array_index_len.
+ */
+ uint32_t array_indexes_len; /* Array indexes length (input/output). */
+} __attribute__((packed));
+
+/*
+ * Dimension indexing: All events should use the same key type to index
+ * a given map dimension.
+ */
+enum lttng_kernel_abi_key_type {
+ LTTNG_KERNEL_ABI_KEY_TYPE_TOKENS = 0, /* Dimension key is a set of tokens. */
+ LTTNG_KERNEL_ABI_KEY_TYPE_INTEGER = 1, /* Dimension key is an integer value. */
+};
+
+struct lttng_kernel_abi_counter_key_dimension {
+ uint32_t len; /* length of child structure */
+ uint32_t key_type; /* enum lttng_kernel_abi_key_type */
+ /*
+ * The size of this structure is fixed because it is embedded
+ * into children structures.
+ */
+} __attribute__((packed));
+
+struct lttng_kernel_abi_counter_key_dimension_tokens {
+ struct lttng_kernel_abi_counter_key_dimension parent;
+ uint32_t nr_key_tokens;
+
+ /* Followed by an array of nr_key_tokens struct lttng_kernel_abi_key_token elements. */
+} __attribute__((packed));
+
+/*
+ * The "integer" key type is not implemented yet, but when it will be
+ * introduced in the future, its specific key dimension will allow
+ * defining the function to apply over input argument, bytecode to run
+ * and so on.
+ */
+
+enum lttng_kernel_abi_counter_action {
+ LTTNG_KERNEL_ABI_COUNTER_ACTION_INCREMENT = 0,
+
+ /*
+ * Can be extended with additional actions, such as decrement,
+ * set value, run bytecode, and so on.
+ */
+};
+
+struct lttng_kernel_abi_counter_event {
+ uint32_t len; /* length of this structure */
+ uint32_t action; /* enum lttng_kernel_abi_counter_action */
+
+ struct lttng_kernel_abi_event event;
+ uint32_t number_key_dimensions; /* array of dimensions is an array of var. len. elements. */
+
+ /*
+ * Followed by additional data specific to the action, and by a
+ * variable-length array of key dimensions.
+ */
+} __attribute__((packed));
+
+enum lttng_kernel_abi_counter_dimension_flags {
+ LTTNG_KERNEL_ABI_COUNTER_DIMENSION_FLAG_UNDERFLOW = (1 << 0),
+ LTTNG_KERNEL_ABI_COUNTER_DIMENSION_FLAG_OVERFLOW = (1 << 1),
+};
+
struct lttng_kernel_abi_counter_dimension {
- uint64_t size;
+ uint32_t key_type; /* enum lttng_kernel_abi_key_type */
+ uint32_t flags; /* enum lttng_kernel_abi_counter_dimension_flags */
+ uint64_t size; /* dimension size */
uint64_t underflow_index;
uint64_t overflow_index;
- uint8_t has_underflow;
- uint8_t has_overflow;
} __attribute__((packed));
-#define LTTNG_KERNEL_ABI_COUNTER_CONF_PADDING1 67
-struct lttng_kernel_abi_counter_conf {
- uint32_t arithmetic; /* enum lttng_kernel_abi_counter_arithmetic */
- uint32_t bitness; /* enum lttng_kernel_abi_counter_bitness */
+struct lttng_kernel_abi_counter_dimension_array {
uint32_t number_dimensions;
+ uint32_t elem_len; /* array stride (size of struct lttng_kernel_abi_counter_dimension) */
+ uint64_t ptr; /* pointer to array of struct lttng_kernel_abi_counter_dimension */
+} __attribute__((packed));
+
+enum lttng_kernel_abi_counter_conf_flags {
+ LTTNG_KERNEL_ABI_COUNTER_CONF_FLAG_COALESCE_HITS = (1 << 0),
+};
+
+struct lttng_kernel_abi_counter_conf {
+ uint32_t len; /* length of this structure */
+ uint32_t flags; /* enum lttng_kernel_abi_counter_conf_flags */
+ uint32_t arithmetic; /* enum lttng_kernel_abi_counter_arithmetic */
+ uint32_t bitness; /* enum lttng_kernel_abi_counter_bitness */
int64_t global_sum_step;
- struct lttng_kernel_abi_counter_dimension dimensions[LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX];
- uint8_t coalesce_hits;
- char padding[LTTNG_KERNEL_ABI_COUNTER_CONF_PADDING1];
+ struct lttng_kernel_abi_counter_dimension_array dimension_array;
} __attribute__((packed));
struct lttng_kernel_abi_counter_index {
uint32_t number_dimensions;
- uint64_t dimension_indexes[LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX];
+ uint64_t ptr; /* pointer to dimension indexes (array of uint64_t) */
} __attribute__((packed));
+enum lttng_kernel_abi_counter_value_flags {
+ LTTNG_KERNEL_ABI_COUNTER_VALUE_FLAG_UNDERFLOW = (1 << 0),
+ LTTNG_KERNEL_ABI_COUNTER_VALUE_FLAG_OVERFLOW = (1 << 1),
+};
+
struct lttng_kernel_abi_counter_value {
int64_t value;
- uint8_t underflow;
- uint8_t overflow;
+ uint32_t flags; /* enum lttng_kernel_abi_counter_value_flags */
} __attribute__((packed));
-#define LTTNG_KERNEL_ABI_COUNTER_READ_PADDING 32
struct lttng_kernel_abi_counter_read {
+ uint32_t len; /* length of this structure */
struct lttng_kernel_abi_counter_index index;
int32_t cpu; /* -1 for global counter, >= 0 for specific cpu. */
struct lttng_kernel_abi_counter_value value; /* output */
- char padding[LTTNG_KERNEL_ABI_COUNTER_READ_PADDING];
} __attribute__((packed));
-#define LTTNG_KERNEL_ABI_COUNTER_AGGREGATE_PADDING 32
struct lttng_kernel_abi_counter_aggregate {
+ uint32_t len; /* length of this structure */
struct lttng_kernel_abi_counter_index index;
struct lttng_kernel_abi_counter_value value; /* output */
- char padding[LTTNG_KERNEL_ABI_COUNTER_AGGREGATE_PADDING];
} __attribute__((packed));
-#define LTTNG_KERNEL_ABI_COUNTER_CLEAR_PADDING 32
struct lttng_kernel_abi_counter_clear {
+ uint32_t len; /* length of this structure */
struct lttng_kernel_abi_counter_index index;
- char padding[LTTNG_KERNEL_ABI_COUNTER_CLEAR_PADDING];
-} __attribute__((packed));
-
-#define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
-struct lttng_kernel_abi_event_notifier_notification {
- uint64_t token;
- uint16_t capture_buf_size;
- char padding[LTTNG_KERNEL_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING];
} __attribute__((packed));
struct lttng_kernel_abi_tracer_version {
#define LTTNG_KERNEL_ABI_STREAM _IO(0xF6, 0x62)
#define LTTNG_KERNEL_ABI_EVENT \
_IOW(0xF6, 0x63, struct lttng_kernel_abi_event)
+/* LTTNG_KERNEL_ABI_SYSCALL_MASK applies to both channel and counter fds. */
#define LTTNG_KERNEL_ABI_SYSCALL_MASK \
_IOWR(0xF6, 0x64, struct lttng_kernel_abi_syscall_mask)
#define LTTNG_KERNEL_ABI_ENABLE _IO(0xF6, 0x82)
#define LTTNG_KERNEL_ABI_DISABLE _IO(0xF6, 0x83)
-/* Trigger group and session ioctl */
+/* Event notifier group and session ioctl */
+
+/* (0xF6, 0x84) is reserved for old ABI. */
+
#define LTTNG_KERNEL_ABI_COUNTER \
- _IOW(0xF6, 0x84, struct lttng_kernel_abi_counter_conf)
+ _IOW(0xF6, 0x85, struct lttng_kernel_abi_counter_conf)
/* Event and Event notifier FD ioctl */
#define LTTNG_KERNEL_ABI_FILTER _IO(0xF6, 0x90)
/* Event notifier file descriptor ioctl */
#define LTTNG_KERNEL_ABI_CAPTURE _IO(0xF6, 0xB8)
+/* (0xF6, {0xC0, 0xC1, 0xC2}) are reserved for old ABI. */
+
/* Counter file descriptor ioctl */
+#define LTTNG_KERNEL_ABI_COUNTER_MAP_NR_DESCRIPTORS \
+ _IOR(0xF6, 0xC3, uint64_t)
+#define LTTNG_KERNEL_ABI_COUNTER_MAP_DESCRIPTOR \
+ _IOWR(0xF6, 0xC4, struct lttng_kernel_abi_counter_map_descriptor)
+#define LTTNG_KERNEL_ABI_COUNTER_EVENT \
+ _IOW(0xF6, 0xC5, struct lttng_kernel_abi_counter_event)
#define LTTNG_KERNEL_ABI_COUNTER_READ \
- _IOWR(0xF6, 0xC0, struct lttng_kernel_abi_counter_read)
+ _IOWR(0xF6, 0xC6, struct lttng_kernel_abi_counter_read)
#define LTTNG_KERNEL_ABI_COUNTER_AGGREGATE \
- _IOWR(0xF6, 0xC1, struct lttng_kernel_abi_counter_aggregate)
+ _IOWR(0xF6, 0xC7, struct lttng_kernel_abi_counter_aggregate)
#define LTTNG_KERNEL_ABI_COUNTER_CLEAR \
- _IOW(0xF6, 0xC2, struct lttng_kernel_abi_counter_clear)
-
+ _IOW(0xF6, 0xC8, struct lttng_kernel_abi_counter_clear)
/*
* LTTng-specific ioctls for the lib ringbuffer.
struct perf_event;
struct perf_event_attr;
struct lttng_kernel_ring_buffer_config;
+struct lttng_kernel_counter_dimension;
enum lttng_enabler_format_type {
LTTNG_ENABLER_FORMAT_STAR_GLOB,
LTTNG_ENABLER_FORMAT_NAME,
};
+enum lttng_kernel_event_enabler_type {
+ LTTNG_EVENT_ENABLER_TYPE_RECORDER,
+ LTTNG_EVENT_ENABLER_TYPE_NOTIFIER,
+ LTTNG_EVENT_ENABLER_TYPE_COUNTER,
+};
+
enum channel_type {
PER_CPU_CHANNEL,
METADATA_CHANNEL,
struct lttng_kprobe {
struct kprobe kp;
char *symbol_name;
+ uint64_t addr;
+ uint64_t offset;
+ kprobe_pre_handler_t pre_handler;
};
struct lttng_uprobe {
LTTNG_SYSCALL_ABI_COMPAT,
};
+enum lttng_kretprobe_entryexit {
+ LTTNG_KRETPROBE_ENTRY,
+ LTTNG_KRETPROBE_EXIT,
+
+ NR_LTTNG_KRETPROBE_ENTRYEXIT,
+};
+
struct lttng_kernel_event_common_private {
struct lttng_kernel_event_common *pub; /* Public event interface */
/* list of struct lttng_kernel_bytecode_runtime, sorted by seqnum */
struct list_head filter_bytecode_runtime_head;
- struct hlist_node hlist_node; /* node in events hash table */
+ struct hlist_node hlist_name_node; /* node in events name hash table */
struct list_head node; /* node in event list */
enum lttng_kernel_abi_instrumentation instrumentation;
struct lttng_kprobe kprobe;
struct lttng_uprobe uprobe;
struct {
+ enum lttng_kretprobe_entryexit entryexit;
struct lttng_krp *lttng_krp;
char *symbol_name;
} kretprobe;
} u;
};
-struct lttng_kernel_event_recorder_private {
+struct lttng_kernel_event_session_common_private {
struct lttng_kernel_event_common_private parent;
+ struct lttng_kernel_channel_common *chan;
+ uint64_t id; /* Event id */
+};
+
+struct lttng_kernel_event_recorder_private {
+ struct lttng_kernel_event_session_common_private parent;
+
struct lttng_kernel_event_recorder *pub; /* Public event interface */
- struct lttng_kernel_ctx *ctx;
- unsigned int id;
unsigned int metadata_dumped:1;
};
+#define LTTNG_KERNEL_COUNTER_KEY_LEN 256
+
+enum lttng_event_counter_action {
+ LTTNG_EVENT_COUNTER_ACTION_INCREMENT = 0,
+};
+
+struct lttng_kernel_event_counter_private {
+ struct lttng_kernel_event_session_common_private parent;
+
+ struct lttng_kernel_event_counter *pub; /* Public event interface */
+ struct hlist_node hlist_key_node; /* node in events key hash table */
+ enum lttng_event_counter_action action;
+ char key[LTTNG_KERNEL_COUNTER_KEY_LEN];
+};
+
struct lttng_kernel_event_notifier_private {
struct lttng_kernel_event_common_private parent;
struct file *file; /* File associated to channel */
unsigned int tstate:1; /* Transient enable state */
+ bool coalesce_hits;
+
+ struct list_head node; /* Channel list in session */
struct lttng_kernel_syscall_table syscall_table;
};
struct lttng_kernel_ctx *ctx;
struct lttng_kernel_ring_buffer_channel *rb_chan; /* Ring buffer channel */
unsigned int metadata_dumped:1;
- struct list_head node; /* Channel list in session */
struct lttng_transport *transport;
};
+struct lttng_kernel_channel_counter_ops_private {
+ struct lttng_kernel_channel_counter_ops *pub; /* Public channel counter ops interface */
+
+ struct lttng_kernel_channel_counter *(*counter_create)(size_t nr_dimensions,
+ const struct lttng_kernel_counter_dimension *dimensions,
+ int64_t global_sum_step);
+ void (*counter_destroy)(struct lttng_kernel_channel_counter *counter);
+ int (*counter_add)(struct lttng_kernel_channel_counter *counter,
+ const size_t *dimension_indexes, int64_t v);
+ /*
+ * counter_read reads a specific cpu's counter if @cpu >= 0, or
+ * the global aggregation counter if @cpu == -1.
+ */
+ int (*counter_read)(struct lttng_kernel_channel_counter *counter,
+ const size_t *dimension_indexes, int cpu,
+ int64_t *value, bool *overflow, bool *underflow);
+ /*
+ * counter_aggregate returns the total sum of all per-cpu counters and
+ * the global aggregation counter.
+ */
+ int (*counter_aggregate)(struct lttng_kernel_channel_counter *counter,
+ const size_t *dimension_indexes, int64_t *value,
+ bool *overflow, bool *underflow);
+ int (*counter_clear)(struct lttng_kernel_channel_counter *counter,
+ const size_t *dimension_indexes);
+ int (*counter_get_nr_dimensions)(struct lttng_kernel_channel_counter *counter,
+ size_t *nr_dimensions);
+ int (*counter_get_max_nr_elem)(struct lttng_kernel_channel_counter *counter,
+ size_t *max_nr_elem); /* array of size nr_dimensions */
+};
+
+struct lttng_counter_map_descriptor {
+ uint64_t user_token;
+ size_t array_index;
+ char key[LTTNG_KERNEL_COUNTER_KEY_LEN];
+};
+
+struct lttng_counter_map {
+ struct lttng_counter_map_descriptor *descriptors;
+ size_t nr_descriptors;
+ size_t alloc_len;
+ struct mutex lock; /* counter map lock */
+};
+
+struct lttng_kernel_channel_counter_private {
+ struct lttng_kernel_channel_common_private parent;
+
+ struct lttng_kernel_channel_counter *pub; /* Public channel counter interface */
+ struct lib_counter *counter;
+ struct lttng_kernel_channel_counter_ops *ops;
+
+ struct lttng_counter_map map;
+
+ /* Owned either by session or event notifier group. */
+
+ /* Session or event notifier group file owner. */
+ struct file *owner;
+
+ /* Event notifier group owner. */
+ struct lttng_event_notifier_group *event_notifier_group;
+
+ /* Session owner. */
+ size_t free_index; /* Next index to allocate */
+ struct lttng_counter_transport *transport;
+};
+
enum lttng_kernel_bytecode_interpreter_ret {
LTTNG_KERNEL_BYTECODE_INTERPRETER_ERROR = -1,
LTTNG_KERNEL_BYTECODE_INTERPRETER_OK = 0,
LTTNG_KERNEL_BYTECODE_TYPE_CAPTURE,
};
-enum lttng_kernel_event_enabler_type {
- LTTNG_EVENT_ENABLER_TYPE_RECORDER,
- LTTNG_EVENT_ENABLER_TYPE_NOTIFIER,
-};
-
struct lttng_kernel_bytecode_node {
enum lttng_kernel_bytecode_type type;
struct list_head node;
bool published; /* published in list. */
};
-struct lttng_event_recorder_enabler {
+struct lttng_event_enabler_session_common {
struct lttng_event_enabler_common parent;
+ struct lttng_kernel_channel_common *chan;
+};
+
+struct lttng_event_recorder_enabler {
+ struct lttng_event_enabler_session_common parent;
struct lttng_kernel_channel_buffer *chan;
};
+struct lttng_event_counter_enabler {
+ struct lttng_event_enabler_session_common parent;
+ struct lttng_kernel_channel_counter *chan;
+ struct lttng_kernel_counter_key *key;
+
+ enum lttng_event_counter_action action;
+};
+
struct lttng_event_notifier_enabler {
struct lttng_event_enabler_common parent;
uint64_t error_counter_index;
unsigned int metadata_out; /* Bytes consumed from stream */
int finalized; /* Has channel been finalized */
wait_queue_head_t read_wait; /* Reader buffer-level wait queue */
- struct list_head list; /* Stream list */
+ struct list_head node; /* Stream list */
struct lttng_transport *transport;
uint64_t version; /* Current version of the metadata cache */
bool coherent; /* Stream in a coherent state */
};
+struct lttng_kernel_event_pair {
+ /* Input */
+ char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
+ struct lttng_krp *krp;
+ bool check_ids;
+ enum lttng_kretprobe_entryexit entryexit;
+};
+
struct lttng_kernel_channel_buffer_ops_private {
struct lttng_kernel_channel_buffer_ops *pub; /* Public channel buffer ops interface */
uint64_t *id);
};
-struct lttng_counter_ops {
- struct lib_counter *(*counter_create)(size_t nr_dimensions,
- const size_t *max_nr_elem, /* for each dimension */
- int64_t global_sum_step);
- void (*counter_destroy)(struct lib_counter *counter);
- int (*counter_add)(struct lib_counter *counter, const size_t *dimension_indexes,
- int64_t v);
- /*
- * counter_read reads a specific cpu's counter if @cpu >= 0, or
- * the global aggregation counter if @cpu == -1.
- */
- int (*counter_read)(struct lib_counter *counter, const size_t *dimension_indexes, int cpu,
- int64_t *value, bool *overflow, bool *underflow);
- /*
- * counter_aggregate returns the total sum of all per-cpu counters and
- * the global aggregation counter.
- */
- int (*counter_aggregate)(struct lib_counter *counter, const size_t *dimension_indexes,
- int64_t *value, bool *overflow, bool *underflow);
- int (*counter_clear)(struct lib_counter *counter, const size_t *dimension_indexes);
-};
-
-struct lttng_counter {
- struct file *file; /* File associated to counter. */
- struct file *owner;
- struct lttng_counter_transport *transport;
- struct lib_counter *counter;
- struct lttng_counter_ops *ops;
-};
-
#define LTTNG_EVENT_HT_BITS 12
#define LTTNG_EVENT_HT_SIZE (1U << LTTNG_EVENT_HT_BITS)
struct list_head node; /* event notifier group list */
struct list_head enablers_head; /* List of enablers */
struct list_head event_notifiers_head; /* List of event notifier */
- struct lttng_event_ht events_ht; /* Hash table of event notifiers */
+ struct lttng_event_ht events_name_ht; /* Hash table of event notifiers, indexed by name */
struct lttng_kernel_channel_buffer_ops *ops;
struct lttng_transport *transport;
struct lttng_kernel_ring_buffer_channel *chan; /* Ring buffer channel for event notifier group. */
struct lttng_kernel_syscall_table syscall_table;
- struct lttng_counter *error_counter;
+ struct lttng_kernel_channel_counter *error_counter;
size_t error_counter_len;
};
char *name;
struct module *owner;
struct list_head node;
- struct lttng_counter_ops ops;
+ struct lttng_kernel_channel_counter_ops ops;
};
struct lttng_kernel_session_private {
int been_active; /* Has trace session been active ? */
struct file *file; /* File associated to session */
- struct list_head chan; /* Channel list head */
- struct list_head events; /* Event list head */
- struct list_head list; /* Session list */
+ struct list_head chan_head; /* Channel list head */
+ struct list_head events_head; /* Event list head */
+ struct list_head enablers_head; /* List of event enablers */
+
+ struct lttng_event_ht events_name_ht; /* Hash table of events, indexed by name */
+ struct lttng_event_ht events_key_ht; /* Hash table of events, indexed by key */
+
+ struct list_head node; /* Session list */
unsigned int free_chan_id; /* Next chan ID to allocate */
guid_t uuid; /* Trace session unique ID */
struct lttng_metadata_cache *metadata_cache;
unsigned int metadata_dumped:1,
tstate:1; /* Transient enable state */
- /* List of event enablers */
- struct list_head enablers_head;
- /* Hash table of events */
- struct lttng_event_ht events_ht;
+
char name[LTTNG_KERNEL_ABI_SESSION_NAME_LEN];
char creation_time[LTTNG_KERNEL_ABI_SESSION_CREATION_TIME_ISO8601_LEN];
};
enum tracker_type tracker_type;
};
+enum lttng_kernel_counter_dimension_flags {
+ LTTNG_KERNEL_COUNTER_DIMENSION_FLAG_UNDERFLOW = (1 << 0),
+ LTTNG_KERNEL_COUNTER_DIMENSION_FLAG_OVERFLOW = (1 << 1),
+};
+
+enum lttng_kernel_counter_conf_flags {
+ LTTNG_KERNEL_COUNTER_CONF_FLAG_COALESCE_HITS = (1 << 0),
+};
+
+enum lttng_kernel_counter_arithmetic {
+ LTTNG_KERNEL_COUNTER_ARITHMETIC_MODULAR = 0,
+};
+
+enum lttng_kernel_counter_bitness {
+ LTTNG_KERNEL_COUNTER_BITNESS_32 = 0,
+ LTTNG_KERNEL_COUNTER_BITNESS_64 = 1,
+};
+
+/* Internally, only 1 dimension is supported fow now. */
+#define LTTNG_KERNEL_COUNTER_MAX_DIMENSIONS 1
+/* Internally, only 16 tokens are supported for now. */
+#define LTTNG_KERNEL_COUNTER_MAX_TOKENS 16
+
+struct lttng_kernel_counter_dimension {
+ uint32_t flags; /* enum lttng_kernel_counter_dimension_flags */
+ uint64_t size; /* dimension size */
+ uint64_t underflow_index;
+ uint64_t overflow_index;
+};
+
+struct lttng_kernel_counter_conf {
+ uint32_t flags; /* enum lttng_kernel_counter_conf_flags */
+ uint32_t arithmetic; /* enum lttng_kernel_counter_arithmetic */
+ uint32_t bitness; /* enum lttng_kernel_counter_bitness */
+ int64_t global_sum_step;
+ struct lttng_kernel_counter_dimension dimension_array[LTTNG_KERNEL_COUNTER_MAX_DIMENSIONS];
+};
+
+enum lttng_key_token_type {
+ LTTNG_KEY_TOKEN_UNKNOWN = 0, /* Uninitialized. */
+
+ LTTNG_KEY_TOKEN_STRING = 1,
+ LTTNG_KEY_TOKEN_EVENT_NAME = 2,
+};
+
+struct lttng_key_token {
+ enum lttng_key_token_type type;
+ char *str;
+};
+
+struct lttng_kernel_counter_key_dimension {
+ size_t nr_key_tokens;
+ struct lttng_key_token *token_array;
+};
+
+struct lttng_kernel_counter_key {
+ size_t nr_dimensions;
+ struct lttng_kernel_counter_key_dimension dimension_array[LTTNG_KERNEL_COUNTER_MAX_DIMENSIONS];
+};
+
+struct lttng_kernel_counter_event {
+ struct lttng_kernel_abi_event event_param;
+ struct lttng_kernel_abi_event_ext event_param_ext;
+
+ struct lttng_kernel_counter_key *counter_key;
+};
+
extern struct lttng_kernel_ctx *lttng_static_ctx;
static inline
struct lttng_kernel_probe_ctx *probe_ctx,
void *event_filter_ctx);
-static inline
-struct lttng_event_enabler_common *lttng_event_recorder_enabler_as_enabler(
- struct lttng_event_recorder_enabler *event_recorder_enabler)
-{
- return &event_recorder_enabler->parent;
-}
-
static inline
struct lttng_event_enabler_common *lttng_event_notifier_enabler_as_enabler(
struct lttng_event_notifier_enabler *event_notifier_enabler)
}
static inline
-struct lttng_event_ht *lttng_get_event_ht_from_enabler(struct lttng_event_enabler_common *event_enabler)
+struct lttng_event_ht *lttng_get_events_name_ht_from_enabler(struct lttng_event_enabler_common *event_enabler)
{
switch (event_enabler->enabler_type) {
case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
+ lttng_fallthrough;
+ case LTTNG_EVENT_ENABLER_TYPE_COUNTER:
{
- struct lttng_event_recorder_enabler *event_recorder_enabler =
- container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
- return &event_recorder_enabler->chan->parent.session->priv->events_ht;
+ struct lttng_event_enabler_session_common *event_enabler_session =
+ container_of(event_enabler, struct lttng_event_enabler_session_common, parent);
+ return &event_enabler_session->chan->session->priv->events_name_ht;
}
case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
{
struct lttng_event_notifier_enabler *event_notifier_enabler =
container_of(event_enabler, struct lttng_event_notifier_enabler, parent);
- return &event_notifier_enabler->group->events_ht;
+ return &event_notifier_enabler->group->events_name_ht;
}
default:
return NULL;
}
}
+static inline
+struct lttng_event_ht *lttng_get_events_key_ht_from_enabler(struct lttng_event_enabler_common *event_enabler)
+{
+ switch (event_enabler->enabler_type) {
+ case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
+ lttng_fallthrough;
+ case LTTNG_EVENT_ENABLER_TYPE_COUNTER:
+ {
+ struct lttng_event_enabler_session_common *event_enabler_session =
+ container_of(event_enabler, struct lttng_event_enabler_session_common, parent);
+ return &event_enabler_session->chan->session->priv->events_key_ht;
+ }
+ case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
+ lttng_fallthrough;
+ default:
+ return NULL;
+ }
+}
+
static inline
struct list_head *lttng_get_event_list_head_from_enabler(struct lttng_event_enabler_common *event_enabler)
{
switch (event_enabler->enabler_type) {
case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
+ lttng_fallthrough;
+ case LTTNG_EVENT_ENABLER_TYPE_COUNTER:
{
- struct lttng_event_recorder_enabler *event_recorder_enabler =
- container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
- return &event_recorder_enabler->chan->parent.session->priv->events;
+ struct lttng_event_enabler_session_common *event_enabler_session =
+ container_of(event_enabler, struct lttng_event_enabler_session_common, parent);
+ return &event_enabler_session->chan->session->priv->events_head;
}
case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
{
struct lttng_kernel_abi_event *event_param,
struct lttng_kernel_channel_buffer *chan);
void lttng_event_enabler_session_add(struct lttng_kernel_session *session,
- struct lttng_event_recorder_enabler *event_enabler);
+ struct lttng_event_enabler_session_common *event_enabler);
struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create(
enum lttng_enabler_format_type format_type,
struct lttng_event_enabler_common *enabler);
bool lttng_event_enabler_match_event(struct lttng_event_enabler_common *event_enabler,
struct lttng_kernel_event_common *event);
-bool lttng_event_enabler_desc_match_event(struct lttng_event_enabler_common *event_enabler,
- const struct lttng_kernel_event_desc *desc,
- struct lttng_kernel_event_common *event);
-bool lttng_event_enabler_event_name_match_event(struct lttng_event_enabler_common *event_enabler,
- const char *event_name,
- struct lttng_kernel_event_common *event);
void lttng_enabler_link_bytecode(const struct lttng_kernel_event_desc *event_desc,
struct lttng_kernel_ctx *ctx,
#endif
#ifdef CONFIG_KPROBES
-int lttng_kprobes_register_event(const char *name,
+int lttng_kprobes_init_event(const char *name,
const char *symbol_name,
uint64_t offset,
uint64_t addr,
struct lttng_kernel_event_common *event);
+int lttng_kprobes_register_event(struct lttng_kernel_event_common *event);
void lttng_kprobes_unregister_event(struct lttng_kernel_event_common *event);
void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_common *event);
+int lttng_kprobes_match_check(const char *symbol_name, uint64_t offset, uint64_t addr);
+
#else
static inline
-int lttng_kprobes_register_event(const char *name,
+int lttng_kprobes_init_event(const char *name,
const char *symbol_name,
uint64_t offset,
uint64_t addr,
{
return -ENOSYS;
}
+static inline
+int lttng_kprobes_register_event(struct lttng_kernel_event_common *event)
+{
+ return -ENOSYS;
+}
static inline
void lttng_kprobes_unregister_event(struct lttng_kernel_event_common *event)
void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_common *event)
{
}
+static inline
+int lttng_kprobes_match_check(const char *symbol_name, uint64_t offset, uint64_t addr)
+{
+ return -ENOENT;
+}
#endif
int lttng_event_add_callsite(struct lttng_kernel_event_common *event,
#endif
#ifdef CONFIG_KRETPROBES
-int lttng_kretprobes_register(const char *name,
- const char *symbol_name,
- uint64_t offset,
- uint64_t addr,
- struct lttng_kernel_event_common *event_entry,
- struct lttng_kernel_event_common *event_exit);
-void lttng_kretprobes_unregister(struct lttng_kernel_event_common *event);
-void lttng_kretprobes_destroy_private(struct lttng_kernel_event_common *event);
-int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common *event,
- int enable);
+struct lttng_krp *lttng_kretprobes_create_krp(const char *symbol_name,
+ uint64_t offset, uint64_t addr);
+void lttng_kretprobes_put_krp(struct lttng_krp *krp);
+int lttng_kretprobes_init_event(const char *name,
+ enum lttng_kretprobe_entryexit entryexit,
+ struct lttng_kernel_event_common *event,
+ struct lttng_krp *krp);
+int lttng_kretprobes_register_event(struct lttng_kernel_event_common *event);
+void lttng_kretprobes_unregister_event(struct lttng_kernel_event_common *event);
+void lttng_kretprobes_destroy_event_private(struct lttng_kernel_event_common *event);
+int lttng_kretprobes_match_check(const char *symbol_name, uint64_t offset, uint64_t addr);
#else
static inline
-int lttng_kretprobes_register(const char *name,
- const char *symbol_name,
- uint64_t offset,
- uint64_t addr,
- struct lttng_kernel_event_common *event_entry,
- struct lttng_kernel_event_common *event_exit)
+struct lttng_krp *lttng_kretprobes_create_krp(const char *symbol_name,
+ uint64_t offset, uint64_t addr)
+{
+ return NULL;
+}
+
+static inline
+void lttng_kretprobes_put_krp(struct lttng_krp *krp)
+{
+}
+
+static inline
+int lttng_kretprobes_init_event(const char *name,
+ enum lttng_kretprobe_entryexit entryexit,
+ struct lttng_kernel_event_common *event,
+ struct lttng_krp *krp)
{
return -ENOSYS;
}
static inline
-void lttng_kretprobes_unregister(struct lttng_kernel_event_common *event)
+int lttng_kretprobes_register_event(struct lttng_kernel_event_common *event)
{
+ return -ENOSYS;
+}
+
+static inline
+void lttng_kretprobes_unregister_event(struct lttng_kernel_event_common *event)
+{
+}
+
+static inline
+void lttng_kretprobes_destroy_event_private(struct lttng_kernel_event_common *event)
+{
+}
+
+static inline
+int lttng_kretprobes_match_check(const char *symbol_name, uint64_t offset, uint64_t addr)
+{
+ return -ENOENT;
}
static inline
-void lttng_kretprobes_destroy_private(struct lttng_kernel_event_common *event)
+struct lttng_kernel_event_desc *lttng_create_kretprobes_event_desc(const char *name)
{
+ return NULL;
}
static inline
-int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common *event,
- int enable)
+int lttng_kretprobes_register(const char *symbol_name,
+ uint64_t offset,
+ uint64_t addr,
+ struct lttng_kernel_event_common *event_entry,
+ struct lttng_kernel_event_common *event_exit)
{
return -ENOSYS;
}
int lttng_session_statedump(struct lttng_kernel_session *session);
void metadata_cache_destroy(struct kref *kref);
-struct lttng_counter *lttng_kernel_counter_create(
- const char *counter_transport_name, size_t number_dimensions,
- const size_t *dimensions_sizes);
-int lttng_kernel_counter_read(struct lttng_counter *counter,
+struct lttng_kernel_channel_counter *lttng_kernel_counter_create(
+ const char *counter_transport_name,
+ size_t number_dimensions,
+ const struct lttng_kernel_counter_dimension *dimensions,
+ int64_t global_sum_step,
+ bool coalesce_hits);
+int lttng_kernel_counter_read(struct lttng_kernel_channel_counter *counter,
const size_t *dimension_indexes, int32_t cpu,
int64_t *val, bool *overflow, bool *underflow);
-int lttng_kernel_counter_aggregate(struct lttng_counter *counter,
+int lttng_kernel_counter_aggregate(struct lttng_kernel_channel_counter *counter,
const size_t *dimension_indexes, int64_t *val,
bool *overflow, bool *underflow);
-int lttng_kernel_counter_clear(struct lttng_counter *counter,
+int lttng_kernel_counter_clear(struct lttng_kernel_channel_counter *counter,
const size_t *dimension_indexes);
+int lttng_kernel_counter_get_nr_dimensions(struct lttng_kernel_channel_counter *counter,
+ size_t *nr_dimensions);
+int lttng_kernel_counter_get_max_nr_elem(struct lttng_kernel_channel_counter *counter,
+ size_t *max_nr_elem);
struct lttng_event_notifier_group *lttng_event_notifier_group_create(void);
-int lttng_event_notifier_group_create_error_counter(
- struct file *event_notifier_group_file,
- const struct lttng_kernel_abi_counter_conf *error_counter_conf);
void lttng_event_notifier_group_destroy(
struct lttng_event_notifier_group *event_notifier_group);
unsigned int switch_timer_interval,
unsigned int read_timer_interval);
-void lttng_metadata_channel_destroy(struct lttng_kernel_channel_buffer *chan);
+void lttng_metadata_channel_buffer_destroy(struct lttng_kernel_channel_buffer *chan);
struct lttng_kernel_event_common *_lttng_kernel_event_create(struct lttng_event_enabler_common *event_enabler,
- const struct lttng_kernel_event_desc *event_desc);
+ const struct lttng_kernel_event_desc *event_desc,
+ struct lttng_kernel_event_pair *event_pair);
struct lttng_kernel_event_common *lttng_kernel_event_create(struct lttng_event_enabler_common *event_enabler,
- const struct lttng_kernel_event_desc *event_desc);
+ const struct lttng_kernel_event_desc *event_desc,
+ struct lttng_kernel_event_pair *event_pair);
int lttng_channel_enable(struct lttng_kernel_channel_common *channel);
int lttng_channel_disable(struct lttng_kernel_channel_common *channel);
extern const struct file_operations lttng_tracepoint_list_fops;
extern const struct file_operations lttng_syscall_list_fops;
+struct lttng_kernel_channel_buffer *lttng_kernel_alloc_channel_buffer(void);
+struct lttng_kernel_channel_counter *lttng_kernel_alloc_channel_counter(void);
+void lttng_kernel_free_channel_common(struct lttng_kernel_channel_common *chan);
+
+int format_event_key(struct lttng_event_enabler_common *event_enabler, char *key_string,
+ const char *event_name);
+bool lttng_event_enabler_event_name_key_match_event(struct lttng_event_enabler_common *event_enabler,
+ const char *event_name, const char *key_string, struct lttng_kernel_event_common *event);
+struct lttng_event_counter_enabler *lttng_event_counter_enabler_create(
+ enum lttng_enabler_format_type format_type,
+ struct lttng_kernel_abi_event *event_param,
+ struct lttng_kernel_counter_key *counter_key,
+ struct lttng_kernel_channel_counter *chan);
+
+int create_counter_key_from_kernel(struct lttng_kernel_counter_key **counter_key,
+ const struct lttng_kernel_counter_key *key);
+void destroy_counter_key(struct lttng_kernel_counter_key *counter_key);
+
#define lttng_kernel_static_ctx_field(_event_field, _get_size, _record, _get_value, _destroy, _priv) \
__LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_ctx_field, { \
.event_field = (_event_field), \
#define lttng_is_signed_type(type) (((type) -1) < (type) 1)
struct lttng_kernel_channel_buffer;
+struct lttng_kernel_channel_counter;
struct lttng_kernel_session;
struct lttng_kernel_ring_buffer_ctx;
enum lttng_kernel_event_type {
LTTNG_KERNEL_EVENT_TYPE_RECORDER = 0,
LTTNG_KERNEL_EVENT_TYPE_NOTIFIER = 1,
+ LTTNG_KERNEL_EVENT_TYPE_COUNTER = 2
};
struct lttng_kernel_event_common {
struct lttng_kernel_channel_buffer *chan;
};
+struct lttng_kernel_event_counter_ctx {
+ int args_available;
+};
+
+struct lttng_kernel_event_counter_private;
+
+struct lttng_kernel_event_counter {
+ struct lttng_kernel_event_common parent;
+ struct lttng_kernel_event_counter_private *priv; /* Private event counter interface */
+
+ struct lttng_kernel_channel_counter *chan;
+
+ int use_args; /* Use input arguments. */
+};
+
struct lttng_kernel_notification_ctx {
int eval_capture; /* Capture evaluation available. */
};
enum lttng_kernel_channel_type {
LTTNG_KERNEL_CHANNEL_TYPE_BUFFER = 0,
+ LTTNG_KERNEL_CHANNEL_TYPE_COUNTER = 1,
};
struct lttng_kernel_channel_common_private;
struct lttng_kernel_channel_buffer_ops *ops;
};
+struct lttng_kernel_channel_counter;
+struct lttng_kernel_channel_counter_ops_private;
+
+struct lttng_kernel_channel_counter_ops {
+ struct lttng_kernel_channel_counter_ops_private *priv; /* Private channel counter ops interface */
+
+ int (*counter_hit)(struct lttng_kernel_event_counter *event_counter,
+ const char *stack_data,
+ struct lttng_kernel_probe_ctx *probe_ctx,
+ struct lttng_kernel_event_counter_ctx *event_counter_ctx);
+};
+
+struct lttng_kernel_channel_counter {
+ struct lttng_kernel_channel_common parent;
+ struct lttng_kernel_channel_counter_private *priv; /* Private channel counter interface */
+
+ struct lttng_kernel_channel_counter_ops *ops;
+};
+
#define LTTNG_DYNAMIC_LEN_STACK_SIZE 128
struct lttng_dynamic_len_stack {
bool lttng_id_tracker_lookup(struct lttng_kernel_id_tracker_rcu *p, int id);
+static inline
+struct lttng_kernel_channel_common *lttng_kernel_get_chan_common_from_event_common(
+ struct lttng_kernel_event_common *event)
+{
+ switch (event->type) {
+ case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
+ {
+ struct lttng_kernel_event_recorder *event_recorder =
+ container_of(event, struct lttng_kernel_event_recorder, parent);
+ struct lttng_kernel_channel_buffer *chan_buf = event_recorder->chan;
+
+ return &chan_buf->parent;
+ }
+ case LTTNG_KERNEL_EVENT_TYPE_COUNTER:
+ {
+ struct lttng_kernel_event_counter *event_counter =
+ container_of(event, struct lttng_kernel_event_counter, parent);
+ struct lttng_kernel_channel_counter *chan_counter = event_counter->chan;
+
+ return &chan_counter->parent;
+ }
+ default:
+ return NULL;
+ }
+}
+
#endif /* _LTTNG_EVENTS_H */
+/* SPDX-License-Identifier: LGPL-2.1-only
+ * SPDX-FileCopyrightText: 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
+ */
+
#ifndef _LTTNG_KERNEL_MSGPACK_H
#define _LTTNG_KERNEL_MSGPACK_H
-/*
- * msgpack.h
- *
- * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; only
- * version 2.1 of the License.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
#ifdef __KERNEL__
#include <linux/types.h>
#else /* __KERNEL__ */
{ \
struct probe_local_vars { _locvar }; \
struct lttng_kernel_event_common *__event = __data; \
+ struct lttng_kernel_channel_common *__chan_common; \
struct lttng_kernel_probe_ctx __lttng_probe_ctx = { \
.event = __event, \
.interruptible = !irqs_disabled(), \
&__tp_locvar; \
bool __interpreter_stack_prepared = false; \
\
- switch (__event->type) { \
- case LTTNG_KERNEL_EVENT_TYPE_RECORDER: \
- { \
- struct lttng_kernel_event_recorder *__event_recorder = \
- container_of(__event, struct lttng_kernel_event_recorder, parent); \
- struct lttng_kernel_channel_buffer *__chan = __event_recorder->chan; \
- struct lttng_kernel_session *__session = __chan->parent.session; \
+ if (unlikely(!READ_ONCE(__event->enabled))) \
+ return; \
+ __chan_common = lttng_kernel_get_chan_common_from_event_common(__event); \
+ if (__chan_common) { \
+ struct lttng_kernel_session *__session = __chan_common->session; \
struct lttng_kernel_id_tracker_rcu *__lf; \
\
if (!_TP_SESSION_CHECK(session, __session)) \
return; \
if (unlikely(!LTTNG_READ_ONCE(__session->active))) \
return; \
- if (unlikely(!LTTNG_READ_ONCE(__chan->parent.enabled))) \
+ if (unlikely(!LTTNG_READ_ONCE(__chan_common->enabled))) \
return; \
__lf = lttng_rcu_dereference(__session->pid_tracker.p); \
if (__lf && likely(!lttng_id_tracker_lookup(__lf, current->tgid))) \
if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
from_kgid_munged(current_user_ns(), current_gid())))) \
return; \
- break; \
- } \
- case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER: \
- break; \
- default: \
- WARN_ON_ONCE(1); \
} \
- if (unlikely(!READ_ONCE(__event->enabled))) \
- return; \
__orig_dynamic_len_offset = this_cpu_ptr(<tng_dynamic_len_stack)->offset; \
__dynamic_len_idx = __orig_dynamic_len_offset; \
_code_pre \
&__notif_ctx); \
break; \
} \
+ case LTTNG_KERNEL_EVENT_TYPE_COUNTER: \
+ { \
+ struct lttng_kernel_event_counter *__event_counter = \
+ container_of(__event, struct lttng_kernel_event_counter, parent); \
+ struct lttng_kernel_event_counter_ctx __event_counter_ctx; \
+ \
+ __event_counter_ctx.args_available = LTTNG_READ_ONCE(__event_counter->use_args); \
+ if (unlikely(!__interpreter_stack_prepared && __event_counter_ctx.args_available)) \
+ __event_prepare_interpreter_stack__##_name( \
+ __stackvar.__interpreter_stack_data, \
+ _locvar_args); \
+ \
+ (void) __event_counter->chan->ops->counter_hit(__event_counter, \
+ __stackvar.__interpreter_stack_data, \
+ &__lttng_probe_ctx, \
+ &__event_counter_ctx); \
+ break; \
+ } \
default: \
WARN_ON_ONCE(1); \
} \
-/* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1) */
+/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
#ifndef _LTTNG_UTILS_H
#define _LTTNG_UTILS_H
--- /dev/null
+// SPDX-FileCopyrightText: 2024 Michael Jeanson <mjeanson@efficios.com>
+// SPDX-License-Identifier: GPL-2.0-only
+
+#ifndef _LTTNG_WRAPPER_BITOPS_H
+#define _LTTNG_WRAPPER_BITOPS_H
+
+#include <linux/bitops.h>
+#include <lttng/kernel-version.h>
+
+#if LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(5,4,0)
+
+#include <asm/byteorder.h>
+
+/* Set bits in the first 'n' bytes when loaded from memory */
+# ifdef __LITTLE_ENDIAN
+# define lttng_aligned_byte_mask(n) ((1UL << 8*(n))-1)
+# else
+# define lttng_aligned_byte_mask(n) (~0xffUL << (BITS_PER_LONG - 8 - 8*(n)))
+# endif
+
+#endif
+
+#endif /* _LTTNG_WRAPPER_BITOPS_H */
return lookup_fdget_rcu(fd);
}
-#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,11,0))
+#elif ((LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,11,0)) || \
+ LTTNG_KERNEL_RANGE(5,10,220, 5,11,0))
static inline
struct file *lttng_lookup_fdget_rcu(unsigned int fd)
{
}
#endif
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,10,0))
+static inline
+bool lttng_close_on_exec(unsigned int fd, const struct files_struct *files)
+{
+ return close_on_exec(fd, files);
+}
+#else
+static inline
+bool lttng_close_on_exec(unsigned int fd, const struct files_struct *files)
+{
+ return close_on_exec(fd, files_fdtable(files));
+}
+#endif
+
#endif /* _LTTNG_WRAPPER_FDTABLE_H */
#include <lttng/kernel-version.h>
-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,3,0))
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,3,0) || \
+ LTTNG_RHEL_KERNEL_RANGE(5,14,0,452,0,0, 5,15,0,0,0,0))
static inline
void wrapper_vm_flags_set(struct vm_area_struct *vma,
vm_flags_t flags)
#define _LTTNG_WRAPPER_UACCESS_H
#include <linux/uaccess.h>
+#include <wrapper/bitops.h>
#include <lttng/kernel-version.h>
#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,0,0) || \
#endif /* LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,0,0) */
+#if LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,4,0)
+static __always_inline __must_check int
+lttng_copy_struct_from_user(void *dst, size_t ksize, const void __user *src,
+ size_t usize)
+{
+ return copy_struct_from_user(dst, ksize, src, usize);
+}
+#else /* LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,4,0) */
+/**
+ * lttng_check_zeroed_user: check if a userspace buffer only contains zero bytes
+ * @from: Source address, in userspace.
+ * @size: Size of buffer.
+ *
+ * This is effectively shorthand for "memchr_inv(from, 0, size) == NULL" for
+ * userspace addresses (and is more efficient because we don't care where the
+ * first non-zero byte is).
+ *
+ * Returns:
+ * * 0: There were non-zero bytes present in the buffer.
+ * * 1: The buffer was full of zero bytes.
+ * * -EFAULT: access to userspace failed.
+ */
+static inline
+int lttng_check_zeroed_user(const void __user *from, size_t size)
+{
+ unsigned long val;
+ uintptr_t align = (uintptr_t) from % sizeof(unsigned long);
+ int ret;
+
+ if (unlikely(size == 0))
+ return 1;
+
+ from -= align;
+ size += align;
+
+ if (!lttng_access_ok(VERIFY_READ, from, size))
+ return -EFAULT;
+
+ ret = get_user(val, (unsigned long __user *) from);
+ if (ret)
+ return ret;
+ if (align)
+ val &= ~lttng_aligned_byte_mask(align);
+
+ while (size > sizeof(unsigned long)) {
+ if (unlikely(val))
+ goto done;
+
+ from += sizeof(unsigned long);
+ size -= sizeof(unsigned long);
+
+ ret = get_user(val, (unsigned long __user *) from);
+ if (ret)
+ return ret;
+ }
+
+ if (size < sizeof(unsigned long))
+ val &= lttng_aligned_byte_mask(size);
+
+done:
+ return (val == 0);
+}
+
+static __always_inline __must_check int
+lttng_copy_struct_from_user(void *dst, size_t ksize, const void __user *src,
+ size_t usize)
+{
+ size_t size = min(ksize, usize);
+ size_t rest = max(ksize, usize) - size;
+
+ /* Deal with trailing bytes. */
+ if (usize < ksize) {
+ memset(dst + size, 0, rest);
+ } else if (usize > ksize) {
+ int ret = lttng_check_zeroed_user(src + size, rest);
+ if (ret <= 0)
+ return ret ?: -E2BIG;
+ }
+ /* Copy the interoperable parts of the struct. */
+ if (copy_from_user(dst, src, size))
+ return -EFAULT;
+ return 0;
+}
+#endif /* LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,4,0) */
+
#endif /* _LTTNG_WRAPPER_UACCESS_H */
#!/bin/sh
# SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2015-2024 EfficiOS Inc.
# First argument is the path to the kernel headers.
KPATH="$1"
#!/bin/sh
# SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2018 EfficiOS Inc.
# First argument is the path to the kernel headers.
KPATH="$1"
#!/bin/sh
# SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2016-2018 EfficiOS Inc.
# First argument is the path to the kernel headers.
KPATH="$1"
#!/bin/sh
# SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2016-2021 EfficiOS Inc.
# First argument is the path to the kernel headers.
KPATH=$1
#!/bin/bash
# SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2015-2021 EfficiOS Inc.
set -e
#!/bin/sh
# SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2018-2019 EfficiOS Inc.
# First argument is the path to the lttng modules sources.
TOP_LTTNG_MODULES_DIR="$1"
#!/bin/sh
# SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2018 EfficiOS Inc.
# First argument is the path to the lttng modules sources.
TOP_LTTNG_MODULES_DIR="$1"
#!/bin/sh
# SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2018-2020 EfficiOS Inc.
# First argument is the path to the lttng modules sources.
TOP_LTTNG_MODULES_DIR="$1"
TMPFILE="$(mktemp)"
-find "${TOP_LTTNG_MODULES_DIR}/extra_version/patches/" -maxdepth 1 ! -name 'README' -type f -printf '%f\n' | sort -r \
+find "${TOP_LTTNG_MODULES_DIR}/extra_version/patches/" -maxdepth 1 ! -name 'README.md' -type f -printf '%f\n' | sort -r \
| sed -E 's/[^a-zA-Z0-9 \.]/-/g ; s/(.*)/MODULE_INFO(extra_version_patch, "\1");/g' >"${TMPFILE}" 2>/dev/null
if test ! -d "${TOP_LTTNG_MODULES_DIR}/${INCLUDE_DIR}"; then
#!/bin/bash
+# SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2020 EfficiOS Inc.
set -eu
set -o pipefail
#!/bin/sh
# SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2016-2018 EfficiOS Inc.
# First argument is the path to the kernel headers.
KPATH="$1"
# SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2010-2024 EfficiOS Inc.
ifdef CONFIG_LOCALVERSION # Check if dot-config is included.
ifeq ($(CONFIG_TRACEPOINTS),)
lttng-tracer-objs += lttng-context-time-ns.o
endif
+ifneq ($(CONFIG_KPROBES),)
+ lttng-tracer-objs += lttng-kprobes.o
+endif
+
+ifneq ($(CONFIG_UPROBES),)
+ lttng-tracer-objs += lttng-uprobes.o
+endif
+
+ifneq ($(CONFIG_KRETPROBES),)
+ lttng-tracer-objs += lttng-kretprobes.o
+endif
+
obj-$(CONFIG_LTTNG) += lttng-statedump.o
lttng-statedump-objs := lttng-statedump-impl.o
# SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2015-2024 EfficiOS Inc.
ccflags-y += -DLTTNG_LINUX_MAJOR=$(VERSION)
ccflags-y += -DLTTNG_LINUX_MINOR=$(PATCHLEVEL)
# SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2015-2024 EfficiOS Inc.
config LTTNG
tristate "LTTng support"
# SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2011-2024 EfficiOS Inc.
TOP_LTTNG_MODULES_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST)))/../..
-/*
- * msgpack.c
- *
- * Copyright (C) 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; only
- * version 2.1 of the License.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+/* SPDX-License-Identifier: LGPL-2.1-only
+ * SPDX-FileCopyrightText: 2020 Francis Deslauriers <francis.deslauriers@efficios.com>
*/
#define _GNU_SOURCE
#include <wrapper/compiler_attributes.h>
#include <wrapper/poll.h>
#include <wrapper/kref.h>
+#include <wrapper/uaccess.h>
#include <lttng/string-utils.h>
#include <lttng/abi.h>
#include <lttng/abi-old.h>
static const struct file_operations lttng_event_notifier_group_fops;
static const struct file_operations lttng_channel_fops;
static const struct file_operations lttng_metadata_fops;
-static const struct file_operations lttng_event_recorder_event_fops;
-static const struct file_operations lttng_event_recorder_enabler_fops;
+static const struct file_operations lttng_event_session_fops;
+static const struct file_operations lttng_event_session_enabler_fops;
static struct file_operations lttng_stream_ring_buffer_file_operations;
static int put_u64(uint64_t val, unsigned long arg);
static int put_u32(uint32_t val, unsigned long arg);
+static
+int lttng_abi_create_event_counter_enabler(struct file *channel_file,
+ struct lttng_kernel_counter_event *counter_event);
+static
+long lttng_abi_session_create_counter(
+ struct lttng_kernel_session *session,
+ const struct lttng_kernel_counter_conf *counter_conf);
+
static int validate_zeroed_padding(char *p, size_t len)
{
size_t i;
static
int lttng_counter_release(struct inode *inode, struct file *file)
{
- struct lttng_counter *counter = file->private_data;
+ struct lttng_kernel_channel_counter *counter = file->private_data;
if (counter) {
/*
* Do not destroy the counter itself. Wait of the owner
* (event_notifier group) to be destroyed.
*/
- fput(counter->owner);
+ fput(counter->priv->owner);
}
return 0;
}
static
-long lttng_counter_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+int copy_user_event_param_ext(struct lttng_kernel_abi_event_ext *event_param_ext,
+ struct lttng_kernel_abi_event *event_param)
{
- struct lttng_counter *counter = file->private_data;
- size_t indexes[LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX] = { 0 };
- int i;
+ struct lttng_kernel_abi_event_ext __user *uevent_ext =
+ (struct lttng_kernel_abi_event_ext __user *) (unsigned long) event_param->event_ext;
+ uint32_t len;
+ int ret;
- switch (cmd) {
- case LTTNG_KERNEL_ABI_COUNTER_READ:
+ /* Use zeroed defaults if extension parameters are not set. */
+ if (!uevent_ext)
+ return 0;
+ ret = get_user(len, &uevent_ext->len);
+ if (ret)
+ return ret;
+ if (len > PAGE_SIZE)
+ return -E2BIG;
+ ret = lttng_copy_struct_from_user(event_param_ext, sizeof(*event_param_ext), uevent_ext, len);
+ if (ret)
+ return ret;
+ /* Ensure that len is consistent with the initial get_user(). */
+ event_param_ext->len = len;
+
+ /* Validate that we know of all flags and enum values used. */
+ switch (event_param_ext->match_check) {
+ case LTTNG_KERNEL_ABI_MATCH_DEFAULT:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_MATCH_IMMEDIATE:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_MATCH_LAZY:
+ break;
+ default:
+ return -EINVAL;
+ }
+ return 0;
+}
+
+static
+int user_event_param_ext_get_match_check(const struct lttng_kernel_abi_event_ext *event_param_ext,
+ enum lttng_kernel_abi_match_check *_match_check)
+{
+ enum lttng_kernel_abi_match_check match_check = LTTNG_KERNEL_ABI_MATCH_DEFAULT;
+
+ if (event_param_ext->len < offsetofend(struct lttng_kernel_abi_event_ext, match_check))
+ goto end;
+ match_check = event_param_ext->match_check;
+end:
+ *_match_check = match_check;
+ return 0;
+}
+
+static
+int create_counter_key_from_abi_dimensions(struct lttng_kernel_counter_key **_counter_key,
+ uint32_t nr_dimensions, void __user *ptr)
+{
+ struct lttng_kernel_abi_counter_key_dimension __user *udimension;
+ struct lttng_kernel_abi_counter_key_dimension kdimension = {};
+ struct lttng_kernel_counter_key *counter_key = NULL;
+ struct lttng_key_token *token_array = NULL;
+ uint32_t i;
+ int ret = 0;
+
+ if (!nr_dimensions || nr_dimensions > LTTNG_KERNEL_COUNTER_MAX_DIMENSIONS)
+ return -EINVAL;
+ counter_key = kzalloc(sizeof(*counter_key), GFP_KERNEL);
+ if (!counter_key)
+ return -ENOMEM;
+ counter_key->nr_dimensions = nr_dimensions;
+ /* Only a single dimension is supported. */
+ if (WARN_ON_ONCE(nr_dimensions != 1)) {
+ ret = -EINVAL;
+ goto error;
+ }
+ udimension = (struct lttng_kernel_abi_counter_key_dimension __user *)ptr;
+ ret = lttng_copy_struct_from_user(&kdimension, sizeof(kdimension), udimension, sizeof(*udimension));
+ if (ret)
+ goto error;
+ if (kdimension.len > PAGE_SIZE) {
+ ret = -E2BIG;
+ goto error;
+ }
+ switch (kdimension.key_type) {
+ case LTTNG_KERNEL_ABI_KEY_TYPE_TOKENS:
{
- struct lttng_kernel_abi_counter_read local_counter_read;
- struct lttng_kernel_abi_counter_read __user *ucounter_read =
- (struct lttng_kernel_abi_counter_read __user *) arg;
- bool overflow, underflow;
- int64_t value;
- int32_t cpu;
- int ret;
+ struct lttng_kernel_abi_counter_key_dimension_tokens kdimension_tokens = {};
+ struct lttng_kernel_abi_counter_key_dimension_tokens __user *udimension_tokens;
+ struct lttng_kernel_abi_key_token __user *utoken;
+ uint32_t nr_tokens;
+
+ udimension_tokens = (struct lttng_kernel_abi_counter_key_dimension_tokens __user *)ptr;
+ ret = lttng_copy_struct_from_user(&kdimension_tokens, sizeof(kdimension_tokens),
+ udimension_tokens, kdimension.len);
+ if (ret)
+ goto error;
+ nr_tokens = kdimension_tokens.nr_key_tokens;
+ if (nr_tokens > LTTNG_KERNEL_COUNTER_MAX_TOKENS) {
+ ret = -EINVAL;
+ goto error;
+ }
+ token_array = kzalloc(nr_tokens * sizeof(*token_array), GFP_KERNEL);
+ if (!token_array) {
+ ret = -ENOMEM;
+ goto error;
+ }
+ counter_key->dimension_array[0].token_array = token_array;
+ counter_key->dimension_array[0].nr_key_tokens = nr_tokens;
+ utoken = (struct lttng_kernel_abi_key_token __user *)((unsigned long)ptr + kdimension.len);
+ for (i = 0; i < nr_tokens; i++) {
+ struct lttng_kernel_abi_key_token ktoken = {};
+ struct lttng_key_token *key_token = &token_array[i];
+ uint32_t token_len = 0;
+
+ ret = lttng_copy_struct_from_user(&ktoken, sizeof(ktoken), utoken, sizeof(*utoken));
+ if (ret)
+ goto error;
+ token_len += ktoken.len;
+ switch (ktoken.type) {
+ case LTTNG_KERNEL_ABI_KEY_TOKEN_STRING:
+ {
+ struct lttng_kernel_abi_key_token_string __user *utoken_string;
+ struct lttng_kernel_abi_key_token_string *ktoken_string;
+ char __user *string_ptr;
+ size_t string_len;
+
+ utoken_string = (struct lttng_kernel_abi_key_token_string __user *) utoken;
+ ret = lttng_copy_struct_from_user(&ktoken_string, sizeof(ktoken_string),
+ utoken_string, ktoken.len);
+ if (ret)
+ goto error;
+ string_ptr = (char __user *) ((unsigned long)utoken_string + ktoken.len);
+ string_len = ktoken_string->string_len;
+ key_token->type = LTTNG_KEY_TOKEN_STRING;
+ if (!string_len || string_len > PAGE_SIZE) {
+ ret = -EINVAL;
+ goto error;
+ }
+ key_token->str = kzalloc(string_len, GFP_KERNEL);
+ if (!key_token->str) {
+ ret = -ENOMEM;
+ goto error;
+ }
+ ret = copy_from_user(key_token->str, string_ptr, string_len);
+ if (ret)
+ goto error;
+ if (key_token->str[string_len - 1] != '\0') {
+ ret = -EINVAL;
+ goto error;
+ }
+ token_len += string_len;
+ break;
+ }
+ case LTTNG_KERNEL_ABI_KEY_TOKEN_EVENT_NAME:
+ key_token->type = LTTNG_KEY_TOKEN_EVENT_NAME;
+ break;
+
+ case LTTNG_KERNEL_ABI_KEY_TOKEN_PROVIDER_NAME:
+ lttng_fallthrough;
+ default:
+ ret = -EINVAL;
+ goto error;
+ }
+ utoken = (struct lttng_kernel_abi_key_token __user *)((unsigned long)utoken + token_len);
+ }
- if (copy_from_user(&local_counter_read, ucounter_read,
- sizeof(local_counter_read)))
- return -EFAULT;
- if (validate_zeroed_padding(local_counter_read.padding,
- sizeof(local_counter_read.padding)))
- return -EINVAL;
- if (local_counter_read.index.number_dimensions > LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX)
- return -EINVAL;
+ break;
+ }
+ case LTTNG_KERNEL_ABI_KEY_TYPE_INTEGER:
+ default:
+ ret = -EINVAL;
+ goto error;
+ }
+ *_counter_key = counter_key;
+ return 0;
+
+error:
+ destroy_counter_key(counter_key);
+ return ret;
+}
+
+int create_counter_key_from_kernel(struct lttng_kernel_counter_key **_new_key,
+ const struct lttng_kernel_counter_key *src_key)
+{
+ struct lttng_kernel_counter_key *new_key;
+ int i, ret = 0;
+
+ new_key = kzalloc(sizeof(*new_key), GFP_KERNEL);
+ if (!new_key)
+ return -ENOMEM;
+ new_key->nr_dimensions = src_key->nr_dimensions;
+ for (i = 0; i < src_key->nr_dimensions; i++) {
+ struct lttng_kernel_counter_key_dimension *new_dimension = &new_key->dimension_array[i];
+ const struct lttng_kernel_counter_key_dimension *src_dimension = &src_key->dimension_array[i];
+ uint32_t nr_tokens = src_dimension->nr_key_tokens;
+ int j;
+
+ new_dimension->nr_key_tokens = nr_tokens;
+ new_dimension->token_array = kzalloc(nr_tokens * sizeof(*new_dimension->token_array), GFP_KERNEL);
+ if (!new_dimension->token_array) {
+ ret = -ENOMEM;
+ goto error;
+ }
+ for (j = 0; j < nr_tokens; j++) {
+ struct lttng_key_token *new_key_token = &new_dimension->token_array[j];
+ struct lttng_key_token *src_key_token = &src_dimension->token_array[j];
+
+ switch (src_key_token->type) {
+ case LTTNG_KEY_TOKEN_STRING:
+ new_key_token->type = LTTNG_KEY_TOKEN_STRING;
+ new_key_token->str = kstrdup(src_key_token->str, GFP_KERNEL);
+ if (!new_key_token->str) {
+ ret = -ENOMEM;
+ goto error;
+ }
+ break;
+ case LTTNG_KEY_TOKEN_EVENT_NAME:
+ new_key_token->type = LTTNG_KEY_TOKEN_EVENT_NAME;
+ break;
+
+ default:
+ ret = -EINVAL;
+ goto error;
+ }
+ }
+ }
+ *_new_key = new_key;
+ return 0;
+
+error:
+ destroy_counter_key(new_key);
+ return ret;
+}
+
+void destroy_counter_key(struct lttng_kernel_counter_key *counter_key)
+{
+ int i;
+
+ if (!counter_key)
+ return;
+ for (i = 0; i < counter_key->nr_dimensions; i++) {
+ struct lttng_kernel_counter_key_dimension *dimension = &counter_key->dimension_array[i];
+ uint32_t nr_tokens = dimension->nr_key_tokens;
+ int j;
+
+ for (j = 0; j < nr_tokens; j++) {
+ struct lttng_key_token *key_token = &dimension->token_array[j];
+
+ switch (key_token->type) {
+ case LTTNG_KEY_TOKEN_STRING:
+ kfree(key_token->str);
+ break;
+
+ case LTTNG_KEY_TOKEN_EVENT_NAME:
+ lttng_fallthrough;
+ case LTTNG_KEY_TOKEN_UNKNOWN:
+ break;
+
+ default:
+ WARN_ON_ONCE(1);
+ }
+ }
+ kfree(dimension->token_array);
+ }
+ kfree(counter_key);
+}
+
+static
+long lttng_counter_ioctl_abi_old_counter_read(struct lttng_kernel_channel_counter *counter,
+ unsigned int cmd, unsigned long arg)
+{
+ size_t indexes[LTTNG_KERNEL_ABI_OLD_COUNTER_DIMENSION_MAX] = {};
+ struct lttng_kernel_abi_old_counter_read local_counter_read;
+ struct lttng_kernel_abi_old_counter_read __user *ucounter_read =
+ (struct lttng_kernel_abi_old_counter_read __user *) arg;
+ bool overflow, underflow;
+ int64_t value;
+ int32_t cpu;
+ int ret, i;
+
+ if (copy_from_user(&local_counter_read, ucounter_read,
+ sizeof(local_counter_read)))
+ return -EFAULT;
+ if (validate_zeroed_padding(local_counter_read.padding,
+ sizeof(local_counter_read.padding)))
+ return -EINVAL;
+ if (local_counter_read.index.number_dimensions > LTTNG_KERNEL_ABI_OLD_COUNTER_DIMENSION_MAX)
+ return -EINVAL;
+ /* Cast all indexes into size_t. */
+ for (i = 0; i < local_counter_read.index.number_dimensions; i++)
+ indexes[i] = local_counter_read.index.dimension_indexes[i];
+ cpu = local_counter_read.cpu;
+
+ ret = lttng_kernel_counter_read(counter, indexes, cpu, &value, &overflow, &underflow);
+ if (ret)
+ return ret;
+ local_counter_read.value.value = value;
+ local_counter_read.value.overflow = overflow;
+ local_counter_read.value.underflow = underflow;
+
+ if (copy_to_user(&ucounter_read->value, &local_counter_read.value,
+ sizeof(local_counter_read.value)))
+ return -EFAULT;
+
+ return 0;
+}
- /* Cast all indexes into size_t. */
- for (i = 0; i < local_counter_read.index.number_dimensions; i++)
- indexes[i] = (size_t) local_counter_read.index.dimension_indexes[i];
- cpu = local_counter_read.cpu;
+static
+long lttng_counter_ioctl_abi_old_counter_aggregate(struct lttng_kernel_channel_counter *counter,
+ unsigned int cmd, unsigned long arg)
+{
+ size_t indexes[LTTNG_KERNEL_ABI_OLD_COUNTER_DIMENSION_MAX] = {};
+ struct lttng_kernel_abi_old_counter_aggregate local_counter_aggregate;
+ struct lttng_kernel_abi_old_counter_aggregate __user *ucounter_aggregate =
+ (struct lttng_kernel_abi_old_counter_aggregate __user *) arg;
+ bool overflow, underflow;
+ int64_t value;
+ int ret, i;
+
+ if (copy_from_user(&local_counter_aggregate, ucounter_aggregate,
+ sizeof(local_counter_aggregate)))
+ return -EFAULT;
+ if (validate_zeroed_padding(local_counter_aggregate.padding,
+ sizeof(local_counter_aggregate.padding)))
+ return -EINVAL;
+ if (local_counter_aggregate.index.number_dimensions > LTTNG_KERNEL_ABI_OLD_COUNTER_DIMENSION_MAX)
+ return -EINVAL;
+ /* Cast all indexes into size_t. */
+ for (i = 0; i < local_counter_aggregate.index.number_dimensions; i++)
+ indexes[i] = local_counter_aggregate.index.dimension_indexes[i];
+
+ ret = lttng_kernel_counter_aggregate(counter, indexes, &value, &overflow, &underflow);
+ if (ret)
+ return ret;
+ local_counter_aggregate.value.value = value;
+ local_counter_aggregate.value.overflow = overflow;
+ local_counter_aggregate.value.underflow = underflow;
+
+ if (copy_to_user(&ucounter_aggregate->value, &local_counter_aggregate.value,
+ sizeof(local_counter_aggregate.value)))
+ return -EFAULT;
+
+ return 0;
+}
+
+static
+long lttng_counter_ioctl_abi_old_counter_clear(struct lttng_kernel_channel_counter *counter,
+ unsigned int cmd, unsigned long arg)
+{
+ size_t indexes[LTTNG_KERNEL_ABI_OLD_COUNTER_DIMENSION_MAX] = {};
+ struct lttng_kernel_abi_old_counter_clear local_counter_clear;
+ struct lttng_kernel_abi_old_counter_clear __user *ucounter_clear =
+ (struct lttng_kernel_abi_old_counter_clear __user *) arg;
+ int i;
+
+ if (copy_from_user(&local_counter_clear, ucounter_clear,
+ sizeof(local_counter_clear)))
+ return -EFAULT;
+ if (validate_zeroed_padding(local_counter_clear.padding,
+ sizeof(local_counter_clear.padding)))
+ return -EINVAL;
+ if (local_counter_clear.index.number_dimensions > LTTNG_KERNEL_ABI_OLD_COUNTER_DIMENSION_MAX)
+ return -EINVAL;
+ /* Cast all indexes into size_t. */
+ for (i = 0; i < local_counter_clear.index.number_dimensions; i++)
+ indexes[i] = local_counter_clear.index.dimension_indexes[i];
+ return lttng_kernel_counter_clear(counter, indexes);
+}
+
+static
+long lttng_counter_ioctl_abi_counter_read(struct lttng_kernel_channel_counter *counter,
+ unsigned int cmd, unsigned long arg)
+{
+ size_t indexes[LTTNG_KERNEL_COUNTER_MAX_DIMENSIONS] = {};
+ struct lttng_kernel_abi_counter_read kcounter_read = {};
+ struct lttng_kernel_abi_counter_read __user *ucounter_read =
+ (struct lttng_kernel_abi_counter_read __user *) arg;
+ uint32_t len, number_dimensions;
+ bool overflow, underflow;
+ int64_t value;
+ int32_t cpu;
+ int ret, i;
+
+ ret = get_user(len, &ucounter_read->len);
+ if (ret)
+ return ret;
+ if (len > PAGE_SIZE)
+ return -E2BIG;
+ if (len < offsetofend(struct lttng_kernel_abi_counter_read, value))
+ return -EINVAL;
+ ret = lttng_copy_struct_from_user(&kcounter_read, sizeof(kcounter_read),
+ ucounter_read, len);
+ if (ret)
+ return ret;
+ number_dimensions = kcounter_read.index.number_dimensions;
+ if (!number_dimensions || number_dimensions > LTTNG_KERNEL_COUNTER_MAX_DIMENSIONS)
+ return -EINVAL;
+ /* Cast all indexes into size_t. */
+ for (i = 0; i < number_dimensions; i++) {
+ uint64_t __user *ptr = ((uint64_t __user *)(unsigned long)kcounter_read.index.ptr) + i;
+ uint64_t index;
- ret = lttng_kernel_counter_read(counter, indexes, cpu, &value,
- &overflow, &underflow);
+ ret = get_user(index, ptr);
if (ret)
return ret;
- local_counter_read.value.value = value;
- local_counter_read.value.overflow = overflow;
- local_counter_read.value.underflow = underflow;
+ indexes[i] = index;
+ }
+ cpu = kcounter_read.cpu;
+ ret = lttng_kernel_counter_read(counter, indexes, cpu, &value, &overflow, &underflow);
+ if (ret)
+ return ret;
+ kcounter_read.value.value = value;
+ kcounter_read.value.flags |= underflow ? LTTNG_KERNEL_ABI_COUNTER_VALUE_FLAG_UNDERFLOW : 0;
+ kcounter_read.value.flags |= overflow ? LTTNG_KERNEL_ABI_COUNTER_VALUE_FLAG_OVERFLOW : 0;
- if (copy_to_user(&ucounter_read->value, &local_counter_read.value,
- sizeof(local_counter_read.value)))
- return -EFAULT;
+ if (copy_to_user(&ucounter_read->value, &kcounter_read.value, sizeof(kcounter_read.value)))
+ return -EFAULT;
- return 0;
+ return 0;
+}
+
+static
+long lttng_counter_ioctl_abi_counter_aggregate(struct lttng_kernel_channel_counter *counter,
+ unsigned int cmd, unsigned long arg)
+{
+ size_t indexes[LTTNG_KERNEL_COUNTER_MAX_DIMENSIONS] = {};
+ struct lttng_kernel_abi_counter_aggregate kcounter_aggregate = {};
+ struct lttng_kernel_abi_counter_aggregate __user *ucounter_aggregate =
+ (struct lttng_kernel_abi_counter_aggregate __user *) arg;
+ uint32_t len, number_dimensions;
+ bool overflow, underflow;
+ int64_t value;
+ int ret, i;
+
+ ret = get_user(len, &ucounter_aggregate->len);
+ if (ret)
+ return ret;
+ if (len > PAGE_SIZE)
+ return -E2BIG;
+ if (len < offsetofend(struct lttng_kernel_abi_counter_aggregate, value))
+ return -EINVAL;
+ ret = lttng_copy_struct_from_user(&kcounter_aggregate, sizeof(kcounter_aggregate),
+ ucounter_aggregate, len);
+ if (ret)
+ return ret;
+ number_dimensions = kcounter_aggregate.index.number_dimensions;
+ if (!number_dimensions || number_dimensions > LTTNG_KERNEL_COUNTER_MAX_DIMENSIONS)
+ return -EINVAL;
+ /* Cast all indexes into size_t. */
+ for (i = 0; i < number_dimensions; i++) {
+ uint64_t __user *ptr = ((uint64_t __user *)(unsigned long)kcounter_aggregate.index.ptr) + i;
+ uint64_t index;
+
+ ret = get_user(index, ptr);
+ if (ret)
+ return ret;
+ indexes[i] = index;
}
- case LTTNG_KERNEL_ABI_COUNTER_AGGREGATE:
- {
- struct lttng_kernel_abi_counter_aggregate local_counter_aggregate;
- struct lttng_kernel_abi_counter_aggregate __user *ucounter_aggregate =
- (struct lttng_kernel_abi_counter_aggregate __user *) arg;
- bool overflow, underflow;
- int64_t value;
- int ret;
+ ret = lttng_kernel_counter_aggregate(counter, indexes, &value, &overflow, &underflow);
+ if (ret)
+ return ret;
+ kcounter_aggregate.value.value = value;
+ kcounter_aggregate.value.flags |= underflow ? LTTNG_KERNEL_ABI_COUNTER_VALUE_FLAG_UNDERFLOW : 0;
+ kcounter_aggregate.value.flags |= overflow ? LTTNG_KERNEL_ABI_COUNTER_VALUE_FLAG_OVERFLOW : 0;
- if (copy_from_user(&local_counter_aggregate, ucounter_aggregate,
- sizeof(local_counter_aggregate)))
- return -EFAULT;
- if (validate_zeroed_padding(local_counter_aggregate.padding,
- sizeof(local_counter_aggregate.padding)))
- return -EINVAL;
- if (local_counter_aggregate.index.number_dimensions > LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX)
- return -EINVAL;
+ if (copy_to_user(&ucounter_aggregate->value, &kcounter_aggregate.value, sizeof(kcounter_aggregate.value)))
+ return -EFAULT;
- /* Cast all indexes into size_t. */
- for (i = 0; i < local_counter_aggregate.index.number_dimensions; i++)
- indexes[i] = (size_t) local_counter_aggregate.index.dimension_indexes[i];
+ return 0;
+}
- ret = lttng_kernel_counter_aggregate(counter, indexes, &value,
- &overflow, &underflow);
+static
+long lttng_counter_ioctl_abi_counter_clear(struct lttng_kernel_channel_counter *counter,
+ unsigned int cmd, unsigned long arg)
+{
+ size_t indexes[LTTNG_KERNEL_COUNTER_MAX_DIMENSIONS] = {};
+ struct lttng_kernel_abi_counter_clear kcounter_clear = {};
+ struct lttng_kernel_abi_counter_clear __user *ucounter_clear =
+ (struct lttng_kernel_abi_counter_clear __user *) arg;
+ uint32_t len, number_dimensions;
+ int ret, i;
+
+ ret = get_user(len, &ucounter_clear->len);
+ if (ret)
+ return ret;
+ if (len > PAGE_SIZE)
+ return -E2BIG;
+ if (len < offsetofend(struct lttng_kernel_abi_counter_clear, index))
+ return -EINVAL;
+ ret = lttng_copy_struct_from_user(&kcounter_clear, sizeof(kcounter_clear),
+ ucounter_clear, len);
+ if (ret)
+ return ret;
+ number_dimensions = kcounter_clear.index.number_dimensions;
+ if (!number_dimensions || number_dimensions > LTTNG_KERNEL_COUNTER_MAX_DIMENSIONS)
+ return -EINVAL;
+ /* Cast all indexes into size_t. */
+ for (i = 0; i < number_dimensions; i++) {
+ uint64_t __user *ptr = ((uint64_t __user *)(unsigned long)kcounter_clear.index.ptr) + i;
+ uint64_t index;
+
+ ret = get_user(index, ptr);
if (ret)
return ret;
- local_counter_aggregate.value.value = value;
- local_counter_aggregate.value.overflow = overflow;
- local_counter_aggregate.value.underflow = underflow;
+ indexes[i] = index;
+ }
+ return lttng_kernel_counter_clear(counter, indexes);
+}
- if (copy_to_user(&ucounter_aggregate->value, &local_counter_aggregate.value,
- sizeof(local_counter_aggregate.value)))
- return -EFAULT;
+static
+long lttng_counter_ioctl_abi_counter_event(struct file *file,
+ struct lttng_kernel_channel_counter *counter,
+ unsigned int cmd, unsigned long arg)
+{
+ struct lttng_kernel_abi_counter_event __user *ucounter_event =
+ (struct lttng_kernel_abi_counter_event __user *) arg;
+ struct lttng_kernel_abi_counter_event kcounter_event = {};
+ struct lttng_kernel_counter_event *counter_event;
+ uint32_t len;
+ int ret;
- return 0;
+ ret = get_user(len, &ucounter_event->len);
+ if (ret)
+ return ret;
+ if (len > PAGE_SIZE)
+ return -E2BIG;
+ if (len < offsetofend(struct lttng_kernel_abi_counter_event, number_key_dimensions))
+ return -EINVAL;
+ counter_event = kzalloc(sizeof(*counter_event), GFP_KERNEL);
+ if (!counter_event)
+ return -ENOMEM;
+ ret = lttng_copy_struct_from_user(&kcounter_event, sizeof(kcounter_event),
+ ucounter_event, len);
+ if (ret)
+ goto end_counter_event;
+ memcpy(&counter_event->event_param, &kcounter_event.event, sizeof(counter_event->event_param));
+ ret = copy_user_event_param_ext(&counter_event->event_param_ext, &kcounter_event.event);
+ if (ret)
+ goto end_counter_event;
+ switch (kcounter_event.action) {
+ case LTTNG_KERNEL_ABI_COUNTER_ACTION_INCREMENT:
+ /* No specific data for this action. */
+ break;
+ default:
+ ret = -EINVAL;
+ goto end_counter_event;
}
- case LTTNG_KERNEL_ABI_COUNTER_CLEAR:
- {
- struct lttng_kernel_abi_counter_clear local_counter_clear;
- struct lttng_kernel_abi_counter_clear __user *ucounter_clear =
- (struct lttng_kernel_abi_counter_clear __user *) arg;
+ ret = create_counter_key_from_abi_dimensions(&counter_event->counter_key,
+ kcounter_event.number_key_dimensions,
+ (void __user *) arg + len);
+ if (ret)
+ goto end_counter_event;
+ ret = lttng_abi_create_event_counter_enabler(file, counter_event);
+ destroy_counter_key(counter_event->counter_key);
+end_counter_event:
+ kfree(counter_event);
+ return ret;
+}
- if (copy_from_user(&local_counter_clear, ucounter_clear,
- sizeof(local_counter_clear)))
- return -EFAULT;
- if (validate_zeroed_padding(local_counter_clear.padding,
- sizeof(local_counter_clear.padding)))
- return -EINVAL;
- if (local_counter_clear.index.number_dimensions > LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX)
- return -EINVAL;
+static
+long lttng_counter_ioctl_abi_counter_map_descriptor(struct lttng_kernel_channel_counter *counter,
+ unsigned int cmd, unsigned long arg)
+{
+ struct lttng_kernel_abi_counter_map_descriptor __user *udescriptor =
+ (struct lttng_kernel_abi_counter_map_descriptor __user *) arg;
+ struct lttng_kernel_abi_counter_map_descriptor kdescriptor = {};
+ struct lttng_counter_map_descriptor *descriptor;
+ char key[LTTNG_KERNEL_COUNTER_KEY_LEN] = {};
+ uint64_t array_indexes[1];
+ size_t key_strlen;
+ uint32_t len;
+ int ret;
+
+ ret = get_user(len, &udescriptor->len);
+ if (ret)
+ return ret;
+ if (len > PAGE_SIZE)
+ return -E2BIG;
+ if (len < offsetofend(struct lttng_kernel_abi_counter_map_descriptor, array_indexes_len))
+ return -EINVAL;
+ ret = lttng_copy_struct_from_user(&kdescriptor, sizeof(kdescriptor), udescriptor, len);
+ if (ret)
+ return ret;
+ mutex_lock(&counter->priv->map.lock);
+ if (kdescriptor.descriptor_index >= counter->priv->map.nr_descriptors) {
+ ret = -EOVERFLOW;
+ goto map_descriptor_error_unlock;
+ }
+ if (kdescriptor.array_indexes_len < 1) {
+ ret = -EINVAL;
+ goto map_descriptor_error_unlock;
+ }
+ kdescriptor.array_indexes_len = 1;
+ descriptor = &counter->priv->map.descriptors[kdescriptor.descriptor_index];
+ kdescriptor.dimension = 0;
+ kdescriptor.user_token = descriptor->user_token;
+ memcpy(&key, descriptor->key, LTTNG_KERNEL_COUNTER_KEY_LEN);
+ array_indexes[0] = descriptor->array_index;
+ mutex_unlock(&counter->priv->map.lock);
+
+ key_strlen = strlen(key) + 1;
+ if (kdescriptor.key_string_len < key_strlen)
+ return -ENOSPC;
+ kdescriptor.key_string_len = key_strlen;
+ if (copy_to_user((char __user *)(unsigned long)kdescriptor.key_string, key, key_strlen))
+ return -EFAULT;
+ if (copy_to_user((uint64_t __user *)(unsigned long)kdescriptor.array_indexes, array_indexes, sizeof(uint64_t)))
+ return -EFAULT;
+ if (copy_to_user(udescriptor, &kdescriptor, min(sizeof(kdescriptor), (size_t)len)))
+ return -EFAULT;
+ return 0;
- /* Cast all indexes into size_t. */
- for (i = 0; i < local_counter_clear.index.number_dimensions; i++)
- indexes[i] = (size_t) local_counter_clear.index.dimension_indexes[i];
+map_descriptor_error_unlock:
+ mutex_unlock(&counter->priv->map.lock);
+ return ret;
+}
- return lttng_kernel_counter_clear(counter, indexes);
+static
+long lttng_counter_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ struct lttng_kernel_channel_counter *counter = file->private_data;
+
+ switch (cmd) {
+ case LTTNG_KERNEL_ABI_OLD_COUNTER_READ:
+ return lttng_counter_ioctl_abi_old_counter_read(counter, cmd, arg);
+ case LTTNG_KERNEL_ABI_OLD_COUNTER_AGGREGATE:
+ return lttng_counter_ioctl_abi_old_counter_aggregate(counter, cmd, arg);
+ case LTTNG_KERNEL_ABI_OLD_COUNTER_CLEAR:
+ return lttng_counter_ioctl_abi_old_counter_clear(counter, cmd, arg);
+ case LTTNG_KERNEL_ABI_COUNTER_READ:
+ return lttng_counter_ioctl_abi_counter_read(counter, cmd, arg);
+ case LTTNG_KERNEL_ABI_COUNTER_AGGREGATE:
+ return lttng_counter_ioctl_abi_counter_aggregate(counter, cmd, arg);
+ case LTTNG_KERNEL_ABI_COUNTER_CLEAR:
+ return lttng_counter_ioctl_abi_counter_clear(counter, cmd, arg);
+ case LTTNG_KERNEL_ABI_COUNTER_EVENT:
+ return lttng_counter_ioctl_abi_counter_event(file, counter, cmd, arg);
+ case LTTNG_KERNEL_ABI_ENABLE:
+ return lttng_channel_enable(&counter->parent);
+ case LTTNG_KERNEL_ABI_DISABLE:
+ return lttng_channel_disable(&counter->parent);
+ case LTTNG_KERNEL_ABI_SYSCALL_MASK:
+ return lttng_syscall_table_get_active_mask(&counter->priv->parent.syscall_table,
+ (struct lttng_kernel_abi_syscall_mask __user *) arg);
+ case LTTNG_KERNEL_ABI_COUNTER_MAP_NR_DESCRIPTORS:
+ {
+ uint64_t __user *user_nr_descriptors = (uint64_t __user *) arg;
+ uint64_t nr_descriptors;
+
+ mutex_lock(&counter->priv->map.lock);
+ nr_descriptors = counter->priv->map.nr_descriptors;
+ mutex_unlock(&counter->priv->map.lock);
+ return put_user(nr_descriptors, user_nr_descriptors);
}
+ case LTTNG_KERNEL_ABI_COUNTER_MAP_DESCRIPTOR:
+ return lttng_counter_ioctl_abi_counter_map_descriptor(counter, cmd, arg);
default:
return -ENOSYS;
}
}
}
+static
+int lttng_abi_copy_user_old_counter_conf(struct lttng_kernel_counter_conf *counter_conf,
+ struct lttng_kernel_abi_old_counter_conf __user *old_ucounter_conf)
+{
+ struct lttng_kernel_abi_old_counter_conf old_kcounter_conf;
+ struct lttng_kernel_counter_dimension *dimension;
+ int ret;
+
+ memset(counter_conf, 0, sizeof(*counter_conf));
+ ret = copy_from_user(&old_kcounter_conf, old_ucounter_conf,
+ sizeof(old_kcounter_conf));
+ if (ret)
+ return ret;
+ if (!old_kcounter_conf.number_dimensions ||
+ old_kcounter_conf.number_dimensions > LTTNG_KERNEL_COUNTER_MAX_DIMENSIONS)
+ return -EINVAL;
+ switch (old_kcounter_conf.arithmetic) {
+ case LTTNG_KERNEL_ABI_COUNTER_ARITHMETIC_MODULAR:
+ counter_conf->arithmetic = LTTNG_KERNEL_COUNTER_ARITHMETIC_MODULAR;
+ break;
+ default:
+ return -EINVAL;
+ }
+ switch (old_kcounter_conf.bitness) {
+ case LTTNG_KERNEL_ABI_COUNTER_BITNESS_32:
+ counter_conf->bitness = LTTNG_KERNEL_COUNTER_BITNESS_32;
+ break;
+ case LTTNG_KERNEL_ABI_COUNTER_BITNESS_64:
+ counter_conf->bitness = LTTNG_KERNEL_COUNTER_BITNESS_64;
+ break;
+ default:
+ return -EINVAL;
+ }
+ counter_conf->global_sum_step = old_kcounter_conf.global_sum_step;
+ counter_conf->flags |= old_kcounter_conf.coalesce_hits ?
+ LTTNG_KERNEL_COUNTER_CONF_FLAG_COALESCE_HITS : 0;
+ dimension = &counter_conf->dimension_array[0];
+ dimension->flags |= old_kcounter_conf.dimensions[0].has_underflow ?
+ LTTNG_KERNEL_COUNTER_DIMENSION_FLAG_UNDERFLOW : 0;
+ dimension->flags |= old_kcounter_conf.dimensions[0].has_overflow ?
+ LTTNG_KERNEL_COUNTER_DIMENSION_FLAG_OVERFLOW : 0;
+ dimension->size = old_kcounter_conf.dimensions[0].size;
+ dimension->underflow_index = old_kcounter_conf.dimensions[0].underflow_index;
+ dimension->overflow_index = old_kcounter_conf.dimensions[0].overflow_index;
+ return 0;
+}
+
+static
+int lttng_abi_copy_user_counter_conf(struct lttng_kernel_counter_conf *counter_conf,
+ struct lttng_kernel_abi_counter_conf __user *ucounter_conf)
+{
+ uint32_t len, number_dimensions;
+ struct lttng_kernel_abi_counter_conf kcounter_conf = {};
+ struct lttng_kernel_counter_dimension *dimension;
+ struct lttng_kernel_abi_counter_dimension kdimension = {};
+ struct lttng_kernel_abi_counter_dimension __user *udimension;
+ int ret;
+
+ memset(counter_conf, 0, sizeof(*counter_conf));
+ ret = get_user(len, &ucounter_conf->len);
+ if (ret)
+ return ret;
+ if (len < offsetofend(struct lttng_kernel_abi_counter_conf, dimension_array))
+ return -EINVAL;
+ if (len > PAGE_SIZE)
+ return -EINVAL;
+
+ ret = lttng_copy_struct_from_user(&kcounter_conf, sizeof(kcounter_conf), ucounter_conf, len);
+ if (ret)
+ return ret;
+
+ /* Validate flags and enumerations */
+ switch (kcounter_conf.arithmetic) {
+ case LTTNG_KERNEL_ABI_COUNTER_ARITHMETIC_MODULAR:
+ counter_conf->arithmetic = LTTNG_KERNEL_COUNTER_ARITHMETIC_MODULAR;
+ break;
+ default:
+ return -EINVAL;
+ }
+ switch (kcounter_conf.bitness) {
+ case LTTNG_KERNEL_ABI_COUNTER_BITNESS_32:
+ counter_conf->bitness = LTTNG_KERNEL_COUNTER_BITNESS_32;
+ break;
+ case LTTNG_KERNEL_ABI_COUNTER_BITNESS_64:
+ counter_conf->bitness = LTTNG_KERNEL_COUNTER_BITNESS_64;
+ break;
+ default:
+ return -EINVAL;
+ }
+ if (kcounter_conf.flags & ~LTTNG_KERNEL_ABI_COUNTER_CONF_FLAG_COALESCE_HITS)
+ return -EINVAL;
+ counter_conf->global_sum_step = kcounter_conf.global_sum_step;
+ counter_conf->flags |= (kcounter_conf.flags & LTTNG_KERNEL_ABI_COUNTER_CONF_FLAG_COALESCE_HITS) ?
+ LTTNG_KERNEL_COUNTER_CONF_FLAG_COALESCE_HITS : 0;
+
+ number_dimensions = kcounter_conf.dimension_array.number_dimensions;
+ if (!number_dimensions || number_dimensions > LTTNG_KERNEL_COUNTER_MAX_DIMENSIONS)
+ return -EINVAL;
+ dimension = &counter_conf->dimension_array[0];
+ len = kcounter_conf.dimension_array.elem_len;
+ if (len > PAGE_SIZE)
+ return -E2BIG;
+ if (len < offsetofend(struct lttng_kernel_abi_counter_dimension, overflow_index))
+ return -EINVAL;
+ udimension = (struct lttng_kernel_abi_counter_dimension __user *)(unsigned long)kcounter_conf.dimension_array.ptr;
+ ret = lttng_copy_struct_from_user(&kdimension, sizeof(kdimension), udimension, len);
+ if (ret)
+ return ret;
+
+ /* Validate flags */
+ if (kdimension.flags & ~(LTTNG_KERNEL_ABI_COUNTER_DIMENSION_FLAG_UNDERFLOW |
+ LTTNG_KERNEL_ABI_COUNTER_DIMENSION_FLAG_OVERFLOW))
+ return -EINVAL;
+
+ dimension->flags |= (kdimension.flags & LTTNG_KERNEL_ABI_COUNTER_DIMENSION_FLAG_UNDERFLOW) ?
+ LTTNG_KERNEL_COUNTER_DIMENSION_FLAG_UNDERFLOW : 0;
+ dimension->flags |= (kdimension.flags & LTTNG_KERNEL_ABI_COUNTER_DIMENSION_FLAG_OVERFLOW) ?
+ LTTNG_KERNEL_COUNTER_DIMENSION_FLAG_OVERFLOW : 0;
+ dimension->size = kdimension.size;
+ dimension->underflow_index = kdimension.underflow_index;
+ dimension->overflow_index = kdimension.overflow_index;
+ return 0;
+}
+
/**
* lttng_session_ioctl - lttng session fd ioctl
*
struct lttng_kernel_session *session = file->private_data;
struct lttng_kernel_abi_channel chan_param;
struct lttng_kernel_abi_old_channel old_chan_param;
+ int ret;
/*
* Handle backward compatibility. OLD commands have wrong
return -EFAULT;
return lttng_abi_session_set_creation_time(session, &time);
}
+ case LTTNG_KERNEL_ABI_COUNTER:
+ {
+ struct lttng_kernel_counter_conf counter_conf;
+
+ ret = lttng_abi_copy_user_counter_conf(&counter_conf,
+ (struct lttng_kernel_abi_counter_conf __user *) arg);
+ if (ret)
+ return ret;
+ return lttng_abi_session_create_counter(session, &counter_conf);
+ }
default:
return -ENOIOCTLCMD;
}
struct lttng_kernel_ring_buffer *buf = stream->priv;
mutex_lock(&stream->metadata_cache->lock);
- list_del(&stream->list);
+ list_del(&stream->node);
mutex_unlock(&stream->metadata_cache->lock);
kref_put(&stream->metadata_cache->refcount, metadata_cache_destroy);
module_put(stream->transport->owner);
goto fd_error;
mutex_lock(&session->priv->metadata_cache->lock);
- list_add(&metadata_stream->list,
+ list_add(&metadata_stream->node,
&session->priv->metadata_cache->metadata_stream);
mutex_unlock(&session->priv->metadata_cache->lock);
return ret;
}
static
-int lttng_abi_validate_event_param(struct lttng_kernel_abi_event *event_param)
+int lttng_abi_validate_event_param(struct lttng_kernel_abi_event *event_param,
+ struct lttng_kernel_abi_event_ext *event_param_ext)
{
+ enum lttng_kernel_abi_match_check match_check;
+
+ if (user_event_param_ext_get_match_check(event_param_ext, &match_check))
+ return -EINVAL;
+
/* Limit ABI to implemented features. */
switch (event_param->instrumentation) {
case LTTNG_KERNEL_ABI_SYSCALL:
switch (event_param->u.syscall.entryexit) {
+ case LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT:
+ lttng_fallthrough;
case LTTNG_KERNEL_ABI_SYSCALL_ENTRY:
lttng_fallthrough;
case LTTNG_KERNEL_ABI_SYSCALL_EXIT:
- lttng_fallthrough;
- case LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT:
break;
default:
return -EINVAL;
default:
return -EINVAL;
}
+ switch (match_check) {
+ case LTTNG_KERNEL_ABI_MATCH_DEFAULT:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_MATCH_LAZY:
+ break;
+ default:
+ return -EINVAL;
+ }
+ break;
+
+ case LTTNG_KERNEL_ABI_KRETPROBE:
+ switch (event_param->u.kretprobe.entryexit) {
+ case LTTNG_KERNEL_ABI_KRETPROBE_ENTRYEXIT:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_KRETPROBE_ENTRY:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_KRETPROBE_EXIT:
+ break;
+ default:
+ return -EINVAL;
+ }
+ switch (match_check) {
+ case LTTNG_KERNEL_ABI_MATCH_DEFAULT:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_MATCH_IMMEDIATE:
+ break;
+ default:
+ return -EINVAL;
+ }
+ break;
+
+ case LTTNG_KERNEL_ABI_TRACEPOINT:
+ switch (match_check) {
+ case LTTNG_KERNEL_ABI_MATCH_DEFAULT:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_MATCH_LAZY:
+ break;
+ default:
+ return -EINVAL;
+ }
break;
- case LTTNG_KERNEL_ABI_KRETPROBE:
- switch (event_param->u.kretprobe.entryexit) {
- case LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT:
- break;
- case LTTNG_KERNEL_ABI_SYSCALL_ENTRY:
- lttng_fallthrough;
- case LTTNG_KERNEL_ABI_SYSCALL_EXIT:
- lttng_fallthrough;
- default:
- return -EINVAL;
+ case LTTNG_KERNEL_ABI_KPROBE:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_UPROBE:
+ switch (match_check) {
+ case LTTNG_KERNEL_ABI_MATCH_DEFAULT:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_MATCH_IMMEDIATE:
+ break;
+ default:
+ return -EINVAL;
+ }
+ break;
+
+ case LTTNG_KERNEL_ABI_FUNCTION:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_NOOP:
+ lttng_fallthrough;
+ default:
+ return -EINVAL;
+ }
+ return 0;
+}
+
+static
+int lttng_abi_validate_event_match(struct lttng_kernel_abi_event *event_param,
+ struct lttng_kernel_abi_event_ext *event_param_ext)
+{
+ enum lttng_kernel_abi_match_check match_check;
+ int ret;
+
+ if (user_event_param_ext_get_match_check(event_param_ext, &match_check))
+ return -EINVAL;
+
+ /* Validate match */
+ if (match_check == LTTNG_KERNEL_ABI_MATCH_DEFAULT) {
+ switch (event_param->instrumentation) {
+ case LTTNG_KERNEL_ABI_TRACEPOINT:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_SYSCALL:
+ match_check = LTTNG_KERNEL_ABI_MATCH_LAZY;
+ break;
+ case LTTNG_KERNEL_ABI_KPROBE:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_KRETPROBE:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_UPROBE:
+ match_check = LTTNG_KERNEL_ABI_MATCH_IMMEDIATE;
+ break;
+
+ case LTTNG_KERNEL_ABI_FUNCTION:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_NOOP:
+ lttng_fallthrough;
+ default:
+ return -EINVAL;
+ }
+ }
+
+ if (match_check == LTTNG_KERNEL_ABI_MATCH_IMMEDIATE) {
+ switch (event_param->instrumentation) {
+ break;
+ case LTTNG_KERNEL_ABI_KPROBE:
+ ret = lttng_kprobes_match_check(event_param->u.kprobe.symbol_name,
+ event_param->u.kprobe.offset,
+ event_param->u.kprobe.addr);
+ if (ret)
+ return ret;
+ break;
+ case LTTNG_KERNEL_ABI_KRETPROBE:
+ ret = lttng_kretprobes_match_check(event_param->u.kretprobe.symbol_name,
+ event_param->u.kretprobe.offset,
+ event_param->u.kretprobe.addr);
+ if (ret)
+ return ret;
+ break;
+ case LTTNG_KERNEL_ABI_UPROBE:
+ /*
+ * uprobes are immediately created, which includes match checking.
+ */
+ break;
+
+ case LTTNG_KERNEL_ABI_TRACEPOINT:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_SYSCALL:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_FUNCTION:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_NOOP:
+ lttng_fallthrough;
+ default:
+ return -EINVAL;
+ }
+ }
+ return 0;
+}
+
+static
+int lttng_abi_create_event_recorder_enabler(struct file *channel_file,
+ struct lttng_kernel_abi_event *event_param,
+ struct lttng_kernel_abi_event_ext *event_param_ext)
+{
+ const struct file_operations *fops;
+ struct lttng_kernel_channel_buffer *channel = channel_file->private_data;
+ int event_fd, ret;
+ struct file *event_file;
+ void *priv;
+
+ event_param->name[LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1] = '\0';
+ switch (event_param->instrumentation) {
+ case LTTNG_KERNEL_ABI_KRETPROBE:
+ event_param->u.kretprobe.symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1] = '\0';
+ break;
+ case LTTNG_KERNEL_ABI_KPROBE:
+ event_param->u.kprobe.symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1] = '\0';
+ break;
+ case LTTNG_KERNEL_ABI_FUNCTION:
+ WARN_ON_ONCE(1);
+ /* Not implemented. */
+ break;
+ default:
+ break;
+ }
+
+ switch (event_param->instrumentation) {
+ case LTTNG_KERNEL_ABI_TRACEPOINT:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_SYSCALL:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_KPROBE:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_KRETPROBE:
+ fops = <tng_event_session_enabler_fops;
+ break;
+
+ case LTTNG_KERNEL_ABI_UPROBE:
+ fops = <tng_event_session_fops;
+ break;
+
+ case LTTNG_KERNEL_ABI_FUNCTION:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_NOOP:
+ lttng_fallthrough;
+ default:
+ return -EINVAL;
+ }
+
+ event_fd = get_unused_fd_flags(0);
+ if (event_fd < 0) {
+ ret = event_fd;
+ goto fd_error;
+ }
+ event_file = anon_inode_getfile("[lttng_event_recorder]",
+ fops, NULL, O_RDWR);
+ if (IS_ERR(event_file)) {
+ ret = PTR_ERR(event_file);
+ goto file_error;
+ }
+ /* The event holds a reference on the channel */
+ if (!atomic_long_add_unless(&channel_file->f_count, 1, LONG_MAX)) {
+ ret = -EOVERFLOW;
+ goto refcount_error;
+ }
+ ret = lttng_abi_validate_event_param(event_param, event_param_ext);
+ if (ret)
+ goto event_error;
+ ret = lttng_abi_validate_event_match(event_param, event_param_ext);
+ if (ret)
+ goto event_error;
+
+ switch (event_param->instrumentation) {
+ case LTTNG_KERNEL_ABI_TRACEPOINT:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_SYSCALL:
+ {
+ struct lttng_event_recorder_enabler *event_enabler;
+
+ if (strutils_is_star_glob_pattern(event_param->name)) {
+ /*
+ * If the event name is a star globbing pattern,
+ * we create the special star globbing enabler.
+ */
+ event_enabler = lttng_event_recorder_enabler_create(LTTNG_ENABLER_FORMAT_STAR_GLOB,
+ event_param, channel);
+ } else {
+ event_enabler = lttng_event_recorder_enabler_create(LTTNG_ENABLER_FORMAT_NAME,
+ event_param, channel);
}
+ if (event_enabler)
+ lttng_event_enabler_session_add(channel->parent.session, &event_enabler->parent);
+ priv = event_enabler;
break;
+ }
- case LTTNG_KERNEL_ABI_TRACEPOINT:
- lttng_fallthrough;
case LTTNG_KERNEL_ABI_KPROBE:
lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_KRETPROBE:
+ {
+ struct lttng_event_recorder_enabler *event_enabler;
+
+ event_enabler = lttng_event_recorder_enabler_create(LTTNG_ENABLER_FORMAT_NAME,
+ event_param, channel);
+ if (event_enabler)
+ lttng_event_enabler_session_add(channel->parent.session, &event_enabler->parent);
+ priv = event_enabler;
+ break;
+ }
+
case LTTNG_KERNEL_ABI_UPROBE:
+ {
+ struct lttng_kernel_event_common *event;
+ struct lttng_event_recorder_enabler *event_enabler;
+
+ event_enabler = lttng_event_recorder_enabler_create(LTTNG_ENABLER_FORMAT_NAME,
+ event_param, channel);
+ if (!event_enabler) {
+ ret = -ENOMEM;
+ goto event_error;
+ }
+ /*
+ * We tolerate no failure path after event creation. It
+ * will stay invariant for the rest of the session.
+ */
+ event = lttng_kernel_event_create(&event_enabler->parent.parent, NULL, NULL);
+ lttng_event_enabler_destroy(&event_enabler->parent.parent);
+ if (IS_ERR(event)) {
+ ret = PTR_ERR(event);
+ goto event_error;
+ }
+ priv = event;
break;
+ }
case LTTNG_KERNEL_ABI_FUNCTION:
lttng_fallthrough;
case LTTNG_KERNEL_ABI_NOOP:
lttng_fallthrough;
default:
- return -EINVAL;
+ ret = -EINVAL;
+ goto event_error;
}
- return 0;
+ event_file->private_data = priv;
+ fd_install(event_fd, event_file);
+ return event_fd;
+
+event_error:
+ atomic_long_dec(&channel_file->f_count);
+refcount_error:
+ fput(event_file);
+file_error:
+ put_unused_fd(event_fd);
+fd_error:
+ return ret;
}
static
-int lttng_abi_create_event(struct file *channel_file,
- struct lttng_kernel_abi_event *event_param)
+int lttng_abi_create_event_counter_enabler(struct file *channel_file,
+ struct lttng_kernel_counter_event *counter_event)
{
const struct file_operations *fops;
- struct lttng_kernel_channel_buffer *channel = channel_file->private_data;
+ struct lttng_kernel_channel_counter *channel = channel_file->private_data;
+ struct lttng_kernel_abi_event *event_param = &counter_event->event_param;
+ struct lttng_kernel_abi_event_ext *event_param_ext = &counter_event->event_param_ext;
+ struct lttng_kernel_counter_key *counter_key = counter_event->counter_key;
int event_fd, ret;
struct file *event_file;
void *priv;
case LTTNG_KERNEL_ABI_TRACEPOINT:
lttng_fallthrough;
case LTTNG_KERNEL_ABI_SYSCALL:
- fops = <tng_event_recorder_enabler_fops;
- break;
+ lttng_fallthrough;
case LTTNG_KERNEL_ABI_KPROBE:
lttng_fallthrough;
case LTTNG_KERNEL_ABI_KRETPROBE:
- lttng_fallthrough;
+ fops = <tng_event_session_enabler_fops;
+ break;
+
case LTTNG_KERNEL_ABI_UPROBE:
- fops = <tng_event_recorder_event_fops;
+ fops = <tng_event_session_fops;
break;
case LTTNG_KERNEL_ABI_FUNCTION:
ret = event_fd;
goto fd_error;
}
- event_file = anon_inode_getfile("[lttng_event]",
+ event_file = anon_inode_getfile("[lttng_event_counter]",
fops, NULL, O_RDWR);
if (IS_ERR(event_file)) {
ret = PTR_ERR(event_file);
ret = -EOVERFLOW;
goto refcount_error;
}
- ret = lttng_abi_validate_event_param(event_param);
+ ret = lttng_abi_validate_event_param(event_param, event_param_ext);
+ if (ret)
+ goto event_error;
+ ret = lttng_abi_validate_event_match(event_param, event_param_ext);
if (ret)
goto event_error;
lttng_fallthrough;
case LTTNG_KERNEL_ABI_SYSCALL:
{
- struct lttng_event_recorder_enabler *event_enabler;
+ struct lttng_event_counter_enabler *event_enabler;
if (strutils_is_star_glob_pattern(event_param->name)) {
/*
* If the event name is a star globbing pattern,
* we create the special star globbing enabler.
*/
- event_enabler = lttng_event_recorder_enabler_create(LTTNG_ENABLER_FORMAT_STAR_GLOB,
- event_param, channel);
+ event_enabler = lttng_event_counter_enabler_create(LTTNG_ENABLER_FORMAT_STAR_GLOB,
+ event_param, counter_key, channel);
} else {
- event_enabler = lttng_event_recorder_enabler_create(LTTNG_ENABLER_FORMAT_NAME,
- event_param, channel);
+ event_enabler = lttng_event_counter_enabler_create(LTTNG_ENABLER_FORMAT_NAME,
+ event_param, counter_key, channel);
}
if (event_enabler)
- lttng_event_enabler_session_add(channel->parent.session, event_enabler);
+ lttng_event_enabler_session_add(channel->parent.session, &event_enabler->parent);
priv = event_enabler;
break;
}
case LTTNG_KERNEL_ABI_KPROBE:
lttng_fallthrough;
case LTTNG_KERNEL_ABI_KRETPROBE:
- lttng_fallthrough;
+ {
+ struct lttng_event_counter_enabler *event_enabler;
+
+ event_enabler = lttng_event_counter_enabler_create(LTTNG_ENABLER_FORMAT_NAME,
+ event_param, counter_key, channel);
+ if (event_enabler)
+ lttng_event_enabler_session_add(channel->parent.session, &event_enabler->parent);
+ priv = event_enabler;
+ break;
+ }
+
case LTTNG_KERNEL_ABI_UPROBE:
{
struct lttng_kernel_event_common *event;
- struct lttng_event_recorder_enabler *event_enabler;
+ struct lttng_event_counter_enabler *event_enabler;
- event_enabler = lttng_event_recorder_enabler_create(LTTNG_ENABLER_FORMAT_NAME,
- event_param, channel);
+ event_enabler = lttng_event_counter_enabler_create(LTTNG_ENABLER_FORMAT_NAME,
+ event_param, counter_key, channel);
if (!event_enabler) {
ret = -ENOMEM;
goto event_error;
* We tolerate no failure path after event creation. It
* will stay invariant for the rest of the session.
*/
- event = lttng_kernel_event_create(&event_enabler->parent, NULL);
- WARN_ON_ONCE(IS_ERR(event));
- lttng_event_enabler_destroy(&event_enabler->parent);
+ event = lttng_kernel_event_create(&event_enabler->parent.parent, NULL, NULL);
+ lttng_event_enabler_destroy(&event_enabler->parent.parent);
if (IS_ERR(event)) {
ret = PTR_ERR(event);
goto event_error;
}
- priv = container_of(event, struct lttng_kernel_event_recorder, parent);
+ priv = event;
break;
}
static
long lttng_event_notifier_event_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
- struct lttng_kernel_event_notifier *event_notifier = file->private_data;
+ struct lttng_kernel_event_common *event = file->private_data;
switch (cmd) {
case LTTNG_KERNEL_ABI_ENABLE:
- return lttng_event_enable(&event_notifier->parent);
+ return lttng_event_enable(event);
case LTTNG_KERNEL_ABI_DISABLE:
- return lttng_event_disable(&event_notifier->parent);
+ return lttng_event_disable(event);
case LTTNG_KERNEL_ABI_FILTER:
return -EINVAL;
case LTTNG_KERNEL_ABI_CAPTURE:
return -EINVAL;
case LTTNG_KERNEL_ABI_ADD_CALLSITE:
- return lttng_event_add_callsite(&event_notifier->parent,
+ return lttng_event_add_callsite(event,
(struct lttng_kernel_abi_event_callsite __user *) arg);
default:
return -ENOIOCTLCMD;
static
long lttng_event_notifier_enabler_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
- struct lttng_event_notifier_enabler *event_notifier_enabler = file->private_data;
+ struct lttng_event_enabler_common *event = file->private_data;
switch (cmd) {
case LTTNG_KERNEL_ABI_ENABLE:
- return lttng_event_enabler_enable(&event_notifier_enabler->parent);
+ return lttng_event_enabler_enable(event);
case LTTNG_KERNEL_ABI_DISABLE:
- return lttng_event_enabler_disable(&event_notifier_enabler->parent);
+ return lttng_event_enabler_disable(event);
case LTTNG_KERNEL_ABI_FILTER:
- return lttng_event_enabler_attach_filter_bytecode(&event_notifier_enabler->parent,
+ return lttng_event_enabler_attach_filter_bytecode(event,
(struct lttng_kernel_abi_filter_bytecode __user *) arg);
case LTTNG_KERNEL_ABI_CAPTURE:
+ {
+ struct lttng_event_notifier_enabler *event_notifier_enabler =
+ container_of(event, struct lttng_event_notifier_enabler, parent);
return lttng_event_notifier_enabler_attach_capture_bytecode(
event_notifier_enabler,
(struct lttng_kernel_abi_capture_bytecode __user *) arg);
+ }
case LTTNG_KERNEL_ABI_ADD_CALLSITE:
return -EINVAL;
default:
static
int lttng_event_notifier_event_release(struct inode *inode, struct file *file)
{
- struct lttng_kernel_event_notifier *event_notifier = file->private_data;
+ struct lttng_kernel_event_common *event = file->private_data;
- if (event_notifier)
+ if (event) {
+ struct lttng_kernel_event_notifier *event_notifier =
+ container_of(event, struct lttng_kernel_event_notifier, parent);
fput(event_notifier->priv->group->file);
+ }
return 0;
}
static
int lttng_event_notifier_enabler_release(struct inode *inode, struct file *file)
{
- struct lttng_event_notifier_enabler *event_notifier_enabler = file->private_data;
+ struct lttng_event_enabler_common *event_enabler = file->private_data;
- if (event_notifier_enabler)
+ if (event_enabler) {
+ struct lttng_event_notifier_enabler *event_notifier_enabler =
+ container_of(event_enabler, struct lttng_event_notifier_enabler, parent);
fput(event_notifier_enabler->group->file);
+ }
return 0;
}
static
int lttng_abi_create_event_notifier(struct file *event_notifier_group_file,
- struct lttng_kernel_abi_event_notifier *event_notifier_param)
+ struct lttng_kernel_abi_event_notifier *event_notifier_param,
+ struct lttng_kernel_abi_event_ext *event_param_ext)
{
struct lttng_event_notifier_group *event_notifier_group =
event_notifier_group_file->private_data;
struct file *event_notifier_file;
void *priv;
- switch (event_notifier_param->event.instrumentation) {
- case LTTNG_KERNEL_ABI_TRACEPOINT:
- case LTTNG_KERNEL_ABI_UPROBE:
- break;
- case LTTNG_KERNEL_ABI_KPROBE:
- event_notifier_param->event.u.kprobe.symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1] = '\0';
- break;
- case LTTNG_KERNEL_ABI_SYSCALL:
- break;
- case LTTNG_KERNEL_ABI_KRETPROBE:
- /* Placing an event notifier on kretprobe is not supported. */
- case LTTNG_KERNEL_ABI_FUNCTION:
- case LTTNG_KERNEL_ABI_NOOP:
- default:
- ret = -EINVAL;
- goto inval_instr;
- }
-
switch (event_notifier_param->event.instrumentation) {
case LTTNG_KERNEL_ABI_TRACEPOINT:
lttng_fallthrough;
case LTTNG_KERNEL_ABI_SYSCALL:
- fops = <tng_event_notifier_enabler_fops;
- break;
+ lttng_fallthrough;
case LTTNG_KERNEL_ABI_KPROBE:
lttng_fallthrough;
case LTTNG_KERNEL_ABI_KRETPROBE:
- lttng_fallthrough;
+ fops = <tng_event_notifier_enabler_fops;
+ break;
+
case LTTNG_KERNEL_ABI_UPROBE:
fops = <tng_event_notifier_event_fops;
break;
}
event_notifier_param->event.name[LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1] = '\0';
+ switch (event_notifier_param->event.instrumentation) {
+ case LTTNG_KERNEL_ABI_KRETPROBE:
+ event_notifier_param->event.u.kretprobe.symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1] = '\0';
+ break;
+ case LTTNG_KERNEL_ABI_KPROBE:
+ event_notifier_param->event.u.kprobe.symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1] = '\0';
+ break;
+ default:
+ break;
+ }
event_notifier_fd = get_unused_fd_flags(0);
if (event_notifier_fd < 0) {
goto refcount_error;
}
- ret = lttng_abi_validate_event_param(&event_notifier_param->event);
+ ret = lttng_abi_validate_event_param(&event_notifier_param->event, event_param_ext);
+ if (ret)
+ goto event_notifier_error;
+ ret = lttng_abi_validate_event_match(&event_notifier_param->event, event_param_ext);
if (ret)
goto event_notifier_error;
case LTTNG_KERNEL_ABI_KPROBE:
lttng_fallthrough;
case LTTNG_KERNEL_ABI_KRETPROBE:
- lttng_fallthrough;
+ {
+ struct lttng_event_notifier_enabler *enabler;
+
+ enabler = lttng_event_notifier_enabler_create(LTTNG_ENABLER_FORMAT_NAME,
+ event_notifier_param, event_notifier_group);
+ if (enabler)
+ lttng_event_notifier_enabler_group_add(event_notifier_group, enabler);
+ priv = enabler;
+ break;
+ }
+
case LTTNG_KERNEL_ABI_UPROBE:
{
struct lttng_kernel_event_common *event;
ret = -ENOMEM;
goto event_notifier_error;
}
- event = lttng_kernel_event_create(&event_notifier_enabler->parent, NULL);
- WARN_ON_ONCE(IS_ERR(event));
+ event = lttng_kernel_event_create(&event_notifier_enabler->parent, NULL, NULL);
lttng_event_enabler_destroy(&event_notifier_enabler->parent);
if (IS_ERR(event)) {
ret = PTR_ERR(event);
goto event_notifier_error;
}
- priv = container_of(event, struct lttng_kernel_event_notifier, parent);
+ priv = event;
break;
}
return ret;
}
+static
+long lttng_abi_session_create_counter(
+ struct lttng_kernel_session *session,
+ const struct lttng_kernel_counter_conf *counter_conf)
+{
+ int counter_fd, ret;
+ char *counter_transport_name;
+ struct lttng_kernel_channel_counter *chan_counter = NULL;
+ struct file *counter_file;
+
+ if (counter_conf->arithmetic != LTTNG_KERNEL_COUNTER_ARITHMETIC_MODULAR) {
+ printk(KERN_ERR "LTTng: Maps: Counter of the wrong arithmetic type.\n");
+ return -EINVAL;
+ }
+
+ switch (counter_conf->bitness) {
+ case LTTNG_KERNEL_COUNTER_BITNESS_64:
+ counter_transport_name = "counter-per-cpu-64-modular";
+ break;
+ case LTTNG_KERNEL_COUNTER_BITNESS_32:
+ counter_transport_name = "counter-per-cpu-32-modular";
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ lttng_lock_sessions();
+
+ counter_fd = get_unused_fd_flags(0);
+ if (counter_fd < 0) {
+ ret = counter_fd;
+ goto fd_error;
+ }
+
+ counter_file = anon_inode_getfile("[lttng_counter]",
+ <tng_counter_fops,
+ NULL, O_RDONLY);
+ if (IS_ERR(counter_file)) {
+ ret = PTR_ERR(counter_file);
+ goto file_error;
+ }
+
+ if (!atomic_long_add_unless(&session->priv->file->f_count, 1, LONG_MAX)) {
+ ret = -EOVERFLOW;
+ goto refcount_error;
+ }
+
+ chan_counter = lttng_kernel_counter_create(counter_transport_name, 1, counter_conf->dimension_array, 0,
+ counter_conf->flags & LTTNG_KERNEL_COUNTER_CONF_FLAG_COALESCE_HITS);
+ if (!chan_counter) {
+ ret = -EINVAL;
+ goto create_error;
+ }
+
+ chan_counter->priv->parent.file = counter_file;
+ chan_counter->priv->owner = session->priv->file;
+ chan_counter->parent.session = session;
+ list_add(&chan_counter->priv->parent.node, &session->priv->chan_head);
+ counter_file->private_data = chan_counter;
+
+ fd_install(counter_fd, counter_file);
+ lttng_unlock_sessions();
+
+ return counter_fd;
+
+create_error:
+ atomic_long_dec(&session->priv->file->f_count);
+refcount_error:
+ fput(counter_file);
+file_error:
+ put_unused_fd(counter_fd);
+fd_error:
+ lttng_unlock_sessions();
+ return ret;
+}
+
static
long lttng_abi_event_notifier_group_create_error_counter(
struct file *event_notifier_group_file,
- const struct lttng_kernel_abi_counter_conf *error_counter_conf)
+ const struct lttng_kernel_counter_conf *counter_conf)
{
int counter_fd, ret;
char *counter_transport_name;
- size_t counter_len;
- struct lttng_counter *counter = NULL;
+ struct lttng_kernel_channel_counter *chan_counter = NULL;
struct file *counter_file;
struct lttng_event_notifier_group *event_notifier_group =
(struct lttng_event_notifier_group *) event_notifier_group_file->private_data;
+ size_t counter_len;
- if (error_counter_conf->arithmetic != LTTNG_KERNEL_ABI_COUNTER_ARITHMETIC_MODULAR) {
+ if (counter_conf->arithmetic != LTTNG_KERNEL_COUNTER_ARITHMETIC_MODULAR) {
printk(KERN_ERR "LTTng: event_notifier: Error counter of the wrong arithmetic type.\n");
return -EINVAL;
}
- if (error_counter_conf->number_dimensions != 1) {
- printk(KERN_ERR "LTTng: event_notifier: Error counter has more than one dimension.\n");
- return -EINVAL;
- }
-
- switch (error_counter_conf->bitness) {
- case LTTNG_KERNEL_ABI_COUNTER_BITNESS_64:
+ switch (counter_conf->bitness) {
+ case LTTNG_KERNEL_COUNTER_BITNESS_64:
counter_transport_name = "counter-per-cpu-64-modular";
break;
- case LTTNG_KERNEL_ABI_COUNTER_BITNESS_32:
+ case LTTNG_KERNEL_COUNTER_BITNESS_32:
counter_transport_name = "counter-per-cpu-32-modular";
break;
default:
goto file_error;
}
- counter_len = error_counter_conf->dimensions[0].size;
-
if (!atomic_long_add_unless(&event_notifier_group_file->f_count, 1, LONG_MAX)) {
ret = -EOVERFLOW;
goto refcount_error;
}
- counter = lttng_kernel_counter_create(counter_transport_name,
- 1, &counter_len);
- if (!counter) {
+ counter_len = counter_conf->dimension_array[0].size;
+ chan_counter = lttng_kernel_counter_create(counter_transport_name, 1, counter_conf->dimension_array, 0, false);
+ if (!chan_counter) {
ret = -EINVAL;
- goto counter_error;
+ goto create_error;
}
+ chan_counter->priv->parent.file = counter_file;
+ chan_counter->priv->owner = event_notifier_group->file;
+ counter_file->private_data = chan_counter;
event_notifier_group->error_counter_len = counter_len;
/*
* store-release to publish error counter matches load-acquire
* in record_error. Ensures the counter is created and the
* error_counter_len is set before they are used.
*/
- smp_store_release(&event_notifier_group->error_counter, counter);
-
- counter->file = counter_file;
- counter->owner = event_notifier_group->file;
- counter_file->private_data = counter;
- /* Ownership transferred. */
- counter = NULL;
+ smp_store_release(&event_notifier_group->error_counter,
+ chan_counter);
fd_install(counter_fd, counter_file);
lttng_unlock_sessions();
return counter_fd;
-counter_error:
+create_error:
atomic_long_dec(&event_notifier_group_file->f_count);
refcount_error:
fput(counter_file);
long lttng_event_notifier_group_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
+ int ret;
+
switch (cmd) {
case LTTNG_KERNEL_ABI_EVENT_NOTIFIER_GROUP_NOTIFICATION_FD:
{
case LTTNG_KERNEL_ABI_EVENT_NOTIFIER_CREATE:
{
struct lttng_kernel_abi_event_notifier uevent_notifier_param;
+ struct lttng_kernel_abi_event_ext uevent_param_ext = {};
+ int ret;
if (copy_from_user(&uevent_notifier_param,
(struct lttng_kernel_abi_event_notifier __user *) arg,
sizeof(uevent_notifier_param)))
return -EFAULT;
- return lttng_abi_create_event_notifier(file, &uevent_notifier_param);
+ ret = copy_user_event_param_ext(&uevent_param_ext, &uevent_notifier_param.event);
+ if (ret)
+ return ret;
+ return lttng_abi_create_event_notifier(file, &uevent_notifier_param, &uevent_param_ext);
+ }
+ case LTTNG_KERNEL_ABI_OLD_COUNTER:
+ {
+ struct lttng_kernel_counter_conf counter_conf;
+
+ ret = lttng_abi_copy_user_old_counter_conf(&counter_conf,
+ (struct lttng_kernel_abi_old_counter_conf __user *) arg);
+ if (ret)
+ return ret;
+ return lttng_abi_event_notifier_group_create_error_counter(file, &counter_conf);
}
case LTTNG_KERNEL_ABI_COUNTER:
{
- struct lttng_kernel_abi_counter_conf uerror_counter_conf;
+ struct lttng_kernel_counter_conf counter_conf;
- if (copy_from_user(&uerror_counter_conf,
- (struct lttng_kernel_abi_counter_conf __user *) arg,
- sizeof(uerror_counter_conf)))
- return -EFAULT;
- return lttng_abi_event_notifier_group_create_error_counter(file,
- &uerror_counter_conf);
+ ret = lttng_abi_copy_user_counter_conf(&counter_conf,
+ (struct lttng_kernel_abi_counter_conf __user *) arg);
+ if (ret)
+ return ret;
+ return lttng_abi_event_notifier_group_create_error_counter(file, &counter_conf);
}
default:
return -ENOIOCTLCMD;
default:
break;
}
- ret = lttng_abi_create_event(file, uevent_param);
+ ret = lttng_abi_create_event_recorder_enabler(file, uevent_param, NULL);
old_event_error_free_old_param:
kfree(old_uevent_param);
case LTTNG_KERNEL_ABI_EVENT:
{
struct lttng_kernel_abi_event uevent_param;
+ struct lttng_kernel_abi_event_ext uevent_param_ext = {};
+ int ret;
if (copy_from_user(&uevent_param,
(struct lttng_kernel_abi_event __user *) arg,
sizeof(uevent_param)))
return -EFAULT;
- return lttng_abi_create_event(file, &uevent_param);
+ ret = copy_user_event_param_ext(&uevent_param_ext, &uevent_param);
+ if (ret)
+ return ret;
+ return lttng_abi_create_event_recorder_enabler(file, &uevent_param, &uevent_param_ext);
}
case LTTNG_KERNEL_ABI_OLD_CONTEXT:
{
if (channel) {
fput(channel->parent.session->priv->file);
- lttng_metadata_channel_destroy(channel);
+ lttng_metadata_channel_buffer_destroy(channel);
}
return 0;
};
/**
- * lttng_event_recorder_event_ioctl - lttng syscall through ioctl
+ * lttng_event_ioctl - lttng syscall through ioctl
*
* @file: the file
* @cmd: the command
* Disable recording for this event (strong disable)
*/
static
-long lttng_event_recorder_event_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+long lttng_event_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
- struct lttng_kernel_event_recorder *event_recorder = file->private_data;
+ struct lttng_kernel_event_common *event = file->private_data;
switch (cmd) {
case LTTNG_KERNEL_ABI_OLD_CONTEXT:
}
case LTTNG_KERNEL_ABI_OLD_ENABLE:
case LTTNG_KERNEL_ABI_ENABLE:
- return lttng_event_enable(&event_recorder->parent);
+ return lttng_event_enable(event);
case LTTNG_KERNEL_ABI_OLD_DISABLE:
case LTTNG_KERNEL_ABI_DISABLE:
- return lttng_event_disable(&event_recorder->parent);
+ return lttng_event_disable(event);
case LTTNG_KERNEL_ABI_FILTER:
return -EINVAL;
case LTTNG_KERNEL_ABI_ADD_CALLSITE:
- return lttng_event_add_callsite(&event_recorder->parent,
+ return lttng_event_add_callsite(event,
(struct lttng_kernel_abi_event_callsite __user *) arg);
default:
return -ENOIOCTLCMD;
* Disable recording for this event (strong disable)
*/
static
-long lttng_event_recorder_enabler_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+long lttng_event_enabler_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
- struct lttng_event_recorder_enabler *event_enabler = file->private_data;
+ struct lttng_event_enabler_common *event_enabler = file->private_data;
switch (cmd) {
case LTTNG_KERNEL_ABI_OLD_CONTEXT:
}
case LTTNG_KERNEL_ABI_OLD_ENABLE:
case LTTNG_KERNEL_ABI_ENABLE:
- return lttng_event_enabler_enable(&event_enabler->parent);
+ return lttng_event_enabler_enable(event_enabler);
case LTTNG_KERNEL_ABI_OLD_DISABLE:
case LTTNG_KERNEL_ABI_DISABLE:
- return lttng_event_enabler_disable(&event_enabler->parent);
+ return lttng_event_enabler_disable(event_enabler);
case LTTNG_KERNEL_ABI_FILTER:
- return lttng_event_enabler_attach_filter_bytecode(&event_enabler->parent,
- (struct lttng_kernel_abi_filter_bytecode __user *) arg);
+ /*
+ * Filters are only supported by tracepoint and syscall instrumentation.
+ */
+ switch (event_enabler->event_param.instrumentation) {
+ case LTTNG_KERNEL_ABI_TRACEPOINT:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_SYSCALL:
+ return lttng_event_enabler_attach_filter_bytecode(event_enabler,
+ (struct lttng_kernel_abi_filter_bytecode __user *) arg);
+
+ default:
+ return -EINVAL;
+ }
case LTTNG_KERNEL_ABI_ADD_CALLSITE:
return -EINVAL;
default:
}
static
-int lttng_event_recorder_event_release(struct inode *inode, struct file *file)
+int lttng_event_session_release(struct inode *inode, struct file *file)
{
- struct lttng_kernel_event_recorder *event = file->private_data;
+ struct lttng_kernel_event_common *event = file->private_data;
- if (event)
- fput(event->chan->priv->parent.file);
+ if (event) {
+ struct lttng_kernel_event_session_common_private *event_session_priv =
+ container_of(event->priv, struct lttng_kernel_event_session_common_private, parent);
+ fput(event_session_priv->chan->priv->file);
+ }
return 0;
}
static
-int lttng_event_recorder_enabler_release(struct inode *inode, struct file *file)
+int lttng_event_session_enabler_release(struct inode *inode, struct file *file)
{
- struct lttng_event_recorder_enabler *event_enabler = file->private_data;
+ struct lttng_event_enabler_common *event_enabler = file->private_data;
- if (event_enabler)
- fput(event_enabler->chan->priv->parent.file);
+ if (event_enabler) {
+ struct lttng_event_enabler_session_common *event_session_enabler =
+ container_of(event_enabler, struct lttng_event_enabler_session_common, parent);
+ fput(event_session_enabler->chan->priv->file);
+ }
return 0;
}
-static const struct file_operations lttng_event_recorder_event_fops = {
+static const struct file_operations lttng_event_session_fops = {
.owner = THIS_MODULE,
- .release = lttng_event_recorder_event_release,
- .unlocked_ioctl = lttng_event_recorder_event_ioctl,
+ .release = lttng_event_session_release,
+ .unlocked_ioctl = lttng_event_ioctl,
#ifdef CONFIG_COMPAT
- .compat_ioctl = lttng_event_recorder_event_ioctl,
+ .compat_ioctl = lttng_event_ioctl,
#endif
};
-static const struct file_operations lttng_event_recorder_enabler_fops = {
+static const struct file_operations lttng_event_session_enabler_fops = {
.owner = THIS_MODULE,
- .release = lttng_event_recorder_enabler_release,
- .unlocked_ioctl = lttng_event_recorder_enabler_ioctl,
+ .release = lttng_event_session_enabler_release,
+ .unlocked_ioctl = lttng_event_enabler_ioctl,
#ifdef CONFIG_COMPAT
- .compat_ioctl = lttng_event_recorder_enabler_ioctl,
+ .compat_ioctl = lttng_event_enabler_ioctl,
#endif
};
.counter_size = COUNTER_SIZE_32_BIT,
};
-static struct lib_counter *counter_create(size_t nr_dimensions,
- const size_t *max_nr_elem,
+static struct lttng_kernel_channel_counter *counter_create(size_t nr_dimensions,
+ const struct lttng_kernel_counter_dimension *dimensions,
int64_t global_sum_step)
{
- return lttng_counter_create(&client_config, nr_dimensions, max_nr_elem,
+ size_t max_nr_elem[LTTNG_KERNEL_COUNTER_MAX_DIMENSIONS], i;
+ struct lttng_kernel_channel_counter *lttng_chan_counter;
+ struct lib_counter *counter;
+
+ if (nr_dimensions > LTTNG_KERNEL_COUNTER_MAX_DIMENSIONS)
+ return NULL;
+ for (i = 0; i < nr_dimensions; i++) {
+ if ((dimensions[i].flags & LTTNG_KERNEL_COUNTER_DIMENSION_FLAG_UNDERFLOW)
+ || (dimensions[i].flags & LTTNG_KERNEL_COUNTER_DIMENSION_FLAG_OVERFLOW))
+ return NULL;
+ max_nr_elem[i] = dimensions[i].size;
+ }
+ lttng_chan_counter = lttng_kernel_alloc_channel_counter();
+ if (!lttng_chan_counter)
+ return NULL;
+ counter = lttng_counter_create(&client_config, nr_dimensions, max_nr_elem,
global_sum_step);
+ if (!counter)
+ goto error;
+ lttng_chan_counter->priv->counter = counter;
+ return lttng_chan_counter;
+
+error:
+ lttng_kernel_free_channel_common(<tng_chan_counter->parent);
+ return NULL;
+}
+
+static void counter_destroy(struct lttng_kernel_channel_counter *counter)
+{
+ lttng_counter_destroy(counter->priv->counter);
+ lttng_kernel_free_channel_common(&counter->parent);
}
-static void counter_destroy(struct lib_counter *counter)
+static int counter_add(struct lttng_kernel_channel_counter *counter,
+ const size_t *dimension_indexes, int64_t v)
{
- return lttng_counter_destroy(counter);
+ return lttng_counter_add(&client_config, counter->priv->counter, dimension_indexes, v);
}
-static int counter_add(struct lib_counter *counter, const size_t *dimension_indexes, int64_t v)
+static int counter_hit(struct lttng_kernel_event_counter *event_counter,
+ const char *stack_data __attribute__((unused)),
+ struct lttng_kernel_probe_ctx *probe_ctx __attribute__((unused)),
+ struct lttng_kernel_event_counter_ctx *event_counter_ctx __attribute__((unused)))
{
- return lttng_counter_add(&client_config, counter, dimension_indexes, v);
+ struct lttng_kernel_channel_counter *counter = event_counter->chan;
+
+ switch (event_counter->priv->action) {
+ case LTTNG_EVENT_COUNTER_ACTION_INCREMENT:
+ {
+ size_t index = event_counter->priv->parent.id;
+ return counter_add(counter, &index, 1);
+ }
+ default:
+ return -ENOSYS;
+ }
}
-static int counter_read(struct lib_counter *counter, const size_t *dimension_indexes, int cpu,
+static int counter_read(struct lttng_kernel_channel_counter *counter, const size_t *dimension_indexes, int cpu,
int64_t *value, bool *overflow, bool *underflow)
{
- return lttng_counter_read(&client_config, counter, dimension_indexes, cpu, value,
+ return lttng_counter_read(&client_config, counter->priv->counter, dimension_indexes, cpu, value,
overflow, underflow);
}
-static int counter_aggregate(struct lib_counter *counter, const size_t *dimension_indexes,
+static int counter_aggregate(struct lttng_kernel_channel_counter *counter, const size_t *dimension_indexes,
int64_t *value, bool *overflow, bool *underflow)
{
- return lttng_counter_aggregate(&client_config, counter, dimension_indexes, value,
+ return lttng_counter_aggregate(&client_config, counter->priv->counter, dimension_indexes, value,
overflow, underflow);
}
-static int counter_clear(struct lib_counter *counter, const size_t *dimension_indexes)
+static int counter_clear(struct lttng_kernel_channel_counter *counter, const size_t *dimension_indexes)
+{
+ return lttng_counter_clear(&client_config, counter->priv->counter, dimension_indexes);
+}
+
+static int counter_get_nr_dimensions(struct lttng_kernel_channel_counter *counter, size_t *nr_dimensions)
+{
+ return lttng_counter_get_nr_dimensions(&client_config, counter->priv->counter, nr_dimensions);
+}
+
+static int counter_get_max_nr_elem(struct lttng_kernel_channel_counter *counter, size_t *max_nr_elem)
{
- return lttng_counter_clear(&client_config, counter, dimension_indexes);
+ return lttng_counter_get_max_nr_elem(&client_config, counter->priv->counter, max_nr_elem);
}
static struct lttng_counter_transport lttng_counter_transport = {
.name = "counter-per-cpu-32-modular",
.owner = THIS_MODULE,
.ops = {
- .counter_create = counter_create,
- .counter_destroy = counter_destroy,
- .counter_add = counter_add,
- .counter_read = counter_read,
- .counter_aggregate = counter_aggregate,
- .counter_clear = counter_clear,
+ .priv = __LTTNG_COMPOUND_LITERAL(struct lttng_kernel_channel_counter_ops_private, {
+ .pub = <tng_counter_transport.ops,
+ .counter_create = counter_create,
+ .counter_destroy = counter_destroy,
+ .counter_add = counter_add,
+ .counter_read = counter_read,
+ .counter_aggregate = counter_aggregate,
+ .counter_clear = counter_clear,
+ .counter_get_nr_dimensions = counter_get_nr_dimensions,
+ .counter_get_max_nr_elem = counter_get_max_nr_elem,
+ }),
+ .counter_hit = counter_hit,
},
};
.counter_size = COUNTER_SIZE_64_BIT,
};
-static struct lib_counter *counter_create(size_t nr_dimensions,
- const size_t *max_nr_elem,
+static struct lttng_kernel_channel_counter *counter_create(size_t nr_dimensions,
+ const struct lttng_kernel_counter_dimension *dimensions,
int64_t global_sum_step)
{
- return lttng_counter_create(&client_config, nr_dimensions, max_nr_elem,
+ size_t max_nr_elem[LTTNG_KERNEL_COUNTER_MAX_DIMENSIONS], i;
+ struct lttng_kernel_channel_counter *lttng_chan_counter;
+ struct lib_counter *counter;
+
+ if (nr_dimensions > LTTNG_KERNEL_COUNTER_MAX_DIMENSIONS)
+ return NULL;
+ for (i = 0; i < nr_dimensions; i++) {
+ if ((dimensions[i].flags & LTTNG_KERNEL_COUNTER_DIMENSION_FLAG_UNDERFLOW)
+ || (dimensions[i].flags & LTTNG_KERNEL_COUNTER_DIMENSION_FLAG_OVERFLOW))
+ return NULL;
+ max_nr_elem[i] = dimensions[i].size;
+ }
+ lttng_chan_counter = lttng_kernel_alloc_channel_counter();
+ if (!lttng_chan_counter)
+ return NULL;
+ counter = lttng_counter_create(&client_config, nr_dimensions, max_nr_elem,
global_sum_step);
+ if (!counter)
+ goto error;
+ lttng_chan_counter->priv->counter = counter;
+ return lttng_chan_counter;
+
+error:
+ lttng_kernel_free_channel_common(<tng_chan_counter->parent);
+ return NULL;
+}
+
+static void counter_destroy(struct lttng_kernel_channel_counter *counter)
+{
+ lttng_counter_destroy(counter->priv->counter);
+ lttng_kernel_free_channel_common(&counter->parent);
}
-static void counter_destroy(struct lib_counter *counter)
+static int counter_add(struct lttng_kernel_channel_counter *counter,
+ const size_t *dimension_indexes, int64_t v)
{
- return lttng_counter_destroy(counter);
+ return lttng_counter_add(&client_config, counter->priv->counter, dimension_indexes, v);
}
-static int counter_add(struct lib_counter *counter, const size_t *dimension_indexes, int64_t v)
+static int counter_hit(struct lttng_kernel_event_counter *event_counter,
+ const char *stack_data __attribute__((unused)),
+ struct lttng_kernel_probe_ctx *probe_ctx __attribute__((unused)),
+ struct lttng_kernel_event_counter_ctx *event_counter_ctx __attribute__((unused)))
{
- return lttng_counter_add(&client_config, counter, dimension_indexes, v);
+ struct lttng_kernel_channel_counter *counter = event_counter->chan;
+
+ switch (event_counter->priv->action) {
+ case LTTNG_EVENT_COUNTER_ACTION_INCREMENT:
+ {
+ size_t index = event_counter->priv->parent.id;
+ return counter_add(counter, &index, 1);
+ }
+ default:
+ return -ENOSYS;
+ }
}
-static int counter_read(struct lib_counter *counter, const size_t *dimension_indexes, int cpu,
+static int counter_read(struct lttng_kernel_channel_counter *counter, const size_t *dimension_indexes, int cpu,
int64_t *value, bool *overflow, bool *underflow)
{
- return lttng_counter_read(&client_config, counter, dimension_indexes, cpu, value,
+ return lttng_counter_read(&client_config, counter->priv->counter, dimension_indexes, cpu, value,
overflow, underflow);
}
-static int counter_aggregate(struct lib_counter *counter, const size_t *dimension_indexes,
+static int counter_aggregate(struct lttng_kernel_channel_counter *counter, const size_t *dimension_indexes,
int64_t *value, bool *overflow, bool *underflow)
{
- return lttng_counter_aggregate(&client_config, counter, dimension_indexes, value,
+ return lttng_counter_aggregate(&client_config, counter->priv->counter, dimension_indexes, value,
overflow, underflow);
}
-static int counter_clear(struct lib_counter *counter, const size_t *dimension_indexes)
+static int counter_clear(struct lttng_kernel_channel_counter *counter, const size_t *dimension_indexes)
+{
+ return lttng_counter_clear(&client_config, counter->priv->counter, dimension_indexes);
+}
+
+static int counter_get_nr_dimensions(struct lttng_kernel_channel_counter *counter, size_t *nr_dimensions)
+{
+ return lttng_counter_get_nr_dimensions(&client_config, counter->priv->counter, nr_dimensions);
+}
+
+static int counter_get_max_nr_elem(struct lttng_kernel_channel_counter *counter, size_t *max_nr_elem)
{
- return lttng_counter_clear(&client_config, counter, dimension_indexes);
+ return lttng_counter_get_max_nr_elem(&client_config, counter->priv->counter, max_nr_elem);
}
static struct lttng_counter_transport lttng_counter_transport = {
.name = "counter-per-cpu-64-modular",
.owner = THIS_MODULE,
.ops = {
- .counter_create = counter_create,
- .counter_destroy = counter_destroy,
- .counter_add = counter_add,
- .counter_read = counter_read,
- .counter_aggregate = counter_aggregate,
- .counter_clear = counter_clear,
+ .priv = __LTTNG_COMPOUND_LITERAL(struct lttng_kernel_channel_counter_ops_private, {
+ .pub = <tng_counter_transport.ops,
+ .counter_create = counter_create,
+ .counter_destroy = counter_destroy,
+ .counter_add = counter_add,
+ .counter_read = counter_read,
+ .counter_aggregate = counter_aggregate,
+ .counter_clear = counter_clear,
+ .counter_get_nr_dimensions = counter_get_nr_dimensions,
+ .counter_get_max_nr_elem = counter_get_max_nr_elem,
+ }),
+ .counter_hit = counter_hit,
},
};
{
struct lttng_event_notifier_group *event_notifier_group = event_notifier->priv->group;
- struct lttng_counter *error_counter;
+ struct lttng_kernel_channel_counter *error_counter;
size_t dimension_index[1];
int ret;
dimension_index[0] = event_notifier->priv->error_counter_index;
- ret = error_counter->ops->counter_add(error_counter->counter,
- dimension_index, 1);
+ ret = error_counter->ops->priv->counter_add(error_counter, dimension_index, 1);
if (ret)
WARN_ON_ONCE(1);
}
#include <lttng/endian.h>
#include <lttng/string-utils.h>
#include <lttng/utils.h>
+#include <counter/counter.h>
#include <ringbuffer/backend.h>
#include <ringbuffer/frontend.h>
static DEFINE_MUTEX(sessions_mutex);
static struct kmem_cache *event_recorder_cache;
static struct kmem_cache *event_recorder_private_cache;
+static struct kmem_cache *event_counter_cache;
+static struct kmem_cache *event_counter_private_cache;
static struct kmem_cache *event_notifier_cache;
static struct kmem_cache *event_notifier_private_cache;
static void lttng_event_enabler_sync(struct lttng_event_enabler_common *event_enabler);
static void _lttng_event_destroy(struct lttng_kernel_event_common *event);
-static void _lttng_channel_destroy(struct lttng_kernel_channel_buffer *chan);
+static void _lttng_channel_destroy(struct lttng_kernel_channel_common *chan);
static void _lttng_event_unregister(struct lttng_kernel_event_common *event);
static
int _lttng_event_recorder_metadata_statedump(struct lttng_kernel_event_common *event);
{
struct lttng_kernel_session_private *iter;
- list_for_each_entry(iter, &sessions, list) {
+ list_for_each_entry(iter, &sessions, node) {
if (iter->pub->active)
return 1;
}
session->priv = session_priv;
session_priv->pub = session;
- INIT_LIST_HEAD(&session_priv->chan);
- INIT_LIST_HEAD(&session_priv->events);
+ INIT_LIST_HEAD(&session_priv->chan_head);
+ INIT_LIST_HEAD(&session_priv->events_head);
lttng_guid_gen(&session_priv->uuid);
metadata_cache = kzalloc(sizeof(struct lttng_metadata_cache),
sizeof(metadata_cache->uuid));
INIT_LIST_HEAD(&session_priv->enablers_head);
for (i = 0; i < LTTNG_EVENT_HT_SIZE; i++)
- INIT_HLIST_HEAD(&session_priv->events_ht.table[i]);
- list_add(&session_priv->list, &sessions);
+ INIT_HLIST_HEAD(&session_priv->events_name_ht.table[i]);
+ for (i = 0; i < LTTNG_EVENT_HT_SIZE; i++)
+ INIT_HLIST_HEAD(&session_priv->events_key_ht.table[i]);
+ list_add(&session_priv->node, &sessions);
if (lttng_id_tracker_init(&session->pid_tracker, session, TRACKER_PID))
goto tracker_alloc_error;
return NULL;
}
-struct lttng_counter *lttng_kernel_counter_create(
+struct lttng_kernel_channel_counter *lttng_kernel_counter_create(
const char *counter_transport_name,
- size_t number_dimensions, const size_t *dimensions_sizes)
+ size_t number_dimensions,
+ const struct lttng_kernel_counter_dimension *dimensions,
+ int64_t global_sum_step,
+ bool coalesce_hits)
{
- struct lttng_counter *counter = NULL;
struct lttng_counter_transport *counter_transport = NULL;
+ struct lttng_kernel_channel_counter *counter = NULL;
counter_transport = lttng_counter_transport_find(counter_transport_name);
if (!counter_transport) {
goto notransport;
}
- counter = lttng_kvzalloc(sizeof(struct lttng_counter), GFP_KERNEL);
+ counter = counter_transport->ops.priv->counter_create(number_dimensions, dimensions,
+ global_sum_step);
if (!counter)
- goto nomem;
+ goto create_error;
/* Create event notifier error counter. */
counter->ops = &counter_transport->ops;
- counter->transport = counter_transport;
-
- counter->counter = counter->ops->counter_create(
- number_dimensions, dimensions_sizes, 0);
- if (!counter->counter) {
- goto create_error;
- }
+ counter->priv->parent.coalesce_hits = coalesce_hits;
+ counter->priv->transport = counter_transport;
+ mutex_init(&counter->priv->map.lock);
return counter;
create_error:
- lttng_kvfree(counter);
-nomem:
if (counter_transport)
module_put(counter_transport->owner);
notransport:
return NULL;
}
+static
+void lttng_kernel_counter_destroy(struct lttng_kernel_channel_counter *counter)
+{
+ struct lttng_counter_transport *counter_transport = counter->priv->transport;
+
+ lttng_kvfree(counter->priv->map.descriptors);
+ counter->ops->priv->counter_destroy(counter);
+ module_put(counter_transport->owner);
+}
+
struct lttng_event_notifier_group *lttng_event_notifier_group_create(void)
{
struct lttng_transport *transport = NULL;
INIT_LIST_HEAD(&event_notifier_group->enablers_head);
INIT_LIST_HEAD(&event_notifier_group->event_notifiers_head);
for (i = 0; i < LTTNG_EVENT_HT_SIZE; i++)
- INIT_HLIST_HEAD(&event_notifier_group->events_ht.table[i]);
+ INIT_HLIST_HEAD(&event_notifier_group->events_name_ht.table[i]);
list_add(&event_notifier_group->node, &event_notifier_groups);
void lttng_session_destroy(struct lttng_kernel_session *session)
{
- struct lttng_kernel_channel_buffer_private *chan_priv, *tmpchan_priv;
+ struct lttng_kernel_channel_common_private *chan_priv, *tmpchan_priv;
struct lttng_kernel_event_recorder_private *event_recorder_priv, *tmpevent_recorder_priv;
struct lttng_metadata_stream *metadata_stream;
struct lttng_event_enabler_common *event_enabler, *tmp_event_enabler;
mutex_lock(&sessions_mutex);
WRITE_ONCE(session->active, 0);
- list_for_each_entry(chan_priv, &session->priv->chan, node) {
- ret = lttng_syscalls_unregister_syscall_table(&chan_priv->parent.syscall_table);
+ list_for_each_entry(chan_priv, &session->priv->chan_head, node) {
+ ret = lttng_syscalls_unregister_syscall_table(&chan_priv->syscall_table);
WARN_ON(ret);
}
- list_for_each_entry(event_recorder_priv, &session->priv->events, parent.node)
+ list_for_each_entry(event_recorder_priv, &session->priv->events_head, parent.parent.node)
_lttng_event_unregister(&event_recorder_priv->pub->parent);
synchronize_trace(); /* Wait for in-flight events to complete */
- list_for_each_entry(chan_priv, &session->priv->chan, node) {
- ret = lttng_syscalls_destroy_syscall_table(&chan_priv->parent.syscall_table);
+ list_for_each_entry(chan_priv, &session->priv->chan_head, node) {
+ ret = lttng_syscalls_destroy_syscall_table(&chan_priv->syscall_table);
WARN_ON(ret);
}
list_for_each_entry_safe(event_enabler, tmp_event_enabler, &session->priv->enablers_head, node)
lttng_event_enabler_destroy(event_enabler);
- list_for_each_entry_safe(event_recorder_priv, tmpevent_recorder_priv, &session->priv->events, parent.node)
+ list_for_each_entry_safe(event_recorder_priv, tmpevent_recorder_priv, &session->priv->events_head, parent.parent.node)
_lttng_event_destroy(&event_recorder_priv->pub->parent);
- list_for_each_entry_safe(chan_priv, tmpchan_priv, &session->priv->chan, node) {
- BUG_ON(chan_priv->channel_type == METADATA_CHANNEL);
+ list_for_each_entry_safe(chan_priv, tmpchan_priv, &session->priv->chan_head, node) {
_lttng_channel_destroy(chan_priv->pub);
}
mutex_lock(&session->priv->metadata_cache->lock);
- list_for_each_entry(metadata_stream, &session->priv->metadata_cache->metadata_stream, list)
+ list_for_each_entry(metadata_stream, &session->priv->metadata_cache->metadata_stream, node)
_lttng_metadata_channel_hangup(metadata_stream);
mutex_unlock(&session->priv->metadata_cache->lock);
lttng_id_tracker_fini(&session->pid_tracker);
lttng_id_tracker_fini(&session->gid_tracker);
lttng_id_tracker_fini(&session->vgid_tracker);
kref_put(&session->priv->metadata_cache->refcount, metadata_cache_destroy);
- list_del(&session->priv->list);
+ list_del(&session->priv->node);
mutex_unlock(&sessions_mutex);
lttng_kvfree(session->priv);
lttng_kvfree(session);
&event_notifier_group->event_notifiers_head, parent.node)
_lttng_event_destroy(&event_notifier_priv->pub->parent);
- if (event_notifier_group->error_counter) {
- struct lttng_counter *error_counter = event_notifier_group->error_counter;
-
- error_counter->ops->counter_destroy(error_counter->counter);
- module_put(error_counter->transport->owner);
- lttng_kvfree(error_counter);
- event_notifier_group->error_counter = NULL;
- }
+ if (event_notifier_group->error_counter)
+ lttng_kernel_counter_destroy(event_notifier_group->error_counter);
event_notifier_group->ops->priv->channel_destroy(event_notifier_group->chan);
module_put(event_notifier_group->transport->owner);
int lttng_session_enable(struct lttng_kernel_session *session)
{
int ret = 0;
- struct lttng_kernel_channel_buffer_private *chan_priv;
+ struct lttng_kernel_channel_common_private *chan_priv;
mutex_lock(&sessions_mutex);
if (session->active) {
* Snapshot the number of events per channel to know the type of header
* we need to use.
*/
- list_for_each_entry(chan_priv, &session->priv->chan, node) {
- if (chan_priv->header_type)
+ list_for_each_entry(chan_priv, &session->priv->chan_head, node) {
+ struct lttng_kernel_channel_buffer_private *chan_buf_priv;
+
+ if (chan_priv->pub->type != LTTNG_KERNEL_CHANNEL_TYPE_BUFFER)
+ continue;
+ chan_buf_priv = container_of(chan_priv, struct lttng_kernel_channel_buffer_private, parent);
+ if (chan_buf_priv->header_type)
continue; /* don't change it if session stop/restart */
- if (chan_priv->free_event_id < 31)
- chan_priv->header_type = 1; /* compact */
+ if (chan_buf_priv->free_event_id < 31)
+ chan_buf_priv->header_type = 1; /* compact */
else
- chan_priv->header_type = 2; /* large */
+ chan_buf_priv->header_type = 2; /* large */
}
/* Clear each stream's quiescent state. */
- list_for_each_entry(chan_priv, &session->priv->chan, node) {
- if (chan_priv->channel_type != METADATA_CHANNEL)
- lib_ring_buffer_clear_quiescent_channel(chan_priv->rb_chan);
+ list_for_each_entry(chan_priv, &session->priv->chan_head, node) {
+ struct lttng_kernel_channel_buffer_private *chan_buf_priv;
+
+ if (chan_priv->pub->type != LTTNG_KERNEL_CHANNEL_TYPE_BUFFER)
+ continue;
+ chan_buf_priv = container_of(chan_priv, struct lttng_kernel_channel_buffer_private, parent);
+ if (chan_buf_priv->channel_type != METADATA_CHANNEL)
+ lib_ring_buffer_clear_quiescent_channel(chan_buf_priv->rb_chan);
}
WRITE_ONCE(session->active, 1);
int lttng_session_disable(struct lttng_kernel_session *session)
{
int ret = 0;
- struct lttng_kernel_channel_buffer_private *chan_priv;
+ struct lttng_kernel_channel_common_private *chan_priv;
mutex_lock(&sessions_mutex);
if (!session->active) {
lttng_session_sync_event_enablers(session);
/* Set each stream's quiescent state. */
- list_for_each_entry(chan_priv, &session->priv->chan, node) {
- if (chan_priv->channel_type != METADATA_CHANNEL)
- lib_ring_buffer_set_quiescent_channel(chan_priv->rb_chan);
+ list_for_each_entry(chan_priv, &session->priv->chan_head, node) {
+ struct lttng_kernel_channel_buffer_private *chan_buf_priv;
+
+ if (chan_priv->pub->type != LTTNG_KERNEL_CHANNEL_TYPE_BUFFER)
+ continue;
+ chan_buf_priv = container_of(chan_priv, struct lttng_kernel_channel_buffer_private, parent);
+ if (chan_buf_priv->channel_type != METADATA_CHANNEL)
+ lib_ring_buffer_set_quiescent_channel(chan_buf_priv->rb_chan);
}
end:
mutex_unlock(&sessions_mutex);
int lttng_session_metadata_regenerate(struct lttng_kernel_session *session)
{
int ret = 0;
- struct lttng_kernel_channel_buffer_private *chan_priv;
+ struct lttng_kernel_channel_common_private *chan_priv;
struct lttng_kernel_event_recorder_private *event_recorder_priv;
struct lttng_metadata_cache *cache = session->priv->metadata_cache;
struct lttng_metadata_stream *stream;
memset(cache->data, 0, cache->cache_alloc);
cache->metadata_written = 0;
cache->version++;
- list_for_each_entry(stream, &session->priv->metadata_cache->metadata_stream, list) {
+ list_for_each_entry(stream, &session->priv->metadata_cache->metadata_stream, node) {
stream->metadata_out = 0;
stream->metadata_in = 0;
}
mutex_unlock(&cache->lock);
session->priv->metadata_dumped = 0;
- list_for_each_entry(chan_priv, &session->priv->chan, node) {
- chan_priv->metadata_dumped = 0;
+ list_for_each_entry(chan_priv, &session->priv->chan_head, node) {
+ struct lttng_kernel_channel_buffer_private *chan_buf_priv;
+
+ if (chan_priv->pub->type != LTTNG_KERNEL_CHANNEL_TYPE_BUFFER)
+ continue;
+ chan_buf_priv = container_of(chan_priv, struct lttng_kernel_channel_buffer_private, parent);
+ chan_buf_priv->metadata_dumped = 0;
}
- list_for_each_entry(event_recorder_priv, &session->priv->events, parent.node) {
+ list_for_each_entry(event_recorder_priv, &session->priv->events_head, parent.parent.node) {
event_recorder_priv->metadata_dumped = 0;
}
break;
}
case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
- switch (event->priv->instrumentation) {
- case LTTNG_KERNEL_ABI_KRETPROBE:
- ret = -EINVAL;
- goto end;
- default:
- break;
- }
+ lttng_fallthrough;
+ case LTTNG_KERNEL_EVENT_TYPE_COUNTER:
break;
default:
break;
case LTTNG_KERNEL_ABI_TRACEPOINT:
lttng_fallthrough;
case LTTNG_KERNEL_ABI_SYSCALL:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_KPROBE:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_KRETPROBE:
ret = -EINVAL;
break;
- case LTTNG_KERNEL_ABI_KPROBE:
- lttng_fallthrough;
case LTTNG_KERNEL_ABI_UPROBE:
WRITE_ONCE(event->enabled, 1);
break;
- case LTTNG_KERNEL_ABI_KRETPROBE:
- ret = lttng_kretprobes_event_enable_state(event, 1);
- break;
-
case LTTNG_KERNEL_ABI_FUNCTION:
lttng_fallthrough;
case LTTNG_KERNEL_ABI_NOOP:
break;
}
case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
- switch (event->priv->instrumentation) {
- case LTTNG_KERNEL_ABI_KRETPROBE:
- ret = -EINVAL;
- goto end;
- default:
- break;
- }
+ lttng_fallthrough;
+ case LTTNG_KERNEL_EVENT_TYPE_COUNTER:
break;
default:
break;
case LTTNG_KERNEL_ABI_TRACEPOINT:
lttng_fallthrough;
case LTTNG_KERNEL_ABI_SYSCALL:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_KPROBE:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_KRETPROBE:
ret = -EINVAL;
break;
- case LTTNG_KERNEL_ABI_KPROBE:
- lttng_fallthrough;
case LTTNG_KERNEL_ABI_UPROBE:
WRITE_ONCE(event->enabled, 0);
break;
- case LTTNG_KERNEL_ABI_KRETPROBE:
- ret = lttng_kretprobes_event_enable_state(event, 0);
- break;
-
case LTTNG_KERNEL_ABI_FUNCTION:
lttng_fallthrough;
case LTTNG_KERNEL_ABI_NOOP:
enum channel_type channel_type)
{
struct lttng_kernel_channel_buffer *chan;
- struct lttng_kernel_channel_buffer_private *chan_priv;
struct lttng_transport *transport = NULL;
mutex_lock(&sessions_mutex);
printk(KERN_WARNING "LTTng: Can't lock transport module.\n");
goto notransport;
}
- chan = kzalloc(sizeof(struct lttng_kernel_channel_buffer), GFP_KERNEL);
+ chan = lttng_kernel_alloc_channel_buffer();
if (!chan)
goto nomem;
- chan_priv = kzalloc(sizeof(struct lttng_kernel_channel_buffer_private), GFP_KERNEL);
- if (!chan_priv)
- goto nomem_priv;
- chan->priv = chan_priv;
- chan_priv->pub = chan;
- chan->parent.type = LTTNG_KERNEL_CHANNEL_TYPE_BUFFER;
chan->parent.session = session;
chan->priv->id = session->priv->free_chan_id++;
chan->ops = &transport->ops;
chan->parent.enabled = 1;
chan->priv->transport = transport;
chan->priv->channel_type = channel_type;
- list_add(&chan->priv->node, &session->priv->chan);
+ list_add(&chan->priv->parent.node, &session->priv->chan_head);
mutex_unlock(&sessions_mutex);
return chan;
create_error:
- kfree(chan_priv);
-nomem_priv:
- kfree(chan);
+ lttng_kernel_free_channel_common(&chan->parent);
nomem:
if (transport)
module_put(transport->owner);
* Needs to be called with sessions mutex held.
*/
static
-void _lttng_channel_destroy(struct lttng_kernel_channel_buffer *chan)
+void lttng_kernel_buffer_destroy(struct lttng_kernel_channel_buffer *chan)
{
chan->ops->priv->channel_destroy(chan->priv->rb_chan);
module_put(chan->priv->transport->owner);
- list_del(&chan->priv->node);
lttng_kernel_destroy_context(chan->priv->ctx);
kfree(chan->priv);
kfree(chan);
}
-void lttng_metadata_channel_destroy(struct lttng_kernel_channel_buffer *chan)
+static
+void _lttng_channel_destroy(struct lttng_kernel_channel_common *chan)
+{
+ list_del(&chan->priv->node);
+
+ switch (chan->type) {
+ case LTTNG_KERNEL_CHANNEL_TYPE_BUFFER:
+ {
+ struct lttng_kernel_channel_buffer *chan_buf =
+ container_of(chan, struct lttng_kernel_channel_buffer, parent);
+ lttng_kernel_buffer_destroy(chan_buf);
+ break;
+ }
+ case LTTNG_KERNEL_CHANNEL_TYPE_COUNTER:
+ {
+ struct lttng_kernel_channel_counter *chan_counter =
+ container_of(chan, struct lttng_kernel_channel_counter, parent);
+ lttng_kernel_counter_destroy(chan_counter);
+ break;
+ }
+ default:
+ WARN_ON_ONCE(1);
+ }
+}
+
+void lttng_metadata_channel_buffer_destroy(struct lttng_kernel_channel_buffer *chan)
{
BUG_ON(chan->priv->channel_type != METADATA_CHANNEL);
/* Protect the metadata cache with the sessions_mutex. */
mutex_lock(&sessions_mutex);
- _lttng_channel_destroy(chan);
+ _lttng_channel_destroy(&chan->parent);
mutex_unlock(&sessions_mutex);
}
-EXPORT_SYMBOL_GPL(lttng_metadata_channel_destroy);
+EXPORT_SYMBOL_GPL(lttng_metadata_channel_buffer_destroy);
static
void _lttng_metadata_channel_hangup(struct lttng_metadata_stream *stream)
case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
{
struct lttng_event_recorder_enabler *event_recorder_enabler =
- container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
+ container_of(event_enabler, struct lttng_event_recorder_enabler, parent.parent);
struct lttng_kernel_channel_buffer *chan = event_recorder_enabler->chan;
switch (itype) {
return false;
}
}
+ case LTTNG_EVENT_ENABLER_TYPE_COUNTER:
+ {
+ struct lttng_event_counter_enabler *event_counter_enabler =
+ container_of(event_enabler, struct lttng_event_counter_enabler, parent.parent);
+ struct lttng_kernel_channel_counter *chan = event_counter_enabler->chan;
+ size_t nr_dimensions, max_nr_elem;
+
+ if (lttng_kernel_counter_get_nr_dimensions(chan, &nr_dimensions))
+ return false;
+ WARN_ON_ONCE(nr_dimensions != 1);
+ if (nr_dimensions != 1)
+ return false;
+ if (lttng_kernel_counter_get_max_nr_elem(chan, &max_nr_elem))
+ return false;
+ switch (itype) {
+ case LTTNG_KERNEL_ABI_TRACEPOINT:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_KPROBE:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_SYSCALL:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_UPROBE:
+ if (chan->priv->free_index >= max_nr_elem)
+ return false;
+ return true;
+ case LTTNG_KERNEL_ABI_KRETPROBE:
+ /* kretprobes require 2 event IDs. */
+ if (chan->priv->free_index + 1 >= max_nr_elem)
+ return false;
+ return true;
+ default:
+ WARN_ON_ONCE(1);
+ return false;
+ }
+ }
case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
return true;
default:
}
static
-struct lttng_kernel_event_common *lttng_kernel_event_alloc(struct lttng_event_enabler_common *event_enabler)
+struct lttng_kernel_event_common *lttng_kernel_event_alloc(struct lttng_event_enabler_common *event_enabler,
+ struct hlist_head *key_head,
+ const char *key_string)
{
struct lttng_kernel_abi_event *event_param = &event_enabler->event_param;
enum lttng_kernel_abi_instrumentation itype = event_param->instrumentation;
case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
{
struct lttng_event_recorder_enabler *event_recorder_enabler =
- container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
+ container_of(event_enabler, struct lttng_event_recorder_enabler, parent.parent);
struct lttng_kernel_event_recorder *event_recorder;
struct lttng_kernel_event_recorder_private *event_recorder_priv;
struct lttng_kernel_channel_buffer *chan = event_recorder_enabler->chan;
+ WARN_ON_ONCE(key_head); /* not implemented. */
event_recorder = kmem_cache_zalloc(event_recorder_cache, GFP_KERNEL);
if (!event_recorder)
return NULL;
return NULL;
}
event_recorder_priv->pub = event_recorder;
- event_recorder_priv->parent.pub = &event_recorder->parent;
+ event_recorder_priv->parent.parent.pub = &event_recorder->parent;
event_recorder->priv = event_recorder_priv;
- event_recorder->parent.priv = &event_recorder_priv->parent;
+ event_recorder->parent.priv = &event_recorder_priv->parent.parent;
event_recorder->parent.type = LTTNG_KERNEL_EVENT_TYPE_RECORDER;
event_recorder->parent.run_filter = lttng_kernel_interpret_event_filter;
- event_recorder->priv->parent.instrumentation = itype;
- INIT_LIST_HEAD(&event_recorder->priv->parent.filter_bytecode_runtime_head);
- INIT_LIST_HEAD(&event_recorder->priv->parent.enablers_ref_head);
+ event_recorder->priv->parent.parent.instrumentation = itype;
+ INIT_LIST_HEAD(&event_recorder->priv->parent.parent.filter_bytecode_runtime_head);
+ INIT_LIST_HEAD(&event_recorder->priv->parent.parent.enablers_ref_head);
event_recorder->chan = chan;
- event_recorder->priv->id = chan->priv->free_event_id++;
+ event_recorder->priv->parent.chan = &chan->parent;
+ event_recorder->priv->parent.id = chan->priv->free_event_id++;
return &event_recorder->parent;
}
case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
struct lttng_kernel_event_notifier *event_notifier;
struct lttng_kernel_event_notifier_private *event_notifier_priv;
+ WARN_ON_ONCE(key_head); /* not implemented. */
event_notifier = kmem_cache_zalloc(event_notifier_cache, GFP_KERNEL);
if (!event_notifier)
return NULL;
INIT_LIST_HEAD(&event_notifier->priv->capture_bytecode_runtime_head);
return &event_notifier->parent;
}
+ case LTTNG_EVENT_ENABLER_TYPE_COUNTER:
+ {
+ struct lttng_event_counter_enabler *event_counter_enabler =
+ container_of(event_enabler, struct lttng_event_counter_enabler, parent.parent);
+ struct lttng_kernel_event_counter *event_counter;
+ struct lttng_kernel_event_counter_private *event_counter_priv;
+ struct lttng_kernel_channel_counter *chan = event_counter_enabler->chan;
+ bool key_found = false;
+
+ event_counter = kmem_cache_zalloc(event_counter_cache, GFP_KERNEL);
+ if (!event_counter)
+ return NULL;
+ event_counter_priv = kmem_cache_zalloc(event_counter_private_cache, GFP_KERNEL);
+ if (!event_counter_priv) {
+ kmem_cache_free(event_counter_private_cache, event_counter);
+ return NULL;
+ }
+ event_counter_priv->pub = event_counter;
+ event_counter_priv->parent.parent.pub = &event_counter->parent;
+ event_counter->priv = event_counter_priv;
+ event_counter->parent.priv = &event_counter_priv->parent.parent;
+
+ event_counter->parent.type = LTTNG_KERNEL_EVENT_TYPE_COUNTER;
+ event_counter->parent.run_filter = lttng_kernel_interpret_event_filter;
+ event_counter->priv->parent.parent.instrumentation = itype;
+ INIT_LIST_HEAD(&event_counter->priv->parent.parent.filter_bytecode_runtime_head);
+ INIT_LIST_HEAD(&event_counter->priv->parent.parent.enablers_ref_head);
+
+ event_counter->chan = chan;
+ event_counter->priv->parent.chan = &chan->parent;
+ if (!chan->priv->parent.coalesce_hits)
+ event_counter->priv->parent.parent.user_token = event_counter_enabler->parent.parent.user_token;
+ strcpy(event_counter_priv->key, key_string);
+ event_counter_priv->action = event_counter_enabler->action;
+ if (key_head) {
+ struct lttng_kernel_event_counter_private *event_counter_priv_iter;
+
+ lttng_hlist_for_each_entry(event_counter_priv_iter, key_head, hlist_key_node) {
+ if (!strcmp(key_string, event_counter_priv_iter->key)) {
+ /* Same key, use same id. */
+ key_found = true;
+ event_counter->priv->parent.id = event_counter_priv_iter->parent.id;
+ break;
+ }
+ }
+ }
+ if (!key_found)
+ event_counter->priv->parent.id = chan->priv->free_index++;
+ return &event_counter->parent;
+ }
default:
return NULL;
}
kmem_cache_free(event_recorder_cache, event_recorder);
break;
}
+ case LTTNG_KERNEL_EVENT_TYPE_COUNTER:
+ {
+ struct lttng_kernel_event_counter *event_counter =
+ container_of(event, struct lttng_kernel_event_counter, parent);
+
+ kmem_cache_free(event_counter_private_cache, event_counter->priv);
+ kmem_cache_free(event_counter_cache, event_counter);
+ break;
+ }
case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
{
struct lttng_kernel_event_notifier *event_notifier =
{
switch (event->type) {
case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_EVENT_TYPE_COUNTER:
return 0;
+
case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
{
struct lttng_kernel_event_notifier *event_notifier =
container_of(event, struct lttng_kernel_event_notifier, parent);
- struct lttng_counter *error_counter;
+ struct lttng_kernel_channel_counter *error_counter;
struct lttng_event_notifier_group *event_notifier_group = event_notifier->priv->group;
size_t dimension_index[1];
int ret;
}
dimension_index[0] = event_notifier->priv->error_counter_index;
- ret = error_counter->ops->counter_clear(error_counter->counter, dimension_index);
+ ret = error_counter->ops->priv->counter_clear(error_counter, dimension_index);
if (ret) {
printk(KERN_INFO "LTTng: event_notifier: Unable to clear error counter bucket %llu\n",
event_notifier->priv->error_counter_index);
}
}
+int format_event_key(struct lttng_event_enabler_common *event_enabler, char *key_string,
+ const char *event_name)
+{
+ struct lttng_event_counter_enabler *event_counter_enabler;
+ const struct lttng_kernel_counter_key_dimension *dim;
+ size_t i, left = LTTNG_KERNEL_COUNTER_KEY_LEN;
+ const struct lttng_kernel_counter_key *key;
+
+ if (event_enabler->enabler_type != LTTNG_EVENT_ENABLER_TYPE_COUNTER)
+ return 0;
+ event_counter_enabler = container_of(event_enabler, struct lttng_event_counter_enabler, parent.parent);
+ key = event_counter_enabler->key;
+ if (!key->nr_dimensions)
+ return 0;
+ /* Currently event keys can only be specified on a single dimension. */
+ if (key->nr_dimensions != 1)
+ return -EINVAL;
+ dim = &key->dimension_array[0];
+ for (i = 0; i < dim->nr_key_tokens; i++) {
+ const struct lttng_key_token *token = &dim->token_array[i];
+ size_t token_len;
+ const char *str;
+
+ switch (token->type) {
+ case LTTNG_KEY_TOKEN_STRING:
+ str = token->str;
+ break;
+ case LTTNG_KEY_TOKEN_EVENT_NAME:
+ str = event_name;
+ break;
+ default:
+ return -EINVAL;
+ }
+ token_len = strlen(str);
+ if (token_len >= left)
+ return -EINVAL;
+ strcat(key_string, str);
+ left -= token_len;
+ }
+ return 0;
+}
+
+static
+bool match_event_key(struct lttng_kernel_event_common *event, const char *key_string)
+{
+ switch (event->type) {
+ case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
+ return true;
+
+ case LTTNG_KERNEL_EVENT_TYPE_COUNTER:
+ {
+ struct lttng_kernel_event_counter_private *event_counter_priv =
+ container_of(event->priv, struct lttng_kernel_event_counter_private, parent.parent);
+
+ if (key_string[0] == '\0')
+ return true;
+ return !strcmp(key_string, event_counter_priv->key);
+ }
+
+ default:
+ WARN_ON_ONCE(1);
+ return false;
+ }
+}
+
+static
+bool match_event_session_token(struct lttng_kernel_event_session_common_private *event_session_priv,
+ uint64_t token)
+{
+ if (event_session_priv->chan->priv->coalesce_hits)
+ return true;
+ if (event_session_priv->parent.user_token == token)
+ return true;
+ return false;
+}
+
+bool lttng_event_enabler_event_name_key_match_event(struct lttng_event_enabler_common *event_enabler,
+ const char *event_name, const char *key_string, struct lttng_kernel_event_common *event)
+{
+ switch (event_enabler->enabler_type) {
+ case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
+ lttng_fallthrough;
+ case LTTNG_EVENT_ENABLER_TYPE_COUNTER:
+ {
+ struct lttng_event_enabler_session_common *event_session_enabler =
+ container_of(event_enabler, struct lttng_event_enabler_session_common, parent);
+ struct lttng_kernel_event_session_common_private *event_session_priv =
+ container_of(event->priv, struct lttng_kernel_event_session_common_private, parent);
+ bool same_event = false, same_channel = false, same_key = false,
+ same_token = false;
+
+ WARN_ON_ONCE(!event->priv->desc);
+ if (!strncmp(event->priv->desc->event_name, event_name, LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1))
+ same_event = true;
+ if (event_session_enabler->chan == event_session_priv->chan) {
+ same_channel = true;
+ if (match_event_session_token(event_session_priv, event_enabler->user_token))
+ same_token = true;
+ }
+ if (match_event_key(event, key_string))
+ same_key = true;
+ return same_event && same_channel && same_key && same_token;
+ }
+
+ case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
+ {
+ /*
+ * Check if event_notifier already exists by checking
+ * if the event_notifier and enabler share the same
+ * description and id.
+ */
+ if (!strncmp(event->priv->desc->event_name, event_name, LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1)
+ && event->priv->user_token == event_enabler->user_token)
+ return true;
+ else
+ return false;
+ }
+ default:
+ WARN_ON_ONCE(1);
+ return false;
+ }
+}
+
+static
+int lttng_counter_append_descriptor(struct lttng_kernel_channel_counter *counter,
+ uint64_t user_token,
+ size_t index,
+ const char *key)
+{
+ struct lttng_counter_map *map = &counter->priv->map;
+ struct lttng_counter_map_descriptor *last;
+ int ret = 0;
+
+ if (strlen(key) >= LTTNG_KERNEL_COUNTER_KEY_LEN) {
+ WARN_ON_ONCE(1);
+ return -EOVERFLOW;
+ }
+ mutex_lock(&map->lock);
+ if (map->nr_descriptors == map->alloc_len) {
+ struct lttng_counter_map_descriptor *new_table, *old_table;
+ size_t old_len = map->nr_descriptors;
+ size_t new_len = max_t(size_t, old_len + 1, map->alloc_len * 2);
+
+ old_table = map->descriptors;
+ new_table = lttng_kvzalloc(sizeof(struct lttng_counter_map_descriptor) * new_len,
+ GFP_KERNEL);
+ if (!new_table) {
+ ret = -ENOMEM;
+ goto unlock;
+ }
+
+ if (old_table)
+ memcpy(new_table, old_table, old_len * sizeof(struct lttng_counter_map_descriptor));
+
+ map->descriptors = new_table;
+ map->alloc_len = new_len;
+ lttng_kvfree(old_table);
+ }
+ last = &map->descriptors[map->nr_descriptors++];
+ last->user_token = user_token;
+ last->array_index = index;
+ strcpy(last->key, key);
+unlock:
+ mutex_unlock(&map->lock);
+ return ret;
+}
+
+static
+int lttng_append_event_to_channel_map(struct lttng_event_enabler_common *event_enabler,
+ struct lttng_kernel_event_common *event,
+ const char *event_name)
+{
+ struct lttng_event_counter_enabler *event_counter_enabler;
+ struct lttng_kernel_channel_counter *chan_counter;
+ struct lttng_kernel_event_counter *event_counter;
+ const char *name = "<UNKNOWN>";
+
+ if (event_enabler->enabler_type != LTTNG_EVENT_ENABLER_TYPE_COUNTER)
+ return 0;
+ event_counter_enabler = container_of(event_enabler, struct lttng_event_counter_enabler, parent.parent);
+ event_counter = container_of(event, struct lttng_kernel_event_counter, parent);
+ chan_counter = event_counter_enabler->chan;
+ if (event_counter->priv->key[0])
+ name = event_counter->priv->key;
+ else
+ name = event_name;
+ return lttng_counter_append_descriptor(chan_counter, event_enabler->user_token,
+ event_counter->priv->parent.id, name);
+}
+
/*
* Supports event creation while tracing session is active.
* Needs to be called with sessions mutex held.
*/
struct lttng_kernel_event_common *_lttng_kernel_event_create(struct lttng_event_enabler_common *event_enabler,
- const struct lttng_kernel_event_desc *event_desc)
+ const struct lttng_kernel_event_desc *event_desc,
+ struct lttng_kernel_event_pair *event_pair)
{
- struct lttng_event_ht *events_ht = lttng_get_event_ht_from_enabler(event_enabler);
+ char key_string[LTTNG_KERNEL_COUNTER_KEY_LEN] = { 0 };
+ struct lttng_event_ht *events_name_ht = lttng_get_events_name_ht_from_enabler(event_enabler);
+ struct lttng_event_ht *events_key_ht = lttng_get_events_key_ht_from_enabler(event_enabler);
struct list_head *event_list_head = lttng_get_event_list_head_from_enabler(event_enabler);
struct lttng_kernel_abi_event *event_param = &event_enabler->event_param;
enum lttng_kernel_abi_instrumentation itype = event_param->instrumentation;
- struct lttng_kernel_event_common_private *event_priv;
+ struct lttng_kernel_event_common_private *event_priv_iter;
struct lttng_kernel_event_common *event;
+ struct hlist_head *name_head, *key_head = NULL;
const char *event_name;
- struct hlist_head *head;
int ret;
- if (!lttng_kernel_event_id_available(event_enabler)) {
- ret = -EMFILE;
- goto full;
+ if (event_pair == NULL || event_pair->check_ids) {
+ if (!lttng_kernel_event_id_available(event_enabler)) {
+ ret = -EMFILE;
+ goto full;
+ }
}
switch (itype) {
lttng_fallthrough;
case LTTNG_KERNEL_ABI_UPROBE:
lttng_fallthrough;
- case LTTNG_KERNEL_ABI_KRETPROBE:
- lttng_fallthrough;
case LTTNG_KERNEL_ABI_SYSCALL:
event_name = event_param->name;
break;
+ case LTTNG_KERNEL_ABI_KRETPROBE:
+ event_name = event_pair->name;
+ break;
+
case LTTNG_KERNEL_ABI_FUNCTION:
lttng_fallthrough;
case LTTNG_KERNEL_ABI_NOOP:
goto type_error;
}
- head = utils_borrow_hash_table_bucket(events_ht->table, LTTNG_EVENT_HT_SIZE, event_name);
- lttng_hlist_for_each_entry(event_priv, head, hlist_node) {
- if (lttng_event_enabler_event_name_match_event(event_enabler, event_name, event_priv->pub)) {
+ if (format_event_key(event_enabler, key_string, event_name)) {
+ ret = -EINVAL;
+ goto type_error;
+ }
+
+ name_head = utils_borrow_hash_table_bucket(events_name_ht->table, LTTNG_EVENT_HT_SIZE, event_name);
+ lttng_hlist_for_each_entry(event_priv_iter, name_head, hlist_name_node) {
+ if (lttng_event_enabler_event_name_key_match_event(event_enabler,
+ event_name, key_string, event_priv_iter->pub)) {
ret = -EEXIST;
goto exist;
}
}
- event = lttng_kernel_event_alloc(event_enabler);
+ if (key_string[0] != '\0')
+ key_head = utils_borrow_hash_table_bucket(events_key_ht->table, LTTNG_EVENT_HT_SIZE, key_string);
+
+ event = lttng_kernel_event_alloc(event_enabler, key_head, key_string);
if (!event) {
ret = -ENOMEM;
goto alloc_error;
break;
case LTTNG_KERNEL_ABI_KPROBE:
- /*
- * Needs to be explicitly enabled after creation, since
- * we may want to apply filters.
- */
+ /* Event will be enabled by enabler sync. */
event->enabled = 0;
- event->priv->registered = 1;
- /*
- * Populate lttng_event structure before event
- * registration.
- */
- smp_wmb();
- ret = lttng_kprobes_register_event(event_name,
+ event->priv->registered = 0;
+ ret = lttng_kprobes_init_event(event_name,
event_param->u.kprobe.symbol_name,
event_param->u.kprobe.offset,
event_param->u.kprobe.addr,
ret = -EINVAL;
goto register_error;
}
+ /*
+ * Populate lttng_event structure before event
+ * registration.
+ */
+ smp_wmb();
ret = try_module_get(event->priv->desc->owner);
WARN_ON_ONCE(!ret);
break;
case LTTNG_KERNEL_ABI_KRETPROBE:
{
- struct lttng_kernel_event_common *event_return;
-
- /* kretprobe defines 2 events */
- /*
- * Needs to be explicitly enabled after creation, since
- * we may want to apply filters.
- */
+ /* Event will be enabled by enabler sync. */
event->enabled = 0;
- event->priv->registered = 1;
-
- event_return = lttng_kernel_event_alloc(event_enabler);
- if (!event) {
- ret = -ENOMEM;
- goto alloc_error;
- }
-
- event_return->enabled = 0;
- event_return->priv->registered = 1;
-
- /*
- * Populate lttng_event structure before kretprobe registration.
- */
- smp_wmb();
- ret = lttng_kretprobes_register(event_name,
- event_param->u.kretprobe.symbol_name,
- event_param->u.kretprobe.offset,
- event_param->u.kretprobe.addr,
- event, event_return);
+ event->priv->registered = 0;
+ ret = lttng_kretprobes_init_event(event_name,
+ event_pair->entryexit,
+ event, event_pair->krp);
if (ret) {
- lttng_kernel_event_free(event_return);
ret = -EINVAL;
goto register_error;
}
- /* Take 2 refs on the module: one per event. */
ret = try_module_get(event->priv->desc->owner);
WARN_ON_ONCE(!ret);
- ret = try_module_get(event_return->priv->desc->owner);
- WARN_ON_ONCE(!ret);
- ret = _lttng_event_recorder_metadata_statedump(event_return);
- WARN_ON_ONCE(ret > 0);
- if (ret) {
- lttng_kernel_event_free(event_return);
- module_put(event_return->priv->desc->owner);
- module_put(event->priv->desc->owner);
- goto statedump_error;
- }
- list_add(&event_return->priv->node, event_list_head);
break;
}
case LTTNG_KERNEL_ABI_SYSCALL:
- /*
- * Needs to be explicitly enabled after creation, since
- * we may want to apply filters.
- */
+ /* Event will be enabled by enabler sync. */
event->enabled = 0;
event->priv->registered = 0;
event->priv->desc = event_desc;
goto register_error;
ret = try_module_get(event->priv->desc->owner);
WARN_ON_ONCE(!ret);
+ ret = lttng_append_event_to_channel_map(event_enabler, event, event_name);
+ WARN_ON_ONCE(ret);
break;
default:
}
ret = lttng_kernel_event_notifier_clear_error_counter(event);
- if (ret)
+ if (ret) {
goto register_error;
+ }
- hlist_add_head(&event->priv->hlist_node, head);
+ hlist_add_head(&event->priv->hlist_name_node, name_head);
+ if (key_head) {
+ struct lttng_kernel_event_counter_private *event_counter_priv =
+ container_of(event->priv, struct lttng_kernel_event_counter_private, parent.parent);
+ hlist_add_head(&event_counter_priv->hlist_key_node, key_head);
+ }
list_add(&event->priv->node, event_list_head);
return event;
}
struct lttng_kernel_event_common *lttng_kernel_event_create(struct lttng_event_enabler_common *event_enabler,
- const struct lttng_kernel_event_desc *event_desc)
+ const struct lttng_kernel_event_desc *event_desc,
+ struct lttng_kernel_event_pair *event_pair)
{
struct lttng_kernel_event_common *event;
mutex_lock(&sessions_mutex);
- event = _lttng_kernel_event_create(event_enabler, event_desc);
+ event = _lttng_kernel_event_create(event_enabler, event_desc, event_pair);
mutex_unlock(&sessions_mutex);
return event;
}
-int lttng_kernel_counter_read(struct lttng_counter *counter,
+int lttng_kernel_counter_read(struct lttng_kernel_channel_counter *counter,
const size_t *dim_indexes, int32_t cpu,
int64_t *val, bool *overflow, bool *underflow)
{
- return counter->ops->counter_read(counter->counter, dim_indexes,
+ return counter->ops->priv->counter_read(counter, dim_indexes,
cpu, val, overflow, underflow);
}
-int lttng_kernel_counter_aggregate(struct lttng_counter *counter,
+int lttng_kernel_counter_aggregate(struct lttng_kernel_channel_counter *counter,
const size_t *dim_indexes, int64_t *val,
bool *overflow, bool *underflow)
{
- return counter->ops->counter_aggregate(counter->counter, dim_indexes,
+ return counter->ops->priv->counter_aggregate(counter, dim_indexes,
val, overflow, underflow);
}
-int lttng_kernel_counter_clear(struct lttng_counter *counter,
+int lttng_kernel_counter_clear(struct lttng_kernel_channel_counter *counter,
const size_t *dim_indexes)
{
- return counter->ops->counter_clear(counter->counter, dim_indexes);
+ return counter->ops->priv->counter_clear(counter, dim_indexes);
+}
+
+int lttng_kernel_counter_get_nr_dimensions(struct lttng_kernel_channel_counter *counter,
+ size_t *nr_dimensions)
+{
+ return counter->ops->priv->counter_get_nr_dimensions(counter, nr_dimensions);
}
-/* Only used for tracepoints and system calls for now. */
+int lttng_kernel_counter_get_max_nr_elem(struct lttng_kernel_channel_counter *counter,
+ size_t *max_nr_elem)
+{
+ return counter->ops->priv->counter_get_max_nr_elem(counter, max_nr_elem);
+}
+
+/* Used for tracepoints, system calls, and kprobe. */
static
void register_event(struct lttng_kernel_event_common *event)
{
break;
case LTTNG_KERNEL_ABI_KPROBE:
- lttng_fallthrough;
+ ret = lttng_kprobes_register_event(event);
+ break;
+
case LTTNG_KERNEL_ABI_UPROBE:
ret = 0;
break;
case LTTNG_KERNEL_ABI_KRETPROBE:
- switch (event->type) {
- case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
- ret = 0;
- break;
- case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
- WARN_ON_ONCE(1);
- break;
- }
+ ret = lttng_kretprobes_register_event(event);
break;
case LTTNG_KERNEL_ABI_FUNCTION:
break;
case LTTNG_KERNEL_ABI_KRETPROBE:
- switch (event->type) {
- case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
- lttng_kretprobes_unregister(event);
- ret = 0;
- break;
- case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
- WARN_ON_ONCE(1);
- break;
- }
+ lttng_kretprobes_unregister_event(event);
+ ret = 0;
break;
case LTTNG_KERNEL_ABI_SYSCALL:
case LTTNG_KERNEL_ABI_NOOP:
switch (event->type) {
case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_EVENT_TYPE_COUNTER:
ret = 0;
break;
case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
static
void _lttng_event_destroy(struct lttng_kernel_event_common *event)
{
- struct lttng_kernel_event_common_private *event_priv = event->priv;
struct lttng_enabler_ref *enabler_ref, *tmp_enabler_ref;
lttng_free_event_filter_runtime(event);
/* Free event enabler refs */
list_for_each_entry_safe(enabler_ref, tmp_enabler_ref,
- &event_priv->enablers_ref_head, node)
+ &event->priv->enablers_ref_head, node)
kfree(enabler_ref);
+ /* Remove from event list. */
+ list_del(&event->priv->node);
+ /* Remove from event hash table. */
+ hlist_del(&event->priv->hlist_name_node);
+
switch (event->type) {
- case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
+ case LTTNG_KERNEL_EVENT_TYPE_COUNTER:
{
- struct lttng_kernel_event_recorder *event_recorder =
- container_of(event, struct lttng_kernel_event_recorder, parent);
-
- switch (event_priv->instrumentation) {
- case LTTNG_KERNEL_ABI_TRACEPOINT:
- lttng_event_desc_put(event_priv->desc);
- break;
-
- case LTTNG_KERNEL_ABI_KPROBE:
- module_put(event_priv->desc->owner);
- lttng_kprobes_destroy_event_private(&event_recorder->parent);
- break;
-
- case LTTNG_KERNEL_ABI_KRETPROBE:
- module_put(event_priv->desc->owner);
- lttng_kretprobes_destroy_private(&event_recorder->parent);
- break;
-
- case LTTNG_KERNEL_ABI_SYSCALL:
- break;
-
- case LTTNG_KERNEL_ABI_UPROBE:
- module_put(event_priv->desc->owner);
- lttng_uprobes_destroy_event_private(&event_recorder->parent);
- break;
-
- case LTTNG_KERNEL_ABI_FUNCTION:
- lttng_fallthrough;
- case LTTNG_KERNEL_ABI_NOOP:
- lttng_fallthrough;
- default:
- WARN_ON_ONCE(1);
- }
- list_del(&event_recorder->priv->parent.node);
- kmem_cache_free(event_recorder_private_cache, event_recorder->priv);
- kmem_cache_free(event_recorder_cache, event_recorder);
+ struct lttng_kernel_event_counter_private *event_counter_priv =
+ container_of(event->priv, struct lttng_kernel_event_counter_private, parent.parent);
+ if (event_counter_priv->key[0] != '\0')
+ hlist_del(&event_counter_priv->hlist_key_node);
break;
}
+ case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
+ lttng_fallthrough;
case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
- {
- struct lttng_kernel_event_notifier *event_notifier =
- container_of(event, struct lttng_kernel_event_notifier, parent);
+ break;
+ default:
+ WARN_ON_ONCE(1);
+ }
- switch (event_notifier->priv->parent.instrumentation) {
- case LTTNG_KERNEL_ABI_TRACEPOINT:
- lttng_event_desc_put(event_notifier->priv->parent.desc);
- break;
+ switch (event->priv->instrumentation) {
+ case LTTNG_KERNEL_ABI_TRACEPOINT:
+ lttng_event_desc_put(event->priv->desc);
+ break;
- case LTTNG_KERNEL_ABI_KPROBE:
- module_put(event_notifier->priv->parent.desc->owner);
- lttng_kprobes_destroy_event_private(&event_notifier->parent);
- break;
+ case LTTNG_KERNEL_ABI_KPROBE:
+ module_put(event->priv->desc->owner);
+ lttng_kprobes_destroy_event_private(event);
+ break;
- case LTTNG_KERNEL_ABI_SYSCALL:
- break;
+ case LTTNG_KERNEL_ABI_KRETPROBE:
+ module_put(event->priv->desc->owner);
+ lttng_kretprobes_destroy_event_private(event);
+ break;
- case LTTNG_KERNEL_ABI_UPROBE:
- module_put(event_notifier->priv->parent.desc->owner);
- lttng_uprobes_destroy_event_private(&event_notifier->parent);
- break;
+ case LTTNG_KERNEL_ABI_SYSCALL:
+ break;
- case LTTNG_KERNEL_ABI_KRETPROBE:
- lttng_fallthrough;
- case LTTNG_KERNEL_ABI_FUNCTION:
- lttng_fallthrough;
- case LTTNG_KERNEL_ABI_NOOP:
- lttng_fallthrough;
- default:
- WARN_ON_ONCE(1);
- }
- list_del(&event_notifier->priv->parent.node);
- kmem_cache_free(event_notifier_private_cache, event_notifier->priv);
- kmem_cache_free(event_notifier_cache, event_notifier);
+ case LTTNG_KERNEL_ABI_UPROBE:
+ module_put(event->priv->desc->owner);
+ lttng_uprobes_destroy_event_private(event);
break;
- }
+
+ case LTTNG_KERNEL_ABI_FUNCTION:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_NOOP:
+ lttng_fallthrough;
default:
WARN_ON_ONCE(1);
}
+
+ lttng_kernel_event_free(event);
}
static
}
break;
+ case LTTNG_KERNEL_ABI_KPROBE:
+ desc_name = desc->event_name;
+ switch (enabler->format_type) {
+ case LTTNG_ENABLER_FORMAT_STAR_GLOB:
+ return -EINVAL;
+ case LTTNG_ENABLER_FORMAT_NAME:
+ return lttng_match_enabler_name(desc_name, enabler_name);
+ default:
+ return -EINVAL;
+ }
+ break;
+
+ case LTTNG_KERNEL_ABI_KRETPROBE:
+ {
+ char base_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
+ size_t base_name_len; /* includes \0 */
+ char *last_separator, *entryexit;
+
+ desc_name = desc->event_name;
+ last_separator = strrchr(desc_name, '_');
+ base_name_len = last_separator - desc_name + 1;
+ memcpy(base_name, desc_name, base_name_len);
+ base_name[base_name_len - 1] = '\0'; /* Replace '_' by '\0' */
+ entryexit = last_separator + 1;
+
+ if (!strcmp(entryexit, "entry")) {
+ entry = true;
+ } else if (!strcmp(entryexit, "exit")) {
+ /* Nothing to do. */
+ } else {
+ WARN_ON_ONCE(1);
+ return -EINVAL;
+ }
+
+ switch (enabler->event_param.u.kretprobe.entryexit) {
+ case LTTNG_KERNEL_ABI_KRETPROBE_ENTRYEXIT:
+ break;
+ case LTTNG_KERNEL_ABI_KRETPROBE_ENTRY:
+ if (!entry)
+ return 0;
+ break;
+ case LTTNG_KERNEL_ABI_KRETPROBE_EXIT:
+ if (entry)
+ return 0;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ switch (enabler->format_type) {
+ case LTTNG_ENABLER_FORMAT_STAR_GLOB:
+ return -EINVAL;
+ case LTTNG_ENABLER_FORMAT_NAME:
+ return lttng_match_enabler_name(base_name, enabler_name);
+ default:
+ return -EINVAL;
+ }
+ break;
+ }
+
default:
WARN_ON_ONCE(1);
return -EINVAL;
return ret;
}
-bool lttng_event_enabler_match_event(struct lttng_event_enabler_common *event_enabler,
- struct lttng_kernel_event_common *event)
+static
+bool lttng_event_session_enabler_match_event_session(struct lttng_event_enabler_session_common *event_enabler_session,
+ struct lttng_kernel_event_session_common_private *event_session_priv)
{
- if (event_enabler->event_param.instrumentation != event->priv->instrumentation)
- return false;
-
- switch (event_enabler->enabler_type) {
- case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
- {
- struct lttng_event_recorder_enabler *event_recorder_enabler =
- container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
- struct lttng_kernel_event_recorder *event_recorder =
- container_of(event, struct lttng_kernel_event_recorder, parent);
-
- if (lttng_desc_match_enabler(event->priv->desc, event_enabler)
- && event_recorder->chan == event_recorder_enabler->chan)
- return true;
- else
- return false;
- }
- case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
- {
- struct lttng_event_notifier_enabler *event_notifier_enabler =
- container_of(event_enabler, struct lttng_event_notifier_enabler, parent);
- struct lttng_kernel_event_notifier *event_notifier =
- container_of(event, struct lttng_kernel_event_notifier, parent);
-
- if (lttng_desc_match_enabler(event->priv->desc, event_enabler)
- && event_notifier->priv->group == event_notifier_enabler->group
- && event->priv->user_token == event_enabler->user_token)
- return true;
- else
- return false;
- }
- default:
- WARN_ON_ONCE(1);
+ if (lttng_desc_match_enabler(event_session_priv->parent.desc, &event_enabler_session->parent)
+ && event_session_priv->chan == event_enabler_session->chan
+ && match_event_session_token(event_session_priv, event_enabler_session->parent.user_token))
+ return true;
+ else
return false;
- }
}
-bool lttng_event_enabler_desc_match_event(struct lttng_event_enabler_common *event_enabler,
- const struct lttng_kernel_event_desc *desc,
- struct lttng_kernel_event_common *event)
+static
+int lttng_event_notifier_enabler_match_event_notifier(
+ struct lttng_event_notifier_enabler *event_notifier_enabler,
+ struct lttng_kernel_event_notifier_private *event_notifier_priv)
{
- if (event_enabler->event_param.instrumentation != event->priv->instrumentation)
- return false;
-
- switch (event_enabler->enabler_type) {
- case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
- {
- struct lttng_event_recorder_enabler *event_recorder_enabler =
- container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
- struct lttng_kernel_event_recorder *event_recorder =
- container_of(event, struct lttng_kernel_event_recorder, parent);
-
- if (event->priv->desc == desc && event_recorder->chan == event_recorder_enabler->chan)
- return true;
- else
- return false;
- }
- case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
- {
- struct lttng_event_notifier_enabler *event_notifier_enabler =
- container_of(event_enabler, struct lttng_event_notifier_enabler, parent);
- struct lttng_kernel_event_notifier *event_notifier =
- container_of(event, struct lttng_kernel_event_notifier, parent);
+ int desc_matches = lttng_desc_match_enabler(event_notifier_priv->parent.desc,
+ lttng_event_notifier_enabler_as_enabler(event_notifier_enabler));
- if (event->priv->desc == desc
- && event_notifier->priv->group == event_notifier_enabler->group
- && event->priv->user_token == event_enabler->user_token)
- return true;
- else
- return false;
- }
- default:
- WARN_ON_ONCE(1);
- return false;
- }
+ if (desc_matches && event_notifier_priv->group == event_notifier_enabler->group &&
+ event_notifier_priv->parent.user_token == event_notifier_enabler->parent.user_token)
+ return 1;
+ else
+ return 0;
}
-bool lttng_event_enabler_event_name_match_event(struct lttng_event_enabler_common *event_enabler,
- const char *event_name,
+bool lttng_event_enabler_match_event(struct lttng_event_enabler_common *event_enabler,
struct lttng_kernel_event_common *event)
{
if (event_enabler->event_param.instrumentation != event->priv->instrumentation)
switch (event_enabler->enabler_type) {
case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
+ lttng_fallthrough;
+ case LTTNG_EVENT_ENABLER_TYPE_COUNTER:
{
- struct lttng_event_recorder_enabler *event_recorder_enabler =
- container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
- struct lttng_kernel_event_recorder *event_recorder =
- container_of(event, struct lttng_kernel_event_recorder, parent);
-
- if (!strncmp(event->priv->desc->event_name, event_name, LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1)
- && event_recorder->chan == event_recorder_enabler->chan)
- return true;
- else
- return false;
+ struct lttng_event_enabler_session_common *event_enabler_session =
+ container_of(event_enabler, struct lttng_event_enabler_session_common, parent);
+ struct lttng_kernel_event_session_common_private *event_session_priv =
+ container_of(event->priv, struct lttng_kernel_event_session_common_private, parent);
+ return lttng_event_session_enabler_match_event_session(event_enabler_session, event_session_priv);
}
case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
{
struct lttng_event_notifier_enabler *event_notifier_enabler =
container_of(event_enabler, struct lttng_event_notifier_enabler, parent);
- struct lttng_kernel_event_notifier *event_notifier =
- container_of(event, struct lttng_kernel_event_notifier, parent);
-
- if (!strncmp(event->priv->desc->event_name, event_name, LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1)
- && event_notifier->priv->group == event_notifier_enabler->group
- && event->priv->user_token == event_enabler->user_token)
- return true;
- else
- return false;
+ struct lttng_kernel_event_notifier_private *event_notifier_priv =
+ container_of(event->priv, struct lttng_kernel_event_notifier_private, parent);
+ return lttng_event_notifier_enabler_match_event_notifier(event_notifier_enabler, event_notifier_priv);
}
default:
WARN_ON_ONCE(1);
static
void lttng_event_enabler_create_tracepoint_events_if_missing(struct lttng_event_enabler_common *event_enabler)
{
- struct lttng_event_ht *events_ht = lttng_get_event_ht_from_enabler(event_enabler);
struct lttng_kernel_probe_desc *probe_desc;
const struct lttng_kernel_event_desc *desc;
struct list_head *probe_list;
*/
list_for_each_entry(probe_desc, probe_list, head) {
for (i = 0; i < probe_desc->nr_events; i++) {
- bool found = false;
- struct hlist_head *head;
struct lttng_kernel_event_common *event;
- struct lttng_kernel_event_common_private *event_priv;
desc = probe_desc->event_desc[i];
if (!lttng_desc_match_enabler(desc, event_enabler))
continue;
-
- /*
- * Check if already created.
- */
- head = utils_borrow_hash_table_bucket(events_ht->table, LTTNG_EVENT_HT_SIZE, desc->event_name);
- lttng_hlist_for_each_entry(event_priv, head, hlist_node) {
- if (lttng_event_enabler_desc_match_event(event_enabler, desc, event_priv->pub)) {
- found = true;
- break;
- }
- }
- if (found)
- continue;
-
/*
* We need to create an event for this event probe.
*/
- event = _lttng_kernel_event_create(event_enabler, desc);
+ event = _lttng_kernel_event_create(event_enabler, desc, NULL);
if (IS_ERR(event)) {
+ /* Skip if already found. */
+ if (PTR_ERR(event) == -EEXIST)
+ continue;
printk(KERN_INFO "LTTng: Unable to create event %s\n",
probe_desc->event_desc[i]->event_name);
}
}
}
+/* Try to create the event associated with this kprobe enabler. */
+static
+void lttng_event_enabler_create_kprobe_event_if_missing(struct lttng_event_enabler_common *event_enabler)
+{
+ struct lttng_kernel_event_common *event;
+
+ event = _lttng_kernel_event_create(event_enabler, NULL, NULL);
+ if (IS_ERR(event)) {
+ if (PTR_ERR(event) != -EEXIST) {
+ printk(KERN_INFO "LTTng: Unable to create kprobe event %s\n",
+ event_enabler->event_param.name);
+ }
+ }
+}
+
+/* Try to create the event associated with this kretprobe enabler. */
+static
+void lttng_event_enabler_create_kretprobe_event_if_missing(struct lttng_event_enabler_common *event_enabler)
+{
+ struct lttng_kernel_abi_event *event_param = &event_enabler->event_param;
+ struct lttng_kernel_event_pair event_pair;
+ struct lttng_kernel_event_common *event;
+
+ if (strlen(event_param->name) + strlen("_entry") >= LTTNG_KERNEL_ABI_SYM_NAME_LEN) {
+ WARN_ON_ONCE(1);
+ return;
+ }
+
+ memset(&event_pair, 0, sizeof(event_pair));
+ event_pair.krp = lttng_kretprobes_create_krp(event_param->u.kretprobe.symbol_name,
+ event_param->u.kretprobe.offset, event_param->u.kretprobe.addr);
+ if (!event_pair.krp) {
+ WARN_ON_ONCE(1);
+ return;
+ }
+ strcpy(event_pair.name, event_enabler->event_param.name);
+ strcat(event_pair.name, "_entry");
+ event_pair.check_ids = true;
+ event_pair.entryexit = LTTNG_KRETPROBE_ENTRY;
+ event = _lttng_kernel_event_create(event_enabler, NULL, &event_pair);
+ if (IS_ERR(event)) {
+ if (PTR_ERR(event) != -EEXIST) {
+ printk(KERN_INFO "LTTng: Unable to create kretprobe event %s\n",
+ event_enabler->event_param.name);
+ }
+ }
+
+ strcpy(event_pair.name, event_enabler->event_param.name);
+ strcat(event_pair.name, "_exit");
+ event_pair.check_ids = false;
+ event_pair.entryexit = LTTNG_KRETPROBE_EXIT;
+ event = _lttng_kernel_event_create(event_enabler, NULL, &event_pair);
+ if (IS_ERR(event)) {
+ if (PTR_ERR(event) != -EEXIST) {
+ printk(KERN_INFO "LTTng: Unable to create kretprobe event %s\n",
+ event_enabler->event_param.name);
+ }
+ }
+
+ lttng_kretprobes_put_krp(event_pair.krp);
+}
+
/*
* Create event if it is missing and present in the list of tracepoint probes.
* Should be called with sessions mutex held.
WARN_ON_ONCE(ret);
break;
+ case LTTNG_KERNEL_ABI_KPROBE:
+ lttng_event_enabler_create_kprobe_event_if_missing(event_enabler);
+ break;
+
+ case LTTNG_KERNEL_ABI_KRETPROBE:
+ lttng_event_enabler_create_kretprobe_event_if_missing(event_enabler);
+ break;
+
default:
WARN_ON_ONCE(1);
break;
{
switch (event_enabler->enabler_type) {
case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
+ lttng_fallthrough;
+ case LTTNG_EVENT_ENABLER_TYPE_COUNTER:
break;
case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
{
struct list_head *event_list_head = lttng_get_event_list_head_from_enabler(event_enabler);
struct lttng_kernel_event_common_private *event_priv;
+ /*
+ * Only try to create events for enablers that are enabled, the user
+ * might still be attaching filter or exclusion to the event enabler.
+ */
+ if (!event_enabler->enabled)
+ goto end;
+
lttng_syscall_table_set_wildcard_all(event_enabler);
/* First ensure that probe events are created for this enabler. */
enabler_ref = lttng_enabler_ref(&event_priv->enablers_ref_head, event_enabler);
if (!enabler_ref) {
+ int ret;
+
/*
* If no backward ref, create it.
* Add backward ref from event_notifier to enabler.
enabler_ref->ref = event_enabler;
list_add(&enabler_ref->node, &event_priv->enablers_ref_head);
+
+ ret = lttng_append_event_to_channel_map(event_enabler, event,
+ event->priv->desc->event_name);
+ WARN_ON_ONCE(ret);
}
lttng_event_enabler_init_event_filter(event_enabler, event);
lttng_event_enabler_init_event_capture(event_enabler, event);
}
+end:
return 0;
}
{
struct lttng_kernel_session_private *session_priv;
- list_for_each_entry(session_priv, &sessions, list)
+ list_for_each_entry(session_priv, &sessions, node)
lttng_session_lazy_sync_event_enablers(session_priv->pub);
return 0;
}
event_enabler = kzalloc(sizeof(*event_enabler), GFP_KERNEL);
if (!event_enabler)
return NULL;
- event_enabler->parent.enabler_type = LTTNG_EVENT_ENABLER_TYPE_RECORDER;
- event_enabler->parent.format_type = format_type;
- INIT_LIST_HEAD(&event_enabler->parent.filter_bytecode_head);
- memcpy(&event_enabler->parent.event_param, event_param,
- sizeof(event_enabler->parent.event_param));
+ event_enabler->parent.parent.enabler_type = LTTNG_EVENT_ENABLER_TYPE_RECORDER;
+ event_enabler->parent.parent.format_type = format_type;
+ INIT_LIST_HEAD(&event_enabler->parent.parent.filter_bytecode_head);
+ memcpy(&event_enabler->parent.parent.event_param, event_param,
+ sizeof(event_enabler->parent.parent.event_param));
+ event_enabler->chan = chan;
+ event_enabler->parent.chan = &chan->parent;
+
+ /* ctx left NULL */
+ event_enabler->parent.parent.enabled = 0;
+ return event_enabler;
+}
+
+struct lttng_event_counter_enabler *lttng_event_counter_enabler_create(
+ enum lttng_enabler_format_type format_type,
+ struct lttng_kernel_abi_event *event_param,
+ struct lttng_kernel_counter_key *counter_key,
+ struct lttng_kernel_channel_counter *chan)
+{
+ struct lttng_event_counter_enabler *event_enabler;
+
+ event_enabler = kzalloc(sizeof(*event_enabler), GFP_KERNEL);
+ if (!event_enabler)
+ return NULL;
+ event_enabler->parent.parent.enabler_type = LTTNG_EVENT_ENABLER_TYPE_COUNTER;
+ event_enabler->parent.parent.format_type = format_type;
+ INIT_LIST_HEAD(&event_enabler->parent.parent.filter_bytecode_head);
+ memcpy(&event_enabler->parent.parent.event_param, event_param,
+ sizeof(event_enabler->parent.parent.event_param));
event_enabler->chan = chan;
+ event_enabler->parent.chan = &chan->parent;
+ if (create_counter_key_from_kernel(&event_enabler->key, counter_key)) {
+ kfree(event_enabler);
+ return NULL;
+ }
+
/* ctx left NULL */
- event_enabler->parent.enabled = 0;
+ event_enabler->parent.parent.enabled = 0;
+ event_enabler->parent.parent.user_token = event_param->token;
return event_enabler;
}
void lttng_event_enabler_session_add(struct lttng_kernel_session *session,
- struct lttng_event_recorder_enabler *event_enabler)
+ struct lttng_event_enabler_session_common *event_enabler)
{
mutex_lock(&sessions_mutex);
list_add(&event_enabler->parent.node, &session->priv->enablers_head);
case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
{
struct lttng_event_recorder_enabler *event_recorder_enabler =
- container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
+ container_of(event_enabler, struct lttng_event_recorder_enabler, parent.parent);
kfree(event_recorder_enabler);
break;
kfree(event_notifier_enabler);
break;
}
+ case LTTNG_EVENT_ENABLER_TYPE_COUNTER:
+ {
+ struct lttng_event_counter_enabler *event_counter_enabler =
+ container_of(event_enabler, struct lttng_event_counter_enabler, parent.parent);
+
+ destroy_counter_key(event_counter_enabler->key);
+ kfree(event_counter_enabler);
+ break;
+ }
default:
WARN_ON_ONCE(1);
}
{
switch (event->type) {
case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_EVENT_TYPE_COUNTER:
break;
case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
{
case LTTNG_KERNEL_ABI_TRACEPOINT:
lttng_fallthrough;
case LTTNG_KERNEL_ABI_SYSCALL:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_KPROBE:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_KRETPROBE:
/* Enable events */
list_for_each_entry(enabler_ref, &event->priv->enablers_ref_head, node) {
if (enabler_ref->ref->enabled) {
switch (event->type) {
case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_EVENT_TYPE_COUNTER:
{
- struct lttng_kernel_event_recorder *event_recorder =
- container_of(event, struct lttng_kernel_event_recorder, parent);
+ struct lttng_kernel_event_session_common_private *event_session_common_priv =
+ container_of(event->priv, struct lttng_kernel_event_session_common_private, parent);
/*
* Enabled state is based on union of enablers, with
* intersection of session and channel transient enable
* states.
*/
- return enabled && event_recorder->chan->parent.session->priv->tstate && event_recorder->chan->priv->parent.tstate;
+ return enabled && event_session_common_priv->chan->session->priv->tstate && event_session_common_priv->chan->priv->tstate;
}
case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
return enabled;
case LTTNG_KERNEL_ABI_TRACEPOINT:
lttng_fallthrough;
case LTTNG_KERNEL_ABI_SYSCALL:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_KPROBE:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_ABI_KRETPROBE:
return true;
default:
static
void lttng_session_sync_event_enablers(struct lttng_kernel_session *session)
{
- lttng_sync_event_list(&session->priv->enablers_head, &session->priv->events);
+ lttng_sync_event_list(&session->priv->enablers_head, &session->priv->events_head);
}
/*
{
switch (event_enabler->enabler_type) {
case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
+ lttng_fallthrough;
+ case LTTNG_EVENT_ENABLER_TYPE_COUNTER:
{
- struct lttng_event_recorder_enabler *event_recorder_enabler =
- container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
- lttng_session_lazy_sync_event_enablers(event_recorder_enabler->chan->parent.session);
+ struct lttng_event_enabler_session_common *event_enabler_session =
+ container_of(event_enabler, struct lttng_event_enabler_session_common, parent);
+ lttng_session_lazy_sync_event_enablers(event_enabler_session->chan->session);
break;
}
case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
if (atomic_dec_return(&session->priv->metadata_cache->producing) == 0) {
struct lttng_metadata_stream *stream;
- list_for_each_entry(stream, &session->priv->metadata_cache->metadata_stream, list)
+ list_for_each_entry(stream, &session->priv->metadata_cache->metadata_stream, node)
wake_up_interruptible(&stream->read_wait);
mutex_unlock(&session->priv->metadata_cache->lock);
}
struct lttng_kernel_event_recorder *event_recorder)
{
const char *prev_field_name = NULL;
- const struct lttng_kernel_event_desc *desc = event_recorder->priv->parent.desc;
+ const struct lttng_kernel_event_desc *desc = event_recorder->priv->parent.parent.desc;
int ret = 0;
int i;
ret = lttng_metadata_printf(session,
"event {\n"
" name = \"%s\";\n"
- " id = %u;\n"
+ " id = %llu;\n"
" stream_id = %u;\n",
- event_recorder->priv->parent.desc->event_name,
- event_recorder->priv->id,
+ event_recorder->priv->parent.parent.desc->event_name,
+ event_recorder->priv->parent.id,
event_recorder->chan->priv->id);
if (ret)
goto end;
unsigned char *uuid_c = session->priv->uuid.b;
unsigned char uuid_s[37], clock_uuid_s[BOOT_ID_LEN];
const char *product_uuid;
- struct lttng_kernel_channel_buffer_private *chan_priv;
+ struct lttng_kernel_channel_common_private *chan_priv;
struct lttng_kernel_event_recorder_private *event_recorder_priv;
int ret = 0;
goto end;
skip_session:
- list_for_each_entry(chan_priv, &session->priv->chan, node) {
- ret = _lttng_channel_metadata_statedump(session, chan_priv->pub);
+ list_for_each_entry(chan_priv, &session->priv->chan_head, node) {
+ struct lttng_kernel_channel_buffer_private *chan_buf_priv;
+
+ if (chan_priv->pub->type != LTTNG_KERNEL_CHANNEL_TYPE_BUFFER)
+ continue;
+ chan_buf_priv = container_of(chan_priv, struct lttng_kernel_channel_buffer_private, parent);
+ ret = _lttng_channel_metadata_statedump(session, chan_buf_priv->pub);
if (ret)
goto end;
}
- list_for_each_entry(event_recorder_priv, &session->priv->events, parent.node) {
+ list_for_each_entry(event_recorder_priv, &session->priv->events_head, parent.parent.node) {
ret = _lttng_event_recorder_metadata_statedump(&event_recorder_priv->pub->parent);
if (ret)
goto end;
}
EXPORT_SYMBOL_GPL(lttng_counter_transport_unregister);
+struct lttng_kernel_channel_buffer *lttng_kernel_alloc_channel_buffer(void)
+{
+ struct lttng_kernel_channel_buffer *lttng_chan_buf;
+ struct lttng_kernel_channel_common *lttng_chan_common;
+ struct lttng_kernel_channel_buffer_private *lttng_chan_buf_priv;
+
+ lttng_chan_buf = kzalloc(sizeof(struct lttng_kernel_channel_buffer), GFP_KERNEL);
+ if (!lttng_chan_buf)
+ goto nomem;
+ lttng_chan_buf_priv = kzalloc(sizeof(struct lttng_kernel_channel_buffer_private), GFP_KERNEL);
+ if (!lttng_chan_buf_priv)
+ goto nomem_priv;
+ lttng_chan_common = <tng_chan_buf->parent;
+ lttng_chan_common->type = LTTNG_KERNEL_CHANNEL_TYPE_BUFFER;
+ lttng_chan_buf->priv = lttng_chan_buf_priv;
+ lttng_chan_common->priv = <tng_chan_buf_priv->parent;
+ lttng_chan_buf_priv->pub = lttng_chan_buf;
+ lttng_chan_buf_priv->parent.pub = lttng_chan_common;
+ return lttng_chan_buf;
+
+nomem_priv:
+ kfree(lttng_chan_buf);
+nomem:
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(lttng_kernel_alloc_channel_buffer);
+
+struct lttng_kernel_channel_counter *lttng_kernel_alloc_channel_counter(void)
+{
+ struct lttng_kernel_channel_counter *lttng_chan_counter;
+ struct lttng_kernel_channel_common *lttng_chan_common;
+ struct lttng_kernel_channel_counter_private *lttng_chan_counter_priv;
+
+ lttng_chan_counter = kzalloc(sizeof(struct lttng_kernel_channel_counter), GFP_KERNEL);
+ if (!lttng_chan_counter)
+ goto nomem;
+ lttng_chan_counter_priv = kzalloc(sizeof(struct lttng_kernel_channel_counter_private), GFP_KERNEL);
+ if (!lttng_chan_counter_priv)
+ goto nomem_priv;
+ lttng_chan_common = <tng_chan_counter->parent;
+ lttng_chan_common->type = LTTNG_KERNEL_CHANNEL_TYPE_COUNTER;
+ lttng_chan_counter->priv = lttng_chan_counter_priv;
+ lttng_chan_common->priv = <tng_chan_counter_priv->parent;
+ lttng_chan_counter_priv->pub = lttng_chan_counter;
+ lttng_chan_counter_priv->parent.pub = lttng_chan_common;
+ return lttng_chan_counter;
+
+nomem_priv:
+ kfree(lttng_chan_counter);
+nomem:
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(lttng_kernel_alloc_channel_counter);
+
+void lttng_kernel_free_channel_common(struct lttng_kernel_channel_common *chan)
+{
+ switch (chan->type) {
+ case LTTNG_KERNEL_CHANNEL_TYPE_BUFFER:
+ {
+ struct lttng_kernel_channel_buffer *chan_buf = container_of(chan,
+ struct lttng_kernel_channel_buffer, parent);
+
+ kfree(chan_buf->priv);
+ kfree(chan_buf);
+ break;
+ }
+ case LTTNG_KERNEL_CHANNEL_TYPE_COUNTER:
+ {
+ struct lttng_kernel_channel_counter *chan_counter = container_of(chan,
+ struct lttng_kernel_channel_counter, parent);
+
+ kfree(chan_counter->priv);
+ kfree(chan_counter);
+ break;
+ }
+ default:
+ WARN_ON_ONCE(1);
+ }
+}
+EXPORT_SYMBOL_GPL(lttng_kernel_free_channel_common);
+
#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0))
enum cpuhp_state lttng_hp_prepare;
ret = -ENOMEM;
goto error_kmem_event_recorder_private;
}
+ event_counter_cache = KMEM_CACHE(lttng_kernel_event_counter, 0);
+ if (!event_counter_cache) {
+ ret = -ENOMEM;
+ goto error_kmem_event_counter;
+ }
+ event_counter_private_cache = KMEM_CACHE(lttng_kernel_event_counter_private, 0);
+ if (!event_counter_private_cache) {
+ ret = -ENOMEM;
+ goto error_kmem_event_counter_private;
+ }
event_notifier_cache = KMEM_CACHE(lttng_kernel_event_notifier, 0);
if (!event_notifier_cache) {
ret = -ENOMEM;
error_kmem_event_notifier_private:
kmem_cache_destroy(event_notifier_cache);
error_kmem_event_notifier:
+ kmem_cache_destroy(event_counter_private_cache);
+error_kmem_event_counter_private:
+ kmem_cache_destroy(event_counter_cache);
+error_kmem_event_counter:
kmem_cache_destroy(event_recorder_private_cache);
error_kmem_event_recorder_private:
kmem_cache_destroy(event_recorder_cache);
lttng_exit_cpu_hotplug();
lttng_logger_exit();
lttng_abi_exit();
- list_for_each_entry_safe(session_priv, tmpsession_priv, &sessions, list)
+ list_for_each_entry_safe(session_priv, tmpsession_priv, &sessions, node)
lttng_session_destroy(session_priv->pub);
kmem_cache_destroy(event_recorder_cache);
kmem_cache_destroy(event_recorder_private_cache);
+ kmem_cache_destroy(event_counter_cache);
+ kmem_cache_destroy(event_counter_private_cache);
kmem_cache_destroy(event_notifier_cache);
kmem_cache_destroy(event_notifier_private_cache);
lttng_tracepoint_exit();
--- /dev/null
+/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+ *
+ * probes/lttng-kprobes.c
+ *
+ * LTTng kprobes integration module.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#include <linux/module.h>
+#include <linux/kprobes.h>
+#include <linux/slab.h>
+#include <lttng/events.h>
+#include <lttng/events-internal.h>
+#include <ringbuffer/frontend_types.h>
+#include <wrapper/vmalloc.h>
+#include <wrapper/irqflags.h>
+#include <wrapper/rcu.h>
+#include <lttng/tracer.h>
+#include <blacklist/kprobes.h>
+
+static
+int lttng_kprobes_event_handler_pre(struct kprobe *p, struct pt_regs *regs)
+{
+ struct lttng_kernel_event_common_private *event_priv =
+ container_of(p, struct lttng_kernel_event_common_private, u.kprobe.kp);
+ struct lttng_kernel_event_common *event = event_priv->pub;
+ struct lttng_kernel_channel_common *chan_common;
+ struct lttng_kernel_probe_ctx lttng_probe_ctx = {
+ .event = event,
+ .interruptible = !lttng_regs_irqs_disabled(regs),
+ };
+ unsigned long data = (unsigned long) p->addr;
+
+ if (unlikely(!LTTNG_READ_ONCE(event->enabled)))
+ goto end;
+
+ chan_common = lttng_kernel_get_chan_common_from_event_common(event);
+ if (chan_common) {
+ struct lttng_kernel_session *session = chan_common->session;
+ struct lttng_kernel_id_tracker_rcu *lf;
+
+ if (unlikely(!LTTNG_READ_ONCE(session->active)))
+ goto end;
+ if (unlikely(!LTTNG_READ_ONCE(chan_common->enabled)))
+ goto end;
+ lf = lttng_rcu_dereference(session->pid_tracker.p);
+ if (lf && likely(!lttng_id_tracker_lookup(lf, current->tgid)))
+ goto end;
+ lf = lttng_rcu_dereference(session->vpid_tracker.p);
+ if (lf && likely(!lttng_id_tracker_lookup(lf, task_tgid_vnr(current))))
+ goto end;
+ lf = lttng_rcu_dereference(session->uid_tracker.p);
+ if (lf && likely(!lttng_id_tracker_lookup(lf, from_kuid_munged(&init_user_ns, current_uid()))))
+ goto end;
+ lf = lttng_rcu_dereference(session->vuid_tracker.p);
+ if (lf && likely(!lttng_id_tracker_lookup(lf, from_kuid_munged(current_user_ns(), current_uid()))))
+ goto end;
+ lf = lttng_rcu_dereference(session->gid_tracker.p);
+ if (lf && likely(!lttng_id_tracker_lookup(lf, from_kgid_munged(&init_user_ns, current_gid()))))
+ goto end;
+ lf = lttng_rcu_dereference(session->vgid_tracker.p);
+ if (lf && likely(!lttng_id_tracker_lookup(lf, from_kgid_munged(current_user_ns(), current_gid()))))
+ goto end;
+ }
+ switch (event->type) {
+ case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
+ {
+ struct lttng_kernel_event_recorder *event_recorder =
+ container_of(event, struct lttng_kernel_event_recorder, parent);
+ struct lttng_kernel_channel_buffer *chan = event_recorder->chan;
+ struct lttng_kernel_ring_buffer_ctx ctx;
+ int ret;
+
+ lib_ring_buffer_ctx_init(&ctx, event_recorder, sizeof(data),
+ lttng_alignof(data), <tng_probe_ctx);
+ ret = chan->ops->event_reserve(&ctx);
+ if (ret < 0)
+ return 0;
+ chan->ops->event_write(&ctx, &data, sizeof(data), lttng_alignof(data));
+ chan->ops->event_commit(&ctx);
+ break;
+ }
+ case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
+ {
+ struct lttng_kernel_event_notifier *event_notifier =
+ container_of(event, struct lttng_kernel_event_notifier, parent);
+ struct lttng_kernel_notification_ctx notif_ctx;
+
+ notif_ctx.eval_capture = false;
+ event_notifier->notification_send(event_notifier, NULL, NULL, ¬if_ctx);
+ break;
+ }
+ case LTTNG_KERNEL_EVENT_TYPE_COUNTER:
+ {
+ struct lttng_kernel_event_counter *event_counter =
+ container_of(event, struct lttng_kernel_event_counter, parent);
+ struct lttng_kernel_event_counter_ctx event_counter_ctx;
+
+ event_counter_ctx.args_available = false;
+ (void) event_counter->chan->ops->counter_hit(event_counter,
+ NULL, NULL, &event_counter_ctx);
+ break;
+ }
+ default:
+ WARN_ON_ONCE(1);
+ }
+end:
+ return 0;
+}
+
+static const struct lttng_kernel_event_field *event_fields[] = {
+ lttng_kernel_static_event_field("ip",
+ lttng_kernel_static_type_integer_from_type(unsigned long, __BYTE_ORDER, 16),
+ false, false),
+};
+
+static const struct lttng_kernel_tracepoint_class tp_class = {
+ .nr_fields = ARRAY_SIZE(event_fields),
+ .fields = event_fields,
+};
+
+static
+int lttng_kp_init(struct lttng_kprobe *lttng_kp, const char *symbol_name, uint64_t offset, uint64_t addr,
+ kprobe_pre_handler_t pre_handler)
+{
+ /* Kprobes expects a NULL symbol name if unused */
+ if (symbol_name[0] == '\0')
+ symbol_name = NULL;
+
+ lttng_kp->pre_handler = pre_handler;
+
+ if (symbol_name) {
+ lttng_kp->symbol_name =
+ kzalloc(LTTNG_KERNEL_ABI_SYM_NAME_LEN * sizeof(char),
+ GFP_KERNEL);
+ if (!lttng_kp->symbol_name)
+ return -ENOMEM;
+ memcpy(lttng_kp->symbol_name, symbol_name,
+ LTTNG_KERNEL_ABI_SYM_NAME_LEN * sizeof(char));
+ }
+
+ lttng_kp->offset = offset;
+ lttng_kp->addr = addr;
+ return 0;
+}
+
+/*
+ * Initialize event
+ */
+int lttng_kprobes_init_event(const char *name,
+ const char *symbol_name,
+ uint64_t offset,
+ uint64_t addr,
+ struct lttng_kernel_event_common *event)
+{
+ struct lttng_kernel_event_desc *desc;
+ int ret;
+
+ desc = kzalloc(sizeof(*desc), GFP_KERNEL);
+ if (!desc)
+ return -ENOMEM;
+ desc->tp_class = &tp_class;
+ desc->event_name = kstrdup(name, GFP_KERNEL);
+ if (!desc->event_name) {
+ ret = -ENOMEM;
+ goto error_str;
+ }
+ desc->owner = THIS_MODULE;
+ event->priv->desc = desc;
+ ret = lttng_kp_init(&event->priv->u.kprobe, symbol_name, offset, addr,
+ lttng_kprobes_event_handler_pre);
+ if (ret)
+ goto error_init;
+ return 0;
+
+error_init:
+ kfree(desc->event_name);
+error_str:
+ kfree(desc);
+ return ret;
+}
+
+static
+int _lttng_kprobes_register(struct lttng_kprobe *lttng_kp)
+{
+ /*
+ * Ensure the memory we just allocated don't notify page faults.
+ * Well.. kprobes itself puts the page fault handler on the blacklist,
+ * but we can never be too careful.
+ */
+ wrapper_vmalloc_sync_mappings();
+
+ /*
+ * Populate struct kprobe on each registration because kprobe internally
+ * does destructive changes to its state (e.g. addr=NULL).
+ */
+ memset(<tng_kp->kp, 0, sizeof(lttng_kp->kp));
+ lttng_kp->kp.symbol_name = lttng_kp->symbol_name;
+ lttng_kp->kp.addr = (void *)(unsigned long)lttng_kp->addr;
+ lttng_kp->kp.offset = lttng_kp->offset;
+ lttng_kp->kp.pre_handler = lttng_kp->pre_handler;
+ return register_kprobe(<tng_kp->kp);
+}
+
+int lttng_kprobes_register_event(struct lttng_kernel_event_common *event)
+{
+ return _lttng_kprobes_register(&event->priv->u.kprobe);
+}
+
+void lttng_kprobes_unregister_event(struct lttng_kernel_event_common *event)
+{
+ unregister_kprobe(&event->priv->u.kprobe.kp);
+}
+
+int lttng_kprobes_match_check(const char *symbol_name, uint64_t offset, uint64_t addr)
+{
+ struct lttng_kprobe lttng_kp;
+ int ret = 0;
+
+ memset(<tng_kp, 0, sizeof(lttng_kp));
+ ret = lttng_kp_init(<tng_kp, symbol_name, offset, addr, NULL);
+ if (ret)
+ return ret;
+ ret = _lttng_kprobes_register(<tng_kp);
+ if (ret) {
+ ret = -ENOENT;
+ goto end;
+ }
+ unregister_kprobe(<tng_kp.kp);
+end:
+ kfree(lttng_kp.symbol_name);
+ return ret;
+
+}
+
+void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_common *event)
+{
+ kfree(event->priv->u.kprobe.symbol_name);
+ kfree(event->priv->desc->event_name);
+ kfree(event->priv->desc);
+}
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");
+MODULE_DESCRIPTION("LTTng kprobes probes");
+MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "."
+ __stringify(LTTNG_MODULES_MINOR_VERSION) "."
+ __stringify(LTTNG_MODULES_PATCHLEVEL_VERSION)
+ LTTNG_MODULES_EXTRAVERSION);
--- /dev/null
+/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+ *
+ * probes/lttng-kretprobes.c
+ *
+ * LTTng kretprobes integration module.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#include <linux/module.h>
+#include <wrapper/kprobes.h>
+#include <linux/slab.h>
+#include <linux/kref.h>
+#include <lttng/events.h>
+#include <lttng/events-internal.h>
+#include <ringbuffer/frontend_types.h>
+#include <wrapper/compiler_attributes.h>
+#include <wrapper/vmalloc.h>
+#include <wrapper/irqflags.h>
+#include <wrapper/rcu.h>
+#include <lttng/tracer.h>
+#include <blacklist/kprobes.h>
+
+enum lttng_kretprobe_type {
+ EVENT_ENTRY = 0,
+ EVENT_EXIT = 1,
+};
+
+struct lttng_krp {
+ struct kretprobe krp;
+ char *symbol_name;
+ uint64_t addr;
+ uint64_t offset;
+ kretprobe_handler_t entry_handler;
+ kretprobe_handler_t exit_handler;
+ struct lttng_kernel_event_common *event[NR_LTTNG_KRETPROBE_ENTRYEXIT]; /* entry/exit events */
+
+ int refcount_register; /* register kretprobe when > 0 */
+ struct kref kref_alloc;
+};
+
+static
+int _lttng_kretprobes_handler(struct kretprobe_instance *krpi,
+ struct pt_regs *regs,
+ enum lttng_kretprobe_type type)
+{
+ struct lttng_krp *lttng_krp =
+ container_of(lttng_get_kretprobe(krpi), struct lttng_krp, krp);
+ struct lttng_kernel_event_common *event = lttng_krp->event[type];
+ struct lttng_kernel_channel_common *chan_common;
+ struct lttng_kernel_probe_ctx lttng_probe_ctx = {
+ .event = event,
+ .interruptible = !lttng_regs_irqs_disabled(regs),
+ };
+ struct {
+ unsigned long ip;
+ unsigned long parent_ip;
+ } payload;
+
+ if (unlikely(!LTTNG_READ_ONCE(event->enabled)))
+ goto end;
+
+ chan_common = lttng_kernel_get_chan_common_from_event_common(event);
+ if (chan_common) {
+ struct lttng_kernel_session *session = chan_common->session;
+ struct lttng_kernel_id_tracker_rcu *lf;
+
+ if (unlikely(!LTTNG_READ_ONCE(session->active)))
+ goto end;
+ if (unlikely(!LTTNG_READ_ONCE(chan_common->enabled)))
+ goto end;
+ lf = lttng_rcu_dereference(session->pid_tracker.p);
+ if (lf && likely(!lttng_id_tracker_lookup(lf, current->tgid)))
+ goto end;
+ lf = lttng_rcu_dereference(session->vpid_tracker.p);
+ if (lf && likely(!lttng_id_tracker_lookup(lf, task_tgid_vnr(current))))
+ goto end;
+ lf = lttng_rcu_dereference(session->uid_tracker.p);
+ if (lf && likely(!lttng_id_tracker_lookup(lf, from_kuid_munged(&init_user_ns, current_uid()))))
+ goto end;
+ lf = lttng_rcu_dereference(session->vuid_tracker.p);
+ if (lf && likely(!lttng_id_tracker_lookup(lf, from_kuid_munged(current_user_ns(), current_uid()))))
+ goto end;
+ lf = lttng_rcu_dereference(session->gid_tracker.p);
+ if (lf && likely(!lttng_id_tracker_lookup(lf, from_kgid_munged(&init_user_ns, current_gid()))))
+ goto end;
+ lf = lttng_rcu_dereference(session->vgid_tracker.p);
+ if (lf && likely(!lttng_id_tracker_lookup(lf, from_kgid_munged(current_user_ns(), current_gid()))))
+ goto end;
+ }
+
+ switch (event->type) {
+ case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
+ {
+ struct lttng_kernel_event_recorder *event_recorder =
+ container_of(event, struct lttng_kernel_event_recorder, parent);
+ struct lttng_kernel_channel_buffer *chan = event_recorder->chan;
+ struct lttng_kernel_ring_buffer_ctx ctx;
+ int ret;
+
+ payload.ip = (unsigned long) lttng_get_kretprobe(krpi)->kp.addr;
+ payload.parent_ip = lttng_get_kretprobe_retaddr(krpi);
+
+ lib_ring_buffer_ctx_init(&ctx, event_recorder, sizeof(payload),
+ lttng_alignof(payload), <tng_probe_ctx);
+ ret = chan->ops->event_reserve(&ctx);
+ if (ret < 0)
+ return 0;
+ chan->ops->event_write(&ctx, &payload, sizeof(payload), lttng_alignof(payload));
+ chan->ops->event_commit(&ctx);
+ break;
+ }
+ case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
+ {
+ struct lttng_kernel_event_notifier *event_notifier =
+ container_of(event, struct lttng_kernel_event_notifier, parent);
+ struct lttng_kernel_notification_ctx notif_ctx;
+
+ notif_ctx.eval_capture = false;
+ event_notifier->notification_send(event_notifier, NULL, NULL, ¬if_ctx);
+ break;
+ }
+ case LTTNG_KERNEL_EVENT_TYPE_COUNTER:
+ {
+ struct lttng_kernel_event_counter *event_counter =
+ container_of(event, struct lttng_kernel_event_counter, parent);
+ struct lttng_kernel_event_counter_ctx event_counter_ctx;
+
+ event_counter_ctx.args_available = false;
+ (void) event_counter->chan->ops->counter_hit(event_counter,
+ NULL, NULL, &event_counter_ctx);
+ break;
+ }
+ default:
+ WARN_ON_ONCE(1);
+ }
+end:
+ return 0;
+}
+
+static
+int lttng_kretprobes_handler_entry(struct kretprobe_instance *krpi,
+ struct pt_regs *regs)
+{
+ return _lttng_kretprobes_handler(krpi, regs, EVENT_ENTRY);
+}
+
+static
+int lttng_kretprobes_handler_exit(struct kretprobe_instance *krpi,
+ struct pt_regs *regs)
+{
+ return _lttng_kretprobes_handler(krpi, regs, EVENT_EXIT);
+}
+
+static const struct lttng_kernel_event_field *event_fields[] = {
+ lttng_kernel_static_event_field("ip",
+ lttng_kernel_static_type_integer_from_type(unsigned long, __BYTE_ORDER, 16),
+ false, false),
+ lttng_kernel_static_event_field("parent_ip",
+ lttng_kernel_static_type_integer_from_type(unsigned long, __BYTE_ORDER, 16),
+ false, false),
+};
+
+static const struct lttng_kernel_tracepoint_class tp_class = {
+ .nr_fields = ARRAY_SIZE(event_fields),
+ .fields = event_fields,
+};
+
+static
+int lttng_krp_init(struct lttng_krp *lttng_krp,
+ const char *symbol_name, uint64_t offset, uint64_t addr,
+ kretprobe_handler_t entry_handler,
+ kretprobe_handler_t exit_handler)
+{
+ /* Kretprobes expects a NULL symbol name if unused */
+ if (symbol_name[0] == '\0')
+ symbol_name = NULL;
+
+ lttng_krp->entry_handler = entry_handler;
+ lttng_krp->exit_handler = exit_handler;
+
+ if (symbol_name) {
+ lttng_krp->symbol_name =
+ kzalloc(LTTNG_KERNEL_ABI_SYM_NAME_LEN * sizeof(char),
+ GFP_KERNEL);
+ if (!lttng_krp->symbol_name)
+ return -ENOMEM;
+ memcpy(lttng_krp->symbol_name, symbol_name,
+ LTTNG_KERNEL_ABI_SYM_NAME_LEN * sizeof(char));
+ }
+
+ lttng_krp->offset = offset;
+ lttng_krp->addr = addr;
+ return 0;
+}
+
+struct lttng_krp *lttng_kretprobes_create_krp(const char *symbol_name,
+ uint64_t offset, uint64_t addr)
+{
+ struct lttng_krp *lttng_krp;
+ int ret;
+
+ lttng_krp = kzalloc(sizeof(*lttng_krp), GFP_KERNEL);
+ if (!lttng_krp)
+ return NULL;
+ kref_init(<tng_krp->kref_alloc);
+ ret = lttng_krp_init(lttng_krp, symbol_name, offset, addr,
+ lttng_kretprobes_handler_entry,
+ lttng_kretprobes_handler_exit);
+ if (ret)
+ goto error_init;
+ return lttng_krp;
+
+error_init:
+ kfree(lttng_krp);
+ return NULL;
+}
+
+static
+void _lttng_kretprobes_release(struct kref *kref)
+{
+ struct lttng_krp *lttng_krp = container_of(kref, struct lttng_krp, kref_alloc);
+
+ kfree(lttng_krp->krp.kp.symbol_name);
+ kfree(lttng_krp);
+}
+
+void lttng_kretprobes_put_krp(struct lttng_krp *krp)
+{
+ kref_put(&krp->kref_alloc, _lttng_kretprobes_release);
+}
+
+/*
+ * Initialize event
+ */
+int lttng_kretprobes_init_event(const char *name,
+ enum lttng_kretprobe_entryexit entryexit,
+ struct lttng_kernel_event_common *event,
+ struct lttng_krp *krp)
+{
+ struct lttng_kernel_event_desc *desc;
+ int ret;
+
+ desc = kzalloc(sizeof(*desc), GFP_KERNEL);
+ if (!desc)
+ return -ENOMEM;
+ desc->tp_class = &tp_class;
+ desc->event_name = kstrdup(name, GFP_KERNEL);
+ if (!desc->event_name) {
+ ret = -ENOMEM;
+ goto error_str;
+ }
+ desc->owner = THIS_MODULE;
+ event->priv->desc = desc;
+ event->priv->u.kretprobe.lttng_krp = krp;
+ event->priv->u.kretprobe.entryexit = entryexit;
+ kref_get(&krp->kref_alloc);
+ krp->event[entryexit] = event;
+ return 0;
+
+error_str:
+ kfree(desc);
+ return ret;
+}
+
+static
+int _lttng_kretprobes_register(struct lttng_krp *lttng_krp)
+{
+ if (lttng_krp->refcount_register++ != 0)
+ return 0; /* Already registered */
+
+ /*
+ * Ensure the memory we just allocated don't notify page faults.
+ * Well.. kprobes itself puts the page fault handler on the blacklist,
+ * but we can never be too careful.
+ */
+ wrapper_vmalloc_sync_mappings();
+
+ /*
+ * Populate struct kprobe on each registration because kprobe internally
+ * does destructive changes to its state (e.g. addr=NULL).
+ */
+ memset(<tng_krp->krp, 0, sizeof(lttng_krp->krp));
+ lttng_krp->krp.kp.symbol_name = lttng_krp->symbol_name;
+ lttng_krp->krp.kp.addr = (void *)(unsigned long)lttng_krp->addr;
+ lttng_krp->krp.kp.offset = lttng_krp->offset;
+ lttng_krp->krp.entry_handler = lttng_krp->entry_handler;
+ lttng_krp->krp.handler = lttng_krp->exit_handler;
+ return register_kretprobe(<tng_krp->krp);
+}
+
+int lttng_kretprobes_register_event(struct lttng_kernel_event_common *event)
+{
+ return _lttng_kretprobes_register(event->priv->u.kretprobe.lttng_krp);
+}
+
+void lttng_kretprobes_unregister_event(struct lttng_kernel_event_common *event)
+{
+ struct lttng_krp *lttng_krp = event->priv->u.kretprobe.lttng_krp;
+
+ WARN_ON_ONCE(!lttng_krp->refcount_register);
+ if (--lttng_krp->refcount_register != 0)
+ return; /* Already unregistered */
+ unregister_kretprobe(<tng_krp->krp);
+}
+
+int lttng_kretprobes_match_check(const char *symbol_name, uint64_t offset, uint64_t addr)
+{
+ struct lttng_krp lttng_krp;
+ int ret = 0;
+
+ memset(<tng_krp, 0, sizeof(lttng_krp));
+ ret = lttng_krp_init(<tng_krp, symbol_name, offset, addr, NULL, NULL);
+ if (ret)
+ return ret;
+ ret = _lttng_kretprobes_register(<tng_krp);
+ if (ret) {
+ ret = -ENOENT;
+ goto end;
+ }
+ unregister_kretprobe(<tng_krp.krp);
+end:
+ kfree(lttng_krp.symbol_name);
+ return ret;
+}
+
+void lttng_kretprobes_destroy_event_private(struct lttng_kernel_event_common *event)
+{
+ kfree(event->priv->desc->event_name);
+ kfree(event->priv->desc);
+ lttng_kretprobes_put_krp(event->priv->u.kretprobe.lttng_krp);
+}
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");
+MODULE_DESCRIPTION("LTTng kretprobes probes");
+MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "."
+ __stringify(LTTNG_MODULES_MINOR_VERSION) "."
+ __stringify(LTTNG_MODULES_PATCHLEVEL_VERSION)
+ LTTNG_MODULES_EXTRAVERSION);
cpu = lib_ring_buffer_get_cpu(&client_config);
if (unlikely(cpu < 0))
return -EPERM;
- event_id = event_recorder->priv->id;
+ event_id = (uint32_t)event_recorder->priv->parent.id;
memset(&ctx->priv, 0, sizeof(ctx->priv));
ctx->priv.chan = lttng_chan->priv->rb_chan;
ctx->priv.reserve_cpu = cpu;
-/* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
+/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
*
* lttng-ring-buffer-event-notifier-client.c
*
-/* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
+/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
*
* lttng-ring-buffer-event-notifier-client.h
*
#include <wrapper/fdtable.h>
#include <wrapper/tracepoint.h>
#include <wrapper/blkdev.h>
-#include <wrapper/fdtable.h>
#include <wrapper/sched.h>
/* Define the tracepoints, but do not build the probes */
*/
flags &= ~FMODE_NONOTIFY;
fdt = files_fdtable(ctx->files);
+
/*
- * We need to check here again whether fd is within the fdt
- * max_fds range, because we might be seeing a different
- * files_fdtable() than iterate_fd(), assuming only RCU is
- * protecting the read. In reality, iterate_fd() holds
- * file_lock, which should ensure the fdt does not change while
- * the lock is taken, but we are not aware whether this is
- * guaranteed or not, so play safe.
+ * The fdt should only grow and iterate_fd() holds file_lock, which
+ * should ensure the fdt does not change while the lock is taken but be
+ * cautious and check anyway.
*/
- if (fd < fdt->max_fds && close_on_exec(fd, fdt))
+ if (WARN_ON_ONCE(fd >= fdt->max_fds))
+ return 0;
+
+ if (lttng_close_on_exec(fd, ctx->files))
flags |= O_CLOEXEC;
+
+ /*
+ * If d_path() failed to get a full path for the file, use the dentry
+ * name instead to at least get a filename.
+ */
if (IS_ERR(s)) {
struct dentry *dentry = file->f_path.dentry;
{
switch (event_enabler->enabler_type) {
case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
+ lttng_fallthrough;
+ case LTTNG_EVENT_ENABLER_TYPE_COUNTER:
{
- struct lttng_event_recorder_enabler *event_recorder_enabler =
- container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
- return &event_recorder_enabler->chan->priv->parent.syscall_table;
+ struct lttng_event_enabler_session_common *event_enabler_session =
+ container_of(event_enabler, struct lttng_event_enabler_session_common, parent);
+ return &event_enabler_session->chan->priv->syscall_table;
}
case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
{
{
switch (event->type) {
case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
+ lttng_fallthrough;
+ case LTTNG_KERNEL_EVENT_TYPE_COUNTER:
{
- struct lttng_kernel_event_recorder *event_recorder =
- container_of(event, struct lttng_kernel_event_recorder, parent);
- return &event_recorder->chan->priv->parent.syscall_table;
+ struct lttng_kernel_event_common_private *event_priv = event->priv;
+ struct lttng_kernel_event_session_common_private *event_session_priv =
+ container_of(event_priv, struct lttng_kernel_event_session_common_private, parent);
+ return &event_session_priv->chan->priv->syscall_table;
}
case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
{
case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
{
struct lttng_event_recorder_enabler *syscall_event_recorder_enabler =
- container_of(syscall_event_enabler, struct lttng_event_recorder_enabler, parent);
+ container_of(syscall_event_enabler, struct lttng_event_recorder_enabler, parent.parent);
struct lttng_event_recorder_enabler *event_recorder_enabler;
struct lttng_kernel_abi_event ev;
strncpy(ev.name, desc->event_name, LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1);
ev.name[LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1] = '\0';
ev.instrumentation = LTTNG_KERNEL_ABI_SYSCALL;
+ ev.token = syscall_event_enabler->user_token;
event_recorder_enabler = lttng_event_recorder_enabler_create(LTTNG_ENABLER_FORMAT_NAME, &ev,
syscall_event_recorder_enabler->chan);
WARN_ON_ONCE(!event_recorder_enabler);
if (!event_recorder_enabler)
return;
- event = _lttng_kernel_event_create(&event_recorder_enabler->parent, desc);
+ event = _lttng_kernel_event_create(&event_recorder_enabler->parent.parent, desc, NULL);
WARN_ON_ONCE(IS_ERR(event));
- lttng_event_enabler_destroy(&event_recorder_enabler->parent);
+ lttng_event_enabler_destroy(&event_recorder_enabler->parent.parent);
if (IS_ERR(event)) {
printk(KERN_INFO "Unable to create event recorder %s\n", desc->event_name);
return;
container_of(syscall_event_enabler, struct lttng_event_notifier_enabler, parent);
struct lttng_event_notifier_enabler *event_notifier_enabler;
struct lttng_kernel_abi_event_notifier event_notifier_param;
- uint64_t user_token = syscall_event_enabler->user_token;
uint64_t error_counter_index = syscall_event_notifier_enabler->error_counter_index;
memset(&event_notifier_param, 0, sizeof(event_notifier_param));
LTTNG_KERNEL_ABI_SYM_NAME_LEN - strlen(event_notifier_param.event.name) - 1);
event_notifier_param.event.name[LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1] = '\0';
event_notifier_param.event.instrumentation = LTTNG_KERNEL_ABI_SYSCALL;
- event_notifier_param.event.token = user_token;
+ event_notifier_param.event.token = syscall_event_enabler->user_token;
event_notifier_param.error_counter_index = error_counter_index;
event_notifier_enabler = lttng_event_notifier_enabler_create(LTTNG_ENABLER_FORMAT_NAME,
&event_notifier_param, syscall_event_notifier_enabler->group);
WARN_ON_ONCE(!event_notifier_enabler);
- event = _lttng_kernel_event_create(&event_notifier_enabler->parent, desc);
+ event = _lttng_kernel_event_create(&event_notifier_enabler->parent, desc, NULL);
WARN_ON_ONCE(IS_ERR(event));
lttng_event_enabler_destroy(&event_notifier_enabler->parent);
if (IS_ERR(event)) {
}
event->priv->u.syscall.syscall_id = syscall_nr;
break;
+ case LTTNG_EVENT_ENABLER_TYPE_COUNTER:
+ {
+ struct lttng_event_counter_enabler *syscall_event_counter_enabler =
+ container_of(syscall_event_enabler, struct lttng_event_counter_enabler, parent.parent);
+ struct lttng_event_counter_enabler *event_counter_enabler;
+ struct lttng_kernel_abi_event ev;
+
+ /* We need to create an event for this syscall/enabler. */
+ memset(&ev, 0, sizeof(ev));
+ switch (type) {
+ case SC_TYPE_ENTRY:
+ ev.u.syscall.entryexit = LTTNG_KERNEL_ABI_SYSCALL_ENTRY;
+ ev.u.syscall.abi = LTTNG_KERNEL_ABI_SYSCALL_ABI_NATIVE;
+ break;
+ case SC_TYPE_EXIT:
+ ev.u.syscall.entryexit = LTTNG_KERNEL_ABI_SYSCALL_EXIT;
+ ev.u.syscall.abi = LTTNG_KERNEL_ABI_SYSCALL_ABI_NATIVE;
+ break;
+ case SC_TYPE_COMPAT_ENTRY:
+ ev.u.syscall.entryexit = LTTNG_KERNEL_ABI_SYSCALL_ENTRY;
+ ev.u.syscall.abi = LTTNG_KERNEL_ABI_SYSCALL_ABI_COMPAT;
+ break;
+ case SC_TYPE_COMPAT_EXIT:
+ ev.u.syscall.entryexit = LTTNG_KERNEL_ABI_SYSCALL_EXIT;
+ ev.u.syscall.abi = LTTNG_KERNEL_ABI_SYSCALL_ABI_COMPAT;
+ break;
+ }
+ strncpy(ev.name, desc->event_name, LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1);
+ ev.name[LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1] = '\0';
+ ev.instrumentation = LTTNG_KERNEL_ABI_SYSCALL;
+ ev.token = syscall_event_enabler->user_token;
+ event_counter_enabler = lttng_event_counter_enabler_create(LTTNG_ENABLER_FORMAT_NAME, &ev,
+ syscall_event_counter_enabler->key, syscall_event_counter_enabler->chan);
+ WARN_ON_ONCE(!event_counter_enabler);
+ if (!event_counter_enabler)
+ return;
+ event = _lttng_kernel_event_create(&event_counter_enabler->parent.parent, desc, NULL);
+ lttng_event_enabler_destroy(&event_counter_enabler->parent.parent);
+ if (IS_ERR(event)) {
+ if (PTR_ERR(event) != -EEXIST)
+ printk(KERN_INFO "Unable to create event counter %s\n", desc->event_name);
+ return;
+ }
+ event->priv->u.syscall.syscall_id = syscall_nr;
+ break;
+ }
+
}
default:
break;
void lttng_syscall_event_enabler_create_matching_syscall_table_events(struct lttng_event_enabler_common *syscall_event_enabler_common,
const struct trace_syscall_entry *table, size_t table_len, enum sc_type type)
{
- struct lttng_event_ht *events_ht = lttng_get_event_ht_from_enabler(syscall_event_enabler_common);
+ struct lttng_event_ht *events_name_ht = lttng_get_events_name_ht_from_enabler(syscall_event_enabler_common);
const struct lttng_kernel_event_desc *desc;
unsigned int i;
#endif
/* iterate over all syscall and create event that match */
for (i = 0; i < table_len; i++) {
+ char key_string[LTTNG_KERNEL_COUNTER_KEY_LEN] = { 0 };
struct lttng_kernel_event_common_private *event_priv;
struct hlist_head *head;
bool found = false;
if (!lttng_desc_match_enabler(desc, syscall_event_enabler_common))
continue;
+ if (format_event_key(syscall_event_enabler_common, key_string, desc->event_name))
+ continue;
+
/*
* Check if already created.
*/
- head = utils_borrow_hash_table_bucket(events_ht->table, LTTNG_EVENT_HT_SIZE, desc->event_name);
- lttng_hlist_for_each_entry(event_priv, head, hlist_node) {
- if (lttng_event_enabler_desc_match_event(syscall_event_enabler_common, desc, event_priv->pub)) {
+ head = utils_borrow_hash_table_bucket(events_name_ht->table, LTTNG_EVENT_HT_SIZE, desc->event_name);
+ lttng_hlist_for_each_entry(event_priv, head, hlist_name_node) {
+ if (lttng_event_enabler_event_name_key_match_event(syscall_event_enabler_common, desc->event_name, key_string, event_priv->pub)) {
found = true;
break;
}
static
void create_unknown_syscall_event(struct lttng_event_enabler_common *event_enabler, enum sc_type type)
{
- struct lttng_event_ht *events_ht = lttng_get_event_ht_from_enabler(event_enabler);
+ char key_string[LTTNG_KERNEL_COUNTER_KEY_LEN] = { 0 };
+ struct lttng_event_ht *events_name_ht = lttng_get_events_name_ht_from_enabler(event_enabler);
struct lttng_kernel_event_common_private *event_priv;
const struct lttng_kernel_event_desc *desc;
bool found = false;
WARN_ON_ONCE(1);
}
+ if (format_event_key(event_enabler, key_string, desc->event_name))
+ return;
+
/*
* Check if already created.
*/
- head = utils_borrow_hash_table_bucket(events_ht->table, LTTNG_EVENT_HT_SIZE, desc->event_name);
- lttng_hlist_for_each_entry(event_priv, head, hlist_node) {
- if (lttng_event_enabler_desc_match_event(event_enabler, desc, event_priv->pub)) {
+ head = utils_borrow_hash_table_bucket(events_name_ht->table, LTTNG_EVENT_HT_SIZE, desc->event_name);
+ lttng_hlist_for_each_entry(event_priv, head, hlist_name_node) {
+ if (lttng_event_enabler_event_name_key_match_event(event_enabler, desc->event_name, key_string, event_priv->pub)) {
found = true;
break;
}
--- /dev/null
+/* SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only)
+ *
+ * probes/lttng-uprobes.c
+ *
+ * LTTng uprobes integration module.
+ *
+ * Copyright (C) 2013 Yannick Brosseau <yannick.brosseau@gmail.com>
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ */
+
+#include <wrapper/fdtable.h>
+#include <linux/file.h>
+#include <linux/list.h>
+#include <linux/module.h>
+#include <linux/namei.h>
+#include <linux/slab.h>
+#include <linux/uaccess.h>
+#include <linux/uprobes.h>
+
+#include <lttng/events.h>
+#include <lttng/events-internal.h>
+#include <lttng/tracer.h>
+#include <wrapper/irqflags.h>
+#include <wrapper/rcu.h>
+#include <ringbuffer/frontend_types.h>
+#include <wrapper/vmalloc.h>
+
+static
+int lttng_uprobes_event_handler_pre(struct uprobe_consumer *uc, struct pt_regs *regs)
+{
+ struct lttng_uprobe_handler *uprobe_handler =
+ container_of(uc, struct lttng_uprobe_handler, up_consumer);
+ struct lttng_kernel_event_common *event = uprobe_handler->event;
+ struct lttng_kernel_channel_common *chan_common;
+ struct lttng_kernel_probe_ctx lttng_probe_ctx = {
+ .event = event,
+ .interruptible = !lttng_regs_irqs_disabled(regs),
+ };
+ struct {
+ unsigned long ip;
+ } payload;
+
+ if (unlikely(!LTTNG_READ_ONCE(event->enabled)))
+ goto end;
+
+ chan_common = lttng_kernel_get_chan_common_from_event_common(event);
+ if (chan_common) {
+ struct lttng_kernel_session *session = chan_common->session;
+ struct lttng_kernel_id_tracker_rcu *lf;
+
+ if (unlikely(!LTTNG_READ_ONCE(session->active)))
+ goto end;
+ if (unlikely(!LTTNG_READ_ONCE(chan_common->enabled)))
+ goto end;
+ lf = lttng_rcu_dereference(session->pid_tracker.p);
+ if (lf && likely(!lttng_id_tracker_lookup(lf, current->tgid)))
+ goto end;
+ lf = lttng_rcu_dereference(session->vpid_tracker.p);
+ if (lf && likely(!lttng_id_tracker_lookup(lf, task_tgid_vnr(current))))
+ goto end;
+ lf = lttng_rcu_dereference(session->uid_tracker.p);
+ if (lf && likely(!lttng_id_tracker_lookup(lf, from_kuid_munged(&init_user_ns, current_uid()))))
+ goto end;
+ lf = lttng_rcu_dereference(session->vuid_tracker.p);
+ if (lf && likely(!lttng_id_tracker_lookup(lf, from_kuid_munged(current_user_ns(), current_uid()))))
+ goto end;
+ lf = lttng_rcu_dereference(session->gid_tracker.p);
+ if (lf && likely(!lttng_id_tracker_lookup(lf, from_kgid_munged(&init_user_ns, current_gid()))))
+ goto end;
+ lf = lttng_rcu_dereference(session->vgid_tracker.p);
+ if (lf && likely(!lttng_id_tracker_lookup(lf, from_kgid_munged(current_user_ns(), current_gid()))))
+ goto end;
+ }
+ switch (event->type) {
+ case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
+ {
+ struct lttng_kernel_event_recorder *event_recorder =
+ container_of(event, struct lttng_kernel_event_recorder, parent);
+ struct lttng_kernel_channel_buffer *chan = event_recorder->chan;
+ struct lttng_kernel_ring_buffer_ctx ctx;
+ int ret;
+
+ lib_ring_buffer_ctx_init(&ctx, event_recorder,
+ sizeof(payload), lttng_alignof(payload), <tng_probe_ctx);
+
+ ret = chan->ops->event_reserve(&ctx);
+ if (ret < 0)
+ return 0;
+
+ /* Event payload. */
+ payload.ip = (unsigned long)instruction_pointer(regs);
+
+ chan->ops->event_write(&ctx, &payload, sizeof(payload), lttng_alignof(payload));
+ chan->ops->event_commit(&ctx);
+ break;
+ }
+ case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
+ {
+ struct lttng_kernel_event_notifier *event_notifier =
+ container_of(event, struct lttng_kernel_event_notifier, parent);
+ struct lttng_kernel_notification_ctx notif_ctx;
+
+ notif_ctx.eval_capture = false;
+ event_notifier->notification_send(event_notifier, NULL, NULL, ¬if_ctx);
+ break;
+ }
+ case LTTNG_KERNEL_EVENT_TYPE_COUNTER:
+ {
+ struct lttng_kernel_event_counter *event_counter =
+ container_of(event, struct lttng_kernel_event_counter, parent);
+ struct lttng_kernel_event_counter_ctx event_counter_ctx;
+
+ event_counter_ctx.args_available = false;
+ /* uprobes is invoked with preemption enabled. */
+ rcu_read_lock_sched_notrace();
+ (void) event_counter->chan->ops->counter_hit(event_counter,
+ NULL, NULL, &event_counter_ctx);
+ rcu_read_unlock_sched_notrace();
+ break;
+ }
+ default:
+ WARN_ON_ONCE(1);
+ }
+end:
+ return 0;
+}
+
+static const struct lttng_kernel_event_field *event_fields[] = {
+ lttng_kernel_static_event_field("ip",
+ lttng_kernel_static_type_integer_from_type(unsigned long, __BYTE_ORDER, 16),
+ false, false),
+};
+
+static const struct lttng_kernel_tracepoint_class tp_class = {
+ .nr_fields = ARRAY_SIZE(event_fields),
+ .fields = event_fields,
+};
+
+/*
+ * Create event description.
+ */
+static
+int lttng_create_uprobe_event(const char *name, struct lttng_kernel_event_common *event)
+{
+ struct lttng_kernel_event_desc *desc;
+ int ret;
+
+ desc = kzalloc(sizeof(*desc), GFP_KERNEL);
+ if (!desc)
+ return -ENOMEM;
+ desc->tp_class = &tp_class;
+ desc->event_name = kstrdup(name, GFP_KERNEL);
+ if (!desc->event_name) {
+ ret = -ENOMEM;
+ goto error_str;
+ }
+ desc->owner = THIS_MODULE;
+ event->priv->desc = desc;
+
+ return 0;
+
+error_str:
+ kfree(desc);
+ return ret;
+}
+
+/*
+ * Returns the inode struct from the current task and an fd. The inode is
+ * grabbed by this function and must be put once we are done with it using
+ * iput().
+ */
+static struct inode *get_inode_from_fd(int fd)
+{
+ struct file *file;
+ struct inode *inode;
+
+ rcu_read_lock();
+ /*
+ * Returns the file backing the given fd. Needs to be done inside an RCU
+ * critical section.
+ */
+ file = lttng_lookup_fdget_rcu(fd);
+ if (file == NULL) {
+ printk(KERN_WARNING "LTTng: Cannot access file backing the fd(%d)\n", fd);
+ inode = NULL;
+ goto error;
+ }
+
+ /* Grab a reference on the inode. */
+ inode = igrab(file->f_path.dentry->d_inode);
+ if (inode == NULL)
+ printk(KERN_WARNING "LTTng: Cannot grab a reference on the inode.\n");
+
+error:
+ rcu_read_unlock();
+ if (file)
+ fput(file);
+ return inode;
+}
+
+
+static
+int lttng_uprobes_add_callsite(struct lttng_uprobe *uprobe,
+ struct lttng_kernel_abi_event_callsite __user *callsite,
+ int (*handler)(struct uprobe_consumer *self, struct pt_regs *regs),
+ void *priv_data)
+{
+ int ret = 0;
+ struct lttng_uprobe_handler *uprobe_handler;
+
+ if (!priv_data) {
+ ret = -EINVAL;
+ goto end;
+ }
+
+ uprobe_handler = kzalloc(sizeof(struct lttng_uprobe_handler), GFP_KERNEL);
+ if (!uprobe_handler) {
+ printk(KERN_WARNING "LTTng: Error allocating uprobe_handler");
+ ret = -ENOMEM;
+ goto end;
+ }
+
+ /* Ensure the memory we just allocated don't notify page faults. */
+ wrapper_vmalloc_sync_mappings();
+
+ uprobe_handler->event = priv_data;
+ uprobe_handler->up_consumer.handler = handler;
+
+ ret = copy_from_user(&uprobe_handler->offset, &callsite->u.uprobe.offset, sizeof(uint64_t));
+ if (ret) {
+ goto register_error;
+ }
+
+ ret = uprobe_register(uprobe->inode,
+ uprobe_handler->offset, &uprobe_handler->up_consumer);
+ if (ret) {
+ printk(KERN_WARNING "LTTng: Error registering probe on inode %lu "
+ "and offset 0x%llx\n", uprobe->inode->i_ino,
+ uprobe_handler->offset);
+ ret = -1;
+ goto register_error;
+ }
+
+ list_add(&uprobe_handler->node, &uprobe->head);
+
+ return ret;
+
+register_error:
+ kfree(uprobe_handler);
+end:
+ return ret;
+}
+
+int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common *event,
+ struct lttng_kernel_abi_event_callsite __user *callsite)
+{
+ return lttng_uprobes_add_callsite(&event->priv->u.uprobe, callsite,
+ lttng_uprobes_event_handler_pre, event);
+}
+
+static
+int lttng_uprobes_register(struct lttng_uprobe *uprobe, int fd)
+{
+ int ret = 0;
+ struct inode *inode;
+
+ inode = get_inode_from_fd(fd);
+ if (!inode) {
+ printk(KERN_WARNING "LTTng: Cannot get inode from fd\n");
+ ret = -EBADF;
+ goto inode_error;
+ }
+ uprobe->inode = inode;
+ INIT_LIST_HEAD(&uprobe->head);
+
+inode_error:
+ return ret;
+}
+
+int lttng_uprobes_register_event(const char *name, int fd, struct lttng_kernel_event_common *event)
+{
+ int ret = 0;
+
+ ret = lttng_create_uprobe_event(name, event);
+ if (ret)
+ goto error;
+
+ ret = lttng_uprobes_register(&event->priv->u.uprobe, fd);
+ if (ret)
+ goto register_error;
+
+ return 0;
+
+register_error:
+ kfree(event->priv->desc->event_name);
+ kfree(event->priv->desc);
+error:
+ return ret;
+}
+
+static
+void lttng_uprobes_unregister(struct inode *inode, struct list_head *head)
+{
+ struct lttng_uprobe_handler *iter, *tmp;
+
+ /*
+ * Iterate over the list of handler, remove each handler from the list
+ * and free the struct.
+ */
+ list_for_each_entry_safe(iter, tmp, head, node) {
+ uprobe_unregister(inode, iter->offset, &iter->up_consumer);
+ list_del(&iter->node);
+ kfree(iter);
+ }
+}
+
+void lttng_uprobes_unregister_event(struct lttng_kernel_event_common *event)
+{
+ lttng_uprobes_unregister(event->priv->u.uprobe.inode, &event->priv->u.uprobe.head);
+}
+
+void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_common *event)
+{
+ iput(event->priv->u.uprobe.inode);
+ kfree(event->priv->desc->event_name);
+ kfree(event->priv->desc);
+}
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Yannick Brosseau");
+MODULE_DESCRIPTION("Linux Trace Toolkit Uprobes Support");
# SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2010-2024 EfficiOS Inc.
TOP_LTTNG_MODULES_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST)))/../..
endif
endif # CONFIG_KALLSYMS_ALL
-ifneq ($(CONFIG_KPROBES),)
- obj-$(CONFIG_LTTNG) += lttng-kprobes.o
-endif # CONFIG_KPROBES
-
-ifneq ($(CONFIG_UPROBES),)
- obj-$(CONFIG_LTTNG) += lttng-uprobes.o
-endif # CONFIG_UPROBES
-
-ifneq ($(CONFIG_KRETPROBES),)
- obj-$(CONFIG_LTTNG) += lttng-kretprobes.o
-endif # CONFIG_KRETPROBES
-
ifneq ($(CONFIG_PREEMPTIRQ_EVENTS),)
obj-$(CONFIG_LTTNG) += lttng-probe-preemptirq.o
endif # CONFIG_PREEMPTIRQ_EVENTS
+++ /dev/null
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
- *
- * probes/lttng-kprobes.c
- *
- * LTTng kprobes integration module.
- *
- * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- */
-
-#include <linux/module.h>
-#include <linux/kprobes.h>
-#include <linux/slab.h>
-#include <lttng/events.h>
-#include <lttng/events-internal.h>
-#include <ringbuffer/frontend_types.h>
-#include <wrapper/vmalloc.h>
-#include <wrapper/irqflags.h>
-#include <lttng/tracer.h>
-#include <blacklist/kprobes.h>
-
-static
-int lttng_kprobes_event_handler_pre(struct kprobe *p, struct pt_regs *regs)
-{
- struct lttng_kernel_event_common_private *event_priv =
- container_of(p, struct lttng_kernel_event_common_private, u.kprobe.kp);
- struct lttng_kernel_event_common *event = event_priv->pub;
- struct lttng_kernel_probe_ctx lttng_probe_ctx = {
- .event = event,
- .interruptible = !lttng_regs_irqs_disabled(regs),
- };
- unsigned long data = (unsigned long) p->addr;
-
- switch (event->type) {
- case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
- {
- struct lttng_kernel_event_recorder_private *event_recorder_priv =
- container_of(event_priv, struct lttng_kernel_event_recorder_private, parent);
- struct lttng_kernel_event_recorder *event_recorder =
- event_recorder_priv->pub;
- struct lttng_kernel_channel_buffer *chan = event_recorder->chan;
-
- if (unlikely(!LTTNG_READ_ONCE(chan->parent.session->active)))
- return 0;
- if (unlikely(!LTTNG_READ_ONCE(chan->parent.enabled)))
- return 0;
- break;
- }
- case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
- break;
- default:
- WARN_ON_ONCE(1);
- }
-
- if (unlikely(!LTTNG_READ_ONCE(event->enabled)))
- return 0;
-
- switch (event->type) {
- case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
- {
- struct lttng_kernel_event_recorder *event_recorder =
- container_of(event, struct lttng_kernel_event_recorder, parent);
- struct lttng_kernel_channel_buffer *chan = event_recorder->chan;
- struct lttng_kernel_ring_buffer_ctx ctx;
- int ret;
-
- lib_ring_buffer_ctx_init(&ctx, event_recorder, sizeof(data),
- lttng_alignof(data), <tng_probe_ctx);
- ret = chan->ops->event_reserve(&ctx);
- if (ret < 0)
- return 0;
- chan->ops->event_write(&ctx, &data, sizeof(data), lttng_alignof(data));
- chan->ops->event_commit(&ctx);
- break;
- }
- case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
- {
- struct lttng_kernel_event_notifier *event_notifier =
- container_of(event, struct lttng_kernel_event_notifier, parent);
- struct lttng_kernel_notification_ctx notif_ctx;
-
- notif_ctx.eval_capture = LTTNG_READ_ONCE(event_notifier->eval_capture);
- event_notifier->notification_send(event_notifier, NULL, NULL, ¬if_ctx);
- break;
- }
- default:
- WARN_ON_ONCE(1);
- }
- return 0;
-}
-
-static const struct lttng_kernel_event_field *event_fields[] = {
- lttng_kernel_static_event_field("ip",
- lttng_kernel_static_type_integer_from_type(unsigned long, __BYTE_ORDER, 16),
- false, false),
-};
-
-static const struct lttng_kernel_tracepoint_class tp_class = {
- .nr_fields = ARRAY_SIZE(event_fields),
- .fields = event_fields,
-};
-
-/*
- * Create event description
- */
-static
-int lttng_create_kprobe_event(const char *name, struct lttng_kernel_event_common *event)
-{
- struct lttng_kernel_event_desc *desc;
- int ret;
-
- desc = kzalloc(sizeof(*desc), GFP_KERNEL);
- if (!desc)
- return -ENOMEM;
- desc->tp_class = &tp_class;
- desc->event_name = kstrdup(name, GFP_KERNEL);
- if (!desc->event_name) {
- ret = -ENOMEM;
- goto error_str;
- }
- desc->owner = THIS_MODULE;
- event->priv->desc = desc;
-
- return 0;
-
-error_str:
- kfree(desc);
- return ret;
-}
-
-static
-int _lttng_kprobes_register(const char *symbol_name,
- uint64_t offset,
- uint64_t addr,
- struct lttng_kprobe *lttng_kp,
- kprobe_pre_handler_t pre_handler)
-{
- int ret;
-
- /* Kprobes expects a NULL symbol name if unused */
- if (symbol_name[0] == '\0')
- symbol_name = NULL;
-
- memset(<tng_kp->kp, 0, sizeof(lttng_kp->kp));
- lttng_kp->kp.pre_handler = pre_handler;
-
- if (symbol_name) {
- lttng_kp->symbol_name =
- kzalloc(LTTNG_KERNEL_ABI_SYM_NAME_LEN * sizeof(char),
- GFP_KERNEL);
- if (!lttng_kp->symbol_name) {
- ret = -ENOMEM;
- goto name_error;
- }
- memcpy(lttng_kp->symbol_name, symbol_name,
- LTTNG_KERNEL_ABI_SYM_NAME_LEN * sizeof(char));
- lttng_kp->kp.symbol_name = lttng_kp->symbol_name;
- }
-
- lttng_kp->kp.offset = offset;
- lttng_kp->kp.addr = (void *) (unsigned long) addr;
-
- /*
- * Ensure the memory we just allocated don't notify page faults.
- * Well.. kprobes itself puts the page fault handler on the blacklist,
- * but we can never be too careful.
- */
- wrapper_vmalloc_sync_mappings();
-
- ret = register_kprobe(<tng_kp->kp);
- if (ret)
- goto register_error;
-
- return 0;
-
-register_error:
- kfree(lttng_kp->symbol_name);
-name_error:
- return ret;
-}
-
-int lttng_kprobes_register_event(const char *name,
- const char *symbol_name,
- uint64_t offset,
- uint64_t addr,
- struct lttng_kernel_event_common *event)
-{
- int ret;
-
- ret = lttng_create_kprobe_event(name, event);
- if (ret)
- goto error;
-
- ret = _lttng_kprobes_register(symbol_name, offset, addr,
- &event->priv->u.kprobe, lttng_kprobes_event_handler_pre);
- if (ret)
- goto register_error;
-
- return 0;
-
-register_error:
- kfree(event->priv->desc->event_name);
- kfree(event->priv->desc);
-error:
- return ret;
-}
-EXPORT_SYMBOL_GPL(lttng_kprobes_register_event);
-
-void lttng_kprobes_unregister_event(struct lttng_kernel_event_common *event)
-{
- unregister_kprobe(&event->priv->u.kprobe.kp);
-}
-EXPORT_SYMBOL_GPL(lttng_kprobes_unregister_event);
-
-void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_common *event)
-{
- kfree(event->priv->u.kprobe.symbol_name);
- kfree(event->priv->desc->event_name);
- kfree(event->priv->desc);
-}
-EXPORT_SYMBOL_GPL(lttng_kprobes_destroy_event_private);
-
-MODULE_LICENSE("GPL and additional rights");
-MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");
-MODULE_DESCRIPTION("LTTng kprobes probes");
-MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "."
- __stringify(LTTNG_MODULES_MINOR_VERSION) "."
- __stringify(LTTNG_MODULES_PATCHLEVEL_VERSION)
- LTTNG_MODULES_EXTRAVERSION);
+++ /dev/null
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
- *
- * probes/lttng-kretprobes.c
- *
- * LTTng kretprobes integration module.
- *
- * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- */
-
-#include <linux/module.h>
-#include <wrapper/kprobes.h>
-#include <linux/slab.h>
-#include <linux/kref.h>
-#include <lttng/events.h>
-#include <lttng/events-internal.h>
-#include <ringbuffer/frontend_types.h>
-#include <wrapper/compiler_attributes.h>
-#include <wrapper/vmalloc.h>
-#include <wrapper/irqflags.h>
-#include <lttng/tracer.h>
-#include <blacklist/kprobes.h>
-
-enum lttng_kretprobe_type {
- EVENT_ENTRY = 0,
- EVENT_EXIT = 1,
-};
-
-struct lttng_krp {
- struct kretprobe krp;
- struct lttng_kernel_event_common *event[2]; /* ENTRY and EXIT */
- struct kref kref_register;
- struct kref kref_alloc;
-};
-
-static
-int _lttng_kretprobes_handler(struct kretprobe_instance *krpi,
- struct pt_regs *regs,
- enum lttng_kretprobe_type type)
-{
- struct lttng_krp *lttng_krp =
- container_of(lttng_get_kretprobe(krpi), struct lttng_krp, krp);
- struct lttng_kernel_event_common *event = lttng_krp->event[type];
- struct lttng_kernel_probe_ctx lttng_probe_ctx = {
- .event = event,
- .interruptible = !lttng_regs_irqs_disabled(regs),
- };
- struct {
- unsigned long ip;
- unsigned long parent_ip;
- } payload;
-
- switch (event->type) {
- case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
- {
- struct lttng_kernel_event_recorder *event_recorder =
- container_of(event, struct lttng_kernel_event_recorder, parent);
- struct lttng_kernel_channel_buffer *chan = event_recorder->chan;
-
- if (unlikely(!LTTNG_READ_ONCE(chan->parent.session->active)))
- return 0;
- if (unlikely(!LTTNG_READ_ONCE(chan->parent.enabled)))
- return 0;
- break;
- }
- case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
- lttng_fallthrough;
- default:
- WARN_ON_ONCE(1);
- }
-
- if (unlikely(!LTTNG_READ_ONCE(event->enabled)))
- return 0;
-
- switch (event->type) {
- case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
- {
- struct lttng_kernel_event_recorder *event_recorder =
- container_of(event, struct lttng_kernel_event_recorder, parent);
- struct lttng_kernel_channel_buffer *chan = event_recorder->chan;
- struct lttng_kernel_ring_buffer_ctx ctx;
- int ret;
-
- payload.ip = (unsigned long) lttng_get_kretprobe(krpi)->kp.addr;
- payload.parent_ip = lttng_get_kretprobe_retaddr(krpi);
-
- lib_ring_buffer_ctx_init(&ctx, event_recorder, sizeof(payload),
- lttng_alignof(payload), <tng_probe_ctx);
- ret = chan->ops->event_reserve(&ctx);
- if (ret < 0)
- return 0;
- chan->ops->event_write(&ctx, &payload, sizeof(payload), lttng_alignof(payload));
- chan->ops->event_commit(&ctx);
- break;
- }
- case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
- lttng_fallthrough;
- default:
- WARN_ON_ONCE(1);
- }
- return 0;
-}
-
-static
-int lttng_kretprobes_handler_entry(struct kretprobe_instance *krpi,
- struct pt_regs *regs)
-{
- return _lttng_kretprobes_handler(krpi, regs, EVENT_ENTRY);
-}
-
-static
-int lttng_kretprobes_handler_exit(struct kretprobe_instance *krpi,
- struct pt_regs *regs)
-{
- return _lttng_kretprobes_handler(krpi, regs, EVENT_EXIT);
-}
-
-static const struct lttng_kernel_event_field *event_fields[] = {
- lttng_kernel_static_event_field("ip",
- lttng_kernel_static_type_integer_from_type(unsigned long, __BYTE_ORDER, 16),
- false, false),
- lttng_kernel_static_event_field("parent_ip",
- lttng_kernel_static_type_integer_from_type(unsigned long, __BYTE_ORDER, 16),
- false, false),
-};
-
-static const struct lttng_kernel_tracepoint_class tp_class = {
- .nr_fields = ARRAY_SIZE(event_fields),
- .fields = event_fields,
-};
-
-/*
- * Create event description
- */
-static
-int lttng_create_kprobe_event(const char *name, struct lttng_kernel_event_common *event,
- enum lttng_kretprobe_type type)
-{
- struct lttng_kernel_event_desc *desc;
- char *alloc_name;
- size_t name_len;
- const char *suffix = NULL;
- int ret;
-
- desc = kzalloc(sizeof(*desc), GFP_KERNEL);
- if (!desc)
- return -ENOMEM;
- name_len = strlen(name);
- switch (type) {
- case EVENT_ENTRY:
- suffix = "_entry";
- break;
- case EVENT_EXIT:
- suffix = "_exit";
- break;
- }
- name_len += strlen(suffix);
- alloc_name = kmalloc(name_len + 1, GFP_KERNEL);
- if (!alloc_name) {
- ret = -ENOMEM;
- goto error_str;
- }
- strcpy(alloc_name, name);
- strcat(alloc_name, suffix);
- desc->event_name = alloc_name;
- desc->tp_class = &tp_class;
- desc->owner = THIS_MODULE;
- event->priv->desc = desc;
-
- return 0;
-
-error_str:
- kfree(desc);
- return ret;
-}
-
-int lttng_kretprobes_register(const char *name,
- const char *symbol_name,
- uint64_t offset,
- uint64_t addr,
- struct lttng_kernel_event_common *event_entry,
- struct lttng_kernel_event_common *event_exit)
-{
- int ret;
- struct lttng_krp *lttng_krp;
-
- /* Kprobes expects a NULL symbol name if unused */
- if (symbol_name[0] == '\0')
- symbol_name = NULL;
-
- ret = lttng_create_kprobe_event(name, event_entry, EVENT_ENTRY);
- if (ret)
- goto error;
- ret = lttng_create_kprobe_event(name, event_exit, EVENT_EXIT);
- if (ret)
- goto event_exit_error;
- lttng_krp = kzalloc(sizeof(*lttng_krp), GFP_KERNEL);
- if (!lttng_krp)
- goto krp_error;
- lttng_krp->krp.entry_handler = lttng_kretprobes_handler_entry;
- lttng_krp->krp.handler = lttng_kretprobes_handler_exit;
- if (symbol_name) {
- char *alloc_symbol;
-
- alloc_symbol = kstrdup(symbol_name, GFP_KERNEL);
- if (!alloc_symbol) {
- ret = -ENOMEM;
- goto name_error;
- }
- lttng_krp->krp.kp.symbol_name = alloc_symbol;
- event_entry->priv->u.kretprobe.symbol_name = alloc_symbol;
- event_exit->priv->u.kretprobe.symbol_name = alloc_symbol;
- }
- lttng_krp->krp.kp.offset = offset;
- lttng_krp->krp.kp.addr = (void *) (unsigned long) addr;
-
- /* Allow probe handler to find event structures */
- lttng_krp->event[EVENT_ENTRY] = event_entry;
- lttng_krp->event[EVENT_EXIT] = event_exit;
- event_entry->priv->u.kretprobe.lttng_krp = lttng_krp;
- event_exit->priv->u.kretprobe.lttng_krp = lttng_krp;
-
- /*
- * Both events must be unregistered before the kretprobe is
- * unregistered. Same for memory allocation.
- */
- kref_init(<tng_krp->kref_alloc);
- kref_get(<tng_krp->kref_alloc); /* inc refcount to 2, no overflow. */
- kref_init(<tng_krp->kref_register);
- kref_get(<tng_krp->kref_register); /* inc refcount to 2, no overflow. */
-
- /*
- * Ensure the memory we just allocated don't trigger page faults.
- * Well.. kprobes itself puts the page fault handler on the blacklist,
- * but we can never be too careful.
- */
- wrapper_vmalloc_sync_mappings();
-
- ret = register_kretprobe(<tng_krp->krp);
- if (ret)
- goto register_error;
- return 0;
-
-register_error:
- kfree(lttng_krp->krp.kp.symbol_name);
-name_error:
- kfree(lttng_krp);
-krp_error:
- kfree(event_exit->priv->desc->event_name);
- kfree(event_exit->priv->desc);
-event_exit_error:
- kfree(event_entry->priv->desc->event_name);
- kfree(event_entry->priv->desc);
-error:
- return ret;
-}
-EXPORT_SYMBOL_GPL(lttng_kretprobes_register);
-
-static
-void _lttng_kretprobes_unregister_release(struct kref *kref)
-{
- struct lttng_krp *lttng_krp =
- container_of(kref, struct lttng_krp, kref_register);
- unregister_kretprobe(<tng_krp->krp);
-}
-
-void lttng_kretprobes_unregister(struct lttng_kernel_event_common *event)
-{
- kref_put(&event->priv->u.kretprobe.lttng_krp->kref_register,
- _lttng_kretprobes_unregister_release);
-}
-EXPORT_SYMBOL_GPL(lttng_kretprobes_unregister);
-
-static
-void _lttng_kretprobes_release(struct kref *kref)
-{
- struct lttng_krp *lttng_krp =
- container_of(kref, struct lttng_krp, kref_alloc);
- kfree(lttng_krp->krp.kp.symbol_name);
-}
-
-void lttng_kretprobes_destroy_private(struct lttng_kernel_event_common *event)
-{
- kfree(event->priv->desc->event_name);
- kfree(event->priv->desc);
- kref_put(&event->priv->u.kretprobe.lttng_krp->kref_alloc,
- _lttng_kretprobes_release);
-}
-EXPORT_SYMBOL_GPL(lttng_kretprobes_destroy_private);
-
-int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common *event,
- int enable)
-{
- struct lttng_kernel_event_common *event_exit;
- struct lttng_krp *lttng_krp;
-
- if (event->priv->instrumentation != LTTNG_KERNEL_ABI_KRETPROBE) {
- return -EINVAL;
- }
- if (event->enabled == enable) {
- return -EBUSY;
- }
- lttng_krp = event->priv->u.kretprobe.lttng_krp;
- event_exit = lttng_krp->event[EVENT_EXIT];
- WRITE_ONCE(event->enabled, enable);
- WRITE_ONCE(event_exit->enabled, enable);
- return 0;
-}
-EXPORT_SYMBOL_GPL(lttng_kretprobes_event_enable_state);
-
-MODULE_LICENSE("GPL and additional rights");
-MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");
-MODULE_DESCRIPTION("LTTng kretprobes probes");
-MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "."
- __stringify(LTTNG_MODULES_MINOR_VERSION) "."
- __stringify(LTTNG_MODULES_PATCHLEVEL_VERSION)
- LTTNG_MODULES_EXTRAVERSION);
+++ /dev/null
-/* SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only)
- *
- * probes/lttng-uprobes.c
- *
- * LTTng uprobes integration module.
- *
- * Copyright (C) 2013 Yannick Brosseau <yannick.brosseau@gmail.com>
- * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- */
-
-#include <wrapper/fdtable.h>
-#include <linux/file.h>
-#include <linux/list.h>
-#include <linux/module.h>
-#include <linux/namei.h>
-#include <linux/slab.h>
-#include <linux/uaccess.h>
-#include <linux/uprobes.h>
-
-#include <lttng/events.h>
-#include <lttng/events-internal.h>
-#include <lttng/tracer.h>
-#include <wrapper/irqflags.h>
-#include <ringbuffer/frontend_types.h>
-#include <wrapper/vmalloc.h>
-
-static
-int lttng_uprobes_event_handler_pre(struct uprobe_consumer *uc, struct pt_regs *regs)
-{
- struct lttng_uprobe_handler *uprobe_handler =
- container_of(uc, struct lttng_uprobe_handler, up_consumer);
- struct lttng_kernel_event_common *event = uprobe_handler->event;
- struct lttng_kernel_probe_ctx lttng_probe_ctx = {
- .event = event,
- .interruptible = !lttng_regs_irqs_disabled(regs),
- };
- struct {
- unsigned long ip;
- } payload;
-
- switch (event->type) {
- case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
- {
- struct lttng_kernel_event_recorder *event_recorder =
- container_of(event, struct lttng_kernel_event_recorder, parent);
- struct lttng_kernel_channel_buffer *chan = event_recorder->chan;
-
- if (unlikely(!LTTNG_READ_ONCE(chan->parent.session->active)))
- return 0;
- if (unlikely(!LTTNG_READ_ONCE(chan->parent.enabled)))
- return 0;
- break;
- }
- case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
- break;
- default:
- WARN_ON_ONCE(1);
- }
-
- if (unlikely(!LTTNG_READ_ONCE(event->enabled)))
- return 0;
-
- switch (event->type) {
- case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
- {
- struct lttng_kernel_event_recorder *event_recorder =
- container_of(event, struct lttng_kernel_event_recorder, parent);
- struct lttng_kernel_channel_buffer *chan = event_recorder->chan;
- struct lttng_kernel_ring_buffer_ctx ctx;
- int ret;
-
- lib_ring_buffer_ctx_init(&ctx, event_recorder,
- sizeof(payload), lttng_alignof(payload), <tng_probe_ctx);
-
- ret = chan->ops->event_reserve(&ctx);
- if (ret < 0)
- return 0;
-
- /* Event payload. */
- payload.ip = (unsigned long)instruction_pointer(regs);
-
- chan->ops->event_write(&ctx, &payload, sizeof(payload), lttng_alignof(payload));
- chan->ops->event_commit(&ctx);
- break;
- }
- case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
- {
- struct lttng_kernel_event_notifier *event_notifier =
- container_of(event, struct lttng_kernel_event_notifier, parent);
- struct lttng_kernel_notification_ctx notif_ctx;
-
- notif_ctx.eval_capture = LTTNG_READ_ONCE(event_notifier->eval_capture);
- event_notifier->notification_send(event_notifier, NULL, NULL, ¬if_ctx);
- break;
- }
- default:
- WARN_ON_ONCE(1);
- }
- return 0;
-}
-
-static const struct lttng_kernel_event_field *event_fields[] = {
- lttng_kernel_static_event_field("ip",
- lttng_kernel_static_type_integer_from_type(unsigned long, __BYTE_ORDER, 16),
- false, false),
-};
-
-static const struct lttng_kernel_tracepoint_class tp_class = {
- .nr_fields = ARRAY_SIZE(event_fields),
- .fields = event_fields,
-};
-
-/*
- * Create event description.
- */
-static
-int lttng_create_uprobe_event(const char *name, struct lttng_kernel_event_common *event)
-{
- struct lttng_kernel_event_desc *desc;
- int ret;
-
- desc = kzalloc(sizeof(*desc), GFP_KERNEL);
- if (!desc)
- return -ENOMEM;
- desc->tp_class = &tp_class;
- desc->event_name = kstrdup(name, GFP_KERNEL);
- if (!desc->event_name) {
- ret = -ENOMEM;
- goto error_str;
- }
- desc->owner = THIS_MODULE;
- event->priv->desc = desc;
-
- return 0;
-
-error_str:
- kfree(desc);
- return ret;
-}
-
-/*
- * Returns the inode struct from the current task and an fd. The inode is
- * grabbed by this function and must be put once we are done with it using
- * iput().
- */
-static struct inode *get_inode_from_fd(int fd)
-{
- struct file *file;
- struct inode *inode;
-
- rcu_read_lock();
- /*
- * Returns the file backing the given fd. Needs to be done inside an RCU
- * critical section.
- */
- file = lttng_lookup_fdget_rcu(fd);
- if (file == NULL) {
- printk(KERN_WARNING "LTTng: Cannot access file backing the fd(%d)\n", fd);
- inode = NULL;
- goto error;
- }
-
- /* Grab a reference on the inode. */
- inode = igrab(file->f_path.dentry->d_inode);
- if (inode == NULL)
- printk(KERN_WARNING "LTTng: Cannot grab a reference on the inode.\n");
-
-error:
- rcu_read_unlock();
- if (file)
- fput(file);
- return inode;
-}
-
-
-static
-int lttng_uprobes_add_callsite(struct lttng_uprobe *uprobe,
- struct lttng_kernel_abi_event_callsite __user *callsite,
- int (*handler)(struct uprobe_consumer *self, struct pt_regs *regs),
- void *priv_data)
-{
- int ret = 0;
- struct lttng_uprobe_handler *uprobe_handler;
-
- if (!priv_data) {
- ret = -EINVAL;
- goto end;
- }
-
- uprobe_handler = kzalloc(sizeof(struct lttng_uprobe_handler), GFP_KERNEL);
- if (!uprobe_handler) {
- printk(KERN_WARNING "LTTng: Error allocating uprobe_handler");
- ret = -ENOMEM;
- goto end;
- }
-
- /* Ensure the memory we just allocated don't notify page faults. */
- wrapper_vmalloc_sync_mappings();
-
- uprobe_handler->event = priv_data;
- uprobe_handler->up_consumer.handler = handler;
-
- ret = copy_from_user(&uprobe_handler->offset, &callsite->u.uprobe.offset, sizeof(uint64_t));
- if (ret) {
- goto register_error;
- }
-
- ret = uprobe_register(uprobe->inode,
- uprobe_handler->offset, &uprobe_handler->up_consumer);
- if (ret) {
- printk(KERN_WARNING "LTTng: Error registering probe on inode %lu "
- "and offset 0x%llx\n", uprobe->inode->i_ino,
- uprobe_handler->offset);
- ret = -1;
- goto register_error;
- }
-
- list_add(&uprobe_handler->node, &uprobe->head);
-
- return ret;
-
-register_error:
- kfree(uprobe_handler);
-end:
- return ret;
-}
-
-int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common *event,
- struct lttng_kernel_abi_event_callsite __user *callsite)
-{
- return lttng_uprobes_add_callsite(&event->priv->u.uprobe, callsite,
- lttng_uprobes_event_handler_pre, event);
-}
-EXPORT_SYMBOL_GPL(lttng_uprobes_event_add_callsite);
-
-static
-int lttng_uprobes_register(struct lttng_uprobe *uprobe, int fd)
-{
- int ret = 0;
- struct inode *inode;
-
- inode = get_inode_from_fd(fd);
- if (!inode) {
- printk(KERN_WARNING "LTTng: Cannot get inode from fd\n");
- ret = -EBADF;
- goto inode_error;
- }
- uprobe->inode = inode;
- INIT_LIST_HEAD(&uprobe->head);
-
-inode_error:
- return ret;
-}
-
-int lttng_uprobes_register_event(const char *name, int fd, struct lttng_kernel_event_common *event)
-{
- int ret = 0;
-
- ret = lttng_create_uprobe_event(name, event);
- if (ret)
- goto error;
-
- ret = lttng_uprobes_register(&event->priv->u.uprobe, fd);
- if (ret)
- goto register_error;
-
- return 0;
-
-register_error:
- kfree(event->priv->desc->event_name);
- kfree(event->priv->desc);
-error:
- return ret;
-}
-EXPORT_SYMBOL_GPL(lttng_uprobes_register_event);
-
-static
-void lttng_uprobes_unregister(struct inode *inode, struct list_head *head)
-{
- struct lttng_uprobe_handler *iter, *tmp;
-
- /*
- * Iterate over the list of handler, remove each handler from the list
- * and free the struct.
- */
- list_for_each_entry_safe(iter, tmp, head, node) {
- uprobe_unregister(inode, iter->offset, &iter->up_consumer);
- list_del(&iter->node);
- kfree(iter);
- }
-}
-
-void lttng_uprobes_unregister_event(struct lttng_kernel_event_common *event)
-{
- lttng_uprobes_unregister(event->priv->u.uprobe.inode, &event->priv->u.uprobe.head);
-}
-EXPORT_SYMBOL_GPL(lttng_uprobes_unregister_event);
-
-void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_common *event)
-{
- iput(event->priv->u.uprobe.inode);
- kfree(event->priv->desc->event_name);
- kfree(event->priv->desc);
-}
-EXPORT_SYMBOL_GPL(lttng_uprobes_destroy_event_private);
-
-MODULE_LICENSE("GPL and additional rights");
-MODULE_AUTHOR("Yannick Brosseau");
-MODULE_DESCRIPTION("Linux Trace Toolkit Uprobes Support");
# SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2016-2024 EfficiOS Inc.
TOP_LTTNG_MODULES_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST)))/../..
# SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2016-2024 EfficiOS Inc.
config LTTNG_CLOCK_PLUGIN_TEST
tristate "Use test plugin as trace clock"
+# SPDX-FileCopyrightText: 2013 Paul Woegerer <paul_woegerer@mentor.com>
+#
+# SPDX-License-Identifier: CC0-1.0
+
syscall sys_restart_syscall nr 0 nbargs 0 types: () args: ()
syscall sys_exit nr 1 nbargs 1 types: (int) args: (error_code)
syscall sys_read nr 3 nbargs 3 types: (unsigned int, char *, size_t) args: (fd, buf, count)
+# SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+#
+# SPDX-License-Identifier: CC0-1.0
+
syscall sys_restart_syscall nr 0 nbargs 0 types: () args: ()
syscall sys_exit nr 1 nbargs 1 types: (int) args: (error_code)
syscall sys_read nr 3 nbargs 3 types: (unsigned int, char *, size_t) args: (fd, buf, count)
+# SPDX-FileCopyrightText: 2013 Yannick Brosseau <yannick.brosseau@gmail.com>
+#
+# SPDX-License-Identifier: CC0-1.0
+
syscall sys_read nr 0 nbargs 3 types: (unsigned int, char *, size_t) args: (fd, buf, count)
syscall sys_write nr 1 nbargs 3 types: (unsigned int, const char *, size_t) args: (fd, buf, count)
syscall sys_open nr 2 nbargs 3 types: (const char *, int, umode_t) args: (filename, flags, mode)
+# SPDX-FileCopyrightText: 2014 Lars Persson <lars.persson@axis.com>
+#
+# SPDX-License-Identifier: CC0-1.0
+
syscall sys_exit nr 4001 nbargs 1 types: (int) args: (error_code)
syscall sys_read nr 4003 nbargs 3 types: (unsigned int, char *, size_t) args: (fd, buf, count)
syscall sys_write nr 4004 nbargs 3 types: (unsigned int, const char *, size_t) args: (fd, buf, count)
+# SPDX-FileCopyrightText: 2015 Lars Persson <lars.persson@axis.com>
+#
+# SPDX-License-Identifier: CC0-1.0
+
syscall sys_exit nr 4001 nbargs 1 types: (int) args: (error_code)
syscall sys_read nr 4003 nbargs 3 types: (unsigned int, char *, size_t) args: (fd, buf, count)
syscall sys_write nr 4004 nbargs 3 types: (unsigned int, const char *, size_t) args: (fd, buf, count)
+# SPDX-FileCopyrightText: 2013 Jan Glauber <jan.glauber@gmail.com>
+#
+# SPDX-License-Identifier: CC0-1.0
+
syscall sys_restart_syscall nr 0 nbargs 0 types: () args: ()
syscall sys_exit nr 1 nbargs 1 types: (int) args: (error_code)
syscall sys_read nr 3 nbargs 3 types: (unsigned int, char *, size_t) args: (fd, buf, count)
+# SPDX-FileCopyrightText: 2012 Ralf Baechle <ralf@linux-mips.org>
+#
+# SPDX-License-Identifier: CC0-1.0
+
syscall sys_exit nr 4003 nbargs 1 types: (int) args: (error_code)
syscall sys_read nr 4007 nbargs 3 types: (unsigned int, char *, size_t) args: (fd, buf, count)
syscall sys_write nr 4009 nbargs 3 types: (unsigned int, const char *, size_t) args: (fd, buf, count)
+# SPDX-FileCopyrightText: 2012 Ralf Baechle <ralf@linux-mips.org>
+#
+# SPDX-License-Identifier: CC0-1.0
+
syscall sys_waitpid nr 4007 nbargs 3 types: (pid_t, int *, int) args: (pid, stat_addr, options)
syscall sys_oldumount nr 4022 nbargs 1 types: (char *) args: (name)
syscall sys_nice nr 4034 nbargs 1 types: (int) args: (increment)
+# SPDX-FileCopyrightText: 2016 Jan Willeke <jan.willeke@harman.com>
+#
+# SPDX-License-Identifier: CC0-1.0
+
syscall sys_io_setup nr 0 nbargs 2 types: (unsigned, aio_context_t *) args: (nr_events, ctxp)
syscall sys_io_destroy nr 1 nbargs 1 types: (aio_context_t) args: (ctx)
syscall sys_io_submit nr 2 nbargs 3 types: (aio_context_t, long, struct iocb * *) args: (ctx_id, nr, iocbpp)
+# SPDX-FileCopyrightText: 2022 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+#
+# SPDX-License-Identifier: CC0-1.0
+
syscall sys_restart_syscall nr 0 nbargs 0 types: () args: ()
syscall sys_exit nr 1 nbargs 1 types: (int) args: (error_code)
syscall sys_fork nr 2 nbargs 0 types: () args: ()
+# SPDX-FileCopyrightText: 2022 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+#
+# SPDX-License-Identifier: CC0-1.0
+
syscall sys_io_setup nr 0 nbargs 2 types: (unsigned, aio_context_t *) args: (nr_events, ctxp)
syscall sys_io_destroy nr 1 nbargs 1 types: (aio_context_t) args: (ctx)
syscall sys_io_submit nr 2 nbargs 3 types: (aio_context_t, long, struct iocb * *) args: (ctx_id, nr, iocbpp)
+# SPDX-FileCopyrightText: 2022 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+#
+# SPDX-License-Identifier: CC0-1.0
+
syscall sys_restart_syscall nr 0 nbargs 0 types: () args: ()
syscall sys_exit nr 1 nbargs 1 types: (int) args: (error_code)
syscall sys_fork nr 2 nbargs 0 types: () args: ()
+# SPDX-FileCopyrightText: 2022 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+#
+# SPDX-License-Identifier: CC0-1.0
+
syscall sys_read nr 0 nbargs 3 types: (unsigned int, char *, size_t) args: (fd, buf, count)
syscall sys_write nr 1 nbargs 3 types: (unsigned int, const char *, size_t) args: (fd, buf, count)
syscall sys_open nr 2 nbargs 3 types: (const char *, int, umode_t) args: (filename, flags, mode)
+++ /dev/null
-LTTng system call tracing
-
-1) lttng-syscall-extractor
-
-You need to build a kernel with CONFIG_FTRACE_SYSCALLS=y and
-CONFIG_KALLSYMS_ALL=y for extraction. Apply the linker patch to get your
-kernel to keep the system call metadata after boot. Then build and load
-the LTTng syscall extractor module. The module will fail to load (this
-is expected). See the dmesg output for system call metadata.
-
-2) Generate system call TRACE_EVENT().
-
-Take the dmesg data and feed it to lttng-syscalls-generate-headers.sh from the
-tools/syscalls directory. See the script header for usage example. It should be
-run for both the integers and pointers types.
-
-After these are created, you just need to follow the new system call additions,
-no need to regenerate the whole thing, since system calls are only appended to.
-
-3) Override headers
-
-You need to provide override headers (even if they don't contain
-overrides) for each architecture. Those are meant to contain manual
-overrides for specific system calls for cases where the script do not
-generate the correct typing for specific system calls.
-
-4) Integrating the new architecture, updating architecture header
-
-Edit instrumentation/syscalls/syscalls_integers.h and
-instrumentation/syscalls/syscalls_pointers.h. Add the new architecture (e.g.
-CONFIG_X86_64) to the newly-generated headers (e.g. changing the current
-x86-64-syscalls_<CLASS>.h into x86-64-syscalls_<CLASS>.h), then rebuild
-lttng-modules.
--- /dev/null
+
+<!--
+SPDX-FileCopyrightText: 2011-2022 EfficiOS Inc.
+
+SPDX-License-Identifier: CC-BY-SA-4.0
+-->
+
+# LTTng system call tracing
+
+## lttng-syscall-extractor
+
+You need to build a kernel with `CONFIG_FTRACE_SYSCALLS=y` and
+`CONFIG_KALLSYMS_ALL=y` for extraction. Apply the linker patch to get your
+kernel to keep the system call metadata after boot. Then build and load
+the LTTng syscall extractor module. The module will fail to load (this
+is expected). See the dmesg output for system call metadata.
+
+## Generate system call TRACE_EVENT().
+
+Take the dmesg data and feed it to `lttng-syscalls-generate-headers.sh` from the
+tools/syscalls directory. See the script header for usage example. It should be
+run for both the integers and pointers types.
+
+After these are created, you just need to follow the new system call additions,
+no need to regenerate the whole thing, since system calls are only appended to.
+
+## Override headers
+
+You need to provide override headers (even if they don't contain
+overrides) for each architecture. Those are meant to contain manual
+overrides for specific system calls for cases where the script do not
+generate the correct typing for specific system calls.
+
+## Integrating the new architecture, updating architecture header
+
+Edit `instrumentation/syscalls/syscalls_integers.h` and
+`instrumentation/syscalls/syscalls_pointers.h`. Add the new architecture (e.g.
+CONFIG_X86_64) to the newly-generated headers (e.g. changing the current
+`x86-64-syscalls_<CLASS>.h` into `x86-64-syscalls_<CLASS>.h`), then rebuild
+lttng-modules.
#!/bin/bash
# SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2014-2024 EfficiOS Inc.
# example usage:
-# lttng-get-syscall-inout.sh table-syscall-inout.txt select 1
+# lttng-get-syscall-inout.sh arm-64 select 5 1
ARCH_NAME=$1
SYSCALL_NAME=$2
# Delete temp file on exit
trap 'rm -f "$TMPFILE"' EXIT
-if [ "${GENERIC_INOUT_DESCRIPTION_FILE}" = "" ]; then
- echo "Error: Please specify input file name as first argument" >&2
+if [ "${ARCH_NAME}" = "" ]; then
+ echo "Error: Please specify the arch name as first argument" >&2
exit 1
fi
if [ "${SYSCALL_NAME}" = "" ]; then
- echo "Error: Please specify system call name as second argument" >&2
+ echo "Error: Please specify the system call name as second argument" >&2
+ exit 1
+fi
+
+if [[ "${NB_ARGS}" = "" ]]; then
+ echo "Error: Please specify a number of arguments as third argument" >&2
exit 1
fi
if [[ "${ARG_NR}" = "" || ${ARG_NR} == 0 ]]; then
- echo "Error: Please specify argument number larger than 0 as third argument" >&2
+ echo "Error: Please specify an argument number larger than 0 as fourth argument" >&2
exit 1
fi
#!/bin/bash
# SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2020 EfficiOS Inc.
set -eu
--- /dev/null
+SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+SPDX-License-Identifier: GPL-2.0-only
#!/bin/bash
+# SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2011-2024 EfficiOS Inc.
# Generate system call probe description macros from syscall metadata dump file.
# The resulting header will be written in the headers subdirectory, in a file name
fi
-echo "/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
-/* SPDX-FileCopyrightText: $(date +%Y) EfficiOS Inc. */
+echo "// SPDX-FileCopyrightText: $(date +%Y) EfficiOS Inc.
+//
+// SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only */
/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
+# SPDX-FileCopyrightText: 2022 EfficiOS Inc.
+#
+# SPDX-License-Identifier: CC0-1.0
+
# OLD_SIGSUSPEND3: 3 args variant
syscall sigsuspend nbargs 3 rw: (r, r, r)
# CLONE_BACKWARDS: tls passed as the 4th argument of clone(2), not the 5th one.
+# SPDX-FileCopyrightText: 2022 EfficiOS Inc.
+#
+# SPDX-License-Identifier: CC0-1.0
+
# CLONE_BACKWARDS: tls passed as the 4th argument of clone(2), not the 5th one.
syscall clone nbargs 5 rw: (r, r, w, r, w)
+# SPDX-FileCopyrightText: 2022 EfficiOS Inc.
+#
+# SPDX-License-Identifier: CC0-1.0
+
# OLD_SIGSUSPEND: 1 arg variant
syscall sigsuspend nbargs 1 rw: (r)
# CLONE_BACKWARDS: tls passed as the 4th argument of clone(2), not the 5th one.
+# SPDX-FileCopyrightText: 2022 EfficiOS Inc.
+#
+# SPDX-License-Identifier: CC0-1.0
+
# CLONE_BACKWARDS: tls passed as the 4th argument of clone(2), not the 5th one.
syscall clone nbargs 5 rw: (r, r, w, r, w)
+# SPDX-FileCopyrightText: 2022 EfficiOS Inc.
+#
+# SPDX-License-Identifier: CC0-1.0
+
# OLD_SIGSUSPEND: 1 arg variant
syscall sigsuspend nbargs 1 rw: (r)
# CLONE_BACKWARDS: tls passed as the 4th argument of clone(2), not the 5th one.
+# SPDX-FileCopyrightText: 2022 EfficiOS Inc.
+#
+# SPDX-License-Identifier: CC0-1.0
+
# CLONE_BACKWARDS: tls passed as the 4th argument of clone(2), not the 5th one.
syscall clone nbargs 5 rw: (r, r, w, r, w)
+# SPDX-FileCopyrightText: 2022 EfficiOS Inc.
+#
+# SPDX-License-Identifier: CC0-1.0
+
# CLONE_BACKWARDS: tls passed as the 4th argument of clone(2), not the 5th one.
syscall clone nbargs 5 rw: (r, r, w, r, w)
+# SPDX-FileCopyrightText: 2022 EfficiOS Inc.
+#
+# SPDX-License-Identifier: CC0-1.0
+
# CLONE_BACKWARDS: tls passed as the 4th argument of clone(2), not the 5th one.
syscall clone nbargs 5 rw: (r, r, w, r, w)
+# SPDX-FileCopyrightText: 2022 EfficiOS Inc.
+#
+# SPDX-License-Identifier: CC0-1.0
+
# On x86-32, the 64-bit mask parameter is split into two 32-bit parts
syscall fanotify_mark nbargs 6 rw: (r, r, r, r, r, r)
# OLD_SIGSUSPEND3: 3 args variant
+# SPDX-FileCopyrightText: 2022 EfficiOS Inc.
+#
+# SPDX-License-Identifier: CC0-1.0
+
# "Regular" clone
syscall clone nbargs 5 rw: (r, r, w, w, r)
+# SPDX-FileCopyrightText: 2014-2022 EfficiOS Inc.
+#
+# SPDX-License-Identifier: CC0-1.0
+
syscall read nbargs 3 rw: (r, w, r)
syscall write nbargs 3 rw: (r, r, r)
syscall open nbargs 3 rw: (r, r, r)