All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] log: don't build the trace buffer when log is not ready
@ 2020-11-06 17:53 Patrick Delaunay
  2020-11-06 17:53 ` [PATCH 2/3] log: use debug uart to output trace before LOG init Patrick Delaunay
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Patrick Delaunay @ 2020-11-06 17:53 UTC (permalink / raw)
  To: u-boot

Update _log function to drop any traces when log is yet initialized:
vsnprintf is no more executed in this case.

This patch allows to reduce the cost for the dropped early debug trace.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

 common/log.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/common/log.c b/common/log.c
index 4b6f3fcd04..aadf533fb2 100644
--- a/common/log.c
+++ b/common/log.c
@@ -227,6 +227,9 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file,
 	struct log_rec rec;
 	va_list args;
 
+	if (!gd)
+		return -ENOSYS;
+
 	/* Check for message continuation */
 	if (cat == LOGC_CONT)
 		cat = gd->logc_prev;
@@ -239,15 +242,15 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file,
 	rec.file = file;
 	rec.line = line;
 	rec.func = func;
+
+	if (!(gd->flags & GD_FLG_LOG_READY)) {
+		gd->log_drop_count++;
+		return -ENOSYS;
+	}
 	va_start(args, fmt);
 	vsnprintf(buf, sizeof(buf), fmt, args);
 	va_end(args);
 	rec.msg = buf;
-	if (!gd || !(gd->flags & GD_FLG_LOG_READY)) {
-		if (gd)
-			gd->log_drop_count++;
-		return -ENOSYS;
-	}
 	if (!log_dispatch(&rec)) {
 		gd->logc_prev = cat;
 		gd->logl_prev = level;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-11-19 13:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-06 17:53 [PATCH 1/3] log: don't build the trace buffer when log is not ready Patrick Delaunay
2020-11-06 17:53 ` [PATCH 2/3] log: use debug uart to output trace before LOG init Patrick Delaunay
2020-11-11 14:32   ` Simon Glass
2020-11-19 13:42     ` Patrick DELAUNAY
2020-11-06 17:53 ` [PATCH 3/3] log: call vsnprintf only when it is needed to emit trace Patrick Delaunay
2020-11-11 14:32   ` Simon Glass
2020-11-11 14:32 ` [PATCH 1/3] log: don't build the trace buffer when log is not ready Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.