mbox series

[RFC,0/2] virtio-rng: add a control queue

Message ID 20200123151700.1367857-1-lvivier@redhat.com
Headers show
Series virtio-rng: add a control queue | expand

Message

Laurent Vivier Jan. 23, 2020, 3:16 p.m. UTC
The kernel needs sometime to be able to cancel an ongoing command.

For instance, if the virtio-rng device uses the egd backend
and this backend doesn't provide data, the buffer provided by the
kernel is kept as long as it is needed.

On the kernel side, a read blocks until the buffer returns from QEMU.

As the read is done with a mutex held, all the hw_random interface
hangs and we cannot switch to another hw_random backend.

So this series adds a control queue to the virtio-rng device to allow
to flush the virtio-rng input queue to release the kernel mutex and
to allow to switch to another device.

The kernel side series can be found at:

https://github.com/vivier/linux/commits/virtio-rng-ctrl

Laurent Vivier (2):
  virtio-rng: prepare the introduction of a control queue
  virtio-rng: add a control queue

 hw/core/machine.c                           |  1 +
 hw/virtio/trace-events                      |  6 ++
 hw/virtio/virtio-rng.c                      | 99 ++++++++++++++++++---
 include/hw/virtio/virtio-rng.h              |  5 +-
 include/standard-headers/linux/virtio_rng.h | 14 +++
 5 files changed, 111 insertions(+), 14 deletions(-)

Comments

Stefan Hajnoczi Jan. 24, 2020, 11:02 a.m. UTC | #1
On Thu, Jan 23, 2020 at 04:16:58PM +0100, Laurent Vivier wrote:
> The kernel needs sometime to be able to cancel an ongoing command.
> 
> For instance, if the virtio-rng device uses the egd backend
> and this backend doesn't provide data, the buffer provided by the
> kernel is kept as long as it is needed.
> 
> On the kernel side, a read blocks until the buffer returns from QEMU.
> 
> As the read is done with a mutex held, all the hw_random interface
> hangs and we cannot switch to another hw_random backend.
> 
> So this series adds a control queue to the virtio-rng device to allow
> to flush the virtio-rng input queue to release the kernel mutex and
> to allow to switch to another device.
> 
> The kernel side series can be found at:
> 
> https://github.com/vivier/linux/commits/virtio-rng-ctrl
> 
> Laurent Vivier (2):
>   virtio-rng: prepare the introduction of a control queue
>   virtio-rng: add a control queue
> 
>  hw/core/machine.c                           |  1 +
>  hw/virtio/trace-events                      |  6 ++
>  hw/virtio/virtio-rng.c                      | 99 ++++++++++++++++++---
>  include/hw/virtio/virtio-rng.h              |  5 +-
>  include/standard-headers/linux/virtio_rng.h | 14 +++
>  5 files changed, 111 insertions(+), 14 deletions(-)

Where can I find the VIRTIO specification for this new virtqueue?

Thanks,
Stefan
Amit Shah Jan. 24, 2020, 12:43 p.m. UTC | #2
On Thu, 2020-01-23 at 16:16 +0100, Laurent Vivier wrote:
> The kernel needs sometime to be able to cancel an ongoing command.
> 
> For instance, if the virtio-rng device uses the egd backend
> and this backend doesn't provide data, the buffer provided by the
> kernel is kept as long as it is needed.
> 
> On the kernel side, a read blocks until the buffer returns from QEMU.
> 
> As the read is done with a mutex held, all the hw_random interface
> hangs and we cannot switch to another hw_random backend.
> 
> So this series adds a control queue to the virtio-rng device to allow
> to flush the virtio-rng input queue to release the kernel mutex and
> to allow to switch to another device.
> 
> The kernel side series can be found at:
> 
> https://github.com/vivier/linux/commits/virtio-rng-ctrl

Did you submit the kernel series too?  Can you please CC me to it?

This will need spec changes as well, can you please point me to them
too?

I also recall a previous discussion about this, but my search-fu is
failing to find it...

		Amit
