io_uring: Add tracepoint for short writes
authorStefan Roesch <shr@fb.com>
Thu, 16 Jun 2022 21:22:19 +0000 (14:22 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 25 Jul 2022 00:39:32 +0000 (18:39 -0600)
This adds the io_uring_short_write tracepoint to io_uring. A short write
is issued if not all pages that are required for a write are in the page
cache and the async buffered writes have to return EAGAIN.

Signed-off-by: Stefan Roesch <shr@fb.com>
Link: https://lore.kernel.org/r/20220616212221.2024518-13-shr@fb.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/trace/events/io_uring.h
io_uring/rw.c

index 95a8cfa..c5b21ff 100644 (file)
@@ -630,6 +630,31 @@ TRACE_EVENT(io_uring_task_work_run,
                 __entry->tctx, __entry->count, __entry->loops)
 );
 
+TRACE_EVENT(io_uring_short_write,
+
+       TP_PROTO(void *ctx, u64 fpos, u64 wanted, u64 got),
+
+       TP_ARGS(ctx, fpos, wanted, got),
+
+       TP_STRUCT__entry(
+               __field(void *, ctx)
+               __field(u64,    fpos)
+               __field(u64,    wanted)
+               __field(u64,    got)
+       ),
+
+       TP_fast_assign(
+               __entry->ctx    = ctx;
+               __entry->fpos   = fpos;
+               __entry->wanted = wanted;
+               __entry->got    = got;
+       ),
+
+       TP_printk("ring %p, fpos %lld, wanted %lld, got %lld",
+                         __entry->ctx, __entry->fpos,
+                         __entry->wanted, __entry->got)
+);
+
 #endif /* _TRACE_IO_URING_H */
 
 /* This part must be outside protection */
index 1f4a8ff..2b78479 100644 (file)
@@ -933,6 +933,9 @@ int io_write(struct io_kiocb *req, unsigned int issue_flags)
                if (ret2 != req->cqe.res && ret2 >= 0 && need_complete_io(req)) {
                        struct io_async_rw *rw;
 
+                       trace_io_uring_short_write(req->ctx, kiocb->ki_pos - ret2,
+                                               req->cqe.res, ret2);
+
                        /* This is a partial write. The file pos has already been
                         * updated, setup the async struct to complete the request
                         * in the worker. Also update bytes_done to account for