* [PATCH] rtla: Define _GNU_SOURCE in timerlat_bpf.c
@ 2025-04-30 14:46 Tomas Glozar
2025-05-16 22:22 ` John Kacur
2025-05-27 7:01 ` Tomas Glozar
0 siblings, 2 replies; 4+ messages in thread
From: Tomas Glozar @ 2025-04-30 14:46 UTC (permalink / raw)
To: Steven Rostedt
Cc: linux-trace-kernel, linux-kernel, John Kacur, Luis Goncalves,
Tomas Glozar
Newer versions of glibc include a definition of struct sched_attr in
bits/sched.h (included through sched.h which is included by rtla).
Commit 0eecee340672 ("tools/rtla: fix collision with glibc
sched_attr/sched_set_attr") has modified the definition of struct
sched_attr in utils.h, so that it is only applied with older versions of
glibc that do not define it, in order to prevent build failure.
The definition in bits/sched.h depends on _GNU_SOURCE.
timerlat_bpf.c does not define _GNU_SOURCE, making it fall back to the
definition in utils.h. The latter has two fields less, leading to
shifted offsets of struct timerlat_params in timerlat_bpf_init.
Because of the shift, timerlat_bpf_init incorrectly reads
params->entries as 0 for timerlat-hist and disables the creation of
histogram maps, causing breakage in BPF sample collection mode:
$ rtla timerlat hist -d 1s
Error pulling BPF data
Fix the issue by also defining _GNU_SOURCE in timerlat_bpf.c.
Fixes: e34293ddcebd ("rtla/timerlat: Add BPF skeleton to collect samples")
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
---
tools/tracing/rtla/src/timerlat_bpf.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/tracing/rtla/src/timerlat_bpf.c b/tools/tracing/rtla/src/timerlat_bpf.c
index 5abee884037a..0bc44ce5d69b 100644
--- a/tools/tracing/rtla/src/timerlat_bpf.c
+++ b/tools/tracing/rtla/src/timerlat_bpf.c
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#ifdef HAVE_BPF_SKEL
+#define _GNU_SOURCE
#include "timerlat.h"
#include "timerlat_bpf.h"
#include "timerlat.skel.h"
--
2.49.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] rtla: Define _GNU_SOURCE in timerlat_bpf.c
2025-04-30 14:46 [PATCH] rtla: Define _GNU_SOURCE in timerlat_bpf.c Tomas Glozar
@ 2025-05-16 22:22 ` John Kacur
2025-05-19 6:20 ` Tomas Glozar
2025-05-27 7:01 ` Tomas Glozar
1 sibling, 1 reply; 4+ messages in thread
From: John Kacur @ 2025-05-16 22:22 UTC (permalink / raw)
To: Tomas Glozar
Cc: Steven Rostedt, linux-trace-kernel, linux-kernel, Luis Goncalves
On Wed, 30 Apr 2025, Tomas Glozar wrote:
> Newer versions of glibc include a definition of struct sched_attr in
> bits/sched.h (included through sched.h which is included by rtla).
> Commit 0eecee340672 ("tools/rtla: fix collision with glibc
> sched_attr/sched_set_attr") has modified the definition of struct
> sched_attr in utils.h, so that it is only applied with older versions of
> glibc that do not define it, in order to prevent build failure.
>
> The definition in bits/sched.h depends on _GNU_SOURCE.
> timerlat_bpf.c does not define _GNU_SOURCE, making it fall back to the
> definition in utils.h. The latter has two fields less, leading to
> shifted offsets of struct timerlat_params in timerlat_bpf_init.
>
> Because of the shift, timerlat_bpf_init incorrectly reads
> params->entries as 0 for timerlat-hist and disables the creation of
> histogram maps, causing breakage in BPF sample collection mode:
>
> $ rtla timerlat hist -d 1s
> Error pulling BPF data
>
> Fix the issue by also defining _GNU_SOURCE in timerlat_bpf.c.
>
> Fixes: e34293ddcebd ("rtla/timerlat: Add BPF skeleton to collect samples")
> Signed-off-by: Tomas Glozar <tglozar@redhat.com>
> ---
> tools/tracing/rtla/src/timerlat_bpf.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/tracing/rtla/src/timerlat_bpf.c b/tools/tracing/rtla/src/timerlat_bpf.c
> index 5abee884037a..0bc44ce5d69b 100644
> --- a/tools/tracing/rtla/src/timerlat_bpf.c
> +++ b/tools/tracing/rtla/src/timerlat_bpf.c
> @@ -1,5 +1,6 @@
> // SPDX-License-Identifier: GPL-2.0
> #ifdef HAVE_BPF_SKEL
> +#define _GNU_SOURCE
> #include "timerlat.h"
> #include "timerlat_bpf.h"
> #include "timerlat.skel.h"
> --
This works, and we need it, so
Reviewed-by: John Kacur <jkacur@redhat.com>
--
Question for Tomas, should we spend sometime to make this work for older
versions of glibc without a definition of struct sched_attr?
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] rtla: Define _GNU_SOURCE in timerlat_bpf.c
2025-05-16 22:22 ` John Kacur
@ 2025-05-19 6:20 ` Tomas Glozar
0 siblings, 0 replies; 4+ messages in thread
From: Tomas Glozar @ 2025-05-19 6:20 UTC (permalink / raw)
To: John Kacur
Cc: Steven Rostedt, linux-trace-kernel, linux-kernel, Luis Goncalves
so 17. 5. 2025 v 0:22 odesílatel John Kacur <jkacur@redhat.com> napsal:
> Question for Tomas, should we spend sometime to make this work for older
> versions of glibc without a definition of struct sched_attr?
Older versions of glibc without a definition for struct sched_attr use
the one in utils.h:
#ifndef SCHED_ATTR_SIZE_VER0
struct sched_attr {
uint32_t size;
uint32_t sched_policy;
uint64_t sched_flags;
int32_t sched_nice;
uint32_t sched_priority;
uint64_t sched_runtime;
uint64_t sched_deadline;
uint64_t sched_period;
};
#endif /* SCHED_ATTR_SIZE_VER0 */
In fact, this one works fine in timerlat_bpf.c, if you build rtla on
older glibc, it will work even without this patch. It's the glibc one
which is not defined without _GNU_SOURCE.
Tomas
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rtla: Define _GNU_SOURCE in timerlat_bpf.c
2025-04-30 14:46 [PATCH] rtla: Define _GNU_SOURCE in timerlat_bpf.c Tomas Glozar
2025-05-16 22:22 ` John Kacur
@ 2025-05-27 7:01 ` Tomas Glozar
1 sibling, 0 replies; 4+ messages in thread
From: Tomas Glozar @ 2025-05-27 7:01 UTC (permalink / raw)
To: Steven Rostedt
Cc: linux-trace-kernel, linux-kernel, John Kacur, Luis Goncalves
st 30. 4. 2025 v 16:47 odesílatel Tomas Glozar <tglozar@redhat.com> napsal:
>
> Because of the shift, timerlat_bpf_init incorrectly reads
> params->entries as 0 for timerlat-hist and disables the creation of
> histogram maps, causing breakage in BPF sample collection mode:
>
> $ rtla timerlat hist -d 1s
> Error pulling BPF data
Linux 6.15 was released with broken rtla on systems with latest glibc
due to this patch not being merged:
$ rtla --version
rtla version 6.15.0
...
$ rtla timerlat hist -d 1s
Error pulling BPF data
Please have a look at this as soon as possible, so the fix can get
into 6.16 and stable.
Thanks,
Tomas
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-05-27 7:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-30 14:46 [PATCH] rtla: Define _GNU_SOURCE in timerlat_bpf.c Tomas Glozar
2025-05-16 22:22 ` John Kacur
2025-05-19 6:20 ` Tomas Glozar
2025-05-27 7:01 ` Tomas Glozar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox