lttng-modules.git
3 years agoRefactoring: ring buffer context
Mathieu Desnoyers [Wed, 28 Apr 2021 18:56:05 +0000 (14:56 -0400)] 
Refactoring: ring buffer context

Split the ring buffer context into:

- Public ring buffer context (initialized by probe),
- Private context (initialized by reserve callback),

Pass event recorder rather than channel as client_ctx for events
generated from instrumentation (calling ring buffer client).

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Iecd23f11c54da4ba58a97c46192f775a0a74bd85

3 years agosequence and variant types: use previous field for length/tag if NULL
Mathieu Desnoyers [Sat, 24 Apr 2021 00:29:27 +0000 (20:29 -0400)] 
sequence and variant types: use previous field for length/tag if NULL

A common use-case for sequences and variants is to use the field located
immediately prior to the type as length/tag.

The fact that those types need to explicitly contain their length/tag
name ties the sequence/variant type to where it is placed within the
structure fields, preventing re-use of the sequence/variant type.

In order to reduce the memory footprint of the field descriptions and
allow re-use of common field types, special-case the NULL length name
and tag name to use the field prior to the sequence/variant as length.

This allows more efficient type descriptions without reducing the
overall flexibility of sequence/variant layout.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I27053e8541beb4f8f8226e411c71595f7527f533

3 years agoVersion 2.13.0-rc1 v2.13.0-rc1
Mathieu Desnoyers [Sat, 24 Apr 2021 01:13:26 +0000 (21:13 -0400)] 
Version 2.13.0-rc1

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Iebcfdc3cfd2ca16e59107ff7688850239c6a08e9

3 years agoSet the 2.13 release codename and description
Mathieu Desnoyers [Sat, 24 Apr 2021 00:56:57 +0000 (20:56 -0400)] 
Set the 2.13 release codename and description

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I53fbb76eaaac57710cb0bd348eab32fc3c2b93dd

3 years agoFix: LTTng-modules ABI ioctl wrong direction
Mathieu Desnoyers [Tue, 20 Apr 2021 15:05:19 +0000 (11:05 -0400)] 
Fix: LTTng-modules ABI ioctl wrong direction

lttng-modules defines ioctl numbers (include/lttng/abi.h) using the
_IO*() macros. These macros are partly used to specify what type of
parameters that the ioctl will be expecting. It also specifies the
direction of the data flow.

    1. sending data from userspace to the kernel,
    2. sending data from the kernel to userspace,
    3. both.

According to the kernel's
Documentation/userspace-api/ioctl/ioctl-number.rst file here is the
meaning of the various macros:

 ====== == ============================================
 _IO    an ioctl with no parameters
 _IOW   an ioctl with write parameters (copy_from_user)
 _IOR   an ioctl with read parameters  (copy_to_user)
 _IOWR  an ioctl with both write and read parameters.
 ====== == ============================================

Some of our use of these macros are wrong. In some cases, we use _IOW()
when we should be using _IOR():

Here is a list of the ioctl numbers that should be _IOW() as they are
sending data to the kernel:

 #define LTTNG_KERNEL_SESSION_TRACK_PID      IOR(0xF6, 0x58, int32_t)
 #define LTTNG_KERNEL_SESSION_UNTRACK_PID    _IOR(0xF6, 0x59, int32_t)
 #define LTTNG_KERNEL_SESSION_SET_NAME       _IOR(0xF6, 0x5D, struct lttng_kernel_session_name)
 #define LTTNG_KERNEL_SESSION_SET_CREATION_TIME   _IOR(0xF6, 0x5E, struct lttng_kernel_session_creation_time)
 #define LTTNG_KERNEL_SESSION_LIST_TRACKER_IDS  _IOR(0xF6, 0xA0, struct lttng_kernel_tracker_args)
 #define LTTNG_KERNEL_SESSION_TRACK_ID          _IOR(0xF6, 0xA1, struct lttng_kernel_tracker_args)
 #define LTTNG_KERNEL_SESSION_UNTRACK_ID        _IOR(0xF6, 0xA2, struct lttng_kernel_tracker_args)

Fix this by changing the direction of the macros, but introduce "_OLD"
macros for backward compatibility.

User-space should gradually start interacting with the correct ioctl
direction. However, in order to preserve compatibility between newer
user-space tools and older lttng-modules, user-space should fall-back on
the "_OLD" ioctl directions if the new directions are not implemented by
an older lttng-modules.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I70d1963464597e0e3b028a67739d4a13b96c1ea5

3 years agoRefactoring: bytecode interpreter
Mathieu Desnoyers [Fri, 23 Apr 2021 00:37:14 +0000 (20:37 -0400)] 
Refactoring: bytecode interpreter

Refactor bytecode interpreter to combine more code between filter and
capture interpreters.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic9fe054ef4cbbef578e1e2c396bdadce221b9c6f

3 years agoMove probe_ctx argument to align with lttng-ust
Mathieu Desnoyers [Thu, 22 Apr 2021 21:49:54 +0000 (17:49 -0400)] 
Move probe_ctx argument to align with lttng-ust

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: If020f8a982ab66b7a041300b6dc11aa00ce803db

3 years agoCombine event notifier and recorder enable/disable functions
Mathieu Desnoyers [Thu, 22 Apr 2021 20:17:54 +0000 (16:17 -0400)] 
Combine event notifier and recorder enable/disable functions

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I945b24211b48b9d40b1d25f0c9fb78f6eb8439da

3 years agoRefactoring: combine probe callbacks
Mathieu Desnoyers [Thu, 22 Apr 2021 17:52:43 +0000 (13:52 -0400)] 
Refactoring: combine probe callbacks

Combine probe callbacks for event recorder and notifier. Also combine
the code for args vs noargs probes, shrinking the number of probe
implementations from 4 to 1.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic7c0494ffd171caca33cfd13a8a40771691d89b5

3 years agoCombine event recorder and notifier destroy
Mathieu Desnoyers [Thu, 22 Apr 2021 17:20:04 +0000 (13:20 -0400)] 
Combine event recorder and notifier destroy

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I8a7e18d98286ddc1bf132cd39039658c9b669f51

3 years agoRefactoring: event structures
Mathieu Desnoyers [Thu, 15 Apr 2021 12:23:17 +0000 (08:23 -0400)] 
Refactoring: event structures

Combine event recorder and event notifier structures common parts into a
"common" parent structure. Move "internal" fields not meant to be
touched by the probes into private structures.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I1fd8fdb976664ff7cbdf6efdb0c51705682b8560

3 years agolttng-probes: Warn of event's and provider's name for mismatch
He Zhe [Mon, 19 Apr 2021 09:16:57 +0000 (09:16 +0000)] 
lttng-probes: Warn of event's and provider's name for mismatch

We have experience serveral cases of such mismatches. To make it easier to
debug, let's warn users of the event's and the provide's name.

Signed-off-by: He Zhe <zhe.he@windriver.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I455bf92f9f735f890753c9103d22986e56e02e5d

3 years agofix: mm, tracing: kfree event name mismatching with provider kmem (v5.12)
He Zhe [Mon, 19 Apr 2021 09:09:28 +0000 (09:09 +0000)] 
fix: mm, tracing: kfree event name mismatching with provider kmem (v5.12)

