All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <jaxboe@fusionio.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: "fio@vger.kernel.org" <fio@vger.kernel.org>,
	Radha Ramachandran <radha@google.com>
Subject: Re: RFC: Data pattern buffer filling race condition fix
Date: Sun, 7 Nov 2010 12:43:27 +0100	[thread overview]
Message-ID: <4CD690DF.6090807@fusionio.com> (raw)
In-Reply-To: <201011061035.18709.bvanassche@acm.org>

On 2010-11-06 10:35, Bart Van Assche wrote:
> On multicore non-x86 CPUs fio has been observed to frequently reports false
> data verification failures with I/O engine libaio and I/O depths above one.
> This is because of a race condition in the function fill_pattern(). The code
> in that function only works correct if all CPUs of a multicore system
> observe store instructions in the order they were issued. That is the case for
> multicore x86 systems but not for all other CPU families, such as e.g. the
> POWER CPU family.
> 
> As far as I can see this bug was introduced via commit
> cbe8d7561cf6d81d741d87eb7940db2a111d2144 (July 14, 2010).
> 
> I'm posting this patch as an RFC since the fix is GCC-specific.

ppc is notorious for its weaker memory ordering. I do have a ppc test
box, but haven't used it in a while. But it used to find bugs
immediately for race conditions, that x86 would never trigger. So since
you are pin pointing that particular commit, you are convinced that this
bug manifests itself due to bad ordering between the filled buffer and
the fill length?

> diff --git a/verify.c b/verify.c
> index ea1a911..3826198 100644
> --- a/verify.c
> +++ b/verify.c
> @@ -31,18 +31,27 @@ void fill_pattern(struct thread_data *td, void *p, unsigned int len, struct io_u
>  		fill_random_buf(p, len);
>  		break;
>  	case 1:
> +#ifdef __GNUC__
> +		__sync_synchronize();
> +#endif

You should be able to use the fio included write_barrier() and
read_barrier(), which are hooked to the architectures. Then you don't
need to use GNUC additions.

-- 
Jens Axboe


  parent reply	other threads:[~2010-11-07 11:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-06  9:35 RFC: Data pattern buffer filling race condition fix Bart Van Assche
2010-11-07 10:02 ` Bart Van Assche
2010-11-07 11:43 ` Jens Axboe [this message]
2010-11-07 12:58   ` Bart Van Assche
2010-11-08 13:03     ` Jens Axboe
2010-11-09 11:53       ` Bart Van Assche
2010-11-09 13:16         ` Jens Axboe

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=4CD690DF.6090807@fusionio.com \
    --to=jaxboe@fusionio.com \
    --cc=bvanassche@acm.org \
    --cc=fio@vger.kernel.org \
    --cc=radha@google.com \
    /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.