Laurent Vivier Jan. 24, 2020, 1:50 p.m. UTC | #3
On 24/01/2020 13:43, Amit Shah wrote:
> On Thu, 2020-01-23 at 16:16 +0100, Laurent Vivier wrote:
>> The kernel needs sometime to be able to cancel an ongoing command.
>>
>> For instance, if the virtio-rng device uses the egd backend
>> and this backend doesn't provide data, the buffer provided by the
>> kernel is kept as long as it is needed.
>>
>> On the kernel side, a read blocks until the buffer returns from QEMU.
>>
>> As the read is done with a mutex held, all the hw_random interface
>> hangs and we cannot switch to another hw_random backend.
>>
>> So this series adds a control queue to the virtio-rng device to allow
>> to flush the virtio-rng input queue to release the kernel mutex and
>> to allow to switch to another device.
>>
>> The kernel side series can be found at:
>>
>> https://github.com/vivier/linux/commits/virtio-rng-ctrl
> 
> Did you submit the kernel series too?  Can you please CC me to it?

No, I didn't. I'd like to have some comments on the QEMU side first.
QEMU list is generally more responsive than kernel one.

It's why I put the link to my linux branch here.

> This will need spec changes as well, can you please point me to them
> too?

The same here. I didn't update the specs, I'd like to have some comments
before.

BTW, where can I find the specs to update?
Is this https://github.com/oasis-tcs/virtio-spec ?

> I also recall a previous discussion about this, but my search-fu is
> failing to find it...

See

[RFC] virtio-rng: add a watchdog
https://patchwork.kernel.org/patch/10987983/

Thanks,
Laurent
Laurent Vivier Jan. 24, 2020, 2:05 p.m. UTC | #4
On 24/01/2020 12:02, Stefan Hajnoczi wrote:
> On Thu, Jan 23, 2020 at 04:16:58PM +0100, Laurent Vivier wrote:
>> The kernel needs sometime to be able to cancel an ongoing command.
>>
>> For instance, if the virtio-rng device uses the egd backend
>> and this backend doesn't provide data, the buffer provided by the
>> kernel is kept as long as it is needed.
>>
>> On the kernel side, a read blocks until the buffer returns from QEMU.
>>
>> As the read is done with a mutex held, all the hw_random interface
>> hangs and we cannot switch to another hw_random backend.
>>
>> So this series adds a control queue to the virtio-rng device to allow
>> to flush the virtio-rng input queue to release the kernel mutex and
>> to allow to switch to another device.
>>
>> The kernel side series can be found at:
>>
>> https://github.com/vivier/linux/commits/virtio-rng-ctrl
>>
>> Laurent Vivier (2):
>>   virtio-rng: prepare the introduction of a control queue
>>   virtio-rng: add a control queue
>>
>>  hw/core/machine.c                           |  1 +
>>  hw/virtio/trace-events                      |  6 ++
>>  hw/virtio/virtio-rng.c                      | 99 ++++++++++++++++++---
>>  include/hw/virtio/virtio-rng.h              |  5 +-
>>  include/standard-headers/linux/virtio_rng.h | 14 +++
>>  5 files changed, 111 insertions(+), 14 deletions(-)
> 
> Where can I find the VIRTIO specification for this new virtqueue?

I didn't update the specs.

Is https://github.com/oasis-tcs/virtio-spec.git the document to update?

Thanks,
Laurent
Stefan Hajnoczi Jan. 29, 2020, 3:43 p.m. UTC | #5
On Fri, Jan 24, 2020 at 03:05:18PM +0100, Laurent Vivier wrote:
> On 24/01/2020 12:02, Stefan Hajnoczi wrote:
> > On Thu, Jan 23, 2020 at 04:16:58PM +0100, Laurent Vivier wrote:
> >> The kernel needs sometime to be able to cancel an ongoing command.
> >>
> >> For instance, if the virtio-rng device uses the egd backend
> >> and this backend doesn't provide data, the buffer provided by the
> >> kernel is kept as long as it is needed.
> >>
> >> On the kernel side, a read blocks until the buffer returns from QEMU.
> >>
> >> As the read is done with a mutex held, all the hw_random interface
> >> hangs and we cannot switch to another hw_random backend.
> >>
> >> So this series adds a control queue to the virtio-rng device to allow
> >> to flush the virtio-rng input queue to release the kernel mutex and
> >> to allow to switch to another device.
> >>
> >> The kernel side series can be found at:
> >>
> >> https://github.com/vivier/linux/commits/virtio-rng-ctrl
> >>
> >> Laurent Vivier (2):
> >>   virtio-rng: prepare the introduction of a control queue
> >>   virtio-rng: add a control queue
> >>
> >>  hw/core/machine.c                           |  1 +
> >>  hw/virtio/trace-events                      |  6 ++
> >>  hw/virtio/virtio-rng.c                      | 99 ++++++++++++++++++---
> >>  include/hw/virtio/virtio-rng.h              |  5 +-
> >>  include/standard-headers/linux/virtio_rng.h | 14 +++
> >>  5 files changed, 111 insertions(+), 14 deletions(-)
> > 
> > Where can I find the VIRTIO specification for this new virtqueue?
> 
> I didn't update the specs.
> 
> Is https://github.com/oasis-tcs/virtio-spec.git the document to update?

Yes, please.

Stefan
Laurent Vivier July 28, 2020, 1:45 p.m. UTC | #6
On 29/01/2020 16:43, Stefan Hajnoczi wrote:
> On Fri, Jan 24, 2020 at 03:05:18PM +0100, Laurent Vivier wrote:
>> On 24/01/2020 12:02, Stefan Hajnoczi wrote:
>>> On Thu, Jan 23, 2020 at 04:16:58PM +0100, Laurent Vivier wrote:
>>>> The kernel needs sometime to be able to cancel an ongoing command.
>>>>
>>>> For instance, if the virtio-rng device uses the egd backend
>>>> and this backend doesn't provide data, the buffer provided by the
>>>> kernel is kept as long as it is needed.
>>>>
>>>> On the kernel side, a read blocks until the buffer returns from QEMU.
>>>>
>>>> As the read is done with a mutex held, all the hw_random interface
>>>> hangs and we cannot switch to another hw_random backend.
>>>>
>>>> So this series adds a control queue to the virtio-rng device to allow
>>>> to flush the virtio-rng input queue to release the kernel mutex and
>>>> to allow to switch to another device.
>>>>
>>>> The kernel side series can be found at:
>>>>
>>>> https://github.com/vivier/linux/commits/virtio-rng-ctrl
>>>>
>>>> Laurent Vivier (2):
>>>>   virtio-rng: prepare the introduction of a control queue
>>>>   virtio-rng: add a control queue
>>>>
>>>>  hw/core/machine.c                           |  1 +
>>>>  hw/virtio/trace-events                      |  6 ++
>>>>  hw/virtio/virtio-rng.c                      | 99 ++++++++++++++++++---
>>>>  include/hw/virtio/virtio-rng.h              |  5 +-
>>>>  include/standard-headers/linux/virtio_rng.h | 14 +++
>>>>  5 files changed, 111 insertions(+), 14 deletions(-)
>>>
>>> Where can I find the VIRTIO specification for this new virtqueue?
>>
>> I didn't update the specs.
>>
>> Is https://github.com/oasis-tcs/virtio-spec.git the document to update?
> 
> Yes, please.

I've updated the specs,

Following
https://github.com/oasis-tcs/virtio-spec/blob/master/CONTRIBUTING.md,
I've opened an issue:

https://github.com/oasis-tcs/virtio-spec/issues/83

Is this the good process?