a8bc8ae5c932 ("fix: mm, tracing: record slab name for kmem_cache_free() (v5.12)")
introduces the following call trace for kfree. This is caused by mismatch
between kfree event and its provider kmem.

This patch maps kfree to kmem_kfree.

WARNING: CPU: 2 PID: 42294 at src/lttng-probes.c:81 fixup_lazy_probes+0xb0/0x1b0 [lttng_tracer]
CPU: 2 PID: 42294 Comm: modprobe Tainted: G           O      5.12.0-rc6-yoctodev-standard #1
Hardware name: Intel Corporation JACOBSVILLE/JACOBSVILLE, BIOS JBVLCRB2.86B.0014.P20.2004020248 04/02/2020
RIP: 0010:fixup_lazy_probes+0xb0/0x1b0 [lttng_tracer]
Code: 75 28 83 c3 01 3b 5d c4 74 22 48 8b 4d d0 48 63
      c3 4c 89 e2 4c 89 f6 48 8b 04 c1 4c 8b 38 4c 89
      ff e8 64 9f 4b de 85 c0 74 c3 <0f> 0b 48 8b 05 bf
      f2 1e 00 48 8d 50 e8 48 3d f0 a0 98 c0 75 18 eb
RSP: 0018:ffffb976807bfbe0 EFLAGS: 00010286
RAX: 00000000ffffffff RBX: 0000000000000004 RCX: 0000000000000004
RDX: 0000000000000066 RSI: ffffffffc03c10a7 RDI: ffffffffc03c11a1
RBP: ffffb976807bfc28 R08: 0000000000000000 R09: 0000000000000001
R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000004
R13: ffffffffc03c2000 R14: ffffffffc03c10a7 R15: ffffffffc03c11a1
FS:  00007f0ef9533740(0000) GS:ffffa100faa00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000561e8f0aa000 CR3: 000000015b318000 CR4: 0000000000350ee0
Call Trace:
 lttng_probe_register+0x38/0xe0 [lttng_tracer]
 ? __event_probe__module_load+0x520/0x520 [lttng_probe_module]
 __lttng_events_init__module+0x15/0x20 [lttng_probe_module]
 do_one_initcall+0x68/0x310
 ? kmem_cache_alloc_trace+0x2ad/0x4c0
 ? do_init_module+0x28/0x280
 do_init_module+0x62/0x280
 load_module+0x26e4/0x2920
 ? kernel_read_file+0x22e/0x290
 __do_sys_finit_module+0xb1/0xf0
 __x64_sys_finit_module+0x1a/0x20
 do_syscall_64+0x38/0x50
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Signed-off-by: He Zhe <zhe.he@windriver.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I00e8ee2b8c35f6f8602c88295f5113fbbd139709

3 years agofix: refactor contexts for type description structures
Michael Jeanson [Thu, 15 Apr 2021 15:29:06 +0000 (11:29 -0400)] 
fix: refactor contexts for type description structures

The 'preemptible' and 'migratable' contexts were not refactored along
the others in :

  commit 437d5aa59380583ce1cd14d394a53b398be1275d
  Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  Date:   Wed Apr 7 14:52:27 2021 -0400

    Refactoring: type description structures

Change-Id: I8a228c0ff982a4aded27b055baae1f5efec29164
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agofix: remove 'src/' from modules install path
Michael Jeanson [Tue, 16 Feb 2021 21:51:47 +0000 (16:51 -0500)] 
fix: remove 'src/' from modules install path

The move of the modules sources in the 'src/' subdirectory had the
unexpected side effect of adding 'src/' to the module install path
inside '/lib/modules/$(uname -r)/extra'. Adjust the Makefiles to return
to the initial behavior.

Change-Id: I280fe8a1e5ef367edeec0a6351351a233cc6f0be
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ifcc64ea95c0e1435567150d976d42e3add3f7523

3 years agofix: Adjust ranges for Ubuntu 5.4.0-67 kernel
Michael Jeanson [Thu, 15 Apr 2021 14:53:21 +0000 (10:53 -0400)] 
fix: Adjust ranges for Ubuntu 5.4.0-67 kernel

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ifa0f50ffdc946d80b67bb5ae7ca4b0aa152e825b

3 years agofix: block: add a disk_uevent helper (v5.12)
Michael Jeanson [Mon, 15 Mar 2021 18:54:02 +0000 (14:54 -0400)] 
fix: block: add a disk_uevent helper (v5.12)

See upstream commit:

  commit bc359d03c7ec1bf3b86d03bafaf6bbb21e6414fd
  Author: Christoph Hellwig <hch@lst.de>
  Date:   Sun Jan 24 11:02:39 2021 +0100

    block: add a disk_uevent helper

    Add a helper to call kobject_uevent for the disk and all partitions, and
    unexport the disk_part_iter_* helpers that are now only used in the core
    block code.

Change-Id: If6e8797049642ab382d5699660ee1dd734e92c90
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoFix: perf counters: uninitialized field
Mathieu Desnoyers [Thu, 15 Apr 2021 13:39:30 +0000 (09:39 -0400)] 
Fix: perf counters: uninitialized field

Reported by Coverity:
** CID 1452572:  Uninitialized variables  (UNINIT)
>>>     Using uninitialized value "ctx_field". Field "ctx_field.get_size_arg" is uninitialized when calling "lttng_kernel_context_append".

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I064260c6fe78af24768bb141fde2864d2abbe3a5

3 years agoCleanup: implement dedicated file operations for events and enablers
Mathieu Desnoyers [Wed, 14 Apr 2021 19:02:10 +0000 (15:02 -0400)] 
Cleanup: implement dedicated file operations for events and enablers

In order to simplify the code in preparation for refactoring of the
event structures, remove the "event type" field and implement specific
file operations for events and enablers.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I508bdb46fa3747112e7cfef4a62278fb566f842a

3 years agoNamespace LTTng modules ABI with lttng_kernel_abi_ prefix
Mathieu Desnoyers [Wed, 14 Apr 2021 17:52:07 +0000 (13:52 -0400)] 
Namespace LTTng modules ABI with lttng_kernel_abi_ prefix

Standardize on lttng_kernel_abi_ prefix for the lttng modules ABI to
eliminate namespace clash between lttng-modules core code and its ABI.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I3b1c8d6f46702e57defa17d683ede576466ba3ce

3 years agoRefactoring: type description structures
Mathieu Desnoyers [Wed, 7 Apr 2021 18:52:27 +0000 (14:52 -0400)] 
Refactoring: type description structures

Refactoring:

- Type description structures: new API based on structure inheritance
  rather than union,
- Rely on compound literals,
- Rename description fields: name -> event_name,
- Rename types (lttng_kernel_ namespace):
  - struct lttng_kernel_event_desc,
  - struct lttng_kernel_event_field,
  - struct lttng_kernel_ctx.
- Move some internal definitions (not used by probes) to
  events-internal.h.
- Streamline context registration API,
- Introduce the LTTNG_CREATE_FIELD_METADATA define for the tracepoint
  code generation pass which generates the type descriptions, allowing
  to describe structures as an array of fields, and use enumerations
  from those fields.
- Adapt all tracepoint instrumentation to those changes.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I9a968a62888c52438a1f62ec24fcced4c3fd6ddf

3 years agoPrefix lttng_enum_desc with lttng_kernel_
Mathieu Desnoyers [Wed, 7 Apr 2021 18:02:09 +0000 (14:02 -0400)] 
Prefix lttng_enum_desc with lttng_kernel_

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I25b7160875c99c99c18d1e559b09698b5411dae7

3 years agoPrefix lttng_enum_value and lttng_enum_entry with lttng_kernel_
Mathieu Desnoyers [Wed, 7 Apr 2021 18:00:37 +0000 (14:00 -0400)] 
Prefix lttng_enum_value and lttng_enum_entry with lttng_kernel_

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I4b4d502e2af9a1ca6425889da2697c5633200f52

3 years agoIntroduce internal event header
Mathieu Desnoyers [Wed, 7 Apr 2021 17:51:28 +0000 (13:51 -0400)] 
Introduce internal event header

This header is to be included by the tracer, but not by tracepoint
probes.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic9501bb58c4156d3b037b4f15251d03e25cd45f9

3 years agoCleanup: namespace string encoding
Mathieu Desnoyers [Wed, 7 Apr 2021 17:47:03 +0000 (13:47 -0400)] 
Cleanup: namespace string encoding

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic7265a6617feaacfe621d895cd0bc8ce2b50d912

3 years agoCleanup: Rename abstract types to lttng_kernel_type
Mathieu Desnoyers [Wed, 7 Apr 2021 17:40:46 +0000 (13:40 -0400)] 
Cleanup: Rename abstract types to lttng_kernel_type

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Iac1810c9d9830d80109fe72b1965b7b7cf663207

3 years agoCleanup: event_notifier -> notify in comments
Mathieu Desnoyers [Wed, 7 Apr 2021 15:07:29 +0000 (11:07 -0400)] 
Cleanup: event_notifier -> notify in comments

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Icdb4282e8b5fce231f96c56b4568555bd7a442fb

3 years agoFix: event notifier: add missing parameters validation
Mathieu Desnoyers [Wed, 7 Apr 2021 15:05:32 +0000 (11:05 -0400)] 
Fix: event notifier: add missing parameters validation

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Idbbbe369f64c14e7ac8914b4e7eb8e3ef75b1fb5

3 years agomsgpack: use KERNEL namespace for header protection
Mathieu Desnoyers [Fri, 9 Apr 2021 15:50:41 +0000 (11:50 -0400)] 
msgpack: use KERNEL namespace for header protection

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I8a3ee5bd935442dc5d3fcaff97859406279eb73d

3 years agoCleanup: lttng_abi_create_event{,_notifier}: use switch/case rather than if
Mathieu Desnoyers [Tue, 6 Apr 2021 20:21:54 +0000 (16:21 -0400)] 
Cleanup: lttng_abi_create_event{,_notifier}: use switch/case rather than if

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I2a5454521d57fdfcb0c623031b24d590aff40281

3 years agoAdd entryexit field to kretprobes ABI
Mathieu Desnoyers [Tue, 6 Apr 2021 18:37:43 +0000 (14:37 -0400)] 
Add entryexit field to kretprobes ABI

At this stage, only "entryexit = 0" is supported. No behavior change
except for validating that ENTRY and EXIT are unsupported (-EINVAL).

It is possible to extend struct lttng_kernel_kretprobe because it is
always used within struct lttng_kernel_event which contains enough
zero-initialized padding due to char padding[LTTNG_KERNEL_EVENT_PADDING2].

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I96d86eebff66da4af186ef51c2ff13e2ed84a510

3 years agoAdd missing fallthrough comments
Mathieu Desnoyers [Tue, 6 Apr 2021 18:35:25 +0000 (14:35 -0400)] 
Add missing fallthrough comments

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I225a5236c108e5b0d4bd39b5f1ef6988fe8b0096

3 years agoNo-op instrumentation is unsupported, cleanup fallthrough comments
Mathieu Desnoyers [Tue, 6 Apr 2021 18:17:35 +0000 (14:17 -0400)] 
No-op instrumentation is unsupported, cleanup fallthrough comments

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Id76238ead464dda1b40c6006f26d76c8a1049698

3 years agokretprobes: rename "return" to "exit"
Mathieu Desnoyers [Thu, 1 Apr 2021 20:10:09 +0000 (16:10 -0400)] 
kretprobes: rename "return" to "exit"

The kretprobes instrumentation emits <func>_entry and <func>_return.
However, pairing "entry" and "return" is not semantically right. The
term "entry" should be paired with "exit" (similarly to system call
intrumentation), since "return" should be paired with "call".

If we look at what is actually instrumented by kretprobes, we indeed
instrument the entry and exit points of a function.

Therefore, change the "<func>_return" event for "<func>_exit".

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ia541253cbb65a5afc8aaed2a6cfa77d9b296c96c

3 years agocompiler warning cleanup: is_signed_type: compare -1 to 1
Mathieu Desnoyers [Thu, 25 Mar 2021 18:20:58 +0000 (14:20 -0400)] 
compiler warning cleanup: is_signed_type: compare -1 to 1

Comparing -1 to 0 triggers compiler warnings (gcc -Wtype-limits and
-Wbool-compare) and Coverity warning "Macro compares unsigned to 0".

Comparing -1 to 1 instead takes care of silencing those warnings while
keeping the same behavior.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Id42a51759a1c7c669e63588c05f9d4485304c541

3 years agoFix: bytecode linker: validate event and field array/sequence encoding
Mathieu Desnoyers [Mon, 22 Mar 2021 17:33:54 +0000 (13:33 -0400)] 
Fix: bytecode linker: validate event and field array/sequence encoding

The bytecode linker should only allow linking filter expressions loading
fields which are string-encoded arrays and sequence for comparison
against a string, and reject arrays and sequences without encoding, so
the filter interpreter does not attempt to load non-NULL terminated
arrays/sequences as if they were strings.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ia5f33ed036e310d66aee6b682ef0a17eb5b99982

3 years agoFix: racy notifier captures update vs traversal
Mathieu Desnoyers [Fri, 19 Mar 2021 15:27:50 +0000 (11:27 -0400)] 
Fix: racy notifier captures update vs traversal

For captures, a new struct lttng_kernel_notification_ctx is introduced,
which is to be used as additional "context" to the notification_send()
callback. This allows passing the "eval_capture" state from the probe
to the notification callback, and fixes a bug where a sequence of:

- create notification enabler,
- enable notification enabler,
- add capture to enabler,

where a tracepoint runs concurrently with add capture happens to do a
first capture list_empty check which skips the stack preparation,
whereas the second capture list_empty check within the notification
callback finds a capture entry, and thus attempts to use an
uninitialized stack. The notification callback is also modified to use
an RCU-aware list traversal.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ib7ab673fb05b4824d0c7ba2e163dc1e88b465ee9

3 years agoFix: kretprobe: null ptr deref on session destroy
Francis Deslauriers [Wed, 17 Mar 2021 14:40:56 +0000 (10:40 -0400)] 
Fix: kretprobe: null ptr deref on session destroy

