nbd: add tracepoints for send/receive timing
ANBZ: #5530
commit 2abd2de712
upstream.
This adds four tracepoints to nbd, enabling separate tracing of payload
and header sending/receipt.
In the send path for headers that have already been sent, we also
explicitly initialize the handle so it can be referenced by the later
tracepoint.
Signed-off-by: Andrew Hall <hall@fb.com>
Signed-off-by: Matt Mullins <mmullins@fb.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Yuanhe Shu <xiangzao@linux.alibaba.com>
Reviewed-by: Tianchen Ding <dtcccc@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/2576
This commit is contained in:
parent
708fbf4059
commit
e6a78d867c
|
@ -516,6 +516,10 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
|
|||
if (sent) {
|
||||
if (sent >= sizeof(request)) {
|
||||
skip = sent - sizeof(request);
|
||||
|
||||
/* initialize handle for tracing purposes */
|
||||
handle = nbd_cmd_handle(cmd);
|
||||
|
||||
goto send_pages;
|
||||
}
|
||||
iov_iter_advance(&from, sent);
|
||||
|
@ -539,6 +543,7 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
|
|||
(unsigned long long)blk_rq_pos(req) << 9, blk_rq_bytes(req));
|
||||
result = sock_xmit(nbd, index, 1, &from,
|
||||
(type == NBD_CMD_WRITE) ? MSG_MORE : 0, &sent);
|
||||
trace_nbd_header_sent(req, handle);
|
||||
if (result <= 0) {
|
||||
if (was_interrupted(result)) {
|
||||
/* If we havne't sent anything we can just return BUSY,
|
||||
|
@ -611,6 +616,7 @@ send_pages:
|
|||
bio = next;
|
||||
}
|
||||
out:
|
||||
trace_nbd_payload_sent(req, handle);
|
||||
nsock->pending = NULL;
|
||||
nsock->sent = 0;
|
||||
return 0;
|
||||
|
@ -658,6 +664,7 @@ static struct nbd_cmd *nbd_read_stat(struct nbd_device *nbd, int index)
|
|||
tag, req);
|
||||
return ERR_PTR(-ENOENT);
|
||||
}
|
||||
trace_nbd_header_received(req, handle);
|
||||
cmd = blk_mq_rq_to_pdu(req);
|
||||
|
||||
mutex_lock(&cmd->lock);
|
||||
|
@ -717,6 +724,7 @@ static struct nbd_cmd *nbd_read_stat(struct nbd_device *nbd, int index)
|
|||
}
|
||||
}
|
||||
out:
|
||||
trace_nbd_payload_received(req, handle);
|
||||
mutex_unlock(&cmd->lock);
|
||||
return ret ? ERR_PTR(ret) : cmd;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,57 @@
|
|||
|
||||
#include <linux/tracepoint.h>
|
||||
|
||||
DECLARE_EVENT_CLASS(nbd_transport_event,
|
||||
|
||||
TP_PROTO(struct request *req, u64 handle),
|
||||
|
||||
TP_ARGS(req, handle),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field(struct request *, req)
|
||||
__field(u64, handle)
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->req = req;
|
||||
__entry->handle = handle;
|
||||
),
|
||||
|
||||
TP_printk(
|
||||
"nbd transport event: request %p, handle 0x%016llx",
|
||||
__entry->req,
|
||||
__entry->handle
|
||||
)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(nbd_transport_event, nbd_header_sent,
|
||||
|
||||
TP_PROTO(struct request *req, u64 handle),
|
||||
|
||||
TP_ARGS(req, handle)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(nbd_transport_event, nbd_payload_sent,
|
||||
|
||||
TP_PROTO(struct request *req, u64 handle),
|
||||
|
||||
TP_ARGS(req, handle)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(nbd_transport_event, nbd_header_received,
|
||||
|
||||
TP_PROTO(struct request *req, u64 handle),
|
||||
|
||||
TP_ARGS(req, handle)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(nbd_transport_event, nbd_payload_received,
|
||||
|
||||
TP_PROTO(struct request *req, u64 handle),
|
||||
|
||||
TP_ARGS(req, handle)
|
||||
);
|
||||
|
||||
DECLARE_EVENT_CLASS(nbd_send_request,
|
||||
|
||||
TP_PROTO(struct nbd_request *nbd_request, int index,
|
||||
|
|
Loading…
Reference in New Issue