linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@kernel.org>
To: Li Zhijian <lizhijian@cn.fujitsu.com>
Cc: dave@stgolabs.net, josh@joshtriplett.org, rostedt@goodmis.org,
	mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com,
	joel@joelfernandes.org, rcu@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] refscale: simplify the errexit checkpoint
Date: Fri, 22 Oct 2021 16:10:48 -0700	[thread overview]
Message-ID: <20211022231048.GF880162@paulmck-ThinkPad-P17-Gen-1> (raw)
In-Reply-To: <20211022105111.29455-1-lizhijian@cn.fujitsu.com>

On Fri, Oct 22, 2021 at 06:51:10PM +0800, Li Zhijian wrote:
> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>

Good catch!

But given that errexit is only set once at the beginning, why not
eliminate this local variable in favor of a goto at the point that it
is currently assigned to?  That would permit further simplification.

							Thanx, Paul

> ---
>  kernel/rcu/refscale.c | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/kernel/rcu/refscale.c b/kernel/rcu/refscale.c
> index 66dc14cf5687..2cbe2a2ba387 100644
> --- a/kernel/rcu/refscale.c
> +++ b/kernel/rcu/refscale.c
> @@ -698,26 +698,25 @@ static int main_func(void *arg)
>  	// Print the average of all experiments
>  	SCALEOUT("END OF TEST. Calculating average duration per loop (nanoseconds)...\n");
>  
> -	if (!errexit) {
> -		buf[0] = 0;
> -		strcat(buf, "\n");
> -		strcat(buf, "Runs\tTime(ns)\n");
> -	}
> +	if (errexit)
> +		goto err;
> +
> +	buf[0] = 0;
> +	strcat(buf, "\n");
> +	strcat(buf, "Runs\tTime(ns)\n");
>  
>  	for (exp = 0; exp < nruns; exp++) {
>  		u64 avg;
>  		u32 rem;
>  
> -		if (errexit)
> -			break;
>  		avg = div_u64_rem(result_avg[exp], 1000, &rem);
>  		sprintf(buf1, "%d\t%llu.%03u\n", exp + 1, avg, rem);
>  		strcat(buf, buf1);
>  	}
>  
> -	if (!errexit)
> -		SCALEOUT("%s", buf);
> +	SCALEOUT("%s", buf);
>  
> +err:
>  	// This will shutdown everything including us.
>  	if (shutdown) {
>  		shutdown_start = 1;
> -- 
> 2.33.0
> 
> 
> 

  parent reply	other threads:[~2021-10-22 23:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-22 10:51 [PATCH 1/2] refscale: simplify the errexit checkpoint Li Zhijian
2021-10-22 10:51 ` [PATCH 2/2] refscale: prevent buffer to pr_alert() being too long Li Zhijian
2021-10-22 23:15   ` Paul E. McKenney
2021-10-24 14:46     ` Li, Zhijian
2021-10-24 22:56       ` Paul E. McKenney
2021-10-25  3:15         ` lizhijian
2021-10-22 23:10 ` Paul E. McKenney [this message]
2021-10-24 13:34   ` [PATCH 1/2] refscale: simplify the errexit checkpoint Li, Zhijian

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=20211022231048.GF880162@paulmck-ThinkPad-P17-Gen-1 \
    --to=paulmck@kernel.org \
    --cc=dave@stgolabs.net \
    --cc=jiangshanlai@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizhijian@cn.fujitsu.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /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;
as well as URLs for NNTP newsgroup(s).