From: Michael Tokarev <mjt@tls.msk.ru>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/3] Combine bdrv_read and bdrv_write to bdrv_rw
Date: Wed, 29 Feb 2012 20:36:24 +0400 [thread overview]
Message-ID: <4F4E5408.1050701@msgid.tls.msk.ru> (raw)
In-Reply-To: <jilifi$jl6$1@dough.gmane.org>
On 29.02.2012 20:07, Paolo Bonzini wrote:
> Il 29/02/2012 17:00, Michael Tokarev ha scritto:
>> And how it will be a cleanup?
>>
>> The whole cow code (and a few others) is not reenterant. Merely
>> moving this lock/unlock stuff inth actual methods eliminates two
>> current wrappers in cow_co_write() and cow_co_read(), which are
>> exactly the same now, and moves this exactly the same code into
>> actual methods, which has nothing to do with locking - they're
>> not reenterant, and they deal with internal to the format stuff.
>> Having this common locking layer on top and _outside_ of the
>> actual work helps removing irrelevant code from important paths.
>> Also, it will be too easy to forgot to unlock it there by doing
>> just "return" somewhere.
>
> It's not very different from leaking memory. It's just the way C works.
>
> In the future, you may add unlock around image access like in qcow2, and
> then an unlock/lock pair would be confusing without the lock/unlock outside.
>
> If you are worried about forgetting to unlock, add owner tracking to
> qemu-coroutine-lock.c, similar to PTHREAD_MUTEX_ERRORCHECK. That would
> be quite useful.
You're replying to the lest significant part of my whole comment.
I'm not worrying about forgetting about unlock or about freeing
memory. It is just one of the more things that needs remembering,
that's all.
I'm "worrying" about adding irrelevant code into already complex
routine, and adding the same code to two places, too, while it
very naturally fits into one common wrapper with this proposed
infrastructure.
Only when we actually start making these drivers less "lock-dependent"
and let them to be "a bit more" reenterant, -- only then it will
make sense to move the lock/unlock logic _down_ to these routines,
to take locks for as little time as possible.
This is what happened with qcow and qcow2 drivers in the 3/3 patch, --
the change which you missed. There, the drivers actually gained
_new_ wrapper, without any additional cleanups, which does
dispatching from rw to read or write. And only for these two
examples your original NACK for this 1/3 part can be applied :)
The "cleanup" you're referring to above is not a cleanup, it
is particular driver development, and I can try to do that
too, just not in this series, it is a completely separate
issue.
Thanks,
/mjt
next prev parent reply other threads:[~2012-02-29 16:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1330473276-8975-1-git-send-email-mjt@tls.msk.ru>
2012-02-28 23:54 ` [Qemu-devel] [PATCH 1/3] Combine bdrv_read and bdrv_write to bdrv_rw Michael Tokarev
2012-02-29 15:53 ` Paolo Bonzini
2012-02-29 16:00 ` Michael Tokarev
2012-02-29 16:07 ` Paolo Bonzini
2012-02-29 16:36 ` Michael Tokarev [this message]
2012-02-28 23:54 ` [Qemu-devel] [PATCH 2/3] Combine bdrv_aio_readv and bdrv_aio_writev into bdrv_aio_rw_vector Michael Tokarev
2012-02-29 15:54 ` Paolo Bonzini
2012-02-29 16:16 ` Michael Tokarev
2012-02-28 23:54 ` [Qemu-devel] [PATCH 3/3] Combine bdrv_co_readv and bdrv_co_writev into bdrv_co_rw_vector Michael Tokarev
2012-02-29 16:01 ` Paolo Bonzini
2012-02-29 16:12 ` Michael Tokarev
2012-02-29 16:24 ` Paolo Bonzini
2012-02-29 16:45 ` Michael Tokarev
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=4F4E5408.1050701@msgid.tls.msk.ru \
--to=mjt@tls.msk.ru \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.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.