From: Paolo Bonzini <pbonzini@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Amit Shah <amit.shah@redhat.com>,
linux-kernel@vger.kernel.org,
virtualization@lists.linux-foundation.org
Subject: Re: [RFC PATCH] virtio_console: link vq to port with a private pointer in struct virtqueue
Date: Wed, 18 Apr 2012 20:38:00 +0200 [thread overview]
Message-ID: <4F8F0A08.8010900@redhat.com> (raw)
In-Reply-To: <20120418161028.GB12815@redhat.com>
Il 18/04/2012 18:10, Michael S. Tsirkin ha scritto:
> On Wed, Apr 18, 2012 at 04:34:12PM +0200, Paolo Bonzini wrote:
>> Il 18/04/2012 16:21, Michael S. Tsirkin ha scritto:
>>>> @@ -1872,6 +1864,8 @@ static int virtcons_restore(struct virtio_device *vdev)
>>>> list_for_each_entry(port, &portdev->ports, list) {
>>>> port->in_vq = portdev->in_vqs[port->id];
>>>> port->out_vq = portdev->out_vqs[port->id];
>>>> + port->in_vq->vdev_priv = port;
>>>> + port->out_vq->vdev_priv = port;
>>>>
>>>> fill_queue(port->in_vq, &port->inbuf_lock);
>>>>
>>>
>>> Let's add an API to set this pointer.
>>> Document that you must not set it after
>>> probe/restore returned.
>>
>> Why?
>
> How would you prevent races if you do?
With some lock in the driver. It's private to the driver, so the driver
decides how to synchronize access.
>>>> * @priv: a pointer for the virtqueue implementation to use.
>>>> */
>>>> struct virtqueue {
>>>> @@ -21,6 +22,7 @@ struct virtqueue {
>>>> void (*callback)(struct virtqueue *vq);
>>>> const char *name;
>>>> struct virtio_device *vdev;
>>>> + void *vdev_priv;
>>>> void *priv;
>>>
>>> The name is confusing: it seems to imply it's a device pointer.
>>
>> ... it's private to the driver that owns vdev, hence the name.
>
> I own a car but I'm not called Michael Car :)
> driver_priv might be ok too. unfortunately virtio-pci
> is also a driver so it can be misunderstood.
Yes. Is fixing the comment and keeping the vdev_priv name ok with you?
> devices should dominate. ring is an implementation detail.
Ring came first, ring gets the nice name. :)
Paolo
WARNING: multiple messages have this Message-ID (diff)
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: linux-kernel@vger.kernel.org,
virtualization@lists.linux-foundation.org,
Amit Shah <amit.shah@redhat.com>,
Rusty Russell <rusty@rustcorp.com.au>
Subject: Re: [RFC PATCH] virtio_console: link vq to port with a private pointer in struct virtqueue
Date: Wed, 18 Apr 2012 20:38:00 +0200 [thread overview]
Message-ID: <4F8F0A08.8010900@redhat.com> (raw)
In-Reply-To: <20120418161028.GB12815@redhat.com>
Il 18/04/2012 18:10, Michael S. Tsirkin ha scritto:
> On Wed, Apr 18, 2012 at 04:34:12PM +0200, Paolo Bonzini wrote:
>> Il 18/04/2012 16:21, Michael S. Tsirkin ha scritto:
>>>> @@ -1872,6 +1864,8 @@ static int virtcons_restore(struct virtio_device *vdev)
>>>> list_for_each_entry(port, &portdev->ports, list) {
>>>> port->in_vq = portdev->in_vqs[port->id];
>>>> port->out_vq = portdev->out_vqs[port->id];
>>>> + port->in_vq->vdev_priv = port;
>>>> + port->out_vq->vdev_priv = port;
>>>>
>>>> fill_queue(port->in_vq, &port->inbuf_lock);
>>>>
>>>
>>> Let's add an API to set this pointer.
>>> Document that you must not set it after
>>> probe/restore returned.
>>
>> Why?
>
> How would you prevent races if you do?
With some lock in the driver. It's private to the driver, so the driver
decides how to synchronize access.
>>>> * @priv: a pointer for the virtqueue implementation to use.
>>>> */
>>>> struct virtqueue {
>>>> @@ -21,6 +22,7 @@ struct virtqueue {
>>>> void (*callback)(struct virtqueue *vq);
>>>> const char *name;
>>>> struct virtio_device *vdev;
>>>> + void *vdev_priv;
>>>> void *priv;
>>>
>>> The name is confusing: it seems to imply it's a device pointer.
>>
>> ... it's private to the driver that owns vdev, hence the name.
>
> I own a car but I'm not called Michael Car :)
> driver_priv might be ok too. unfortunately virtio-pci
> is also a driver so it can be misunderstood.
Yes. Is fixing the comment and keeping the vdev_priv name ok with you?
> devices should dominate. ring is an implementation detail.
Ring came first, ring gets the nice name. :)
Paolo
next prev parent reply other threads:[~2012-04-18 18:38 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-18 13:33 [RFC PATCH] virtio_console: link vq to port with a private pointer in struct virtqueue Paolo Bonzini
2012-04-18 13:33 ` Paolo Bonzini
2012-04-18 14:21 ` Michael S. Tsirkin
2012-04-18 14:21 ` Michael S. Tsirkin
2012-04-18 14:34 ` Paolo Bonzini
2012-04-18 14:34 ` Paolo Bonzini
2012-04-18 16:10 ` Michael S. Tsirkin
2012-04-18 16:10 ` Michael S. Tsirkin
2012-04-18 18:38 ` Paolo Bonzini [this message]
2012-04-18 18:38 ` Paolo Bonzini
2012-04-18 18:48 ` Michael S. Tsirkin
2012-04-18 18:48 ` Michael S. Tsirkin
2012-04-19 6:21 ` Amit Shah
2012-04-19 6:21 ` Amit Shah
2012-05-08 2:11 ` Rusty Russell
2012-05-08 2:11 ` Rusty Russell
2012-05-08 6:43 ` Paolo Bonzini
2012-05-08 6:43 ` Paolo Bonzini
2012-05-08 9:45 ` Paolo Bonzini
2012-05-08 9:45 ` Paolo Bonzini
2012-05-08 10:18 ` Michael S. Tsirkin
2012-05-08 10:18 ` Michael S. Tsirkin
2012-05-10 1:26 ` Rusty Russell
2012-05-10 1:26 ` Rusty Russell
2012-05-10 6:02 ` Michael S. Tsirkin
2012-05-10 6:02 ` Michael S. Tsirkin
2012-05-08 10:56 ` [PATCH untested] virtio: allocate extra memory before the ring ( was Re: [RFC PATCH] virtio_console: link vq to port with a private) " Michael S. Tsirkin
2012-05-08 10:56 ` Michael S. Tsirkin
2012-05-08 11:06 ` Paolo Bonzini
2012-05-08 11:06 ` Paolo Bonzini
2012-05-08 11:53 ` Michael S. Tsirkin
2012-05-08 11:53 ` Michael S. Tsirkin
2012-05-08 11:34 ` Michael S. Tsirkin
2012-05-08 11:34 ` Michael S. Tsirkin
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=4F8F0A08.8010900@redhat.com \
--to=pbonzini@redhat.com \
--cc=amit.shah@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--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 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.