Linux Trace Kernel
 help / color / mirror / Atom feed
From: John Kacur <jkacur@redhat.com>
To: Tomas Glozar <tglozar@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	linux-trace-kernel@vger.kernel.org,
	 linux-kernel@vger.kernel.org,
	Luis Goncalves <lgoncalv@redhat.com>
Subject: Re: [PATCH] rtla: Define _GNU_SOURCE in timerlat_bpf.c
Date: Fri, 16 May 2025 18:22:06 -0400 (EDT)	[thread overview]
Message-ID: <5c64d78a-1650-5404-c2cb-8190627d10fc@redhat.com> (raw)
In-Reply-To: <20250430144651.621766-1-tglozar@redhat.com>



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?


  reply	other threads:[~2025-05-16 22:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-30 14:46 [PATCH] rtla: Define _GNU_SOURCE in timerlat_bpf.c Tomas Glozar
2025-05-16 22:22 ` John Kacur [this message]
2025-05-19  6:20   ` Tomas Glozar
2025-05-27  7:01 ` Tomas Glozar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5c64d78a-1650-5404-c2cb-8190627d10fc@redhat.com \
    --to=jkacur@redhat.com \
    --cc=lgoncalv@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglozar@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox