dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Jeff Moyer <jmoyer@redhat.com>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
	Jens Axboe <axboe@kernel.dk>,
	Andrea Arcangeli <aarcange@redhat.com>, Jan Kara <jack@suse.cz>,
	dm-devel@redhat.com, linux-kernel@vger.kernel.org,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	kosaki.motohiro@jp.fujitsu.com, linux-fsdevel@vger.kernel.org,
	lwoodman@redhat.com, "Alasdair G. Kergon" <agk@redhat.com>
Subject: Re: [PATCH 0/4] Fix a crash when block device is read and block size is changed at the same time
Date: Fri, 31 Aug 2012 16:11:56 -0400	[thread overview]
Message-ID: <x49liguyg6r.fsf@segfault.boston.devel.redhat.com> (raw)
In-Reply-To: <Pine.LNX.4.64.1208311518340.16960@file.rdu.redhat.com> (Mikulas Patocka's message of "Fri, 31 Aug 2012 15:27:38 -0400 (EDT)")

Mikulas Patocka <mpatocka@redhat.com> writes:

> On Fri, 31 Aug 2012, Mikulas Patocka wrote:
>
>> Hi
>> 
>> This is a series of patches to prevent a crash when when someone is 
>> reading block device and block size is changed simultaneously. (the crash 
>> is already happening in the production environment)
>> 
>> The first patch adds a rw-lock to struct block_device, but doesn't use the 
>> lock anywhere. The reason why I submit this as a separate patch is that on 
>> my computer adding an unused field to this structure affects performance 
>> much more than any locking changes.
>> 
>> The second patch uses the rw-lock. The lock is locked for read when doing 
>> I/O on the block device and it is locked for write when changing block 
>> size.
>> 
>> The third patch converts the rw-lock to a percpu rw-lock for better 
>> performance, to avoid cache line bouncing.
>> 
>> The fourth patch is an alternate percpu rw-lock implementation using RCU 
>> by Eric Dumazet. It avoids any atomic instruction in the hot path.
>> 
>> Mikulas
>
> I tested performance of patches. I created 4GB ramdisk, I initially filled 
> it with zeros (so that ramdisk allocation-on-demand doesn't affect the 
> results).
>
> I ran fio to perform 8 concurrent accesses on 8 core machine (two 
> Barcelona Opterons):
> time fio --rw=randrw --size=4G --bs=512 --filename=/dev/ram0 --direct=1 
> --name=job1 --name=job2 --name=job3 --name=job4 --name=job5 --name=job6 
> --name=job7 --name=job8
>
> The results actually show that the size of struct block_device and 
> alignment of subsequent fields in struct inode have far more effect on 
> result that the type of locking used. (struct inode is placed just after 
> struct block_device in "struct bdev_inode" in fs/block-dev.c)
>
> plain kernel 3.5.3: 57.9s
> patch 1: 43.4s
> patches 1,2: 43.7s
> patches 1,2,3: 38.5s
> patches 1,2,3,4: 58.6s
>
> You can see that patch 1 improves the time by 14.5 seconds, but all that 
> patch 1 does is adding an unused structure field.
>
> Patch 3 is 4.9 seconds faster than patch 1, althogh patch 1 does no 
> locking at all and patch 3 does per-cpu locking. So, the reason for the 
> speedup is different sizeof of struct block_device (and subsequently, 
> different alignment of struct inode), rather than locking improvement.

How many runs did you do?  Did you see much run to run variation?

> I would be interested if other people did performance testing of the 
> patches too.

I'll do some testing next week, but don't expect to get to it before
Wednesday.

Cheers,
Jeff

  reply	other threads:[~2012-08-31 20:11 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-28  3:04 Crash when IO is being submitted and block size is changed Mikulas Patocka
2012-06-28 11:15 ` Jan Kara
2012-06-28 15:44   ` Mikulas Patocka
2012-06-28 16:53     ` Jan Kara
2012-07-16  0:55   ` Mikulas Patocka
2012-07-17 19:19     ` Jeff Moyer
2012-07-19  2:27       ` Mikulas Patocka
2012-07-19 13:33         ` Jeff Moyer
2012-07-28 16:40           ` [PATCH 1/3] Fix " Mikulas Patocka
2012-07-28 16:41             ` [PATCH 2/3] Introduce percpu rw semaphores Mikulas Patocka
2012-07-28 16:42               ` [PATCH 3/3] blockdev: turn a rw semaphore into a percpu rw semaphore Mikulas Patocka
2012-07-28 20:44               ` [PATCH 2/3] Introduce percpu rw semaphores Eric Dumazet
2012-07-29  5:13                 ` [dm-devel] " Mikulas Patocka
2012-07-29 10:10                   ` Eric Dumazet
2012-07-29 18:36                     ` Eric Dumazet
2012-08-01 20:07                       ` Mikulas Patocka
2012-08-01 20:09                       ` [PATCH 4/3] " Mikulas Patocka
2012-08-31 18:40                         ` [PATCH 0/4] Fix a crash when block device is read and block size is changed at the same time Mikulas Patocka
2012-08-31 18:41                           ` [PATCH 1/4] Add a lock that will be needed by the next patch Mikulas Patocka
2012-08-31 18:42                             ` [PATCH 2/4] blockdev: fix a crash when block size is changed and I/O is issued simultaneously Mikulas Patocka
2012-08-31 18:43                               ` [PATCH 3/4] blockdev: turn a rw semaphore into a percpu rw semaphore Mikulas Patocka
2012-08-31 18:43                                 ` [PATCH 4/4] New percpu lock implementation Mikulas Patocka
2012-08-31 19:27                           ` [PATCH 0/4] Fix a crash when block device is read and block size is changed at the same time Mikulas Patocka
2012-08-31 20:11                             ` Jeff Moyer [this message]
2012-08-31 20:34                               ` Mikulas Patocka
2012-09-17 21:19                               ` Jeff Moyer
2012-09-18 17:04                                 ` Mikulas Patocka
2012-09-18 17:22                                   ` Jeff Moyer
2012-09-18 18:55                                     ` Mikulas Patocka
2012-09-18 18:58                                       ` Jeff Moyer
2012-09-18 20:11                                   ` Jeff Moyer
2012-09-25 17:49                                     ` Jeff Moyer
2012-09-25 17:59                                       ` Jens Axboe
2012-09-25 18:11                                         ` Jens Axboe
2012-09-25 22:49                                           ` [PATCH 1/2] " Mikulas Patocka
2012-09-26  5:48                                             ` Jens Axboe
2012-11-16 22:02                                             ` Jeff Moyer
2012-09-25 22:50                                           ` [PATCH 2/2] " Mikulas Patocka
2012-09-25 22:58                                       ` [PATCH 0/4] " Mikulas Patocka
2012-09-26 13:47                                         ` Jeff Moyer
2012-09-26 14:35                                           ` Mikulas Patocka
2012-07-30 17:00                   ` [dm-devel] [PATCH 2/3] Introduce percpu rw semaphores Paul E. McKenney
2012-07-31  0:00                     ` Mikulas Patocka
2012-08-01 17:15                       ` Paul E. McKenney
2012-06-29  6:25 ` Crash when IO is being submitted and block size is changed Vyacheslav Dubeyko

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=x49liguyg6r.fsf@segfault.boston.devel.redhat.com \
    --to=jmoyer@redhat.com \
    --cc=aarcange@redhat.com \
    --cc=agk@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@redhat.com \
    --cc=eric.dumazet@gmail.com \
    --cc=jack@suse.cz \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lwoodman@redhat.com \
    --cc=mpatocka@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /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).