The `filter_bytecode_runtime_head` list is currently not initialized for
the return event of the kretprobe. This caused a kernel null ptr
dereference when destroying a session. It can reproduced with the
following commands:

  lttng create
  lttng enable-event -k --function=lttng_test_filter_event_write my_event
  lttng start
  lttng stop
  lttng destroy

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I1162ce8b10dd7237a26331531f048346b984eee7

3 years agoFix: bytecode linker: iteration on wrong list head
Mathieu Desnoyers [Fri, 12 Mar 2021 14:36:46 +0000 (09:36 -0500)] 
Fix: bytecode linker: iteration on wrong list head

lttng_enabler_link_bytecode() calls link_bytecode() passing an insertion
location (insert_loc) within the list. This insert location is meant to
be used as cursor position where to add the new element.

However, bytecode_is_linked() uses it as iteration list head, and this
is where things fall apart: it will thus consider the real list head as
being a list node, and will erroneously think that it is contained
within a struct lttng_bytecode_runtime, and thus try to perform possibly
out-of-bound read or read garbage data for the comparison.

It worked fine most of the time because in usual scenarios the insert
location is the list head. It falls apart when many bytecodes are linked
to a given event.

Fixes: 2dfda770cc6 ("Decouple `struct lttng_event` from filter code")
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I7463c7a9399b8f7f7d0e3d74e6427aae46cf56ff

3 years agocounters: add coalesce_hits to ABI
Mathieu Desnoyers [Wed, 10 Mar 2021 21:23:13 +0000 (16:23 -0500)] 
counters: add coalesce_hits to ABI

This will be required by an upcoming feature in a subsequent release, so
plan ahead with a coalesce_hits field. It is currently unused by
lttng-modules.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I0dd3a5c00a89c59111b723db8e39390a16764133

3 years agofix: mm, tracing: record slab name for kmem_cache_free() (v5.12)
Michael Jeanson [Thu, 4 Mar 2021 21:50:12 +0000 (16:50 -0500)] 
fix: mm, tracing: record slab name for kmem_cache_free() (v5.12)

See upstream commit:

  commit 3544de8ee6e4817278b15fe08658de49abf58954
  Author: Jacob Wen <jian.w.wen@oracle.com>
  Date:   Wed Feb 24 12:00:55 2021 -0800

    mm, tracing: record slab name for kmem_cache_free()

    Currently, a trace record generated by the RCU core is as below.

    ... kmem_cache_free: call_site=rcu_core+0x1fd/0x610 ptr=00000000f3b49a66

    It doesn't tell us what the RCU core has freed.

    This patch adds the slab name to trace_kmem_cache_free().
    The new format is as follows.

    ... kmem_cache_free: call_site=rcu_core+0x1fd/0x610 ptr=0000000037f79c8d name=dentry
    ... kmem_cache_free: call_site=rcu_core+0x1fd/0x610 ptr=00000000f78cb7b5 name=sock_inode_cache
    ... kmem_cache_free: call_site=rcu_core+0x1fd/0x610 ptr=0000000018768985 name=pool_workqueue
    ... kmem_cache_free: call_site=rcu_core+0x1fd/0x610 ptr=000000006a6cb484 name=radix_tree_node

    We can use it to understand what the RCU core is going to free. For
    example, some users maybe interested in when the RCU core starts
    freeing reclaimable slabs like dentry to reduce memory pressure.

Link: https://lkml.kernel.org/r/20201216072804.8838-1-jian.w.wen@oracle.com
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I1ee2fc476614cadcc8d3ac5d8feddc7910e1aa3a

3 years agoFix: filter interpreter early-exits on uninitialized value
Jérémie Galarneau [Wed, 3 Mar 2021 23:52:19 +0000 (18:52 -0500)] 
Fix: filter interpreter early-exits on uninitialized value

I observed that syscall filtering on string arguments wouldn't work on
my development machines, both running 5.11.2-arch1-1 (Arch Linux).

For instance, enabling the tracing of the `openat()` syscall with the
'filename == "/proc/cpuinfo"' filter would not produce events even
though matching events were present in another session that had no
filtering active. The same problem occurred with `execve()`.

I tried a couple of kernel versions before (5.11.1 and 5.10.13, if
memory serves me well) and I had the same problem. Meanwhile, I couldn't
reproduce the problem on various Debian machines (the LTTng CI) nor on a
fresh Ubuntu 20.04 with both the stock kernel and with an updated 5.11.2
kernel.

I built the lttng-modules with the interpreter debugging printout and
saw the following warning:
  LTTng: [debug bytecode in /home/jgalar/EfficiOS/src/lttng-modules/src/lttng-bytecode-interpreter.c:bytecode_interpret@1508] Bytecode warning: loading a NULL string.

After a shedload (yes, a _shed_load) of digging, I figured that the
problem was hidden in plain sight near that logging statement.

In the `BYTECODE_OP_LOAD_FIELD_REF_USER_STRING` operation, the 'ax'
register's 'user_str' is initialized with the stack value (the user
space string's address in our case). However, a NULL check is performed
against the register's 'str' member.

I initialy suspected that both members would be part of the same union
and alias each-other, but they are actually contiguous in a structure.

On the unaffected machines, I could confirm that the `str` member was
uninitialized to a non-zero value causing the condition to evaluate to
false.

Francis Deslauriers reproduced the problem by initializing the
interpreter stack to zero.

I am unsure of the exact kernel configuration option that reveals this
issue on Arch Linux, but my kernel has the following option enabled:

CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL:
   Zero-initialize any stack variables that may be passed by reference
   and had not already been explicitly initialized. This is intended to
   eliminate all classes of uninitialized stack variable exploits and
   information exposures.

I have not tried to build without this enabled as, anyhow, this seems
to be a legitimate issue.

I have spotted what appears to be an identical problem in
`BYTECODE_OP_LOAD_FIELD_REF_USER_SEQUENCE` and corrected it. However,
I have not exercised that code path.

The commit that introduced this problem is 5b4ad89.

The debug print-out of the `BYTECODE_OP_LOAD_FIELD_REF_USER_STRING`
operation is modified to print the user string (truncated to 31 chars).

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I2da3c31b9e3ce0e1b164cf3d2711c0893cbec273

3 years agoFix: memory leaks on event notifier destroy
Mathieu Desnoyers [Wed, 3 Mar 2021 15:22:38 +0000 (10:22 -0500)] 
Fix: memory leaks on event notifier destroy

Both filter runtime and event enabler ref objects are owned by the
event notifier, but are not freed upon destruction of the event notifier
object, thus leaking memory.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I511569f56a38f670549a93cb6179b77861245712

3 years agoFix: memory leaks on event destroy
Mathieu Desnoyers [Wed, 3 Mar 2021 15:10:16 +0000 (10:10 -0500)] 
Fix: memory leaks on event destroy

Both filter runtime and event enabler ref objects are owned by the
event, but are not freed upon destruction of the event object, thus
leaking memory.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ice9b1c18b47584838aea2b965494d3c8391f4c84

