mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Waiman Long <waiman.long@hpe.com>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: <mingo@kernel.org>, <peterz@infradead.org>,
	<linux-kernel@vger.kernel.org>, Davidlohr Bueso <dbueso@suse.de>
Subject: Re: [PATCH -tip 2/3] locking/pvqspinlock: Avoid double resetting of stats
Date: Mon, 18 Apr 2016 15:39:56 -0400	[thread overview]
Message-ID: <5715380C.5050608@hpe.com> (raw)
In-Reply-To: <1460961103-24953-2-git-send-email-dave@stgolabs.net>

On 04/18/2016 02:31 AM, Davidlohr Bueso wrote:
> ... remove the redundant second iteration, this is most
> likely a copy/past buglet.
>
> Signed-off-by: Davidlohr Bueso<dbueso@suse.de>
> ---
>   kernel/locking/qspinlock_stat.h | 2 --
>   1 file changed, 2 deletions(-)
>
> diff --git a/kernel/locking/qspinlock_stat.h b/kernel/locking/qspinlock_stat.h
> index d734b7502001..72722334237a 100644
> --- a/kernel/locking/qspinlock_stat.h
> +++ b/kernel/locking/qspinlock_stat.h
> @@ -191,8 +191,6 @@ static ssize_t qstat_write(struct file *file, const char __user *user_buf,
>
>   		for (i = 0 ; i<  qstat_num; i++)
>   			WRITE_ONCE(ptr[i], 0);
> -		for (i = 0 ; i<  qstat_num; i++)
> -			WRITE_ONCE(ptr[i], 0);
>   	}
>   	return count;
>   }

The double write is done on purpose. As the statistics count update 
isn't atomic, there is a very small chance (p) that clearing the count 
may happen in the middle of read-modify-write bus transaction. Doing a 
double write will reduce the chance further to p^2. This isn't failsafe, 
but I think is good enough.

However, I don't mind eliminate the double write either as we can always 
view the statistics count after a reset to make sure that they are 
properly cleared.

Cheers,
Longman

  reply	other threads:[~2016-04-18 20:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-18  6:31 [PATCH -tip 1/3] locking/pvqspinlock: Fix div by 0 in qstats Davidlohr Bueso
2016-04-18  6:31 ` [PATCH -tip 2/3] locking/pvqspinlock: Avoid double resetting of stats Davidlohr Bueso
2016-04-18 19:39   ` Waiman Long [this message]
2016-05-05  9:43   ` [tip:locking/core] " tip-bot for Davidlohr Bueso
2016-04-18  6:31 ` [PATCH -tip 3/3] locking/pvqspinlock: Robustify init_qspinlock_stat() Davidlohr Bueso
2016-04-18 16:16   ` Davidlohr Bueso
     [not found]     ` <CS1PR84MB0312315E60265F5E8972CACBF16C0@CS1PR84MB0312.NAMPRD84.PROD.OUTLOOK.COM>
2016-04-20  4:10       ` [PATCH -tip v2] " Davidlohr Bueso
2016-04-20  4:13         ` Davidlohr Bueso
2016-04-20  4:17       ` [PATCH -tip v3 3/3] " Davidlohr Bueso
2016-04-20 20:06         ` Waiman Long
2016-05-05  9:44         ` [tip:locking/core] " tip-bot for Davidlohr Bueso
2016-04-18 19:40   ` [PATCH -tip 3/3] " Waiman Long
2016-04-18 19:34 ` [PATCH -tip 1/3] locking/pvqspinlock: Fix div by 0 in qstats Waiman Long
2016-04-19  9:34 ` [tip:locking/urgent] locking/pvqspinlock: Fix division by zero in qstat_read() tip-bot for Davidlohr Bueso

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=5715380C.5050608@hpe.com \
    --to=waiman.long@hpe.com \
    --cc=dave@stgolabs.net \
    --cc=dbueso@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.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

Powered by JetHome