Skip to content

Commit de48814

Browse files
author
CKI KWF Bot
committed
Merge: Rebase RTLA to v6.17 [rhel-10.2]
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1710 # Merge Request Required Information JIRA: https://issues.redhat.com/browse/RHEL-117874 CVE: CVE-2025-39887 CVE: CVE-2025-39974 ## Summary of Changes Rebase RTLA in RHEL 10.2 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: 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 5af82ba + 090ec82 commit de48814

File tree

8 files changed

+82
-60
lines changed

8 files changed

+82
-60
lines changed

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/rtla-timerlat-hist.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 36 additions & 51 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
}
@@ -1525,27 +1526,25 @@ static int run_osnoise(void)
15251526

15261527
/*
15271528
* In some cases, notably when running on a nohz_full CPU with
1528-
* a stopped tick PREEMPT_RCU has no way to account for QSs.
1529-
* This will eventually cause unwarranted noise as PREEMPT_RCU
1530-
* will force preemption as the means of ending the current
1531-
* grace period. We avoid this problem by calling
1532-
* rcu_momentary_eqs(), which performs a zero duration
1533-
* EQS allowing PREEMPT_RCU to end the current grace period.
1534-
* This call shouldn't be wrapped inside an RCU critical
1535-
* 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.
15361536
*
1537-
* Note that in non PREEMPT_RCU kernels QSs are handled through
1538-
* 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.
15391540
*/
1540-
if (IS_ENABLED(CONFIG_PREEMPT_RCU)) {
1541-
if (!disable_irq)
1542-
local_irq_disable();
1541+
if (!disable_irq)
1542+
local_irq_disable();
15431543

1544-
rcu_momentary_eqs();
1544+
rcu_momentary_eqs();
15451545

1546-
if (!disable_irq)
1547-
local_irq_enable();
1548-
}
1546+
if (!disable_irq)
1547+
local_irq_enable();
15491548

15501549
/*
15511550
* For the non-preemptive kernel config: let threads runs, if
@@ -2075,26 +2074,21 @@ static void osnoise_hotplug_workfn(struct work_struct *dummy)
20752074
{
20762075
unsigned int cpu = smp_processor_id();
20772076

2078-
mutex_lock(&trace_types_lock);
2077+
guard(mutex)(&trace_types_lock);
20792078

20802079
if (!osnoise_has_registered_instances())
2081-
goto out_unlock_trace;
2080+
return;
20822081

2083-
mutex_lock(&interface_lock);
2084-
cpus_read_lock();
2082+
guard(mutex)(&interface_lock);
2083+
guard(cpus_read_lock)();
20852084

20862085
if (!cpu_online(cpu))
2087-
goto out_unlock;
2086+
return;
2087+
20882088
if (!cpumask_test_cpu(cpu, &osnoise_cpumask))
2089-
goto out_unlock;
2089+
return;
20902090

20912091
start_kthread(cpu);
2092-
2093-
out_unlock:
2094-
cpus_read_unlock();
2095-
mutex_unlock(&interface_lock);
2096-
out_unlock_trace:
2097-
mutex_unlock(&trace_types_lock);
20982092
}
20992093

21002094
static DECLARE_WORK(osnoise_hotplug_work, osnoise_hotplug_workfn);
@@ -2292,31 +2286,22 @@ static ssize_t
22922286
osnoise_cpus_read(struct file *filp, char __user *ubuf, size_t count,
22932287
loff_t *ppos)
22942288
{
2295-
char *mask_str;
2289+
char *mask_str __free(kfree) = NULL;
22962290
int len;
22972291

2298-
mutex_lock(&interface_lock);
2292+
guard(mutex)(&interface_lock);
22992293

23002294
len = snprintf(NULL, 0, "%*pbl\n", cpumask_pr_args(&osnoise_cpumask)) + 1;
23012295
mask_str = kmalloc(len, GFP_KERNEL);
2302-
if (!mask_str) {
2303-
count = -ENOMEM;
2304-
goto out_unlock;
2305-
}
2296+
if (!mask_str)
2297+
return -ENOMEM;
23062298

23072299
len = snprintf(mask_str, len, "%*pbl\n", cpumask_pr_args(&osnoise_cpumask));
2308-
if (len >= count) {
2309-
count = -EINVAL;
2310-
goto out_free;
2311-
}
2300+
if (len >= count)
2301+
return -EINVAL;
23122302

23132303
count = simple_read_from_buffer(ubuf, count, ppos, mask_str, len);
23142304

2315-
out_free:
2316-
kfree(mask_str);
2317-
out_unlock:
2318-
mutex_unlock(&interface_lock);
2319-
23202305
return count;
23212306
}
23222307

@@ -2344,12 +2329,12 @@ osnoise_cpus_write(struct file *filp, const char __user *ubuf, size_t count,
23442329
int running, err;
23452330
char *buf __free(kfree) = NULL;
23462331

2347-
buf = kmalloc(count, GFP_KERNEL);
2348-
if (!buf)
2349-
return -ENOMEM;
2332+
if (count < 1)
2333+
return 0;
23502334

2351-
if (copy_from_user(buf, ubuf, count))
2352-
return -EFAULT;
2335+
buf = memdup_user_nul(ubuf, count);
2336+
if (IS_ERR(buf))
2337+
return PTR_ERR(buf);
23532338

23542339
if (!zalloc_cpumask_var(&osnoise_cpumask_new, GFP_KERNEL))
23552340
return -ENOMEM;

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:

tools/tracing/rtla/src/utils.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ long parse_ns_duration(char *val)
227227
# define __NR_sched_setattr 355
228228
# elif __s390x__
229229
# define __NR_sched_setattr 345
230+
# elif __loongarch__
231+
# define __NR_sched_setattr 274
230232
# endif
231233
#endif
232234

0 commit comments

Comments
 (0)