Fix: scsi: sd: Atomic write support added in 6.11-rc1 master
authorKienan Stewart <kstewart@efficios.com>
Mon, 29 Jul 2024 14:23:02 +0000 (14:23 +0000)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 29 Jul 2024 15:22:01 +0000 (11:22 -0400)
See upstream commit:

    commit bf4ae8f2e6407a779c0368eb0f3e047a8333be17
    Author: John Garry <john.g.garry@oracle.com>
    Date:   Thu Jun 20 12:53:57 2024 +0000

        scsi: sd: Atomic write support

        Support is divided into two main areas:
        - reading VPD pages and setting sdev request_queue limits
        - support WRITE ATOMIC (16) command and tracing

        The relevant block limits VPD page need to be read to allow the block layer
        request_queue atomic write limits to be set. These VPD page limits are
        described in sbc4r22 section 6.6.4 - Block limits VPD page.

        There are five limits of interest:
        - MAXIMUM ATOMIC TRANSFER LENGTH
        - ATOMIC ALIGNMENT
        - ATOMIC TRANSFER LENGTH GRANULARITY
        - MAXIMUM ATOMIC TRANSFER LENGTH WITH BOUNDARY
        - MAXIMUM ATOMIC BOUNDARY SIZE

        MAXIMUM ATOMIC TRANSFER LENGTH is the maximum length for a WRITE ATOMIC
        (16) command. It will not be greater than the device MAXIMUM TRANSFER
        LENGTH.

        ATOMIC ALIGNMENT and ATOMIC TRANSFER LENGTH GRANULARITY are the minimum
        alignment and length values for an atomic write in terms of logical blocks.

        Unlike NVMe, SCSI does not specify an LBA space boundary, but does specify
        a per-IO boundary granularity. The maximum boundary size is specified in
        MAXIMUM ATOMIC BOUNDARY SIZE. When used, this boundary value is set in the
        WRITE ATOMIC (16) ATOMIC BOUNDARY field - layout for the WRITE_ATOMIC_16
        command can be found in sbc4r22 section 5.48. This boundary value is the
        granularity size at which the device may atomically write the data. A value
        of zero in WRITE ATOMIC (16) ATOMIC BOUNDARY field means that all data must
        be atomically written together.

        MAXIMUM ATOMIC TRANSFER LENGTH WITH BOUNDARY is the maximum atomic write
        length if a non-zero boundary value is set.

        For atomic write support, the WRITE ATOMIC (16) boundary is not of much
        interest, as the block layer expects each request submitted to be executed
        be atomically written together.

        MAXIMUM ATOMIC TRANSFER LENGTH WITH BOUNDARY is the maximum atomic write
        length if a non-zero boundary value is set.

        For atomic write support, the WRITE ATOMIC (16) boundary is not of much
        interest, as the block layer expects each request submitted to be executed
        atomically. However, the SCSI spec does leave itself open to a quirky
        scenario where MAXIMUM ATOMIC TRANSFER LENGTH is zero, yet MAXIMUM ATOMIC
        TRANSFER LENGTH WITH BOUNDARY and MAXIMUM ATOMIC BOUNDARY SIZE are both
        non-zero. This case will be supported.

        To set the block layer request_queue atomic write capabilities, sanitize
        the VPD page limits and set limits as follows:
        - atomic_write_unit_min is derived from granularity and alignment values.
          If no granularity value is not set, use physical block size
        - atomic_write_unit_max is derived from MAXIMUM ATOMIC TRANSFER LENGTH. In
          the scenario where MAXIMUM ATOMIC TRANSFER LENGTH is zero and boundary
          limits are non-zero, use MAXIMUM ATOMIC BOUNDARY SIZE for
          atomic_write_unit_max. New flag scsi_disk.use_atomic_write_boundary is
          set for this scenario.
        - atomic_write_boundary_bytes is set to zero always

        SCSI also supports a WRITE ATOMIC (32) command, which is for type 2
        protection enabled. This is not going to be supported now, so check for
        T10_PI_TYPE2_PROTECTION when setting any request_queue limits.

        To handle an atomic write request, add support for WRITE ATOMIC (16)
        command in handler sd_setup_atomic_cmnd(). Flag use_atomic_write_boundary
        is checked here for encoding ATOMIC BOUNDARY field.

        Trace info is also added for WRITE_ATOMIC_16 command.

Change-Id: Ie072002fe2184615c72531ac081a324ef18cfb03
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
181 files changed:
.gitattributes
.gitignore
.gitreview
ChangeLog
CodingStyle [deleted file]
CodingStyle.md [new file with mode: 0644]
LICENSE
LICENSES/CC-BY-SA-4.0.txt [new file with mode: 0644]
LICENSES/CC0-1.0.txt [new file with mode: 0644]
LICENSES/GPL-2.0 [deleted file]
LICENSES/GPL-2.0-only.txt [new file with mode: 0644]
LICENSES/LGPL-2.1 [deleted file]
LICENSES/LGPL-2.1-only.txt [new file with mode: 0644]
LICENSES/MIT [deleted file]
LICENSES/MIT.txt [new file with mode: 0644]
Makefile
README.md
doc/lttng-modules-design.md [new file with mode: 0644]
doc/lttng-modules-design.txt [deleted file]
extra_version/README [deleted file]
extra_version/README.md [new file with mode: 0644]
extra_version/patches/README [deleted file]
extra_version/patches/README.md [new file with mode: 0644]
include/counter/counter-api.h
include/instrumentation/events/9p.h
include/instrumentation/events/README [deleted file]
include/instrumentation/events/README.md [new file with mode: 0644]
include/instrumentation/events/arch/x86/exceptions.h
include/instrumentation/events/arch/x86/irq_vectors.h
include/instrumentation/events/arch/x86/kvm/mmutrace.h
include/instrumentation/events/arch/x86/kvm/trace.h
include/instrumentation/events/asoc.h
include/instrumentation/events/block.h
include/instrumentation/events/btrfs.h
include/instrumentation/events/compaction.h
include/instrumentation/events/dma_fence.h
include/instrumentation/events/ext4.h
include/instrumentation/events/gpio.h
include/instrumentation/events/i2c.h
include/instrumentation/events/irq.h
include/instrumentation/events/jbd.h
include/instrumentation/events/jbd2.h
include/instrumentation/events/kmem.h
include/instrumentation/events/kvm.h
include/instrumentation/events/lock.h
include/instrumentation/events/lttng-statedump.h
include/instrumentation/events/lttng-test.h
include/instrumentation/events/lttng.h
include/instrumentation/events/mm_vmscan.h
include/instrumentation/events/module.h
include/instrumentation/events/napi.h
include/instrumentation/events/net.h
include/instrumentation/events/power.h
include/instrumentation/events/preemptirq.h
include/instrumentation/events/printk.h
include/instrumentation/events/random.h
include/instrumentation/events/rcu.h
include/instrumentation/events/regmap.h
include/instrumentation/events/regulator.h
include/instrumentation/events/rpc.h
include/instrumentation/events/rpm.h
include/instrumentation/events/sched.h
include/instrumentation/events/scsi.h
include/instrumentation/events/signal.h
include/instrumentation/events/skb.h
include/instrumentation/events/sock.h
include/instrumentation/events/timer.h
include/instrumentation/events/udp.h
include/instrumentation/events/v4l2.h
include/instrumentation/events/workqueue.h
include/instrumentation/events/writeback.h
include/instrumentation/syscalls/arm-32-syscalls_integers.h
include/instrumentation/syscalls/arm-32-syscalls_integers_override.h
include/instrumentation/syscalls/arm-32-syscalls_pointers.h
include/instrumentation/syscalls/arm-32-syscalls_pointers_override.h
include/instrumentation/syscalls/arm-64-syscalls_integers.h
include/instrumentation/syscalls/arm-64-syscalls_integers_override.h
include/instrumentation/syscalls/arm-64-syscalls_pointers.h
include/instrumentation/syscalls/arm-64-syscalls_pointers_override.h
include/instrumentation/syscalls/compat_syscalls_integers.h
include/instrumentation/syscalls/compat_syscalls_pointers.h
include/instrumentation/syscalls/mips-32-syscalls_integers.h
include/instrumentation/syscalls/mips-32-syscalls_integers_override.h
include/instrumentation/syscalls/mips-32-syscalls_pointers.h
include/instrumentation/syscalls/mips-32-syscalls_pointers_override.h
include/instrumentation/syscalls/mips-64-syscalls_integers.h
include/instrumentation/syscalls/mips-64-syscalls_integers_override.h
include/instrumentation/syscalls/mips-64-syscalls_pointers.h
include/instrumentation/syscalls/mips-64-syscalls_pointers_override.h
include/instrumentation/syscalls/powerpc-32-syscalls_integers.h
include/instrumentation/syscalls/powerpc-32-syscalls_integers_override.h
include/instrumentation/syscalls/powerpc-32-syscalls_pointers.h
include/instrumentation/syscalls/powerpc-32-syscalls_pointers_override.h
include/instrumentation/syscalls/syscalls_integers.h
include/instrumentation/syscalls/syscalls_integers_override.h
include/instrumentation/syscalls/syscalls_pointers.h
include/instrumentation/syscalls/syscalls_pointers_override.h
include/instrumentation/syscalls/syscalls_unknown.h
include/instrumentation/syscalls/x86-32-syscalls_integers.h
include/instrumentation/syscalls/x86-32-syscalls_integers_override.h
include/instrumentation/syscalls/x86-32-syscalls_pointers.h
include/instrumentation/syscalls/x86-32-syscalls_pointers_override.h
include/instrumentation/syscalls/x86-64-syscalls_integers.h
include/instrumentation/syscalls/x86-64-syscalls_integers_override.h
include/instrumentation/syscalls/x86-64-syscalls_pointers.h
include/instrumentation/syscalls/x86-64-syscalls_pointers_override.h
include/lttng/abi-old.h
include/lttng/abi.h
include/lttng/events-internal.h
include/lttng/events.h
include/lttng/msgpack.h
include/lttng/tracepoint-event-impl.h
include/lttng/utils.h
include/wrapper/bitops.h [new file with mode: 0644]
include/wrapper/fdtable.h
include/wrapper/mm.h
include/wrapper/uaccess.h
scripts/abi-debian-version.sh
scripts/abi-fedora-version.sh
scripts/abi-rhel-version.sh
scripts/abi-sle-version.sh
scripts/built-in.sh
scripts/extra-version-git.sh
scripts/extra-version-name.sh
scripts/extra-version-patches.sh
scripts/maintainer/do-release.sh
scripts/rt-patch-version.sh
src/Kbuild
src/Kbuild.common
src/Kconfig
src/lib/Kbuild
src/lib/msgpack/msgpack.c
src/lttng-abi.c
src/lttng-counter-client-percpu-32-modular.c
src/lttng-counter-client-percpu-64-modular.c
src/lttng-event-notifier-notification.c
src/lttng-events.c
src/lttng-kprobes.c [new file with mode: 0644]
src/lttng-kretprobes.c [new file with mode: 0644]
src/lttng-ring-buffer-client.h
src/lttng-ring-buffer-event-notifier-client.c
src/lttng-ring-buffer-event-notifier-client.h
src/lttng-statedump-impl.c
src/lttng-syscalls.c
src/lttng-uprobes.c [new file with mode: 0644]
src/probes/Kbuild
src/probes/lttng-kprobes.c [deleted file]
src/probes/lttng-kretprobes.c [deleted file]
src/probes/lttng-uprobes.c [deleted file]
src/tests/Kbuild
src/tests/Kconfig
tools/syscalls/3.0.34/powerpc-32-syscalls
tools/syscalls/3.1.0-rc6/x86-32-syscalls
tools/syscalls/3.10.0-rc7/x86-64-syscalls
tools/syscalls/3.13.0/mips-32-syscalls
tools/syscalls/3.18.0/mips-32-syscalls
tools/syscalls/3.4.25/arm-32-syscalls
tools/syscalls/3.5.0/mips-32-syscalls
tools/syscalls/3.5.0/mips-64-syscalls
tools/syscalls/4.4.0/arm-64-syscalls
tools/syscalls/6.0.7/arm-32-syscalls
tools/syscalls/6.0.7/arm-64-syscalls
tools/syscalls/6.0.7/x86-32-syscalls
tools/syscalls/6.0.7/x86-64-syscalls
tools/syscalls/README [deleted file]
tools/syscalls/README.md [new file with mode: 0644]
tools/syscalls/lttng-get-syscall-inout.sh
tools/syscalls/lttng-syscalls-extract.sh
tools/syscalls/lttng-syscalls-extractor/linux-link-trace-syscalls-as-data.patch.license [new file with mode: 0644]
tools/syscalls/lttng-syscalls-generate-headers.sh
tools/syscalls/table-syscall-inout-arm-32-override.txt
tools/syscalls/table-syscall-inout-arm-64-override.txt
tools/syscalls/table-syscall-inout-mips-32-override.txt
tools/syscalls/table-syscall-inout-mips-64-override.txt
tools/syscalls/table-syscall-inout-powerpc-32-override.txt
tools/syscalls/table-syscall-inout-powerpc-64-override.txt
tools/syscalls/table-syscall-inout-riscv-32-override.txt
tools/syscalls/table-syscall-inout-riscv-64-override.txt
tools/syscalls/table-syscall-inout-x86-32-override.txt
tools/syscalls/table-syscall-inout-x86-64-override.txt
tools/syscalls/table-syscall-inout.txt

index 7839355a96874483186223d93ffa1e702f6d1ac2..a4429c861a732dc7799e2178aed4f163d39b0a82 100644 (file)
@@ -1,3 +1,7 @@
+# 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
index 61a69862568cca5422800ac548d6e0560433e756..ff7cca179086f3c8d66ebe3714f4597341a8c9da 100644 (file)
@@ -1,3 +1,6 @@
+# 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
index 0d2dcdee1335b3bde331087ce9df4b5eb508b678..9444bc51ad86c1937ae32c1ecc1cb2530ac8687c 100644 (file)
@@ -1,3 +1,6 @@
+# SPDX-FileCopyrightText: 2024 EfficiOS Inc.
+#
+# SPDX-License-Identifier: GPL-2.0-only OR LGPL-2.1-only
 [gerrit]
 host=review.lttng.org
 port=29418
index cd9c692625e6889ff83102ed0f638c23d206a165..1702ef216197526d61a55b3233cf2084390747d1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+# 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
diff --git a/CodingStyle b/CodingStyle
deleted file mode 100644 (file)
index 006d16c..0000000
+++ /dev/null
@@ -1,10 +0,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
diff --git a/CodingStyle.md b/CodingStyle.md
new file mode 100644 (file)
index 0000000..1750f47
--- /dev/null
@@ -0,0 +1,16 @@
+<!--
+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
diff --git a/LICENSE b/LICENSE
index 04013e663acf021b86ae6a5b691f35286bea716e..a8585832a5bda4d3b63d451acad3cd70659126ac 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -4,31 +4,31 @@ June 2, 2011
 
 * 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
diff --git a/LICENSES/CC-BY-SA-4.0.txt b/LICENSES/CC-BY-SA-4.0.txt
new file mode 100644 (file)
index 0000000..835a683
--- /dev/null
@@ -0,0 +1,170 @@
+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.
diff --git a/LICENSES/CC0-1.0.txt b/LICENSES/CC0-1.0.txt
new file mode 100644 (file)
index 0000000..0e259d4
--- /dev/null
@@ -0,0 +1,121 @@
+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.
diff --git a/LICENSES/GPL-2.0 b/LICENSES/GPL-2.0
deleted file mode 100644 (file)
index cdd31bf..0000000
+++ /dev/null
@@ -1,353 +0,0 @@
-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.
diff --git a/LICENSES/GPL-2.0-only.txt b/LICENSES/GPL-2.0-only.txt
new file mode 100644 (file)
index 0000000..17cb286
--- /dev/null
@@ -0,0 +1,117 @@
+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
diff --git a/LICENSES/LGPL-2.1 b/LICENSES/LGPL-2.1
deleted file mode 100644 (file)
index 8738a8d..0000000
+++ /dev/null
@@ -1,503 +0,0 @@
-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!
diff --git a/LICENSES/LGPL-2.1-only.txt b/LICENSES/LGPL-2.1-only.txt
new file mode 100644 (file)
index 0000000..c9aa530
--- /dev/null
@@ -0,0 +1,175 @@
+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!
diff --git a/LICENSES/MIT b/LICENSES/MIT
deleted file mode 100644 (file)
index f33a68c..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-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.
diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt
new file mode 100644 (file)
index 0000000..2071b23
--- /dev/null
@@ -0,0 +1,9 @@
+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.
index 8d25816cc053e03e6d8707fc281b0687bf9b81e9..71aa496d6877d0dccdc3473623b7d6232b303794 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2010-2024 EfficiOS Inc.
 
 ifneq ($(KERNELRELEASE),)
 
index d1e4dbb67693b2eece683403500dca6bca674c3e..035acc675040891f5b34ae1073deabe79c1b47fd 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,3 +1,9 @@
+<!--
+SPDX-FileCopyrightText: 2011-2024 EfficiOS Inc.
+
+SPDX-License-Identifier: CC-BY-SA-4.0
+-->
+
 LTTng-modules
 =============
 
diff --git a/doc/lttng-modules-design.md b/doc/lttng-modules-design.md
new file mode 100644 (file)
index 0000000..bdada5a
--- /dev/null
@@ -0,0 +1,191 @@
+<!--
+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`
diff --git a/doc/lttng-modules-design.txt b/doc/lttng-modules-design.txt
deleted file mode 100644 (file)
index 23beb0c..0000000
+++ /dev/null
@@ -1,184 +0,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
-  - 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
diff --git a/extra_version/README b/extra_version/README
deleted file mode 100644 (file)
index 5eef496..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-The first line of the "name" file is used to populate the "extra_version_name"
-modinfo key of each built module.
diff --git a/extra_version/README.md b/extra_version/README.md
new file mode 100644 (file)
index 0000000..2042851
--- /dev/null
@@ -0,0 +1,8 @@
+<!--
+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.
diff --git a/extra_version/patches/README b/extra_version/patches/README
deleted file mode 100644 (file)
index 22ea3d3..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-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.
diff --git a/extra_version/patches/README.md b/extra_version/patches/README.md
new file mode 100644 (file)
index 0000000..3b1fd2a
--- /dev/null
@@ -0,0 +1,8 @@
+<!--
+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.
index c9f2b141d80e405166364ee9dc98b9d41a2349b5..ffc5ff7d2da0dec4aae03cd61b5e149fce2acbc7 100644 (file)
@@ -56,23 +56,25 @@ static __always_inline int __lttng_counter_add(const struct lib_counter_config *
                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;
@@ -97,23 +99,25 @@ static __always_inline int __lttng_counter_add(const struct lib_counter_config *
                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;
@@ -138,23 +142,25 @@ static __always_inline int __lttng_counter_add(const struct lib_counter_config *
                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;
@@ -180,23 +186,25 @@ static __always_inline int __lttng_counter_add(const struct lib_counter_config *
                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;
index 209943bc2f102a2f3747141b0e31fa6feaa35c8b..051fe3e8cb17ec8d1af3af726817ff304acd1083 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
diff --git a/include/instrumentation/events/README b/include/instrumentation/events/README
deleted file mode 100644 (file)
index b13a30b..0000000
+++ /dev/null
@@ -1,24 +0,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:
-
-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.
diff --git a/include/instrumentation/events/README.md b/include/instrumentation/events/README.md
new file mode 100644 (file)
index 0000000..c73bc6e
--- /dev/null
@@ -0,0 +1,29 @@
+<!--
+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.
index 89769e2ce3de7dd98ffd17fc54e181cb7b2b77ba..49d97797ef90ab8470d4d64fb33b8b63dcf3037b 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 7bc5cbe9da3f3cf7412eb8ba01218c125d0e7dd2..16d99afbdc5246bfbe831113cc31a5e739a56dae 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 45b621d62b146ed72d13db5b5d3df4324e6595fc..5116bf0e6c32b4f33bad843f837a93056a3bd2ce 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 3cf18de84408e3e60e25da9de12e5543be24fcc6..66d1b04bfeccb1cb4ca5726d9b841449039e9f4e 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 47069cefcf3efe13d2416258eb18991b9125420a..38d188786bdbbe5739d3294fa777c7230240b0fb 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index a12eaf23744cea3b5462ddaa2cfd908976cb56f0..42b871ee5a2bae6f512469941db7b95abd12374a 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 4d286ef4e87d9e71a5f254f7f91fcdfa657fcba2..4ceb8e0287900e2314e4bc4ea940078f23b9ffbf 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
@@ -173,7 +176,27 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(btrfs__inode, btrfs_inode_evict,
 )
 #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,
 
@@ -958,7 +981,51 @@ LTTNG_TRACEPOINT_EVENT(btrfs_add_block_group,
 )
 #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) || \
@@ -1159,7 +1226,53 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(btrfs_delayed_tree_ref,
 )
 #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) || \
index 353fe3b5fdf16c99e65bc7768880e55b641dd9b2..cc7453888d31303374ccb27a1cacd2eb8b74c508 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 95d94ed5fd3930cfb171b8cf6eb88f6fe852bec7..ee3b5690814044e46effb544dd4aab918cfcf441 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 8fa9f9335ee614d408af10d5e6f6a73867d3b8bd..addf2246c2e3ba5fd4de7e442f7fb2f94f91f709 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
@@ -727,7 +730,23 @@ LTTNG_TRACEPOINT_EVENT(ext4_da_update_reserve_space,
 )
 #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),
 
index 97e5e847b23e0d089dd134265321c20fc78e6ed5..c8cc886e17aa1e55faa12b9b32dfb62e9bd3d5b0 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index ad0f80bf70d00d9e41c35f408bed26c9b912b7d7..b0587be3e08db989c0a4c4b2dffea7ec52076fb2 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index a66b81398f9ea1c40369bab3ad92ce0bce015af0..94376f628979fbe967c1d205798f7191a7312275 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 72c7af6afd883388c5be2354c4cdc244d3a16f98..d11da78dc961bc43ca6906143bff28ebdf761314 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 81ca8afcb05ce66a2fe896fe27c87c6fe31c988e..1c410ad2c422570bdec96542cc7437c1bfff55a3 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 0d6a87692324f0309be5c3d23321b2f2a7b096a3..3c616cb2252cffce30178ea223d2600d92d33f75 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 4bfe567c6c228cf4a066318579edbb2581075013..85b1df2478d943b65076b51328c825f991f99b9f 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
@@ -72,27 +75,13 @@ LTTNG_TRACEPOINT_EVENT(kvm_ack_irq,
        { 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))
@@ -105,7 +94,7 @@ LTTNG_TRACEPOINT_EVENT(kvm_mmio,
                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)
        )
 )
 
index af28517e82d3bce017c45abb75d9dbaaa982ede6..5a46a30634c98c370853b3755318848342f389cc 100644 (file)
@@ -1,4 +1,6 @@
-/* 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
index 4831a9411620921365ac2ff03baa7fcf191a633e..24ff7bf7f098654d306eb4f6b3a0a57a473ee9c8 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
@@ -253,7 +256,8 @@ LTTNG_TRACEPOINT_EVENT(lttng_statedump_interrupt,
 
 #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),
index a533380412e0d8ad33017804abd8961dfd168255..c416b5e1c3f80d1f49673eede6b1e8c6d7d69590 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 91eb4608096fb1b02b2ffc4874c253ed7f421d14..4b10a0b1b737e17ab8771553ac647a4eab22e6d4 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 90addbf3cc04f14f025d5f953789293719120307..15d56b384580c12aa0a0b52fc21a743a4c57881d 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
@@ -334,7 +337,8 @@ LTTNG_TRACEPOINT_EVENT_MAP(mm_shrink_slab_end,
        )
 )
 
-#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,
index b1686bf195a988158b0a89065f7e2b7236108544..430ba844e93a481594cd1ce41572520b05e9087d 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
index f90b17d12f82eb772e4a3cd63ab3bad0a97826c1..2ae36d655026e5fd211927386be56e45844902e5 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index d8fecd100b5279942df9581b9c6bcad381557317..d5c61d16b6dd7898676f761c249fd1f102343ea5 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 0feb312dfc36513cae1eef15148e10ef7601b5d6..30465d4dccc11a459f4749e13b6c2f7d423eef34 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 80bbbac6748bd18a1c150fb953ef61ce96696e4c..6fcf32007996fba7eed1c29361c7b4e85852fbd3 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
index 0c0b1b3866069667953d30de218dc5d3a1444864..c1e8825ad2bb57a0e1541ad1f3bd8af9e157adce 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index aad9e5e8f25961e3785f14dd63285f8a5d05935d..f768c1fb76ed731a7a5ad9f46e73a3ed56abb248 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index bb058ba853a401072bffa62ad13ca53dfa307ca0..35b6279fc1a26a4fc2d20e9a1b14bb4b916c7d1c 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 6f46f3887fb9dc6c23ab9585b83381bf7eab29a9..e077eb460c1c0fd4f020597a5b930aaae4fef1fa 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index bfdb6b65e5c5f32f3172b3cc623768f1cf720f29..31713427d5e44a3e77ea5eefe37d289f6d89d221 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index ca448b369d8b61162495ed2ce82801fcf3c79643..0bbb717c642ded8faa1bab1526a310a886b71c5f 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 1e425f8eeb020228f4912293af1866551f91c1aa..b5cdd4d23e451bdfba07153f866a8ed864f950d6 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 5f994759d20350af13fcfeb088bce3be4727ff82..b5915e6da6e03c4292e612b29b9853562a5c4076 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
@@ -484,7 +487,8 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_stat_template, sched_stat_blocked,
             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).
index 41d4f7484643e1c98719aaacfa8babd6a3a4d5e1..175ab003189b9a8c947d5eadb2a94f9c176fd42b 100644 (file)
@@ -1,4 +1,7 @@
-/* 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)                                  \
index 8c0661a1c48df2536f204139ff2ec128abe84fe0..c7d4114ed8a133c21f1e926f4b5be2a32373898c 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 9f1047c6e134b8d8c3761430b9919a616db1aafe..0b5a95dce8af77df1f4d6d399d509d7f244ab57e 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
@@ -40,7 +43,25 @@ LTTNG_TRACEPOINT_ENUM(skb_drop_reason,
 )
 #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))
index 39d3f549225d1082e32112cd927c8408a97172bb..1f48c8b4b97af74caabf1a8a09b7372a5b5da4bd 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 2fc280c11b8d2ae30aafef2003e073f6279c585d..f69e069b459f1f70cda5105c12dea180e48191e9 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
@@ -77,7 +80,8 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_init,
        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
index b63a1bb5dcb3a0f0f4d25415e0a6ccc5f96af50a..f79d0b0353e92e84f7550c322e556e9528390644 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
@@ -7,7 +10,36 @@
 
 #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),
@@ -19,6 +51,7 @@ LTTNG_TRACEPOINT_EVENT(udp_fail_queue_rcv_skb,
                ctf_integer(__u16, lport, inet_sk(sk)->inet_num)
        )
 )
+#endif
 
 #endif /* LTTNG_TRACE_UDP_H */
 
index ad16e7ea3f2f799fb0747031e44eae50cf6c64f2..4f274799103a7e390960c8962923d4d1fba265d4 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 585731710b67eafbc9eab94e94f1aa1e175806c1..fdd7b64dd349c416d7cea17a28500b952902602b 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 8e56c0df3f9828d422356239caada9e9c351c0c5..67191e18874fd6984ad084040a8a8b4416081f52 100644 (file)
@@ -1,4 +1,7 @@
-/* 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
 
index 44847ea8a334d7a85a19c9b7c0ed3cda0f947e7d..3f6280e6e64587f3864b53d4e649ca69dc3c0d4f 100644 (file)
@@ -1,4 +1,6 @@
-/* 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 */
 
index 4dfbdebff3fc077e2dc2c60e6c50d6d184c1a1d3..d9dbabab857cc0561834962ab8e1cb77d5fdb797 100644 (file)
@@ -1,4 +1,6 @@
-/* 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
 
index 5f4ca5b1319e07dbc078052f4c0d0977cac50d45..b586b19c55687e37a7e0f37d3fb10caeefa718ef 100644 (file)
@@ -1,4 +1,6 @@
-/* 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 */
 
index 96fb731f7212a5e025a059f498e3f6d94315f7cd..766c88c86aa3f1e1237c288098fbb4b8e8bca468 100644 (file)
@@ -1,4 +1,6 @@
-/* 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),
index 24237a2251c3012db87dabb0c7a3bcd011db479c..e7c07e71f64688cd5489817c50b3de66926d3c5a 100644 (file)
@@ -1,4 +1,6 @@
-/* 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 */
 
index ac0d5443b4f778fbe5b56bf902c587599229af28..f28074ed2fcd7fe34cd30efba32bae88a42c55ba 100644 (file)
@@ -1,4 +1,6 @@
-/* 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.
index 674a10506dc44c68c15638aaa3574b54f85cd6f6..dbfdef0cf11a1daff2ed8e4aa98e3726450a7cfa 100644 (file)
@@ -1,4 +1,6 @@
-/* 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 */
 
index f35ce2f8fb58230758ea6f38b680c8ee8260f441..16e5d73a41d279f0ebf9aeb59651f48f218b25aa 100644 (file)
@@ -1,4 +1,6 @@
-/* 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.
index 080a36a86a02f5129f2dee60a8876620c4fbe99d..6f083c992798a1b6f9ee4050540b59fda891d6da 100644 (file)
@@ -1,4 +1,6 @@
-/* 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"
index 4d893862bcd122f36b8d0abfb29698de3be12b18..6bbe5c24dbc7fcb5f5fb9294255ddecbf5c5cc6f 100644 (file)
@@ -1,4 +1,6 @@
-/* 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"
index 1daea752f32a41a62a87a3d06722d338da267fb5..8f51a31019b61304ffa77f1a58f8813650b8a1e1 100644 (file)
@@ -1,4 +1,6 @@
-/* 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 */
 
index 6402187330c31a20dcde0bd592c7b98e786063e0..f104034ff1fe5d64712fa2d6afaf914382c72bb6 100644 (file)
@@ -1,4 +1,6 @@
-/* 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.
index 3ff5ad7f463f33169f9d094abd2669e811c9e9fc..1f1d7efcc29ca2cc05a42c455e4b9de13c30e3cc 100644 (file)
@@ -1,4 +1,6 @@
-/* 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 */
 
index 9a38fb5a08f0b7e6733535e9110cbfe602dd3255..510d2a686b50725b0c19bde72daee9b960d24acd 100644 (file)
@@ -1,4 +1,6 @@
-/* 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
 
index 855087f6d120134153dca4056b23943273a9c7eb..dae0dee67bc00356e5f89ac845a0d49bcd1e15fa 100644 (file)
@@ -1,4 +1,6 @@
-/* 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 */
 
index 6402187330c31a20dcde0bd592c7b98e786063e0..f104034ff1fe5d64712fa2d6afaf914382c72bb6 100644 (file)
@@ -1,4 +1,6 @@
-/* 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.
index 203da38e651f36cea697d4d59165f892a4d2dd3a..8b27bfb8f03cb80cf7d97204b877e07d63e323da 100644 (file)
@@ -1,4 +1,6 @@
-/* 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 */
 
index eb2b48cf2091ae15e62ac95811e910faabfac725..c34262ad8a4f990fc071efb0ba7c2308e99a6bd5 100644 (file)
@@ -1,4 +1,6 @@
-/* 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
 
index 2c8f40deb87e3a3ac37db9b530911669f428ceac..61c0da10a34dc683ef37ef88d9860abe347e62f2 100644 (file)
@@ -1,4 +1,6 @@
-/* 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 */
 
index 529a492739058f89b4ddc8bd97b7fde79988b233..682ba9d5071048eab327745131f228ae5ad9659b 100644 (file)
@@ -1,4 +1,6 @@
-/* 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
 
index d9cde3a80f3c465c0556f31b90016202d70d4123..8eb3db1af5c1bb18f127a3932c53959e7e0d4c70 100644 (file)
@@ -1,4 +1,6 @@
-/* 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 */
 
index fde30d270ff2cdbaf1307c331997077b0e830475..074dc4d02f808bcf6c6b927dc38e3abeaff135c6 100644 (file)
@@ -1,9 +1,15 @@
-/* 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),
index ea8e29bc5f61f29ed976ae3825d9471b2b55b24f..d528bdb5b18cd8750d8339c6078efa104c6d0b54 100644 (file)
@@ -1,4 +1,6 @@
-/* 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"
index 74bc9dcf5b1c91599c2df21193a673f1cd993fd1..c85ea0a4fe7f646ec3968fb368836824ef02d2dd 100644 (file)
@@ -1,4 +1,6 @@
-/* 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
 
index a2ee31275732706afde4cbb9acd104d68f63ac26..3ca59c7392897bb9a3498aad61163f6a1506ed93 100644 (file)
@@ -1,4 +1,6 @@
-/* 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"
index 924677491b12b343c096eeaa486c4c6228162f42..019be36e0ff9d708fc31d6f7086aadfaef16dbe9 100644 (file)
@@ -1,4 +1,6 @@
-/* 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
 
@@ -193,6 +195,10 @@ SC_LTTNG_TRACEPOINT_EVENT(getcpu,
        )
 )
 
+/*
+ * 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,
index 8645d7144f0e90950d1e24a810a92fe10dda755f..a5ee3e1492af32fea2ff1a52437fb0f4d5fb92be 100644 (file)
@@ -1,4 +1,6 @@
-/* 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
index b053db6769f9127b883c7e40afe0851a852a8a08..814373b6b754fda98ccd453d946c9e3e21e964b4 100644 (file)
@@ -1,4 +1,6 @@
-/* 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 */
 
index 3d933ad3925fac896bc9246b59f856ab9d343df4..ea090b2fd162eef6f2221766b95de6c9a501b5e5 100644 (file)
@@ -1,4 +1,6 @@
-/* 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
 
index 2d8331976e13d2bf9b77f3eff99c12f2aed06ad8..1b5e41f9a61b4289d6231fc255727f65b655a5c0 100644 (file)
@@ -1,4 +1,6 @@
-/* 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 */
 
index bd63ed09ceebda18410da8f6dcd076060f329589..43e11bd859aafd13c9d4ae3d1b89575e8de016ae 100644 (file)
@@ -1,4 +1,6 @@
-/* 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,
index 7b7d83f00caae1a0b4c7e207228beee42aa73665..4df0cb75fc7be5222231613c04441c921c35354f 100644 (file)
@@ -1,4 +1,6 @@
-/* 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 */
 
index a241399b09f25f010f300701cc4da3661756d205..627c3554d079d6a2533794731c440737d2c7c966 100644 (file)
@@ -1,4 +1,6 @@
-/* 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.
index bd1ac35d003b7fdbac1c95098726504dbca627a4..d592755ffb636c0f0a2e1112c5d1161419664529 100644 (file)
@@ -1,4 +1,6 @@
-/* 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 */
 
index bd88945124285608df97c82dc4325c574169ce91..2cb17b8f873ba4fb37b69460df642914be969352 100644 (file)
@@ -1,4 +1,6 @@
-/* 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
 
@@ -155,6 +157,10 @@ SC_LTTNG_TRACEPOINT_EVENT_CODE(accept4,
        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),
index 23eeacf0d357c4431c370f5f5d271b9808b8e426..730b077f9d7b4b53bb82dfde59d1dbfb4e6ce721 100644 (file)
@@ -95,6 +95,59 @@ struct lttng_kernel_abi_old_context {
        } 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            \
@@ -125,4 +178,15 @@ struct lttng_kernel_abi_old_context {
 #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 */
index f8af1dd04f8ce09f0cf5d3ffcb0e24dc594bb76e..8f0a1472350cf626072c7e7c70f9221c46023304 100644 (file)
@@ -130,16 +130,43 @@ struct lttng_kernel_abi_syscall {
        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 {
@@ -160,7 +187,18 @@ struct lttng_kernel_abi_event_notifier {
        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,
@@ -171,62 +209,170 @@ enum lttng_kernel_abi_counter_bitness {
        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 {
@@ -399,6 +545,7 @@ struct lttng_kernel_abi_tracker_args {
 #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)
 
@@ -412,9 +559,12 @@ struct lttng_kernel_abi_tracker_args {
 #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)
@@ -437,14 +587,21 @@ struct lttng_kernel_abi_tracker_args {
 /* 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.
index a727230ffffb8c21320b04b502e98ff4755987d1..224bfec1854e876df063c12ed766784b094b607a 100644 (file)
@@ -18,12 +18,19 @@ struct lttng_metadata_cache;
 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,
@@ -49,6 +56,9 @@ struct lttng_uprobe_handler {
 struct lttng_kprobe {
        struct kprobe kp;
        char *symbol_name;
+       uint64_t addr;
+       uint64_t offset;
+       kprobe_pre_handler_t pre_handler;
 };
 
 struct lttng_uprobe {
@@ -66,6 +76,13 @@ enum lttng_syscall_abi {
        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 */
 
@@ -79,7 +96,7 @@ struct lttng_kernel_event_common_private {
        /* 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;
@@ -88,6 +105,7 @@ struct lttng_kernel_event_common_private {
                struct lttng_kprobe kprobe;
                struct lttng_uprobe uprobe;
                struct {
+                       enum lttng_kretprobe_entryexit entryexit;
                        struct lttng_krp *lttng_krp;
                        char *symbol_name;
                } kretprobe;
@@ -100,15 +118,35 @@ struct lttng_kernel_event_common_private {
        } 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;
 
@@ -150,6 +188,9 @@ struct lttng_kernel_channel_common_private {
 
        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;
 };
@@ -167,10 +208,75 @@ struct lttng_kernel_channel_buffer_private {
        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,
@@ -192,11 +298,6 @@ enum lttng_kernel_bytecode_type {
        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;
@@ -242,11 +343,24 @@ struct lttng_event_enabler_common {
        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;
@@ -322,12 +436,20 @@ struct lttng_metadata_stream {
        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 */
 
@@ -380,36 +502,6 @@ struct lttng_kernel_channel_buffer_ops_private {
                        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)
 
@@ -423,7 +515,7 @@ struct lttng_event_notifier_group {
        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. */
@@ -433,7 +525,7 @@ struct lttng_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;
 };
 
@@ -448,7 +540,7 @@ struct lttng_counter_transport {
        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 {
@@ -456,18 +548,20 @@ 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];
 };
@@ -495,6 +589,73 @@ struct lttng_kernel_id_tracker_private {
        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
@@ -579,13 +740,6 @@ int lttng_kernel_interpret_event_filter(const struct lttng_kernel_event_common *
                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)
@@ -594,35 +748,58 @@ struct lttng_event_enabler_common *lttng_event_notifier_enabler_as_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:
        {
@@ -819,7 +996,7 @@ struct lttng_event_recorder_enabler *lttng_event_recorder_enabler_create(
                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,
@@ -841,12 +1018,6 @@ bool lttng_desc_match_enabler(const struct lttng_kernel_event_desc *desc,
                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,
@@ -908,16 +1079,19 @@ static inline void lttng_syscall_table_set_wildcard_all(struct lttng_event_enabl
 #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,
@@ -925,6 +1099,11 @@ int lttng_kprobes_register_event(const char *name,
 {
        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)
@@ -935,6 +1114,11 @@ static inline
 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,
@@ -974,41 +1158,73 @@ void lttng_uprobes_destroy_event_private(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;
 }
@@ -1032,21 +1248,25 @@ int lttng_session_metadata_regenerate(struct lttng_kernel_session *session);
 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);
 
@@ -1063,11 +1283,13 @@ struct lttng_kernel_channel_buffer *lttng_global_channel_create(struct lttng_ker
                                       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);
@@ -1129,6 +1351,24 @@ int lttng_calibrate(struct lttng_kernel_abi_calibrate *calibrate);
 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),                                                          \
index 22f654be96d4a92ad5c68b80d24fcb372ad0bfc8..8c04ec280820dd663ba5ab5e7dfc9ea3c5c9c0fb 100644 (file)
@@ -27,6 +27,7 @@
 #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;
 
@@ -349,6 +350,7 @@ struct lttng_kernel_event_common_private;
 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 {
@@ -374,6 +376,21 @@ struct lttng_kernel_event_recorder {
        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. */
 };
@@ -415,6 +432,7 @@ struct lttng_kernel_channel_buffer_ops {
 
 enum lttng_kernel_channel_type {
        LTTNG_KERNEL_CHANNEL_TYPE_BUFFER = 0,
+       LTTNG_KERNEL_CHANNEL_TYPE_COUNTER = 1,
 };
 
 struct lttng_kernel_channel_common_private;
@@ -438,6 +456,25 @@ struct lttng_kernel_channel_buffer {
        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 {
@@ -484,4 +521,30 @@ void lttng_kernel_probe_unregister(struct lttng_kernel_probe_desc *desc);
 
 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 */
index 0d19518dd46b0c1d24eb0402733ec039be68438b..7a29c47b1ac893757dfda04ba21502582772b06b 100644 (file)
@@ -1,26 +1,10 @@
+/* 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__ */
index 88a2bccccb21b4f6fab9d06a86184503a3fe1b5d..a0053044f722cba42831e5babf4ab1d979cc98b8 100644 (file)
@@ -1065,6 +1065,7 @@ static void __event_probe__##_name(_data_proto)                                           \
 {                                                                                      \
        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(),                                      \
@@ -1079,20 +1080,18 @@ static void __event_probe__##_name(_data_proto)                                         \
                        &__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)))      \
@@ -1116,15 +1115,7 @@ static void __event_probe__##_name(_data_proto)                                          \
                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(&lttng_dynamic_len_stack)->offset;     \
        __dynamic_len_idx = __orig_dynamic_len_offset;                                  \
        _code_pre                                                                       \
@@ -1180,6 +1171,24 @@ static void __event_probe__##_name(_data_proto)                                          \
                                &__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);                                                        \
        }                                                                               \
index c01b6488eb0b3ef964dfbcf812732e80c9e089ae..b93ad7b5f8520f61d6b04d5123a3ae304e0a48db 100644 (file)
@@ -1,4 +1,4 @@
-/* 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
 
diff --git a/include/wrapper/bitops.h b/include/wrapper/bitops.h
new file mode 100644 (file)
index 0000000..2693cd1
--- /dev/null
@@ -0,0 +1,23 @@
+// 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 */
index 46fc3f33dddef766d7dfea8e71f7a8711b956b74..bd03c08b945b95623837fe63fcf545619f2a072c 100644 (file)
@@ -19,7 +19,8 @@ struct file *lttng_lookup_fdget_rcu(unsigned int fd)
        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)
 {
@@ -41,4 +42,18 @@ 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 */
index 047d9368971527e68b1c7d7e15cc2dae383cdb41..4f603f5a1c63b3931c3dfeae07affc8de3a8c8a0 100644 (file)
@@ -13,7 +13,8 @@
 
 #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)
index 4ccb26a006397350b604cfc7a33cbb072c7dcfe2..e716368765ab749d052d5f069e9fe42ee6a264dc 100644 (file)
@@ -11,6 +11,7 @@
 #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 */
index a84fe925466650cdebf484045c572651c1d86c49..767e2c381513beb53d4c2d37b98e2b275275b206 100755 (executable)
@@ -1,5 +1,6 @@
 #!/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"
index 4d9f144cdb3e81f05bb3898f5e0f30ef3fd3899b..d41f216479c838c6fb89480af7feca3728752330 100755 (executable)
@@ -1,5 +1,6 @@
 #!/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"
index 66376acf5ddcbdddd1d9eed1a4b7fb8aff9517e4..b3bd1c273284b8b1374335dcbe4b330308683ea9 100755 (executable)
@@ -1,5 +1,6 @@
 #!/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"
index 9b7da92d407c99562c2c800fdd02932158fb349c..542895e0a475e4987594a2fbb57be15f91ec44fe 100755 (executable)
@@ -1,5 +1,6 @@
 #!/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
index 5c58042263ae768378c6cee3e08f0b8628d7458e..d416fdf48982e16500027866033b592585135352 100755 (executable)
@@ -1,5 +1,6 @@
 #!/bin/bash
 # SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2015-2021 EfficiOS Inc.
 
 set -e
 
index 5c428080c3294f349741996d2c034c0d7ee445f2..2d72f6303f8200c6083f6bd5c7b3edaf6aa44abf 100755 (executable)
@@ -1,5 +1,6 @@
 #!/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"
index f4e1e122b1e70ffa7f9e2603b96060d330e907b4..dffc07d26e457daab9de17208d69c8a653d4b03c 100755 (executable)
@@ -1,5 +1,6 @@
 #!/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"
index aecbb2c9473fb7a292d7bfd9f1ae8a57348f92a1..b85fc1ad3c50a22bf42b328e51b7723ddf023a3b 100755 (executable)
@@ -1,5 +1,6 @@
 #!/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"
@@ -12,7 +13,7 @@ fi
 
 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
index 5e94e136b90423d0775c1ae55af88b726c0d2516..5fc43455d4110f082332197f35e8713a8869ee0b 100755 (executable)
@@ -1,4 +1,6 @@
 #!/bin/bash
+# SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2020 EfficiOS Inc.
 
 set -eu
 set -o pipefail
index 7c5b108e484d97e8d7d92fd5c5cfed25bcbad7a7..420671b184aae4b15905967cf61540f2d29687eb 100755 (executable)
@@ -1,5 +1,6 @@
 #!/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"
index a341fd9bd85549eb84d0396ab324e7b202342c94..b529e38a6f86287fab6f9bd87dbc621eb96e4477 100644 (file)
@@ -1,4 +1,5 @@
 # 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),)
@@ -140,6 +141,18 @@ ifneq ($(CONFIG_TIME_NS),)
   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
 
index 78afa21ec9d9551f119402c52f9742ca0ff4dffc..f9f47a048d30764f7ca62b114d6b9ca5d041209f 100644 (file)
@@ -1,4 +1,5 @@
 # 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)
index c1e5781be2374d5a5ef4a4534574edcee58e1574..ee693ceb505b58bb131f0e5db85ee124666a77b0 100644 (file)
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2015-2024 EfficiOS Inc.
 
 config LTTNG
        tristate "LTTng support"
index 4d1e9585fbe6f386db7912abc29a6354cd2e33c1..e9075f9b557c7fe0369a8fcbdd4d04738fae3610 100644 (file)
@@ -1,4 +1,5 @@
 # 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)))/../..
 
index 54d5692679cd926fec304dc4bff0821142e6197e..860f98300242d4b876870b8248e7f9d35ec441da 100644 (file)
@@ -1,21 +1,5 @@
-/*
- * 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
index afd233738dc326b66e80df9ae81c53ff52520557..5a3b616fddc7d9daac92c3cf422a48cd641b9eab 100644 (file)
@@ -38,6 +38,7 @@
 #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>
@@ -65,13 +66,21 @@ static const struct file_operations lttng_session_fops;
 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;
@@ -613,122 +622,673 @@ int lttng_abi_session_set_creation_time(struct lttng_kernel_session *session,
 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;
        }
@@ -765,6 +1325,130 @@ enum tracker_type get_tracker_type(struct lttng_kernel_abi_tracker_args *tracker
        }
 }
 
+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
  *
@@ -798,6 +1482,7 @@ long lttng_session_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        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
@@ -964,6 +1649,16 @@ long lttng_session_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                        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;
        }
@@ -1551,7 +2246,7 @@ int lttng_metadata_ring_buffer_release(struct inode *inode, struct file *file)
        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);
@@ -1709,7 +2404,7 @@ int lttng_abi_open_metadata_stream(struct file *channel_file)
                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;
@@ -1761,17 +2456,23 @@ refcount_error:
 }
 
 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;
@@ -1788,44 +2489,311 @@ int lttng_abi_validate_event_param(struct lttng_kernel_abi_event *event_param)
                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 = &lttng_event_session_enabler_fops;
+               break;
+
+       case LTTNG_KERNEL_ABI_UPROBE:
+               fops = &lttng_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;
@@ -1850,14 +2818,15 @@ int lttng_abi_create_event(struct file *channel_file,
        case LTTNG_KERNEL_ABI_TRACEPOINT:
                lttng_fallthrough;
        case LTTNG_KERNEL_ABI_SYSCALL:
-               fops = &lttng_event_recorder_enabler_fops;
-               break;
+               lttng_fallthrough;
        case LTTNG_KERNEL_ABI_KPROBE:
                lttng_fallthrough;
        case LTTNG_KERNEL_ABI_KRETPROBE:
-               lttng_fallthrough;
+               fops = &lttng_event_session_enabler_fops;
+               break;
+
        case LTTNG_KERNEL_ABI_UPROBE:
-               fops = &lttng_event_recorder_event_fops;
+               fops = &lttng_event_session_fops;
                break;
 
        case LTTNG_KERNEL_ABI_FUNCTION:
@@ -1873,7 +2842,7 @@ int lttng_abi_create_event(struct file *channel_file,
                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);
@@ -1884,7 +2853,10 @@ int lttng_abi_create_event(struct file *channel_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;
 
@@ -1893,21 +2865,21 @@ int lttng_abi_create_event(struct file *channel_file,
                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;
        }
@@ -1915,14 +2887,24 @@ int lttng_abi_create_event(struct file *channel_file,
        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;
@@ -1931,14 +2913,13 @@ int lttng_abi_create_event(struct file *channel_file,
                 * 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;
        }
 
@@ -1967,19 +2948,19 @@ fd_error:
 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;
@@ -1989,20 +2970,24 @@ long lttng_event_notifier_event_ioctl(struct file *file, unsigned int cmd, unsig
 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:
@@ -2013,20 +2998,26 @@ long lttng_event_notifier_enabler_ioctl(struct file *file, unsigned int cmd, uns
 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;
 }
 
@@ -2050,7 +3041,8 @@ static const struct file_operations lttng_event_notifier_enabler_fops = {
 
 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;
@@ -2059,34 +3051,17 @@ int lttng_abi_create_event_notifier(struct file *event_notifier_group_file,
        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 = &lttng_event_notifier_enabler_fops;
-               break;
+               lttng_fallthrough;
        case LTTNG_KERNEL_ABI_KPROBE:
                lttng_fallthrough;
        case LTTNG_KERNEL_ABI_KRETPROBE:
-               lttng_fallthrough;
+               fops = &lttng_event_notifier_enabler_fops;
+               break;
+
        case LTTNG_KERNEL_ABI_UPROBE:
                fops = &lttng_event_notifier_event_fops;
                break;
@@ -2101,6 +3076,16 @@ int lttng_abi_create_event_notifier(struct file *event_notifier_group_file,
        }
 
        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) {
@@ -2121,7 +3106,10 @@ int lttng_abi_create_event_notifier(struct file *event_notifier_group_file,
                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;
 
@@ -2156,7 +3144,17 @@ int lttng_abi_create_event_notifier(struct file *event_notifier_group_file,
        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;
@@ -2168,14 +3166,13 @@ int lttng_abi_create_event_notifier(struct file *event_notifier_group_file,
                        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;
        }
 
@@ -2202,34 +3199,105 @@ inval_instr:
        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]",
+                                      &lttng_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:
@@ -2263,40 +3331,36 @@ long lttng_abi_event_notifier_group_create_error_counter(
                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);
@@ -2311,6 +3375,8 @@ static
 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:
        {
@@ -2319,23 +3385,37 @@ long lttng_event_notifier_group_ioctl(struct file *file, unsigned int cmd,
        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;
@@ -2451,7 +3531,7 @@ long lttng_channel_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                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);
@@ -2463,12 +3543,17 @@ old_event_end:
        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:
        {
@@ -2617,7 +3702,7 @@ int lttng_metadata_channel_release(struct inode *inode, struct file *file)
 
        if (channel) {
                fput(channel->parent.session->priv->file);
-               lttng_metadata_channel_destroy(channel);
+               lttng_metadata_channel_buffer_destroy(channel);
        }
 
        return 0;
@@ -2643,7 +3728,7 @@ static const struct file_operations lttng_metadata_fops = {
 };
 
 /**
- *     lttng_event_recorder_event_ioctl - lttng syscall through ioctl
+ *     lttng_event_ioctl - lttng syscall through ioctl
  *
  *     @file: the file
  *     @cmd: the command
@@ -2658,9 +3743,9 @@ static const struct file_operations lttng_metadata_fops = {
  *             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:
@@ -2675,14 +3760,14 @@ long lttng_event_recorder_event_ioctl(struct file *file, unsigned int cmd, unsig
        }
        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;
@@ -2705,9 +3790,9 @@ long lttng_event_recorder_event_ioctl(struct file *file, unsigned int cmd, unsig
  *             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:
@@ -2722,13 +3807,24 @@ long lttng_event_recorder_enabler_ioctl(struct file *file, unsigned int cmd, uns
        }
        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:
@@ -2737,40 +3833,46 @@ long lttng_event_recorder_enabler_ioctl(struct file *file, unsigned int cmd, uns
 }
 
 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
 };
 
index 35a8b54fa2b8d7cabd4e7306954811b55d1a4d51..eb9d74d898f57142a510fe9dba56cd1442c534e6 100644 (file)
@@ -22,53 +22,112 @@ static const struct lib_counter_config client_config = {
        .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(&lttng_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 = &lttng_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,
        },
 };
 
index 771bed3e214ea8abdb97e49319fc5e0805dbc1a8..829e6a7020f02099823338ab20a329c776901dc5 100644 (file)
@@ -22,53 +22,112 @@ static const struct lib_counter_config client_config = {
        .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(&lttng_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 = &lttng_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,
        },
 };
 
index 29d2d1567b80242182fd2a68cffff05da8cb5f59..290e57e31c1c25ace97b9cbde3407b560bea248f 100644 (file)
@@ -394,7 +394,7 @@ void record_error(struct lttng_kernel_event_notifier *event_notifier)
 {
 
        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;
 
@@ -410,8 +410,7 @@ void record_error(struct lttng_kernel_event_notifier *event_notifier)
 
        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);
 }
index 73f591fd9e56702ac2d73c9ae10a8c6069408735..95184984d27cc15721080da921a950fd7f4fb0c9 100644 (file)
@@ -44,6 +44,7 @@
 #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>
 
@@ -66,6 +67,8 @@ static LIST_HEAD(lttng_counter_transport_list);
 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;
 
@@ -75,7 +78,7 @@ static void lttng_event_notifier_group_sync_enablers(struct lttng_event_notifier
 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);
@@ -135,7 +138,7 @@ int lttng_session_active(void)
 {
        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;
        }
@@ -159,8 +162,8 @@ struct lttng_kernel_session *lttng_session_create(void)
        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),
@@ -179,8 +182,10 @@ struct lttng_kernel_session *lttng_session_create(void)
                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;
@@ -229,12 +234,15 @@ struct lttng_counter_transport *lttng_counter_transport_find(const char *name)
        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) {
@@ -247,31 +255,36 @@ struct lttng_counter *lttng_kernel_counter_create(
                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;
@@ -319,7 +332,7 @@ struct lttng_event_notifier_group *lttng_event_notifier_group_create(void)
        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);
 
@@ -347,7 +360,7 @@ void metadata_cache_destroy(struct kref *kref)
 
 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;
@@ -355,27 +368,26 @@ void lttng_session_destroy(struct lttng_kernel_session *session)
 
        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->eventsparent.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->eventsparent.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);
@@ -385,7 +397,7 @@ void lttng_session_destroy(struct lttng_kernel_session *session)
        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);
@@ -426,14 +438,8 @@ void lttng_event_notifier_group_destroy(
                        &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);
@@ -456,7 +462,7 @@ int lttng_session_statedump(struct lttng_kernel_session *session)
 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) {
@@ -474,19 +480,29 @@ int lttng_session_enable(struct lttng_kernel_session *session)
         * 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);
@@ -507,7 +523,7 @@ end:
 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) {
@@ -521,9 +537,14 @@ int lttng_session_disable(struct lttng_kernel_session *session)
        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);
@@ -533,7 +554,7 @@ end:
 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;
@@ -548,18 +569,23 @@ int lttng_session_metadata_regenerate(struct lttng_kernel_session *session)
        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->eventsparent.node) {
+       list_for_each_entry(event_recorder_priv, &session->priv->events_head, parent.parent.node) {
                event_recorder_priv->metadata_dumped = 0;
        }
 
@@ -647,13 +673,8 @@ int lttng_event_enable(struct lttng_kernel_event_common *event)
                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;
@@ -667,19 +688,17 @@ int lttng_event_enable(struct lttng_kernel_event_common *event)
        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:
@@ -711,13 +730,8 @@ int lttng_event_disable(struct lttng_kernel_event_common *event)
                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;
@@ -731,19 +745,17 @@ int lttng_event_disable(struct lttng_kernel_event_common *event)
        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:
@@ -766,7 +778,6 @@ struct lttng_kernel_channel_buffer *lttng_channel_buffer_create(struct lttng_ker
                                       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);
@@ -782,15 +793,9 @@ struct lttng_kernel_channel_buffer *lttng_channel_buffer_create(struct lttng_ker
                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;
@@ -808,14 +813,12 @@ struct lttng_kernel_channel_buffer *lttng_channel_buffer_create(struct lttng_ker
        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);
@@ -831,26 +834,50 @@ active:
  * 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)
@@ -869,7 +896,7 @@ bool lttng_kernel_event_id_available(struct lttng_event_enabler_common *event_en
        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) {
@@ -893,6 +920,41 @@ bool lttng_kernel_event_id_available(struct lttng_event_enabler_common *event_en
                        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:
@@ -902,7 +964,9 @@ bool lttng_kernel_event_id_available(struct lttng_event_enabler_common *event_en
 }
 
 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;
@@ -911,11 +975,12 @@ struct lttng_kernel_event_common *lttng_kernel_event_alloc(struct lttng_event_en
        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;
@@ -925,18 +990,19 @@ struct lttng_kernel_event_common *lttng_kernel_event_alloc(struct lttng_event_en
                        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:
@@ -946,6 +1012,7 @@ struct lttng_kernel_event_common *lttng_kernel_event_alloc(struct lttng_event_en
                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;
@@ -973,6 +1040,56 @@ struct lttng_kernel_event_common *lttng_kernel_event_alloc(struct lttng_event_en
                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;
        }
@@ -991,6 +1108,15 @@ void lttng_kernel_event_free(struct lttng_kernel_event_common *event)
                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 =
@@ -1010,12 +1136,15 @@ int lttng_kernel_event_notifier_clear_error_counter(struct lttng_kernel_event_co
 {
        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;
@@ -1039,7 +1168,7 @@ int lttng_kernel_event_notifier_clear_error_counter(struct lttng_kernel_event_co
                }
 
                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);
@@ -1052,26 +1181,223 @@ int lttng_kernel_event_notifier_clear_error_counter(struct lttng_kernel_event_co
        }
 }
 
+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) {
@@ -1083,12 +1409,14 @@ struct lttng_kernel_event_common *_lttng_kernel_event_create(struct lttng_event_
                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:
@@ -1099,15 +1427,24 @@ struct lttng_kernel_event_common *_lttng_kernel_event_create(struct lttng_event_
                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;
@@ -1128,18 +1465,10 @@ struct lttng_kernel_event_common *_lttng_kernel_event_create(struct lttng_event_
                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,
@@ -1148,67 +1477,34 @@ struct lttng_kernel_event_common *_lttng_kernel_event_create(struct lttng_event_
                        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;
@@ -1261,6 +1557,8 @@ struct lttng_kernel_event_common *_lttng_kernel_event_create(struct lttng_event_
                        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:
@@ -1276,10 +1574,16 @@ struct lttng_kernel_event_common *_lttng_kernel_event_create(struct lttng_event_
        }
 
        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;
@@ -1296,39 +1600,52 @@ full:
 }
 
 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)
 {
@@ -1350,20 +1667,15 @@ 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:
@@ -1401,15 +1713,8 @@ void unregister_event(struct lttng_kernel_event_common *event)
                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:
@@ -1419,6 +1724,8 @@ void unregister_event(struct lttng_kernel_event_common *event)
        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:
@@ -1455,96 +1762,68 @@ void _lttng_event_unregister(struct lttng_kernel_event_common *event)
 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
@@ -1907,6 +2186,66 @@ int lttng_desc_match_enabler_check(const struct lttng_kernel_event_desc *desc,
                }
                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;
@@ -1926,88 +2265,34 @@ bool lttng_desc_match_enabler(const struct lttng_kernel_event_desc *desc,
        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)
@@ -2015,31 +2300,22 @@ bool lttng_event_enabler_event_name_match_event(struct lttng_event_enabler_commo
 
        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);
@@ -2064,7 +2340,6 @@ struct lttng_enabler_ref *lttng_enabler_ref(
 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;
@@ -2078,33 +2353,19 @@ void lttng_event_enabler_create_tracepoint_events_if_missing(struct lttng_event_
         */
        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);
                        }
@@ -2112,6 +2373,68 @@ void lttng_event_enabler_create_tracepoint_events_if_missing(struct lttng_event_
        }
 }
 
+/* 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.
@@ -2131,6 +2454,14 @@ void lttng_event_enabler_create_events_if_missing(struct lttng_event_enabler_com
                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;
@@ -2152,6 +2483,8 @@ void lttng_event_enabler_init_event_capture(struct lttng_event_enabler_common *e
 {
        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:
        {
@@ -2183,6 +2516,13 @@ int lttng_event_enabler_ref_events(struct lttng_event_enabler_common *event_enab
        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. */
@@ -2198,6 +2538,8 @@ int lttng_event_enabler_ref_events(struct lttng_event_enabler_common *event_enab
 
                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.
@@ -2208,11 +2550,16 @@ int lttng_event_enabler_ref_events(struct lttng_event_enabler_common *event_enab
 
                        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;
 }
 
@@ -2225,7 +2572,7 @@ int lttng_fix_pending_events(void)
 {
        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;
 }
@@ -2272,19 +2619,50 @@ struct lttng_event_recorder_enabler *lttng_event_recorder_enabler_create(
        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);
@@ -2392,7 +2770,7 @@ void lttng_event_enabler_destroy(struct lttng_event_enabler_common *event_enable
        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;
@@ -2405,6 +2783,15 @@ void lttng_event_enabler_destroy(struct lttng_event_enabler_common *event_enable
                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);
        }
@@ -2520,6 +2907,8 @@ void lttng_event_sync_capture_state(struct lttng_kernel_event_common *event)
 {
        switch (event->type) {
        case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
+               lttng_fallthrough;
+       case LTTNG_KERNEL_EVENT_TYPE_COUNTER:
                break;
        case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
        {
@@ -2551,6 +2940,10 @@ bool lttng_get_event_enabled_state(struct lttng_kernel_event_common *event)
        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) {
@@ -2566,16 +2959,18 @@ bool lttng_get_event_enabled_state(struct lttng_kernel_event_common *event)
 
        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;
@@ -2592,6 +2987,10 @@ bool lttng_event_is_lazy_sync(struct lttng_kernel_event_common *event)
        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:
@@ -2650,7 +3049,7 @@ void lttng_sync_event_list(struct list_head *event_enabler_list,
 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);
 }
 
 /*
@@ -2680,10 +3079,12 @@ void lttng_event_enabler_sync(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);
-               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:
@@ -2785,7 +3186,7 @@ void lttng_metadata_end(struct lttng_kernel_session *session)
        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);
        }
@@ -3448,7 +3849,7 @@ int _lttng_fields_metadata_statedump(struct lttng_kernel_session *session,
                                   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;
 
@@ -3491,10 +3892,10 @@ int _lttng_event_recorder_metadata_statedump(struct lttng_kernel_event_common *e
        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;
@@ -3752,7 +4153,7 @@ int _lttng_session_metadata_statedump(struct lttng_kernel_session *session)
        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;
 
@@ -3920,13 +4321,18 @@ int _lttng_session_metadata_statedump(struct lttng_kernel_session *session)
                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->eventsparent.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;
@@ -3999,6 +4405,87 @@ void lttng_counter_transport_unregister(struct lttng_counter_transport *transpor
 }
 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 = &lttng_chan_buf->parent;
+       lttng_chan_common->type = LTTNG_KERNEL_CHANNEL_TYPE_BUFFER;
+       lttng_chan_buf->priv = lttng_chan_buf_priv;
+       lttng_chan_common->priv = &lttng_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 = &lttng_chan_counter->parent;
+       lttng_chan_common->type = LTTNG_KERNEL_CHANNEL_TYPE_COUNTER;
+       lttng_chan_counter->priv = lttng_chan_counter_priv;
+       lttng_chan_common->priv = &lttng_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;
@@ -4151,6 +4638,16 @@ static int __init lttng_events_init(void)
                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;
@@ -4200,6 +4697,10 @@ error_abi:
 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);
@@ -4235,10 +4736,12 @@ static void __exit lttng_events_exit(void)
        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();
diff --git a/src/lttng-kprobes.c b/src/lttng-kprobes.c
new file mode 100644 (file)
index 0000000..75eb414
--- /dev/null
@@ -0,0 +1,250 @@
+/* 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), &lttng_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, &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 = 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(&lttng_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(&lttng_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(&lttng_kp, 0, sizeof(lttng_kp));
+       ret = lttng_kp_init(&lttng_kp, symbol_name, offset, addr, NULL);
+       if (ret)
+               return ret;
+       ret = _lttng_kprobes_register(&lttng_kp);
+       if (ret) {
+               ret = -ENOENT;
+               goto end;
+       }
+       unregister_kprobe(&lttng_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);
diff --git a/src/lttng-kretprobes.c b/src/lttng-kretprobes.c
new file mode 100644 (file)
index 0000000..7bc3849
--- /dev/null
@@ -0,0 +1,340 @@
+/* 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), &lttng_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, &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 = 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(&lttng_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(&lttng_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(&lttng_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(&lttng_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(&lttng_krp, 0, sizeof(lttng_krp));
+       ret = lttng_krp_init(&lttng_krp, symbol_name, offset, addr, NULL, NULL);
+       if (ret)
+               return ret;
+       ret = _lttng_kretprobes_register(&lttng_krp);
+       if (ret) {
+               ret = -ENOENT;
+               goto end;
+       }
+       unregister_kretprobe(&lttng_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);
index a1753e986ae3fd68582cdc29e0c7b48a9329a5a6..40afa1f1cd7c9fd9f614afdbfbaf2a33b9c5bf9c 100644 (file)
@@ -616,7 +616,7 @@ int lttng_event_reserve(struct lttng_kernel_ring_buffer_ctx *ctx)
        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;
index c8dcc1d2606ca2fd38d35b43f3bc46d240357578..6963d56282690196c901e8508a383be25e913fff 100644 (file)
@@ -1,4 +1,4 @@
-/* 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
  *
index fa7bbf57a04c62d0e952db8bc83c8277c600e2ed..6f450eb3195d233cf589dadb6a6cac3390dcefdf 100644 (file)
@@ -1,4 +1,4 @@
-/* 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
  *
index a0e97e1ca5a53a0f5975f31aa46bbccc2cff1b34..5ea790f59a1d26e2e889766a54a439f454203d83 100644 (file)
@@ -42,7 +42,6 @@
 #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 */
@@ -436,17 +435,22 @@ int lttng_dump_one_fd(const void *p, struct file *file, unsigned int fd)
         */
        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;
 
index 827ca1d3848baa75daad3a6b7c4b0aa89a571376..3548052ff2d240a076ea5f31d78caf5fd9f15bd5 100644 (file)
@@ -492,10 +492,12 @@ struct lttng_kernel_syscall_table *get_syscall_table_from_enabler(struct lttng_e
 {
        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:
        {
@@ -513,10 +515,13 @@ struct lttng_kernel_syscall_table *get_syscall_table_from_event(struct lttng_ker
 {
        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:
        {
@@ -539,7 +544,7 @@ void lttng_syscall_event_enabler_create_event(struct lttng_event_enabler_common
        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;
 
@@ -566,14 +571,15 @@ void lttng_syscall_event_enabler_create_event(struct lttng_event_enabler_common
                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;
@@ -587,7 +593,6 @@ void lttng_syscall_event_enabler_create_event(struct lttng_event_enabler_common
                        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));
@@ -613,13 +618,13 @@ void lttng_syscall_event_enabler_create_event(struct lttng_event_enabler_common
                        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)) {
@@ -628,6 +633,53 @@ void lttng_syscall_event_enabler_create_event(struct lttng_event_enabler_common
                }
                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;
@@ -638,7 +690,7 @@ static
 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;
 
@@ -648,6 +700,7 @@ void lttng_syscall_event_enabler_create_matching_syscall_table_events(struct ltt
 #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;
@@ -661,12 +714,15 @@ void lttng_syscall_event_enabler_create_matching_syscall_table_events(struct ltt
                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;
                        }
@@ -695,7 +751,8 @@ bool lttng_syscall_event_enabler_is_wildcard_all(struct lttng_event_enabler_comm
 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;
@@ -734,12 +791,15 @@ void create_unknown_syscall_event(struct lttng_event_enabler_common *event_enabl
                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;
                }
diff --git a/src/lttng-uprobes.c b/src/lttng-uprobes.c
new file mode 100644 (file)
index 0000000..1c81b9d
--- /dev/null
@@ -0,0 +1,332 @@
+/* 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), &lttng_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, &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 = 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");
index c4273e01643ae575b47e301f48b049e6838a561a..1812f084a2ddd94c9eef67eb79f4de3da01de8f7 100644 (file)
@@ -1,4 +1,5 @@
 # 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)))/../..
 
@@ -236,18 +237,6 @@ else
   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
diff --git a/src/probes/lttng-kprobes.c b/src/probes/lttng-kprobes.c
deleted file mode 100644 (file)
index 27d2898..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-/* 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), &lttng_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, &notif_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(&lttng_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(&lttng_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);
diff --git a/src/probes/lttng-kretprobes.c b/src/probes/lttng-kretprobes.c
deleted file mode 100644 (file)
index 410e5f7..0000000
+++ /dev/null
@@ -1,316 +0,0 @@
-/* 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), &lttng_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(&lttng_krp->kref_alloc);
-       kref_get(&lttng_krp->kref_alloc);       /* inc refcount to 2, no overflow. */
-       kref_init(&lttng_krp->kref_register);
-       kref_get(&lttng_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(&lttng_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(&lttng_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);
diff --git a/src/probes/lttng-uprobes.c b/src/probes/lttng-uprobes.c
deleted file mode 100644 (file)
index 5463251..0000000
+++ /dev/null
@@ -1,310 +0,0 @@
-/* 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), &lttng_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, &notif_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");
index 9cf13342e679f3c0cb0a30a769fa2261d86ac77c..eecfcca6380c260456ae9da57f3312e68b3961e7 100644 (file)
@@ -1,4 +1,5 @@
 # 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)))/../..
 
index 1bc3fea7adf12aa4fe43cab9930eb936faf79df0..6b2f1f6968ef5420932dafe10bf9c4c7479d3b83 100644 (file)
@@ -1,4 +1,5 @@
 # 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"
index f951c7ade826b79d70a1a77d225276433b4e050a..788d709b2b60280fab87514261d8ecd2c52b38b4 100644 (file)
@@ -1,3 +1,7 @@
+# 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)                                                                                                                                                                            
index 130c1e3ee44e62974e1fd227069e18b91c1464d3..d226289b0f929ce3b7f7e1e528953ae8563d2397 100644 (file)
@@ -1,3 +1,7 @@
+# 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)
index 5db1a4f1dca50c0e2427ed0808aa99708377646a..31d6f675ae83e479b7b690793501a7375d658342 100644 (file)
@@ -1,3 +1,7 @@
+# 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)
index e815a9892124aab53335e84629c6f3a4271a81e2..979789fa2bb597d99928b1f1236e9dd76ea40794 100644 (file)
@@ -1,3 +1,7 @@
+# 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)
index d0b35a674852d9bc6c57f5b00cdb6b0c59567200..45d6a84de656160f16109cc60ad2ff33e7d26519 100644 (file)
@@ -1,3 +1,7 @@
+# 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)
index 65c3973d37836d7be84a32373dee6772d897924b..849197a822250cee5c7c4ed7b66b73362289b264 100644 (file)
@@ -1,3 +1,7 @@
+# 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)
index 5b62cc7b4f14afc53555bce1230db0b8e95e1aec..31e440b101e275362b363272adbb50e35f015a6c 100644 (file)
@@ -1,3 +1,7 @@
+# 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)
index 7753e06ede926c2addc9bf712d352bd7e0fa62fb..b1ed36b4f3fda4902d65ca2a61f6622c03fdc630 100644 (file)
@@ -1,3 +1,7 @@
+# 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)
index 99360cee00a0dbd4ba2c5c012e03b7c3d928f41a..a021c03bce869d4a0a0517b657b210e53ac17ac8 100644 (file)
@@ -1,3 +1,7 @@
+# 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)
index 42a81bf0cd156428d0bc9d20f66f03450e63c775..e8b1cf23b620d4a9b1fa597e5e9749827f57226a 100644 (file)
@@ -1,3 +1,7 @@
+# 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: ()
index 4fe0cb41ebfc85275869f4616d1219af4e822564..60ae1fe6c0eb9320936add33add80fa806b250c0 100644 (file)
@@ -1,3 +1,7 @@
+# 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)
index 6016f06a60c46dbfc656044a050ff8ed71632ea9..b0d9f7d4386f1666f44fa4edb59167712b84a67b 100644 (file)
@@ -1,3 +1,7 @@
+# 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: ()
index 2841ea03d24fe5ced9a09c5f51fabf5fd6582f19..ba051be194a7a2314f7217cd7cdde3064ce152d3 100644 (file)
@@ -1,3 +1,7 @@
+# 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)
diff --git a/tools/syscalls/README b/tools/syscalls/README
deleted file mode 100644 (file)
index a51531b..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-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.
diff --git a/tools/syscalls/README.md b/tools/syscalls/README.md
new file mode 100644 (file)
index 0000000..8e4b663
--- /dev/null
@@ -0,0 +1,40 @@
+
+<!--
+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.
index 1cf963944655e3a9b99f77551dd5a22f9712c22d..aa19291c87c4ee040f392ab442c579b25a8bf068 100755 (executable)
@@ -1,8 +1,9 @@
 #!/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
@@ -14,18 +15,23 @@ GENERIC_INOUT_DESCRIPTION_FILE="$(dirname "$0")/table-syscall-inout.txt"
 # 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
 
index d2dbfcfed170ac6d73041294137b1e2e7b2c1642..f4c915344e4fa5afe22f8d9b72ec67169d0bef1e 100755 (executable)
@@ -1,5 +1,6 @@
 #!/bin/bash
 # SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+# SPDX-FileCopyrightText: 2020 EfficiOS Inc.
 
 set -eu
 
diff --git a/tools/syscalls/lttng-syscalls-extractor/linux-link-trace-syscalls-as-data.patch.license b/tools/syscalls/lttng-syscalls-extractor/linux-link-trace-syscalls-as-data.patch.license
new file mode 100644 (file)
index 0000000..7ecf90c
--- /dev/null
@@ -0,0 +1,2 @@
+SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+SPDX-License-Identifier: GPL-2.0-only
index e8b1bc8ae12867752f9c0c7c8dd847e08ed74e27..e3de861de309b5c13ccacfbf4efe85ba056d7d93 100755 (executable)
@@ -1,4 +1,6 @@
 #!/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
@@ -84,8 +86,9 @@ else
 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 */
 
index 415bba99cc5da06127fd60a0adcf726ebe150144..bd453eec854b3d810cfc58c49417502265409289 100644 (file)
@@ -1,3 +1,7 @@
+# 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.
index 6ccfa9d46d2a2812eb3afd0f6992fb0c056d4516..e0d08a6707b7db0b8defd16bf65494a2465a11dd 100644 (file)
@@ -1,2 +1,6 @@
+# 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)
index b3227800ab4c68127c6347daaf9e8e0445d2e8f3..64f544d7ffc79b81b001ce6dfd4cc4124e9bcae3 100644 (file)
@@ -1,3 +1,7 @@
+# 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.
index 6ccfa9d46d2a2812eb3afd0f6992fb0c056d4516..e0d08a6707b7db0b8defd16bf65494a2465a11dd 100644 (file)
@@ -1,2 +1,6 @@
+# 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)
index b3227800ab4c68127c6347daaf9e8e0445d2e8f3..64f544d7ffc79b81b001ce6dfd4cc4124e9bcae3 100644 (file)
@@ -1,3 +1,7 @@
+# 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.
index 6ccfa9d46d2a2812eb3afd0f6992fb0c056d4516..e0d08a6707b7db0b8defd16bf65494a2465a11dd 100644 (file)
@@ -1,2 +1,6 @@
+# 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)
index 6ccfa9d46d2a2812eb3afd0f6992fb0c056d4516..e0d08a6707b7db0b8defd16bf65494a2465a11dd 100644 (file)
@@ -1,2 +1,6 @@
+# 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)
index 6ccfa9d46d2a2812eb3afd0f6992fb0c056d4516..e0d08a6707b7db0b8defd16bf65494a2465a11dd 100644 (file)
@@ -1,2 +1,6 @@
+# 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)
index 33a6ed5a853d1eb0cc0cc060ac426ca16b0ced4f..10984c56215d1fdb1e5da8499e7714cd4a66803e 100644 (file)
@@ -1,3 +1,7 @@
+# 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
index 8f7c5806b2caf62a7a15f7fc30a208b8c9a2bfc8..c6236b8a34b52d9e26767ec6f981185a97e4a5f1 100644 (file)
@@ -1,2 +1,6 @@
+# SPDX-FileCopyrightText: 2022 EfficiOS Inc.
+#
+# SPDX-License-Identifier: CC0-1.0
+
 # "Regular" clone
 syscall clone nbargs 5 rw: (r, r, w, w, r)
index 69a805a0d4fc8e7cda02db36e68acd2e32c73f99..3bd55c185aac9111e52dbe2795ab183c86c7124e 100644 (file)
@@ -1,3 +1,7 @@
+# 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)
This page took 0.1966 seconds and 4 git commands to generate.