3 years agofix: Adjust ranges for Ubuntu 5.8.0-44 kernel
Michael Jeanson [Tue, 16 Feb 2021 23:08:19 +0000 (18:08 -0500)] 
fix: Adjust ranges for Ubuntu 5.8.0-44 kernel

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I419904dc9da316b38c2c16a08b6c17625b19b305

3 years agoFix: do not use bdi_unknown_name symbol
Mathieu Desnoyers [Wed, 10 Feb 2021 17:33:38 +0000 (12:33 -0500)] 
Fix: do not use bdi_unknown_name symbol

Use the GPL-exported bdi_dev_name introduced in kernel 5.7. Do not use
static inline bdi_dev_name in prior kernels because it uses the bdi_unknown_name
symbol which is not exported to GPL modules.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I8b4e4fd84ecacef7942b308e615ca88db8dce7b6

3 years agofix: memcg: fix a crash in wb_workfn when a device disappears (5.6)
Mathieu Desnoyers [Wed, 10 Feb 2021 16:45:42 +0000 (11:45 -0500)] 
fix: memcg: fix a crash in wb_workfn when a device disappears (5.6)

See upstream commit:

commit 68f23b89067fdf187763e75a56087550624fdbee
("memcg: fix a crash in wb_workfn when a device disappears")

It is currently backported into stable branches 5.4 and 5.5, but appears
to be missing from the 4.4, 4.9, 4.14, 4.19 LTS branches.

Implement our own lttng_bdi_dev_name wrapper to provide this fix on
builds against stable kernels which do not have this fix.

There is one user-visible change with this commit: for builds against
kernels < 4.4.0, the writeback_work_class events did use the
default_backing_dev_info to handle cases where the device is NULL,
writing "default" into the trace. This behavior is now aligned to
match what is done in kernels >= 4.4.0, which is to write "(unknown)"
into the name field.

Link: https://lore.kernel.org/r/537870616.15400.1612973059419.JavaMail.zimbra@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I0823643aa2f9d4c2b9f2005748a2adfd4457979a

3 years agoFix: writeback: out-of-bound reads
Mathieu Desnoyers [Fri, 5 Feb 2021 21:21:47 +0000 (16:21 -0500)] 
Fix: writeback: out-of-bound reads

Use ctf_string rather than ctf_array_text for name fields, because the
source strings are not guaranteed to be at least 32 bytes.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agofix: Add one digit to RHEL major release version
Michael Jeanson [Tue, 9 Feb 2021 16:28:27 +0000 (11:28 -0500)] 
fix: Add one digit to RHEL major release version

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I4e8b10ee985db59f7795e026486b3d47b76b5728

3 years agofix: Add one digit to SLES minor release version
Michael Jeanson [Tue, 9 Feb 2021 16:25:57 +0000 (11:25 -0500)] 
fix: Add one digit to SLES minor release version

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ia4b67b38377bdd997b754b92b09b96934940a013

3 years agofix: RT_PATCH_VERSION is close to overflow
Michael Jeanson [Mon, 8 Feb 2021 20:32:47 +0000 (15:32 -0500)] 
fix: RT_PATCH_VERSION is close to overflow

We allocated only 8bits for RT_PATCH_VERSION in LTTNG_RT_VERSION_CODE,
the current RT patch version for the 4.4 branch is currently 214 which
is getting close to 256. Bump it to 16bits to avoid breakage in the
future.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I0666bbe996854696ac98e025eb02e5fced0540b1

3 years agofix: cast LTTNG_KERNEL_VERSION/LTTNG_LINUX_VERSION_CODE to uint64_t
Michael Jeanson [Tue, 9 Feb 2021 16:04:25 +0000 (11:04 -0500)] 
fix: cast LTTNG_KERNEL_VERSION/LTTNG_LINUX_VERSION_CODE to uint64_t

Cast our version macros to an unsigned 64bits value to prevent
overflowing when we append distro specific version information.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ia42a5dc0dfddf64515aea144283af5cc0c3b97e0

3 years agofix: double defined LTTNG_KERNEL_VERSION
Michael Jeanson [Tue, 9 Feb 2021 15:53:34 +0000 (10:53 -0500)] 
fix: double defined LTTNG_KERNEL_VERSION

Cleanup a rebase error which resulted in double defined macros.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Id9ddce968c0d142c2c1013e0f51f649caa23ee4c

3 years agofix: UTS_UBUNTU_RELEASE_ABI is close to overflow
Michael Jeanson [Fri, 5 Feb 2021 20:21:55 +0000 (15:21 -0500)] 
fix: UTS_UBUNTU_RELEASE_ABI is close to overflow

We allocated only 8bits for UTS_UBUNTU_RELEASE_ABI in
LTTNG_UBUNTU_KERNEL_VERSION, the current Xenial kernel has an ABI of 207
which is getting close to 256. Bump it to 16bits to avoid breakage in
the future.

Change-Id: Iee99757bb28cdd958b044b31df3232b9f8816873
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agofix: sublevel version overflow in LINUX_VERSION_CODE
Michael Jeanson [Fri, 5 Feb 2021 17:08:40 +0000 (12:08 -0500)] 
fix: sublevel version overflow in LINUX_VERSION_CODE

The 4.4.256 and 4.9.256 stable release overflow the 8bits allocated to
the sublevel in LINUX_VERSION_CODE which ends means they report
themselves as 4.5.0 and 4.10.0 respectively. The next releases in these
stables branches will have sublevel clamped at 255 and will thus report
themselves as 4.4.255 and 4.9.255 for all subsequent releases.

We need a way to way to properly detect these release since I doubt they
will stop breaking tracepoints declarations. As a workaround, extract
the version information from the Makefile in the kernel headers and use
this information to generate a version code when the sublevel is equal
or greater than 256.

Change-Id: I96ae9f22c0c1ba8c619643946a5311c767fbcf8c
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoNamespace kernel version macros
Michael Jeanson [Fri, 5 Feb 2021 19:31:51 +0000 (14:31 -0500)] 
Namespace kernel version macros

This patch replaces all uses of the LINUX_VERSION_CODE and
KERNEL_VERSION macros by an 'LTTNG_' prefixed version, this will allow
us to override them.

Change-Id: If8fab7fe341dd35e2211d30427519a48dfb708f9
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoaarch64: blacklist gcc prior to 5.1
Mathieu Desnoyers [Fri, 22 Jan 2021 20:25:47 +0000 (15:25 -0500)] 
aarch64: blacklist gcc prior to 5.1

Linux aarch64 requires GCC 5.1 or better because prior versions perform
unsafe access to deallocated stack.

Some Linux distributions may have backported the fix, but it was never
released into earlier upstream gcc versions.

Link: https://lwn.net/Articles/842122/
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I72993e446f7f54f39d0f360273b68f194be8c13a

3 years agofix: missing include for 'task_struct' in fdtable.h
Michael Jeanson [Tue, 19 Jan 2021 16:34:25 +0000 (11:34 -0500)] 
fix: missing include for 'task_struct' in fdtable.h

In some kernel versions, linux/fdtable.h dereferences a pointer in a
forward declared 'struct task_struct' without an include of 'linux/sched.h'.

Add this missing include to the wrapper.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I06a6a9f7efd456843d1e4fdcc9003b839d7f3329

