* [PATCH v2] rtla/actions: Fix condition for buffer reallocation
@ 2025-09-15 18:10 Wander Lairson Costa
2025-09-16 13:15 ` Tomas Glozar
2025-09-26 14:35 ` Tomas Glozar
0 siblings, 2 replies; 3+ messages in thread
From: Wander Lairson Costa @ 2025-09-15 18:10 UTC (permalink / raw)
To: Steven Rostedt, Tomas Glozar, Wander Lairson Costa,
open list:Real-time Linux Analysis (RTLA) tools, open list
Cc: John Kacur, Luis Goncalves, Arnaldo Carvalho de Melo, Chang Yin,
Costa Shulyupin, Crystal Wood, Gabriele Monaco
The condition to check if the actions buffer needs to be resized was
incorrect. The check `self->size >= self->len` would evaluate to
true on almost every call to `actions_new()`, causing the buffer to
be reallocated unnecessarily each time an action was added.
Fix the condition to `self->len >= self.size`, ensuring
that the buffer is only resized when it is actually full.
Fixes: 6ea082b171e00 ("rtla/timerlat: Add action on threshold feature")
Signed-off-by: Wander Lairson Costa <wander@redhat.com>
---
v1 -> v2
* Put the commit message in imperative language
---
tools/tracing/rtla/src/actions.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/tracing/rtla/src/actions.c b/tools/tracing/rtla/src/actions.c
index aaf0808125d72..af5f76bd1821b 100644
--- a/tools/tracing/rtla/src/actions.c
+++ b/tools/tracing/rtla/src/actions.c
@@ -49,7 +49,7 @@ actions_destroy(struct actions *self)
static struct action *
actions_new(struct actions *self)
{
- if (self->size >= self->len) {
+ if (self->len >= self->size) {
self->size *= 2;
self->list = realloc(self->list, self->size * sizeof(struct action));
}
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] rtla/actions: Fix condition for buffer reallocation
2025-09-15 18:10 [PATCH v2] rtla/actions: Fix condition for buffer reallocation Wander Lairson Costa
@ 2025-09-16 13:15 ` Tomas Glozar
2025-09-26 14:35 ` Tomas Glozar
1 sibling, 0 replies; 3+ messages in thread
From: Tomas Glozar @ 2025-09-16 13:15 UTC (permalink / raw)
To: Wander Lairson Costa
Cc: Steven Rostedt, open list:Real-time Linux Analysis (RTLA) tools,
open list, John Kacur, Luis Goncalves, Arnaldo Carvalho de Melo,
Chang Yin, Costa Shulyupin, Crystal Wood, Gabriele Monaco
po 15. 9. 2025 v 20:11 odesílatel Wander Lairson Costa
<wander@redhat.com> napsal:
>
> The condition to check if the actions buffer needs to be resized was
> incorrect. The check `self->size >= self->len` would evaluate to
> true on almost every call to `actions_new()`, causing the buffer to
> be reallocated unnecessarily each time an action was added.
>
> Fix the condition to `self->len >= self.size`, ensuring
> that the buffer is only resized when it is actually full.
>
> Fixes: 6ea082b171e00 ("rtla/timerlat: Add action on threshold feature")
> Signed-off-by: Wander Lairson Costa <wander@redhat.com>
>
The blame goes entirely on me for getting confused by my own naming of
the fields. Thank you.
Reviewed-by: Tomas Glozar <tglozar@redhat.com>
Tomas
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] rtla/actions: Fix condition for buffer reallocation
2025-09-15 18:10 [PATCH v2] rtla/actions: Fix condition for buffer reallocation Wander Lairson Costa
2025-09-16 13:15 ` Tomas Glozar
@ 2025-09-26 14:35 ` Tomas Glozar
1 sibling, 0 replies; 3+ messages in thread
From: Tomas Glozar @ 2025-09-26 14:35 UTC (permalink / raw)
To: Steven Rostedt
Cc: Wander Lairson Costa,
open list:Real-time Linux Analysis (RTLA) tools, open list,
John Kacur, Luis Goncalves, Arnaldo Carvalho de Melo, Chang Yin,
Costa Shulyupin, Crystal Wood, Gabriele Monaco
Steven,
po 15. 9. 2025 v 20:11 odesílatel Wander Lairson Costa
<wander@redhat.com> napsal:
>
> The condition to check if the actions buffer needs to be resized was
> incorrect. The check `self->size >= self->len` would evaluate to
> true on almost every call to `actions_new()`, causing the buffer to
> be reallocated unnecessarily each time an action was added.
>
> Fix the condition to `self->len >= self.size`, ensuring
> that the buffer is only resized when it is actually full.
>
> Fixes: 6ea082b171e00 ("rtla/timerlat: Add action on threshold feature")
> Signed-off-by: Wander Lairson Costa <wander@redhat.com>
>
> ---
> v1 -> v2
> * Put the commit message in imperative language
>
> ---
> tools/tracing/rtla/src/actions.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
Can you take this fix as well?
Thank you.
Tomas
PS: This should be all for RTLA now.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-26 14:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-15 18:10 [PATCH v2] rtla/actions: Fix condition for buffer reallocation Wander Lairson Costa
2025-09-16 13:15 ` Tomas Glozar
2025-09-26 14:35 ` Tomas Glozar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).