From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Junchang Wang <junchangwang@gmail.com>
Cc: perfbook@vger.kernel.org
Subject: Re: [PATCH 1/2] Replace definition of variable sum from int to unsigned long
Date: Tue, 9 May 2017 07:47:47 -0700 [thread overview]
Message-ID: <20170509144747.GM3956@linux.vnet.ibm.com> (raw)
In-Reply-To: <1494306511-9022-2-git-send-email-junchangwang@gmail.com>
On Tue, May 09, 2017 at 01:08:30PM +0800, Junchang Wang wrote:
> The maximum size of integer variable on 64bit machines is 2^31. Suppose the
> writer takes 5 nanosecond to increase the counter by one, the result wraps
> around in about 10 seconds.
>
> Signed-off-by: Junchang Wang <junchangwang@gmail.com>
Good catch, queued!
Thanx, Paul
> ---
> CodeSamples/count/count_stat_eventual.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/CodeSamples/count/count_stat_eventual.c b/CodeSamples/count/count_stat_eventual.c
> index 75a0ca9..059ab8b 100644
> --- a/CodeSamples/count/count_stat_eventual.c
> +++ b/CodeSamples/count/count_stat_eventual.c
> @@ -38,7 +38,7 @@ unsigned long read_count(void)
> void *eventual(void *arg)
> {
> int t;
> - int sum;
> + unsigned long sum;
>
> while (stopflag < 3) {
> sum = 0;
> --
> 2.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe perfbook" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2017-05-09 14:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-09 5:08 [PATCH 0/2] Reviewing CodeSamples/count/count_stat_eventual.c Junchang Wang
2017-05-09 5:08 ` [PATCH 1/2] Replace definition of variable sum from int to unsigned long Junchang Wang
2017-05-09 14:47 ` Paul E. McKenney [this message]
2017-05-09 5:08 ` [PATCH 2/2] Remove unnecessary memory fence Junchang Wang
2017-05-09 14:47 ` Paul E. McKenney
2017-05-09 15:20 ` Junchang Wang
2017-05-09 15:40 ` Paul E. McKenney
2017-05-09 23:11 ` Junchang Wang
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=20170509144747.GM3956@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=junchangwang@gmail.com \
--cc=perfbook@vger.kernel.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 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.