3 years agoFix: counter-api: always inline counter add function
Mathieu Desnoyers [Wed, 6 Jan 2021 20:07:01 +0000 (15:07 -0500)] 
Fix: counter-api: always inline counter add function

The counter add function uses cmpxchg() and cmpxchg_local() on 1, 2, 4,
and 8 bytes types.

In libcounter, the 8 bytes type is only supported on 64-bit
architectures, but the 1, 2, 4 byte type code is present for all
architectures, even though only the 4 byte code is currently used by
lttng-modules.

The ARM implementation of cmpxchg uses the "__bad_cmpxchg" linker error
to report use of cmpxchg on an unsupported size.

Considering that "inline" does not strictly mean always inline (depends
on CONFIG_OPTIMIZE_INLINING on some kernels, and does not mean forced
inlining in recent kernels), the compiler is free to generate a function
rather than perform inlining. If that happens, then the __bad_cmpxchg
linker error is generated even if the 1 and 2 bytes types are unused.

Therefore, use __always_inline for functions in counter-api.h to force
inlining, and therefore removal of unused code before linking, which is
required by this Linux kernel __bad_cmpxchg linker error trick.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I1adccd1382e71abc5880e0351d976b779245468a

3 years agofix: genirq: Restrict export of irq_to_desc() (v5.11)
Michael Jeanson [Mon, 18 Jan 2021 19:25:49 +0000 (14:25 -0500)] 
fix: genirq: Restrict export of irq_to_desc() (v5.11)

See upstream commit:

  commit 64a1b95bb9fe3ec76e1a2cd803eff06389341ae4
  Author: Thomas Gleixner <tglx@linutronix.de>
  Date:   Thu Dec 10 20:26:06 2020 +0100

    genirq: Restrict export of irq_to_desc()

    No more (ab)use in drivers finally. There is still the modular build of
    PPC/KVM which needs it, so restrict it to this case which still makes it
    unavailable for most drivers.

Link: https://lore.kernel.org/r/20201210194045.551428291@linutronix.de
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ie5a2af2f02ade07c73e1c7a8aa0fb155280b3d8b

3 years agofix: block: merge struct block_device and struct hd_struct (v5.11)
Michael Jeanson [Wed, 13 Jan 2021 19:27:41 +0000 (14:27 -0500)] 
fix: block: merge struct block_device and struct hd_struct (v5.11)

See upstream commit :

  commit 0d02129e76edf91cf04fabf1efbc3a9a1f1d729a
  Author: Christoph Hellwig <hch@lst.de>
  Date:   Fri Nov 27 16:43:51 2020 +0100

    block: merge struct block_device and struct hd_struct

    Instead of having two structures that represent each block device with
    different life time rules, merge them into a single one.  This also
    greatly simplifies the reference counting rules, as we can use the inode
    reference count as the main reference count for the new struct
    block_device, with the device model reference front ending it for device
    model interaction.

Change-Id: I47702d1867fda0d8fc0754d761aa4d1ae702cdeb
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agofix: kprobes: Remove kretprobe hash (v5.11)
Michael Jeanson [Thu, 7 Jan 2021 19:50:50 +0000 (14:50 -0500)] 
fix: kprobes: Remove kretprobe hash (v5.11)

See upstream commit:

  commit d741bf41d7c7db4898bacfcb020353cddc032fd8
  Author: Peter Zijlstra <peterz@infradead.org>
  Date:   Sat Aug 29 22:03:24 2020 +0900

    kprobes: Remove kretprobe hash

    The kretprobe hash is mostly superfluous, replace it with a per-task
    variable.

    This gets rid of the task hash and it's related locking.

    Note that this may change the kprobes module-exported API for kretprobe
    handlers. If any out-of-tree kretprobe user uses ri->rp, use
    get_kretprobe(ri) instead.

Link: https://lore.kernel.org/r/159870620431.1229682.16325792502413731312.stgit@devnote2
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I855765f390ad7caf481ef5fea334645e852f5b0f

3 years agofix: file: Rename fcheck lookup_fd_rcu (v5.11)
Michael Jeanson [Thu, 7 Jan 2021 17:10:23 +0000 (12:10 -0500)] 
fix: file: Rename fcheck lookup_fd_rcu (v5.11)

See upstream commit:

  commit 460b4f812a9d473d4b39d87d37844f9fc30a9eb3
  Author: Eric W. Biederman <ebiederm@xmission.com>
  Date:   Fri Nov 20 17:14:27 2020 -0600

    file: Rename fcheck lookup_fd_rcu

    Also remove the confusing comment about checking if a fd exists.  I
    could not find one instance in the entire kernel that still matches
    the description or the reason for the name fcheck.

    The need for better names became apparent in the last round of
    discussion of this set of changes[1].

    [1] https://lkml.kernel.org/r/CAHk-=wj8BQbgJFLa+J0e=iT-1qpmCRTbPAJ8gd6MJQ=kbRPqyQ@mail.gmail.com

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I33d2c912ebfdf82a68e506c9b6be17c51d2f254e

3 years agofix: block: remove the request_queue argument to the block_bio_remap tracepoint ...
Michael Jeanson [Thu, 7 Jan 2021 17:01:40 +0000 (12:01 -0500)] 
fix: block: remove the request_queue argument to the block_bio_remap tracepoint (v5.11)

See upstream commit:

  commit 1c02fca620f7273b597591065d366e2cca948d8f
  Author: Christoph Hellwig <hch@lst.de>
  Date:   Thu Dec 3 17:21:38 2020 +0100

    block: remove the request_queue argument to the block_bio_remap tracepoint

    The request_queue can trivially be derived from the bio.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic49a9c9ebeea37e4ec79c736382293a6c9ce86d3

3 years agofix: block: remove the request_queue argument to the block_split tracepoint (v5.11)
Michael Jeanson [Thu, 7 Jan 2021 16:56:25 +0000 (11:56 -0500)] 
fix: block: remove the request_queue argument to the block_split tracepoint (v5.11)

See upstream commit:

  commit eb6f7f7cd3af0f67ce57b21fab1bc64beb643581
  Author: Christoph Hellwig <hch@lst.de>
  Date:   Thu Dec 3 17:21:37 2020 +0100

    block: remove the request_queue argument to the block_split tracepoint

    The request_queue can trivially be derived from the bio.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I93e8c4c51ba36d22b587841e95ff4be8d5224230

3 years agofix: block: simplify and extend the block_bio_merge tracepoint class (v5.11)
Michael Jeanson [Thu, 7 Jan 2021 16:50:25 +0000 (11:50 -0500)] 
fix: block: simplify and extend the block_bio_merge tracepoint class (v5.11)

See upstream commit:

  commit e8a676d61c07eccfcd9d6fddfe4dcb630651c29a
  Author: Christoph Hellwig <hch@lst.de>
  Date:   Thu Dec 3 17:21:36 2020 +0100

    block: simplify and extend the block_bio_merge tracepoint class

    The block_bio_merge tracepoint class can be reused for most bio-based
    tracepoints.  For that it just needs to lose the superfluous q and rq
    parameters.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I90a1da20ab07605ed88f29b02f63134fa4aee6a8

