Skip to content

Commit 328bbe2

Browse files
author
CKI KWF Bot
committed
Merge: Rebase RTLA to v6.17 [rhel-9.8]
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7554 # Merge Request Required Information JIRA: https://issues.redhat.com/browse/RHEL-117873 CVE: CVE-2025-38493 CVE: CVE-2025-39887 CVE: CVE-2025-39974 CVE: CVE-2025-21733 ## Summary of Changes Rebase RTLA in RHEL 9.8 to upstream 6.17, with one fix from 6.18. ## Approved Development Ticket(s) All submissions to CentOS Stream must reference a ticket in [Red Hat Jira](https://issues.redhat.com/). <details><summary>Click for formatting instructions</summary> Please follow the CentOS Stream [contribution documentation](https://docs.centos.org/en-US/stream-contrib/quickstart/) for how to file this ticket and have it approved. List tickets each on their own line of this description using the format "Resolves: RHEL-76229", "Related: RHEL-76229" or "Reverts: RHEL-76229", as appropriate. </details> Signed-off-by: Tomas Glozar <tglozar@redhat.com> Approved-by: Phil Auld <pauld@redhat.com> Approved-by: Wander Lairson Costa <wander@redhat.com> Approved-by: Luis Claudio R. Goncalves <lgoncalv@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents 5696c2d + 6434e3e commit 328bbe2

File tree

11 files changed

+109
-75
lines changed

11 files changed

+109
-75
lines changed

Documentation/tools/rtla/common_options.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414

1515
Print debug info.
1616

17-
**-t**, **--trace**\[*=file*]
18-
19-
Save the stopped trace to [*file|osnoise_trace.txt*].
20-
2117
**-e**, **--event** *sys:event*
2218

2319
Enable an event in the trace (**-t**) session. The argument can be a specific event, e.g., **-e** *sched:sched_switch*, or all events of a system group, e.g., **-e** *sched*. Multiple **-e** are allowed. It is only active when **-t** or **-a** are set.

Documentation/tools/rtla/common_osnoise_options.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@
2525

2626
Specify the minimum delta between two time reads to be considered noise.
2727
The default threshold is *5 us*.
28+
29+
**-t**, **--trace** \[*file*]
30+
31+
Save the stopped trace to [*file|osnoise_trace.txt*].

Documentation/tools/rtla/common_timerlat_description.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,13 @@ debugging of operating system timer latency.
66

77
The *timerlat* tracer outputs information in two ways. It periodically
88
prints the timer latency at the timer *IRQ* handler and the *Thread*
9-
handler. It also enable the trace of the most relevant information via
9+
handler. It also enables the trace of the most relevant information via
1010
**osnoise:** tracepoints.
11+
12+
The **rtla timerlat** tool sets the options of the *timerlat* tracer
13+
and collects and displays a summary of the results. By default,
14+
the collection is done synchronously in kernel space using a dedicated
15+
BPF program attached to the *timerlat* tracer. If either BPF or
16+
the **osnoise:timerlat_sample** tracepoint it attaches to is
17+
unavailable, the **rtla timerlat** tool falls back to using tracefs to
18+
process the data asynchronously in user space.

Documentation/tools/rtla/common_timerlat_options.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
Save the stack trace at the *IRQ* if a *Thread* latency is higher than the
2323
argument in us.
2424

25+
**-t**, **--trace** \[*file*]
26+
27+
Save the stopped trace to [*file|timerlat_trace.txt*].
28+
2529
**--dma-latency** *us*
2630
Set the /dev/cpu_dma_latency to *us*, aiming to bound exit from idle latencies.
2731
*cyclictest* sets this value to *0* by default, use **--dma-latency** *0* to have

Documentation/tools/rtla/rtla-timerlat-hist.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ EXAMPLE
3636
In the example below, **rtla timerlat hist** is set to run for *10* minutes,
3737
in the cpus *0-4*, *skipping zero* only lines. Moreover, **rtla timerlat
3838
hist** will change the priority of the *timerlat* threads to run under
39-
*SCHED_DEADLINE* priority, with a *10us* runtime every *1ms* period. The
39+
*SCHED_DEADLINE* priority, with a *100us* runtime every *1ms* period. The
4040
*1ms* period is also passed to the *timerlat* tracer. Auto-analysis is disabled
4141
to reduce overhead ::
4242

43-
[root@alien ~]# timerlat hist -d 10m -c 0-4 -P d:100us:1ms -p 1ms --no-aa
43+
[root@alien ~]# timerlat hist -d 10m -c 0-4 -P d:100us:1ms -p 1000 --no-aa
4444
# RTLA timerlat histogram
4545
# Time unit is microseconds (us)
4646
# Duration: 0 00:10:00
@@ -107,3 +107,5 @@ SEE ALSO
107107
AUTHOR
108108
======
109109
Written by Daniel Bristot de Oliveira <bristot@kernel.org>
110+
111+
.. include:: common_appendix.rst

