Skip to content
Snippets Groups Projects
  1. May 09, 2022
    • Stefan Hajnoczi's avatar
      virtio-scsi: clean up virtio_scsi_handle_cmd_vq() · ad482b57
      Stefan Hajnoczi authored
      
      virtio_scsi_handle_cmd_vq() is only called from hw/scsi/virtio-scsi.c
      now and its return value is no longer used. Remove the function
      prototype from virtio-scsi.h and drop the return value.
      
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 20220427143541.119567-6-stefanha@redhat.com
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      ad482b57
    • Stefan Hajnoczi's avatar
      virtio-scsi: clean up virtio_scsi_handle_ctrl_vq() · 73b3b49f
      Stefan Hajnoczi authored
      
      virtio_scsi_handle_ctrl_vq() is only called from hw/scsi/virtio-scsi.c
      now and its return value is no longer used. Remove the function
      prototype from virtio-scsi.h and drop the return value.
      
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 20220427143541.119567-5-stefanha@redhat.com
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      73b3b49f
    • Stefan Hajnoczi's avatar
      virtio-scsi: clean up virtio_scsi_handle_event_vq() · 37ce2de9
      Stefan Hajnoczi authored
      
      virtio_scsi_handle_event_vq() is only called from hw/scsi/virtio-scsi.c
      now and its return value is no longer used. Remove the function
      prototype from virtio-scsi.h and drop the return value.
      
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 20220427143541.119567-4-stefanha@redhat.com
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      37ce2de9
    • Stefan Hajnoczi's avatar
      virtio-scsi: don't waste CPU polling the event virtqueue · 38738f7d
      Stefan Hajnoczi authored
      
      The virtio-scsi event virtqueue is not emptied by its handler function.
      This is typical for rx virtqueues where the device uses buffers when
      some event occurs (e.g. a packet is received, an error condition
      happens, etc).
      
      Polling non-empty virtqueues wastes CPU cycles. We are not waiting for
      new buffers to become available, we are waiting for an event to occur,
      so it's a misuse of CPU resources to poll for buffers.
      
      Introduce the new virtio_queue_aio_attach_host_notifier_no_poll() API,
      which is identical to virtio_queue_aio_attach_host_notifier() except
      that it does not poll the virtqueue.
      
      Before this patch the following command-line consumed 100% CPU in the
      IOThread polling and calling virtio_scsi_handle_event():
      
        $ qemu-system-x86_64 -M accel=kvm -m 1G -cpu host \
            --object iothread,id=iothread0 \
            --device virtio-scsi-pci,iothread=iothread0 \
            --blockdev file,filename=test.img,aio=native,cache.direct=on,node-name=drive0 \
            --device scsi-hd,drive=drive0
      
      After this patch CPU is no longer wasted.
      
      Reported-by: default avatarNir Soffer <nsoffer@redhat.com>
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Tested-by: default avatarNir Soffer <nsoffer@redhat.com>
      Message-id: 20220427143541.119567-3-stefanha@redhat.com
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      38738f7d
    • Stefan Hajnoczi's avatar
      virtio-scsi: fix ctrl and event handler functions in dataplane mode · 2f743ef6
      Stefan Hajnoczi authored
      
      Commit f34e8d8b ("virtio-scsi: prepare
      virtio_scsi_handle_cmd for dataplane") prepared the virtio-scsi cmd
      virtqueue handler function to be used in both the dataplane and
      non-datpalane code paths.
      
      It failed to convert the ctrl and event virtqueue handler functions,
      which are not designed to be called from the dataplane code path but
      will be since the ioeventfd is set up for those virtqueues when
      dataplane starts.
      
      Convert the ctrl and event virtqueue handler functions now so they
      operate correctly when called from the dataplane code path. Avoid code
      duplication by extracting this code into a helper function.
      
      Fixes: f34e8d8b ("virtio-scsi: prepare virtio_scsi_handle_cmd for dataplane")
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 20220427143541.119567-2-stefanha@redhat.com
      [Fixed s/by used/be used/ typo pointed out by Michael Tokarev
      <mjt@tls.msk.ru>.
      --Stefan]
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      2f743ef6
    • Nicolas Saenz Julienne's avatar
      util/event-loop-base: Introduce options to set the thread pool size · 71ad4713
      Nicolas Saenz Julienne authored
      
      The thread pool regulates itself: when idle, it kills threads until
      empty, when in demand, it creates new threads until full. This behaviour
      doesn't play well with latency sensitive workloads where the price of
      creating a new thread is too high. For example, when paired with qemu's
      '-mlock', or using safety features like SafeStack, creating a new thread
      has been measured take multiple milliseconds.
      
      In order to mitigate this let's introduce a new 'EventLoopBase'
      property to set the thread pool size. The threads will be created during
      the pool's initialization or upon updating the property's value, remain
      available during its lifetime regardless of demand, and destroyed upon
      freeing it. A properly characterized workload will then be able to
      configure the pool to avoid any latency spikes.
      
      Signed-off-by: default avatarNicolas Saenz Julienne <nsaenzju@redhat.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Acked-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-id: 20220425075723.20019-4-nsaenzju@redhat.com
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      71ad4713
    • Nicolas Saenz Julienne's avatar
      util/main-loop: Introduce the main loop into QOM · 70ac26b9
      Nicolas Saenz Julienne authored
      
      'event-loop-base' provides basic property handling for all 'AioContext'
      based event loops. So let's define a new 'MainLoopClass' that inherits
      from it. This will permit tweaking the main loop's properties through
      qapi as well as through the command line using the '-object' keyword[1].
      Only one instance of 'MainLoopClass' might be created at any time.
      
      'EventLoopBaseClass' learns a new callback, 'can_be_deleted()' so as to
      mark 'MainLoop' as non-deletable.
      
      [1] For example:
            -object main-loop,id=main-loop,aio-max-batch=<value>
      
      Signed-off-by: default avatarNicolas Saenz Julienne <nsaenzju@redhat.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Acked-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-id: 20220425075723.20019-3-nsaenzju@redhat.com
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      70ac26b9
    • Nicolas Saenz Julienne's avatar
      Introduce event-loop-base abstract class · 7d5983e3
      Nicolas Saenz Julienne authored
      
      Introduce the 'event-loop-base' abstract class, it'll hold the
      properties common to all event loops and provide the necessary hooks for
      their creation and maintenance. Then have iothread inherit from it.
      
      EventLoopBaseClass is defined as user creatable and provides a hook for
      its children to attach themselves to the user creatable class 'complete'
      function. It also provides an update_params() callback to propagate
      property changes onto its children.
      
      The new 'event-loop-base' class will live in the root directory. It is
      built on its own using the 'link_whole' option (there are no direct
      function dependencies between the class and its children, it all happens
      trough 'constructor' magic). And also imposes new compilation
      dependencies:
      
          qom <- event-loop-base <- blockdev (iothread.c)
      
      And in subsequent patches:
      
          qom <- event-loop-base <- qemuutil (util/main-loop.c)
      
      All this forced some amount of reordering in meson.build:
      
       - Moved qom build definition before qemuutil. Doing it the other way
         around (i.e. moving qemuutil after qom) isn't possible as a lot of
         core libraries that live in between the two depend on it.
      
       - Process the 'hw' subdir earlier, as it introduces files into the
         'qom' source set.
      
      No functional changes intended.
      
      Signed-off-by: default avatarNicolas Saenz Julienne <nsaenzju@redhat.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Acked-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-id: 20220425075723.20019-2-nsaenzju@redhat.com
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      7d5983e3
  2. May 08, 2022
Loading