public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Sean Anderson <seanga2@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2 2/9] log: don't build the trace buffer when log is not ready
Date: Fri, 27 Nov 2020 09:50:36 -0500	[thread overview]
Message-ID: <19fede5c-166c-1cff-643d-d80cbff6c34b@gmail.com> (raw)
In-Reply-To: <20201127102100.11721-3-patrick.delaunay@st.com>

On 11/27/20 5:20 AM, Patrick Delaunay wrote:
> 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.
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
> 
> (no changes since v1)
> 
>   common/log.c | 13 ++++++++-----
>   1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/common/log.c b/common/log.c
> index ce39918e04..212789d6b3 100644
> --- a/common/log.c
> +++ b/common/log.c
> @@ -228,6 +228,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;

How early are you expecting this function to get called? AFAIK this will
only return true before board_init_f_init_reserve. Shouldn't functions
that early just not call log in the first place?

--Sean

> +
>   	/* Check for message continuation */
>   	if (cat == LOGC_CONT)
>   		cat = gd->logc_prev;
> @@ -240,15 +243,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;
> 

  reply	other threads:[~2020-11-27 14:50 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-27 10:20 [PATCH v2 0/9] log: don't build the trace buffer when log is not ready Patrick Delaunay
2020-11-27 10:20 ` [PATCH v2 1/9] test: add LOGL_FORCE_DEBUG flags support in log tests Patrick Delaunay
2020-11-27 14:53   ` Sean Anderson
2020-11-30 20:12   ` Simon Glass
2021-01-16 16:21   ` Tom Rini
2020-11-27 10:20 ` [PATCH v2 2/9] log: don't build the trace buffer when log is not ready Patrick Delaunay
2020-11-27 14:50   ` Sean Anderson [this message]
2020-11-30 20:12     ` Simon Glass
2020-12-02  8:37     ` Patrick DELAUNAY
2021-01-16 16:21   ` Tom Rini
2020-11-27 10:20 ` [PATCH v2 3/9] test: log: add test for dropped messages Patrick Delaunay
2020-11-30 20:11   ` Simon Glass
2021-01-16 16:21   ` Tom Rini
2020-11-27 10:20 ` [PATCH v2 4/9] log: use console puts to output trace before LOG init Patrick Delaunay
2020-11-27 15:01   ` Sean Anderson
2020-12-02  9:15     ` Patrick DELAUNAY
2021-01-16 16:21   ` Tom Rini
2020-11-27 10:20 ` [PATCH v2 5/9] test: add test for dropped trace before log_init Patrick Delaunay
2020-11-30 20:12   ` Simon Glass
2021-01-16 16:21   ` Tom Rini
2020-11-27 10:20 ` [PATCH v2 6/9] console: remove duplicated test on gd value Patrick Delaunay
2020-11-27 15:05   ` Sean Anderson
2020-11-30 20:12   ` Simon Glass
2021-01-16 16:21   ` Tom Rini
2020-11-27 10:20 ` [PATCH v2 7/9] console: allow to record console output before ready Patrick Delaunay
2020-11-30 20:12   ` Simon Glass
2020-12-02  9:55     ` [Uboot-stm32] " Patrick DELAUNAY
2020-12-02 21:46       ` Simon Glass
2021-01-16 16:22   ` Tom Rini
2020-11-27 10:20 ` [PATCH v2 8/9] test: log: add test for console output of dropped messages Patrick Delaunay
2020-11-30 20:12   ` Simon Glass
2021-01-16 16:22   ` Tom Rini
2020-11-27 10:20 ` [PATCH v2 9/9] log: call vsnprintf only when it is needed to emit trace Patrick Delaunay
2021-01-16 16:22   ` Tom Rini

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=19fede5c-166c-1cff-643d-d80cbff6c34b@gmail.com \
    --to=seanga2@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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