Thanks,
Laurent
Stefan Hajnoczi July 29, 2020, 9:42 a.m. UTC | #7
On Tue, Jul 28, 2020 at 03:45:26PM +0200, Laurent Vivier wrote:
> On 29/01/2020 16:43, Stefan Hajnoczi wrote:
> > On Fri, Jan 24, 2020 at 03:05:18PM +0100, Laurent Vivier wrote:
> >> On 24/01/2020 12:02, Stefan Hajnoczi wrote:
> >>> On Thu, Jan 23, 2020 at 04:16:58PM +0100, Laurent Vivier wrote:
> >>>> The kernel needs sometime to be able to cancel an ongoing command.
> >>>>
> >>>> For instance, if the virtio-rng device uses the egd backend
> >>>> and this backend doesn't provide data, the buffer provided by the
> >>>> kernel is kept as long as it is needed.
> >>>>
> >>>> On the kernel side, a read blocks until the buffer returns from QEMU.
> >>>>
> >>>> As the read is done with a mutex held, all the hw_random interface
> >>>> hangs and we cannot switch to another hw_random backend.
> >>>>
> >>>> So this series adds a control queue to the virtio-rng device to allow
> >>>> to flush the virtio-rng input queue to release the kernel mutex and
> >>>> to allow to switch to another device.
> >>>>
> >>>> The kernel side series can be found at:
> >>>>
> >>>> https://github.com/vivier/linux/commits/virtio-rng-ctrl
> >>>>
> >>>> Laurent Vivier (2):
> >>>>   virtio-rng: prepare the introduction of a control queue
> >>>>   virtio-rng: add a control queue
> >>>>
> >>>>  hw/core/machine.c                           |  1 +
> >>>>  hw/virtio/trace-events                      |  6 ++
> >>>>  hw/virtio/virtio-rng.c                      | 99 ++++++++++++++++++---
> >>>>  include/hw/virtio/virtio-rng.h              |  5 +-
> >>>>  include/standard-headers/linux/virtio_rng.h | 14 +++
> >>>>  5 files changed, 111 insertions(+), 14 deletions(-)
> >>>
> >>> Where can I find the VIRTIO specification for this new virtqueue?
> >>
> >> I didn't update the specs.
> >>
> >> Is https://github.com/oasis-tcs/virtio-spec.git the document to update?
> > 
> > Yes, please.
> 
> I've updated the specs,
> 
> Following
> https://github.com/oasis-tcs/virtio-spec/blob/master/CONTRIBUTING.md,
> I've opened an issue:
> 
> https://github.com/oasis-tcs/virtio-spec/issues/83
> 
> Is this the good process?

Please post spec changes to the virtio-comment@lists.oasis-open.org
mailing list:
https://github.com/oasis-tcs/virtio-spec/#providing-feedback

Thanks,
Stefan
Michael S. Tsirkin July 29, 2020, 2:15 p.m. UTC | #8
On Tue, Jul 28, 2020 at 03:45:26PM +0200, Laurent Vivier wrote:
> On 29/01/2020 16:43, Stefan Hajnoczi wrote:
> > On Fri, Jan 24, 2020 at 03:05:18PM +0100, Laurent Vivier wrote:
> >> On 24/01/2020 12:02, Stefan Hajnoczi wrote:
> >>> On Thu, Jan 23, 2020 at 04:16:58PM +0100, Laurent Vivier wrote:
> >>>> The kernel needs sometime to be able to cancel an ongoing command.
> >>>>
> >>>> For instance, if the virtio-rng device uses the egd backend
> >>>> and this backend doesn't provide data, the buffer provided by the
> >>>> kernel is kept as long as it is needed.
> >>>>
> >>>> On the kernel side, a read blocks until the buffer returns from QEMU.
> >>>>
> >>>> As the read is done with a mutex held, all the hw_random interface
> >>>> hangs and we cannot switch to another hw_random backend.
> >>>>
> >>>> So this series adds a control queue to the virtio-rng device to allow
> >>>> to flush the virtio-rng input queue to release the kernel mutex and
> >>>> to allow to switch to another device.
> >>>>
> >>>> The kernel side series can be found at:
> >>>>
> >>>> https://github.com/vivier/linux/commits/virtio-rng-ctrl
> >>>>
> >>>> Laurent Vivier (2):
> >>>>   virtio-rng: prepare the introduction of a control queue
> >>>>   virtio-rng: add a control queue
> >>>>
> >>>>  hw/core/machine.c                           |  1 +
> >>>>  hw/virtio/trace-events                      |  6 ++
> >>>>  hw/virtio/virtio-rng.c                      | 99 ++++++++++++++++++---
> >>>>  include/hw/virtio/virtio-rng.h              |  5 +-
> >>>>  include/standard-headers/linux/virtio_rng.h | 14 +++
> >>>>  5 files changed, 111 insertions(+), 14 deletions(-)
> >>>
> >>> Where can I find the VIRTIO specification for this new virtqueue?
> >>
> >> I didn't update the specs.
> >>
> >> Is https://github.com/oasis-tcs/virtio-spec.git the document to update?
> > 
> > Yes, please.
> 
> I've updated the specs,
> 
> Following
> https://github.com/oasis-tcs/virtio-spec/blob/master/CONTRIBUTING.md,
> I've opened an issue:
> 
> https://github.com/oasis-tcs/virtio-spec/issues/83
> 
> Is this the good process?
> 
> Thanks,
> Laurent


It's ok but you also need to send spec patches by mail so
people can review.