Documentation/tools/rtla/rtla-timerlat.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@ DESCRIPTION
1616

1717
.. include:: common_timerlat_description.rst
1818

19-
The *timerlat* tracer outputs information in two ways. It periodically
20-
prints the timer latency at the timer *IRQ* handler and the *Thread* handler.
21-
It also provides information for each noise via the **osnoise:** tracepoints.
2219
The **rtla timerlat top** mode displays a summary of the periodic output
23-
from the *timerlat* tracer. The **rtla hist hist** mode displays a histogram
24-
of each tracer event occurrence. For further details, please refer to the
25-
respective man page.
20+
from the *timerlat* tracer. The **rtla timerlat hist** mode displays
21+
a histogram of each tracer event occurrence. For further details, please
22+
refer to the respective man page.
2623

2724
MODES
2825
=====

kernel/trace/trace_osnoise.c

Lines changed: 53 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/sched/clock.h>
2525
#include <uapi/linux/sched/types.h>
2626
#include <linux/sched.h>
27+
#include <linux/string.h>
2728
#include "trace.h"
2829

2930
#ifdef CONFIG_X86_LOCAL_APIC
@@ -271,7 +272,7 @@ static inline void tlat_var_reset(void)
271272
* So far, all the values are initialized as 0, so
272273
* zeroing the structure is perfect.
273274
*/
274-
for_each_cpu(cpu, cpu_online_mask) {
275+
for_each_online_cpu(cpu) {
275276
tlat_var = per_cpu_ptr(&per_cpu_timerlat_var, cpu);
276277
if (tlat_var->kthread)
277278
hrtimer_cancel(&tlat_var->timer);
@@ -295,7 +296,7 @@ static inline void osn_var_reset(void)
295296
* So far, all the values are initialized as 0, so
296297
* zeroing the structure is perfect.
297298
*/
298-
for_each_cpu(cpu, cpu_online_mask) {
299+
for_each_online_cpu(cpu) {
299300
osn_var = per_cpu_ptr(&per_cpu_osnoise_var, cpu);
300301
memset(osn_var, 0, sizeof(*osn_var));
301302
}
@@ -642,8 +643,8 @@ __timerlat_dump_stack(struct trace_buffer *buffer, struct trace_stack *fstack, u
642643

643644
entry = ring_buffer_event_data(event);
644645

645-
memcpy(&entry->caller, fstack->calls, size);
646646
entry->size = fstack->nr_entries;
647+
memcpy(&entry->caller, fstack->calls, size);
647648

648649
if (!call_filter_check_discard(call, entry, buffer, event))
649650
trace_buffer_unlock_commit_nostack(buffer, event);
@@ -1212,6 +1213,8 @@ static void trace_sched_migrate_callback(void *data, struct task_struct *p, int
12121213
}
12131214
}
12141215

1216+
static bool monitor_enabled;
1217+
12151218
static int register_migration_monitor(void)
12161219
{
12171220
int ret = 0;
@@ -1220,16 +1223,25 @@ static int register_migration_monitor(void)
12201223
* Timerlat thread migration check is only required when running timerlat in user-space.
12211224
* Thus, enable callback only if timerlat is set with no workload.
12221225
*/
1223-
if (timerlat_enabled() && !test_bit(OSN_WORKLOAD, &osnoise_options))
1226+
if (timerlat_enabled() && !test_bit(OSN_WORKLOAD, &osnoise_options)) {
1227+
if (WARN_ON_ONCE(monitor_enabled))
1228+
return 0;
1229+
12241230
ret = register_trace_sched_migrate_task(trace_sched_migrate_callback, NULL);
1231+
if (!ret)
1232+
monitor_enabled = true;
1233+
}
12251234

12261235
return ret;
12271236
}
12281237

12291238
static void unregister_migration_monitor(void)
12301239
{
1231-
if (timerlat_enabled() && !test_bit(OSN_WORKLOAD, &osnoise_options))
1232-
unregister_trace_sched_migrate_task(trace_sched_migrate_callback, NULL);
1240+
if (!monitor_enabled)
1241+
return;
1242+
1243+
unregister_trace_sched_migrate_task(trace_sched_migrate_callback, NULL);
1244+
monitor_enabled = false;
12331245
}
12341246
#else
12351247
static int register_migration_monitor(void)
@@ -1514,27 +1526,25 @@ static int run_osnoise(void)
15141526

15151527
/*
15161528
* In some cases, notably when running on a nohz_full CPU with
1517-
* a stopped tick PREEMPT_RCU has no way to account for QSs.
1518-
* This will eventually cause unwarranted noise as PREEMPT_RCU
1519-
* will force preemption as the means of ending the current
1520-
* grace period. We avoid this problem by calling
1521-
* rcu_momentary_eqs(), which performs a zero duration
1522-
* EQS allowing PREEMPT_RCU to end the current grace period.
1523-
* This call shouldn't be wrapped inside an RCU critical
1524-
* section.
1529+
* a stopped tick PREEMPT_RCU or PREEMPT_LAZY have no way to
1530+
* account for QSs. This will eventually cause unwarranted
1531+
* noise as RCU forces preemption as the means of ending the
1532+
* current grace period. We avoid this by calling
1533+
* rcu_momentary_eqs(), which performs a zero duration EQS
1534+
* allowing RCU to end the current grace period. This call
1535+
* shouldn't be wrapped inside an RCU critical section.
15251536
*
1526-
* Note that in non PREEMPT_RCU kernels QSs are handled through
1527-
* cond_resched()
1537+
* Normally QSs for other cases are handled through cond_resched().
1538+
* For simplicity, however, we call rcu_momentary_eqs() for all
1539+
* configurations here.
15281540
*/
1529-
if (IS_ENABLED(CONFIG_PREEMPT_RCU)) {
1530-
if (!disable_irq)
1531-
local_irq_disable();
1541+
if (!disable_irq)
1542+
local_irq_disable();
15321543

1533-
rcu_momentary_eqs();
1544+
rcu_momentary_eqs();
15341545

1535-
if (!disable_irq)
1536-
local_irq_enable();
1537-
}
1546+
if (!disable_irq)
1547+
local_irq_enable();
15381548

15391549
/*
15401550
* For the non-preemptive kernel config: let threads runs, if
@@ -1873,8 +1883,7 @@ static int timerlat_main(void *data)
18731883
tlat->count = 0;
18741884
tlat->tracing_thread = false;
18751885

1876-
hrtimer_init(&tlat->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
1877-
tlat->timer.function = timerlat_irq;
1886+
hrtimer_setup(&tlat->timer, timerlat_irq, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
18781887
tlat->kthread = current;
18791888
osn_var->pid = current->pid;
18801889
/*
@@ -2004,7 +2013,6 @@ static int start_kthread(unsigned int cpu)
20042013

20052014
if (IS_ERR(kthread)) {
20062015
pr_err(BANNER "could not start sampling thread\n");
2007-
stop_per_cpu_kthreads();
20082016
return -ENOMEM;
20092017
}
20102018

@@ -2066,26 +2074,21 @@ static void osnoise_hotplug_workfn(struct work_struct *dummy)
20662074
{
20672075
unsigned int cpu = smp_processor_id();
20682076

2069-
mutex_lock(&trace_types_lock);
2077+
guard(mutex)(&trace_types_lock);
20702078

20712079
if (!osnoise_has_registered_instances())
2072-
goto out_unlock_trace;
2080+
return;
20732081

2074-
mutex_lock(&interface_lock);
2075-
cpus_read_lock();
2082+
guard(mutex)(&interface_lock);
2083+
guard(cpus_read_lock)();
20762084

20772085
if (!cpu_online(cpu))
2078-
goto out_unlock;
2086+
return;
2087+
20792088
if (!cpumask_test_cpu(cpu, &osnoise_cpumask))
2080-
goto out_unlock;
2089+
return;
20812090

20822091
start_kthread(cpu);
2083-
2084-
out_unlock:
2085-
cpus_read_unlock();
2086-
mutex_unlock(&interface_lock);
2087-
out_unlock_trace:
2088-
mutex_unlock(&trace_types_lock);
20892092
}
20902093

20912094
static DECLARE_WORK(osnoise_hotplug_work, osnoise_hotplug_workfn);
@@ -2283,31 +2286,22 @@ static ssize_t
22832286
osnoise_cpus_read(struct file *filp, char __user *ubuf, size_t count,
22842287
loff_t *ppos)
22852288
{
2286-
char *mask_str;
2289+
char *mask_str __free(kfree) = NULL;
22872290
int len;
22882291

2289-
mutex_lock(&interface_lock);
2292+
guard(mutex)(&interface_lock);
22902293

22912294
len = snprintf(NULL, 0, "%*pbl\n", cpumask_pr_args(&osnoise_cpumask)) + 1;
22922295
mask_str = kmalloc(len, GFP_KERNEL);
2293-
if (!mask_str) {
2294-
count = -ENOMEM;
2295-
goto out_unlock;
2296-
}
2296+
if (!mask_str)
2297+
return -ENOMEM;
22972298

22982299
len = snprintf(mask_str, len, "%*pbl\n", cpumask_pr_args(&osnoise_cpumask));
2299-
if (len >= count) {
2300-
count = -EINVAL;
2301-
goto out_free;
2302-
}
2300+
if (len >= count)
2301+
return -EINVAL;
23032302

23042303
count = simple_read_from_buffer(ubuf, count, ppos, mask_str, len);
23052304

2306-
out_free:
2307-
kfree(mask_str);
2308-
out_unlock:
2309-
mutex_unlock(&interface_lock);
2310-
23112305
return count;
23122306
}
23132307

@@ -2335,12 +2329,12 @@ osnoise_cpus_write(struct file *filp, const char __user *ubuf, size_t count,
23352329
int running, err;
23362330
char *buf __free(kfree) = NULL;
23372331

2338-
buf = kmalloc(count, GFP_KERNEL);
2339-
if (!buf)
2340-
return -ENOMEM;
2332+
if (count < 1)
2333+
return 0;
23412334

2342-
if (copy_from_user(buf, ubuf, count))
2343-
return -EFAULT;
2335+
buf = memdup_user_nul(ubuf, count);
2336+
if (IS_ERR(buf))
2337+
return PTR_ERR(buf);
23442338

23452339
if (!zalloc_cpumask_var(&osnoise_cpumask_new, GFP_KERNEL))
23462340
return -ENOMEM;
@@ -2443,8 +2437,7 @@ static int timerlat_fd_open(struct inode *inode, struct file *file)
24432437
tlat = this_cpu_tmr_var();
24442438
tlat->count = 0;
24452439

2446-
hrtimer_init(&tlat->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
2447-
tlat->timer.function = timerlat_irq;
2440+
hrtimer_setup(&tlat->timer, timerlat_irq, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
24482441

24492442
migrate_enable();
24502443
return 0;

tools/tracing/rtla/Makefile.config

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22

3+
include $(srctree)/tools/scripts/utilities.mak
4+
35
STOP_ERROR :=
46

57
LIBTRACEEVENT_MIN_VERSION = 1.5
68
LIBTRACEFS_MIN_VERSION = 1.6
79

10+
ifndef ($(NO_LIBTRACEEVENT),1)
11+
ifeq ($(call get-executable,$(PKG_CONFIG)),)
12+
$(error Error: $(PKG_CONFIG) needed by libtraceevent/libtracefs is missing on this system, please install it)
13+
endif
14+
endif
15+
816
define lib_setup
917
$(eval LIB_INCLUDES += $(shell sh -c "$(PKG_CONFIG) --cflags lib$(1)"))
1018
$(eval LDFLAGS += $(shell sh -c "$(PKG_CONFIG) --libs-only-L lib$(1)"))

tools/tracing/rtla/Makefile.rtla

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ INSTALL := install
3434
MKDIR := mkdir
3535
STRIP := strip
3636
BINDIR := /usr/bin
37+
CTAGS := ctags
38+
ETAGS := ctags -e
3739

3840
.PHONY: install
3941
install: doc_install
@@ -47,6 +49,18 @@ install: doc_install
4749
@test ! -f $(DESTDIR)$(BINDIR)/timerlat || $(RM) $(DESTDIR)$(BINDIR)/timerlat
4850
@$(LN) -s rtla $(DESTDIR)$(BINDIR)/timerlat
4951

52+
.PHONY: tags
53+
tags:
54+
$(CTAGS) -R --extras=+f --c-kinds=+p src
55+
56+
.PHONY: TAGS
57+
TAGS:
58+
$(ETAGS) -R --extras=+f --c-kinds=+p src
59+
60+
.PHONY: tags_clean
61+
tags_clean:
62+
$(RM) tags TAGS
63+
5064
.PHONY: doc doc_clean doc_install
5165
doc:
5266
$(MAKE) -C $(DOCSRC)
@@ -57,8 +71,7 @@ doc_clean:
5771
doc_install:
5872
$(MAKE) -C $(DOCSRC) install
5973

60-
# This section is neesary for the tarball, when the tarball
61-
# support is removed, we can delete these entries.
74+
# This section is necessary to make the rtla tarball
6275
NAME := rtla
6376
DIRS := src
6477
FILES := Makefile README.txt

tools/tracing/rtla/README.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ RTLA depends on the following libraries and tools:
1313
- libtraceevent
1414
- libcpupower (optional, for --deepest-idle-state)
1515

16+
For BPF sample collection support, the following extra dependencies are
17+
required:
18+
19+
- libbpf 1.0.0 or later
20+
- bpftool with skeleton support
21+
- clang with BPF CO-RE support
22+
1623
It also depends on python3-docutils to compile man pages.
1724

1825
For development, we suggest the following steps for compiling rtla:

0 commit comments

Comments
 (0)