3 years agofix: block: remove the request_queue to argument request based tracepoints (v5.11)
Michael Jeanson [Thu, 7 Jan 2021 16:17:20 +0000 (11:17 -0500)] 
fix: block: remove the request_queue to argument request based tracepoints (v5.11)

See upstream commit :

  commit a54895fa057c67700270777f7661d8d3c7fda88a
  Author: Christoph Hellwig <hch@lst.de>
  Date:   Thu Dec 3 17:21:39 2020 +0100

    block: remove the request_queue to argument request based tracepoints

    The request_queue can trivially be derived from the request.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ibe4a13f06ed57955fa3e0b77b87a44b7e6b57775

3 years agofix: remove floating-point arguments in msgpack
Michael Jeanson [Mon, 14 Dec 2020 16:20:11 +0000 (11:20 -0500)] 
fix: remove floating-point arguments in msgpack

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I6366ac303157e4ab66045b09c6f03aadee0717c8

3 years agoabi: use 0, 1 for counter enumerations
Mathieu Desnoyers [Fri, 11 Dec 2020 15:51:58 +0000 (10:51 -0500)] 
abi: use 0, 1 for counter enumerations

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoCleanup: use tabs in abi.h
Mathieu Desnoyers [Fri, 11 Dec 2020 15:41:27 +0000 (10:41 -0500)] 
Cleanup: use tabs in abi.h

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoBump LTTNG_MODULES_ABI_MINOR_VERSION to 6
Jérémie Galarneau [Fri, 11 Dec 2020 04:40:51 +0000 (23:40 -0500)] 
Bump LTTNG_MODULES_ABI_MINOR_VERSION to 6

New operations were added to the lttng-modules ABI as part of the 2.13
release cycle to support event notifiers.

This will allow future LTTng-tools versions to check for those
capabilities.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Idfd58f3914b87be3688a10a06239a1b0ab556a7c

3 years agoFix: handle default switch case with -EINVAL in lttng-syscalls
Michael Jeanson [Mon, 30 Nov 2020 19:46:07 +0000 (14:46 -0500)] 
Fix: handle default switch case with -EINVAL in lttng-syscalls

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I7768ea3d0da259976548f6b9417350227390b3be

3 years agofix: use wrapper for hlist_for_each_entry_rcu
Michael Jeanson [Mon, 30 Nov 2020 19:44:36 +0000 (14:44 -0500)] 
fix: use wrapper for hlist_for_each_entry_rcu

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I4a0fe4abea70a4cae605cebc3c51fe5c47b24715

3 years agofix: asm/barrier.h was introduced in v3.4
Michael Jeanson [Mon, 30 Nov 2020 19:26:23 +0000 (14:26 -0500)] 
fix: asm/barrier.h was introduced in v3.4

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I1aa81452fd4c08c151f0f87cfa1b24018ad4fc30

3 years agoFix: handle default switch case with -EINVAL in __lttng_counter_add
Mathieu Desnoyers [Mon, 30 Nov 2020 19:09:31 +0000 (14:09 -0500)] 
Fix: handle default switch case with -EINVAL in __lttng_counter_add

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoIntroduce lttng smp_store_release smp_load_acquire wrappers
Mathieu Desnoyers [Mon, 30 Nov 2020 16:11:39 +0000 (11:11 -0500)] 
Introduce lttng smp_store_release smp_load_acquire wrappers

Kernels prior to 3.14 do not implement smp_store_release nor
smp_load_acquire. Implement our own wrappers with smp_mb instead for
those older kernels.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agofix: include byteorder.h for 'cpu_to_*'
Michael Jeanson [Mon, 30 Nov 2020 15:23:14 +0000 (10:23 -0500)] 
fix: include byteorder.h for 'cpu_to_*'

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ie9da5b1d17b7311ac0d6898c3d23a6c4d592927a

3 years agoFix: notifier: use store-release/load-acquire for error counter
Mathieu Desnoyers [Fri, 27 Nov 2020 21:03:55 +0000 (16:03 -0500)] 
Fix: notifier: use store-release/load-acquire for error counter

The "record_error" operation is executed concurrently with setting the
error counter in the notifier group without locking, so we need to
explicitly provide existance guarantees.

The only visible transition is from NULL -> !NULL, because the only
situation reverting the error counter back to NULL is on destruction of
the notification group, after an RCU synchronisation guarantees that no
record_error can observe this pointer anymore.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoFix: event-notifier: Groups may not have an error counter
Francis Deslauriers [Fri, 27 Nov 2020 19:40:08 +0000 (14:40 -0500)] 
Fix: event-notifier: Groups may not have an error counter

Issue
=====
If no error counter is attached to an event notifier group, calling
the `record_error()` function leads to a NULL pointer dereference.

Solution
========
Check if the error_counter field is allocated before dereferencing it.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I7ba68f9ae5b7b66cea538cf030bc5e1287d6eace

3 years agoBump LTTNG_KERNEL_EVENT_NOTIFIER_PADDING to 32 bytes
Mathieu Desnoyers [Thu, 26 Nov 2020 22:08:44 +0000 (17:08 -0500)] 
Bump LTTNG_KERNEL_EVENT_NOTIFIER_PADDING to 32 bytes

Allows using 3 more 64-bit integers, and one extension pointer.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoFix: remove dead code in msgpack.c
Mathieu Desnoyers [Thu, 26 Nov 2020 20:36:20 +0000 (15:36 -0500)] 
Fix: remove dead code in msgpack.c

Identified by Coverity. Comparing unsigned types < 0 is never true.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoFix: counter: cast UINT*_MAX to 64-bit signed type before negative
Mathieu Desnoyers [Thu, 26 Nov 2020 20:29:28 +0000 (15:29 -0500)] 
Fix: counter: cast UINT*_MAX to 64-bit signed type before negative

(long long)-UINT32_MAX leads to value 1 which is not what we expect.
This is due to implicit type promotion from unsigned to signed 32-bit
integer.

Apply this to 8-bit and 16-bit types as well even though they are
not affected by this issue to keep things regular.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoFix: include limits.h wrapper from libcounter
Mathieu Desnoyers [Thu, 26 Nov 2020 14:02:53 +0000 (09:02 -0500)] 
Fix: include limits.h wrapper from libcounter

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoFix: include kernel.h in wrapper/limits.h
Mathieu Desnoyers [Wed, 25 Nov 2020 21:03:15 +0000 (16:03 -0500)] 
Fix: include kernel.h in wrapper/limits.h

linux/kernel.h is present in older kernels, but linux/limits.h is not.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoIntroduce limits wrapper
Mathieu Desnoyers [Wed, 25 Nov 2020 20:50:16 +0000 (15:50 -0500)] 
Introduce limits wrapper

Older kernels (v3.13.11 and older on the CI) miss the U32_MAX
macro. Implement them in a wrapper.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoIntroduce lazy system call event creation
Mathieu Desnoyers [Wed, 25 Nov 2020 20:30:30 +0000 (15:30 -0500)] 
Introduce lazy system call event creation

Introduce lazy system call event creation. If only specific system call
events are enabled, only create the metadata for those.

Align implementation of system call event probes for recording events
with their notifier counterpart.

This is part of the background work required for a future feature (trace
hit counters and map support) which brings benefits on its own.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoImplement event notifier error counter
Francis Deslauriers [Fri, 7 Aug 2020 21:04:05 +0000 (17:04 -0400)] 
Implement event notifier error counter

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I566d34ab92aaa642f50407d913b16c4a6b8479a2

3 years agoImplement lib counter
Mathieu Desnoyers [Wed, 15 Jul 2020 18:13:24 +0000 (14:13 -0400)] 
Implement lib counter

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I47424817ca874357d5ae4349a048cce889988a76

3 years agocapture: Replace FIXME by explanation of the limit
Mathieu Desnoyers [Wed, 25 Nov 2020 18:44:38 +0000 (13:44 -0500)] 
capture: Replace FIXME by explanation of the limit

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoImplement capturing payload on event notifier
Francis Deslauriers [Thu, 2 Apr 2020 19:14:45 +0000 (15:14 -0400)] 
Implement capturing payload on event notifier

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ibdaa07ecfe36ecd1c340942821503ea4cb494e2c

3 years agoFix: comment related to filter bytecode list
Mathieu Desnoyers [Wed, 25 Nov 2020 18:38:38 +0000 (13:38 -0500)] 
Fix: comment related to filter bytecode list

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoFix: use vmalloc for filter bytecode allocation
Mathieu Desnoyers [Wed, 25 Nov 2020 18:29:47 +0000 (13:29 -0500)] 
Fix: use vmalloc for filter bytecode allocation

Given that the filter bytecode can reach 64kB, use vmalloc rather than
kmalloc to minimize the chances of failure on systems with fragmented
memory.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 years agoImplement enum and sequence capture serialization functions
Francis Deslauriers [Wed, 13 May 2020 22:31:23 +0000 (18:31 -0400)] 
Implement enum and sequence capture serialization functions

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I2a342e5e1d74e7c2f676b21822d8b7f171d68ebd

3 years agobytecode: Add `OBJECT_TYPE_{UN,}SIGNED_ENUM` type
Francis Deslauriers [Wed, 13 May 2020 15:42:09 +0000 (11:42 -0400)] 
bytecode: Add `OBJECT_TYPE_{UN,}SIGNED_ENUM` type

Enumerations are currently converted to their integer counterparts as
soon as they are encountered.

In order to use them in captures, we need to differentiate the
enumerations from integers for the entirety of the interpretation.

This commit adds the `OBJECT_TYPE_SIGNED_ENUM` and
`OBJECT_TYPE_UNSIGNED_ENUM` to keep track of these objects

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic0ab518588d7250190e42576d9baba2e8d8ce94a

3 years agoGeneralize `lttng_enabler_link_bytecode()` bytecode list
Francis Deslauriers [Wed, 13 May 2020 16:56:03 +0000 (12:56 -0400)] 
Generalize `lttng_enabler_link_bytecode()` bytecode list

So it can be used for both filter and capture bytecode runtimes

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I14dd5eb1eb018d358446d68ba14aa376d1647545

3 years agoCleanup: rename `_lttng_filter_link_bytecode()` -> `link_bytecode()`
Francis Deslauriers [Wed, 13 May 2020 15:24:19 +0000 (11:24 -0400)] 
Cleanup: rename `_lttng_filter_link_bytecode()` -> `link_bytecode()`

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I8a9b5d97eae502181ae8673caf39e4f54fdbdeb6

3 years agoAdd `interpreter_funcs` to `lttng_bytecode_runtime`
Francis Deslauriers [Wed, 13 May 2020 14:32:26 +0000 (10:32 -0400)] 
Add `interpreter_funcs` to `lttng_bytecode_runtime`

Background
==========
The current filter interpreter function signature looks like this:

uint64_t lttng_bytecode_filter_interpret(void *filter_data,
              const char *filter_stack_data);

The upcoming capture interpreter function will need an output parameter
to extract the top of stack register. It will look like this:

uint64_t lttng_bytecode_capture_interpret(void *filter_data,
              const char *filter_stack_data, struct output_register *output);

Problems
========
We can't reuse the same function pointer field in `struct
lttng_bytecode_runtime` as both interpreter functions will have
different signatures.

We can't change the signature of this existing filter function because
it's used in the tracepoint probes.

Solution
========
Add a union of callbacks to hold both interpreter functions. This also
doesn't change the layout of the `struct lttng_bytecode_runtime`
objects.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic4423100e1f97654fe43c0927d3b81de2d1d724f

3 years agobytecode: rename `lttng_filter_sync_state()` -> `lttng_bytecode_filter_sync_state()`
Francis Deslauriers [Wed, 13 May 2020 14:36:00 +0000 (10:36 -0400)] 
bytecode: rename `lttng_filter_sync_state()` -> `lttng_bytecode_filter_sync_state()`

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I2d63001ed633236a98eba6398ad06fccf83fde2c

3 years agoRename filter bytecode types and files
Francis Deslauriers [Tue, 12 May 2020 20:10:04 +0000 (16:10 -0400)] 
Rename filter bytecode types and files

File renames:
- filter-bytecode.h -> bytecode.h
- lttng-filter-interpreter.c -> lttng-bytecode-interpreter.c
- lttng-filter-specialize.c -> lttng-bytecode-specialize.c
- lttng-filter-validator.c -> lttng-bytecode-validator.c
- lttng-filter.c -> lttng-bytecode.c
- lttng-filter.h -> lttng-bytecode.h

Function renames:
- `lttng_filter_interpret_bytecode_false()` -> `lttng_bytecode_filter_interpret_false()`
- `lttng_filter_interpret_bytecode()` -> `lttng_bytecode_filter_interpret()`
- `lttng_filter_specialize_bytecode()` -> `lttng_bytecode_specialize()`
- `lttng_filter_validate_bytecode()` -> `lttng_bytecode_validate()`

Type renames
- `filter_opcode_t` to `bytecode_opcode_t`

Enum renames:
- `enum filter_op` to `enum bytecode_op`
- `FILTER_OP_*` to `BYTECODE_OP_*`
- `enum lttng_filter_ret` -> `enum lttng_bytecode_interpreter_ret`
- `LTTNG_FILTER_DISCARD` -> `LTTNG_INTERPRETER_DISCARD`
- `LTTNG_FILTER_RECORD_FLAG` -> `LTTNG_INTERPRETER_RECORD_FLAG`

Define renames:
- `FILTER_STACK_EMPTY` -> `INTERPRETER_STACK_EMPTY`
- `FILTER_STACK_LEN`-> `INTERPRETER_STACK_LEN`
- `FILTER_MAX_DATA_LEN` -> `BYTECODE_MAX_DATA_LEN`

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I8cd3a15c8ba19aa1d66e611913a1b08e51d94a43

3 years agobytecode: generalize `struct lttng_filter_bytecode_node`
Francis Deslauriers [Tue, 12 May 2020 19:52:41 +0000 (15:52 -0400)] 
bytecode: generalize `struct lttng_filter_bytecode_node`

Rename `struct lttng_filter_bytecode_node` to `struct
lttng_bytecode_node` so it can be used by capture bytecode as well.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I27162522bb20d0fdce6af551fbd982a791d1067c

This page took 0.050203 seconds and 4 git commands to generate.