[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250915151807.40851-1-wander@redhat.com>
Date: Mon, 15 Sep 2025 12:18:02 -0300
From: Wander Lairson Costa <wander@...hat.com>
To: Steven Rostedt <rostedt@...dmis.org>,
Tomas Glozar <tglozar@...hat.com>,
Wander Lairson Costa <wander@...hat.com>,
linux-trace-kernel@...r.kernel.org (open list:Real-time Linux Analysis (RTLA) tools),
linux-kernel@...r.kernel.org (open list)
Cc: John Kacur <jkacur@...hat.com>,
Luis Goncalves <lgoncalv@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Chang Yin <cyin@...hat.com>,
Costa Shulyupin <costa.shul@...hat.com>,
Crystal Wood <crwood@...hat.com>,
Gabriele Monaco <gmonaco@...hat.com>
Subject: [PATCH] rtla/actions: Fix condition for buffer reallocation
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.
This patch fixes 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@...hat.com>
---
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
Powered by blists - more mailing lists