From: Jeff Moyer <jmoyer@redhat.com>
To: Ming Lei <ming.lei@canonical.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
Linux FS Devel <linux-fsdevel@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] fs: direct-io: increase bio refcount as batch
Date: Thu, 02 Apr 2015 09:39:39 -0400 [thread overview]
Message-ID: <x49zj6qabtw.fsf@segfault.boston.devel.redhat.com> (raw)
In-Reply-To: <CACVXFVM8Bs9mJZ_TTnz85wy61iyjysua-5kLkTA6tfYku=HwyA@mail.gmail.com> (Ming Lei's message of "Wed, 1 Apr 2015 10:04:44 +0800")
Ming Lei <ming.lei@canonical.com> writes:
> Hi,
>
> On Tue, Mar 31, 2015 at 10:02 PM, Jeff Moyer <jmoyer@redhat.com> wrote:
>> Ming Lei <ming.lei@canonical.com> writes:
>>
>>> Each bio is always submitted to block device one by one,
>>> so it isn't necessary to increase the bio refcount by one
>>> each time with holding dio->bio_lock.
>>
>> This patch opens up a race where a completion event can come in before
>> the refcount for the dio is incremented, resulting in refcount going
>> negative. I don't think that will actually cause problems, but it
>> certainly is ugly, and I doubt it was the intended design.
>
> Could you explain why you think it is a race and a bug? When
> dio->refcount is negative, dio_bio_end_*() only completes the
> current BIO, which is just what the function should do, isn't it?
I didn't say it was a bug. :) Refcounts going negative isn't something
that seems clean, though. If you're going to push this patch through,
at least add a comment saying that this can happen by design, and is
safe.
>> Before I dig into this any further, would you care to comment on why you
>> went down this path? Did you see spinlock contention here? And was
>> there a resultant performance improvement for some benchmark with the
>> patch applied?
>
> It is just a minor optimization in theory, especially in case of lots of BIO
> in one dio.
It seems plausible that it would be a win. It sure would be nice to
have some numbers, though.
Cheers,
Jeff
prev parent reply other threads:[~2015-04-02 13:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-31 11:52 [PATCH] fs: direct-io: increase bio refcount as batch Ming Lei
2015-03-31 14:02 ` Jeff Moyer
2015-04-01 2:04 ` Ming Lei
2015-04-02 13:39 ` Jeff Moyer [this message]
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=x49zj6qabtw.fsf@segfault.boston.devel.redhat.com \
--to=jmoyer@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@canonical.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).