[Qemu-devel] [PATCH 1/3] block/io_uring: add submission and completion trace events

Stefan Hajnoczi posted 3 patches 6 years, 6 months ago
[Qemu-devel] [PATCH 1/3] block/io_uring: add submission and completion trace events
Posted by Stefan Hajnoczi 6 years, 6 months ago
It is useful to follow individual requests as they are submitted.  Add
trace events that show details of each request.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 block/io_uring.c   | 5 +++++
 block/trace-events | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/block/io_uring.c b/block/io_uring.c
index 22e8d3d9ca..19919da4c9 100644
--- a/block/io_uring.c
+++ b/block/io_uring.c
@@ -128,6 +128,8 @@ static void luring_process_completions(LuringState *s)
         LuringAIOCB *luringcb = io_uring_cqe_get_data(cqes);
         ret = cqes->res;
 
+        trace_luring_process_completion(s, luringcb, ret);
+
         if (ret == luringcb->qiov->size) {
             ret = 0;
         } else if (ret >= 0) {
@@ -233,6 +235,7 @@ static int ioq_submit(LuringState *s)
             QSIMPLEQ_REMOVE_HEAD(&s->io_q.sq_overflow, next);
         }
         ret = io_uring_submit(&s->ring);
+        trace_luring_io_uring_submit(s, ret);
         /* Prevent infinite loop if submission is refused */
         if (ret <= 0) {
             if (ret == -EAGAIN) {
@@ -339,6 +342,8 @@ int coroutine_fn luring_co_submit(BlockDriverState *bs, LuringState *s, int fd,
         .is_read    = (type == QEMU_AIO_READ),
     };
 
+    trace_luring_co_submit(bs, s, &luringcb, fd, offset, qiov ? qiov->size : 0, type);
+
     ret = luring_do_submit(fd, &luringcb, s, offset, type);
     if (ret < 0) {
         return ret;
diff --git a/block/trace-events b/block/trace-events
index 069779773b..02952fe4cb 100644
--- a/block/trace-events
+++ b/block/trace-events
@@ -67,6 +67,9 @@ luring_io_plug(void *s) "LuringState %p plug"
 luring_io_unplug(void *s, int blocked, int plugged, int queued, int inflight) "LuringState %p blocked %d plugged %d queued %d inflight %d"
 luring_do_submit(void *s, int blocked, int plugged, int queued, int inflight) "LuringState %p blocked %d plugged %d queued %d inflight %d"
 luring_do_submit_done(void *s, int ret) "LuringState %p submitted to kernel %d"
+luring_co_submit(void *bs, void *s, void *luringcb, int fd, uint64_t offset, size_t nbytes, int type) "bs %p s %p luringcb %p fd %d offset %" PRId64 " nbytes %zd type %d"
+luring_process_completion(void *s, void *aiocb, int ret) "LuringState %p luringcb %p ret %d"
+luring_io_uring_submit(void *s, int ret) "LuringState %p ret %d"
 
 # qcow2.c
 qcow2_writev_start_req(void *co, int64_t offset, int bytes) "co %p offset 0x%" PRIx64 " bytes %d"
-- 
2.21.0


Re: [Qemu-devel] [PATCH 1/3] block/io_uring: add submission and completion trace events
Posted by Philippe Mathieu-Daudé 6 years, 6 months ago
On 7/15/19 10:19 PM, Stefan Hajnoczi wrote:
> It is useful to follow individual requests as they are submitted.  Add
> trace events that show details of each request.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>  block/io_uring.c   | 5 +++++
>  block/trace-events | 3 +++
>  2 files changed, 8 insertions(+)
> 
> diff --git a/block/io_uring.c b/block/io_uring.c
> index 22e8d3d9ca..19919da4c9 100644
> --- a/block/io_uring.c
> +++ b/block/io_uring.c
> @@ -128,6 +128,8 @@ static void luring_process_completions(LuringState *s)
>          LuringAIOCB *luringcb = io_uring_cqe_get_data(cqes);
>          ret = cqes->res;
>  
> +        trace_luring_process_completion(s, luringcb, ret);
> +
>          if (ret == luringcb->qiov->size) {
>              ret = 0;
>          } else if (ret >= 0) {
> @@ -233,6 +235,7 @@ static int ioq_submit(LuringState *s)
>              QSIMPLEQ_REMOVE_HEAD(&s->io_q.sq_overflow, next);
>          }
>          ret = io_uring_submit(&s->ring);
> +        trace_luring_io_uring_submit(s, ret);
>          /* Prevent infinite loop if submission is refused */
>          if (ret <= 0) {
>              if (ret == -EAGAIN) {
> @@ -339,6 +342,8 @@ int coroutine_fn luring_co_submit(BlockDriverState *bs, LuringState *s, int fd,
>          .is_read    = (type == QEMU_AIO_READ),
>      };
>  
> +    trace_luring_co_submit(bs, s, &luringcb, fd, offset, qiov ? qiov->size : 0, type);
> +
>      ret = luring_do_submit(fd, &luringcb, s, offset, type);
>      if (ret < 0) {
>          return ret;
> diff --git a/block/trace-events b/block/trace-events
> index 069779773b..02952fe4cb 100644
> --- a/block/trace-events
> +++ b/block/trace-events
> @@ -67,6 +67,9 @@ luring_io_plug(void *s) "LuringState %p plug"
>  luring_io_unplug(void *s, int blocked, int plugged, int queued, int inflight) "LuringState %p blocked %d plugged %d queued %d inflight %d"
>  luring_do_submit(void *s, int blocked, int plugged, int queued, int inflight) "LuringState %p blocked %d plugged %d queued %d inflight %d"
>  luring_do_submit_done(void *s, int ret) "LuringState %p submitted to kernel %d"
> +luring_co_submit(void *bs, void *s, void *luringcb, int fd, uint64_t offset, size_t nbytes, int type) "bs %p s %p luringcb %p fd %d offset %" PRId64 " nbytes %zd type %d"
> +luring_process_completion(void *s, void *aiocb, int ret) "LuringState %p luringcb %p ret %d"
> +luring_io_uring_submit(void *s, int ret) "LuringState %p ret %d"
>  
>  # qcow2.c
>  qcow2_writev_start_req(void *co, int64_t offset, int bytes) "co %p offset 0x%" PRIx64 " bytes %d"
>