From: Paolo Bonzini <pbonzini@redhat.com>
To: Asias He <asias@redhat.com>
Cc: kvm@vger.kernel.org, "Michael S. Tsirkin" <mst@redhat.com>,
virtualization@lists.linux-foundation.org,
target-devel@vger.kernel.org,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [PATCH 2/4] tcm_vhost: Introduce tcm_vhost_check_endpoint()
Date: Wed, 13 Mar 2013 09:00:43 +0100 [thread overview]
Message-ID: <5140322B.9050908@redhat.com> (raw)
In-Reply-To: <20130313030218.GC15369@hj.localdomain>
Il 13/03/2013 04:02, Asias He ha scritto:
> On Tue, Mar 12, 2013 at 09:26:18AM +0100, Paolo Bonzini wrote:
>> Il 12/03/2013 03:42, Asias He ha scritto:
>>> This helper is useful to check if vs->vs_endpoint is setup by
>>> vhost_scsi_set_endpoint()
>>>
>>> Signed-off-by: Asias He <asias@redhat.com>
>>> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
>>> ---
>>> drivers/vhost/tcm_vhost.c | 12 ++++++++++++
>>> 1 file changed, 12 insertions(+)
>>>
>>> diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c
>>> index b3e50d7..29612bc 100644
>>> --- a/drivers/vhost/tcm_vhost.c
>>> +++ b/drivers/vhost/tcm_vhost.c
>>> @@ -91,6 +91,18 @@ static int iov_num_pages(struct iovec *iov)
>>> ((unsigned long)iov->iov_base & PAGE_MASK)) >> PAGE_SHIFT;
>>> }
>>>
>>> +static bool tcm_vhost_check_endpoint(struct vhost_scsi *vs)
>>> +{
>>> + bool ret = false;
>>> +
>>> + mutex_lock(&vs->dev.mutex);
>>> + if (vs->vs_endpoint)
>>> + ret = true;
>>> + mutex_unlock(&vs->dev.mutex);
>>
>> The return value is invalid as soon as mutex_unlock is called, i.e.
>> before tcm_vhost_check_endpoint returns. Instead, check vs->vs_endpoint
>> in the caller while the mutex is taken.
>
> Do you mean 1) or 2)?
>
> 1)
> vhost_scsi_handle_vq()
> {
>
> mutex_lock(&vs->dev.mutex);
> check vs->vs_endpoint
> mutex_unlock(&vs->dev.mutex);
>
> handle vq
> }
>
> 2)
> vhost_scsi_handle_vq()
> {
>
> lock vs->dev.mutex
> check vs->vs_endpoint
> handle vq
> unlock vs->dev.mutex
> }
>
> 1) does not make any difference with the original
> one right?
Yes, it's just what you have with tcm_vhost_check_endpoint inlined.
> 2) would be too heavy. This might not be a problem in current 1 thread
> per vhost model. But if we want concurrent multiqueue, this will be
> killing us.
I mean (2). You could use an rwlock to enable more concurrency.
Paolo
next prev parent reply other threads:[~2013-03-13 8:00 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-12 2:42 [PATCH 0/4] tcm_vhost lock and flush fix Asias He
2013-03-12 2:42 ` [PATCH 1/4] tcm_vhost: Add missed lock in vhost_scsi_clear_endpoint() Asias He
2013-03-12 11:13 ` Michael S. Tsirkin
2013-03-13 2:54 ` Asias He
2013-03-12 2:42 ` [PATCH 2/4] tcm_vhost: Introduce tcm_vhost_check_endpoint() Asias He
2013-03-12 8:26 ` Paolo Bonzini
2013-03-13 3:02 ` Asias He
2013-03-13 8:00 ` Paolo Bonzini [this message]
2013-03-14 2:14 ` Asias He
2013-03-12 2:42 ` [PATCH 3/4] tcm_vhost: Fix vs->vs_endpoint checking in vhost_scsi_handle_vq() Asias He
2013-03-12 11:11 ` Michael S. Tsirkin
2013-03-13 3:13 ` Asias He
2013-03-13 8:02 ` Paolo Bonzini
2013-03-14 2:12 ` Asias He
2013-03-12 2:42 ` [PATCH 4/4] tcm_vhost: Flush vhost_work in vhost_scsi_flush() Asias He
2013-03-12 8:26 ` [PATCH 0/4] tcm_vhost lock and flush fix Paolo Bonzini
2013-03-12 11:12 ` Michael S. Tsirkin
2013-03-12 11:14 ` Paolo Bonzini
2013-03-14 2:17 ` Asias He
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=5140322B.9050908@redhat.com \
--to=pbonzini@redhat.com \
--cc=asias@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--cc=stefanha@redhat.com \
--cc=target-devel@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.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;
as well as URLs for NNTP newsgroup(s).