Skip to contentSkip to conversation

fuse: add fuse_request_sent tracepoint

PATCH Applied Amir Goldstein 3 participants 7 messages Jun 1 – Jun 10

Subsystems (2)

v2 of 3 Applied Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 fuse: add fuse_request_sent tracepoint

This new tracepoint complements the existing fuse_request_send (enqueue) and fuse_request_end (completion) with a tracepoint at the transition of the request from the fiq->pending queue to the FR_SENT state.

The fuse_request_sent fires when a daemon thread reads the request. The fuse_request_sent does not fire if daemon fails to read the request. It also does not fire for forgets and NOTIFY_REPLY, which also do not trigger the _send and _end tracepoints.

This is needed for tools tracking the in-flight state of user initiated fuse requests.

---

Miklos,

On v1 patch review Bernd did not like the name _recv [1] and I did not like his _enqueue/_dequeue suggestion, so I picked a new name (_sent) which nicely aligns with the request state flag.

It also made me realize that the tracepoint in do_read was premature in some error conditions.

Thanks,
Amir.

Changes from v1:
- Rename tracepoint s/_recv/_sent
- Fire in ioruing
- Fire consistently along with setting FR_SENT, which...
- Avoids firing when request is not sent sue to failure

[1] https://lore.kernel.org/fuse-devel/[email protected]/

 fs/fuse/dev.c        |  1 +
 fs/fuse/dev_uring.c  |  6 ++++--
 fs/fuse/fuse_trace.h | 22 ++++++++++++++++++++++
 3 files changed, 27 insertions(+), 2 deletions(-)
fs/fuse/dev.c +1 -0
index 5dda7080f4a90..2ad9aedc6237b 100644
@@ -1525,6 +1525,7 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
 	list_move_tail(&req->list, &fpq->processing[hash]);
 	__fuse_get_request(req);
 	set_bit(FR_SENT, &req->flags);
+	trace_fuse_request_sent(req);
 	spin_unlock(&fpq->lock);
 	/* matches barrier in request_wait_answer() */
 	smp_mb__after_atomic();
fs/fuse/dev_uring.c +4 -2
index 7b9822e8837bc..50f98e9a23a10 100644
@@ -702,10 +702,12 @@ static int fuse_uring_prepare_send(struct fuse_ring_ent *ent,
 	int err;
 
 	err = fuse_uring_copy_to_ring(ent, req);
-	if (!err)
+	if (!err) {
 		set_bit(FR_SENT, &req->flags);
-	else
+		trace_fuse_request_sent(req);
+	} else {
 		fuse_uring_req_end(ent, req, err);
+	}
 
 	return err;
 }
fs/fuse/fuse_trace.h +22 -0
index bbe9ddd8c7169..c912253996b71 100644
@@ -101,6 +101,28 @@ TRACE_EVENT(fuse_request_send,
 		  __print_symbolic(__entry->opcode, OPCODES), __entry->len)
 );
 
+TRACE_EVENT(fuse_request_sent,
+	TP_PROTO(const struct fuse_req *req),
+
+	TP_ARGS(req),
+
+	TP_STRUCT__entry(
+		__field(dev_t,			connection)
+		__field(uint64_t,		unique)
+		__field(enum fuse_opcode,	opcode)
+	),
+
+	TP_fast_assign(
+		__entry->connection	=	req->fm->fc->dev;
+		__entry->unique		=	req->in.h.unique;
+		__entry->opcode		=	req->in.h.opcode;
+	),
+
+	TP_printk("connection %u req %llu opcode %u (%s)",
+		  __entry->connection, __entry->unique, __entry->opcode,
+		  __print_symbolic(__entry->opcode, OPCODES))
+);
+
 TRACE_EVENT(fuse_request_end,
 	TP_PROTO(const struct fuse_req *req),
 
Signature · 1 line
2.54.0
maintainer
#1 lore raw
Quoted 47 lines · Amir Goldstein

This new tracepoint complements the existing fuse_request_send (enqueue) and fuse_request_end (completion) with a tracepoint at the transition of the request from the fiq->pending queue to the FR_SENT state.

The fuse_request_sent fires when a daemon thread reads the request. The fuse_request_sent does not fire if daemon fails to read the request. It also does not fire for forgets and NOTIFY_REPLY, which also do not trigger the _send and _end tracepoints.

This is needed for tools tracking the in-flight state of user initiated fuse requests.

---

Miklos,

On v1 patch review Bernd did not like the name _recv [1] and I did not like his _enqueue/_dequeue suggestion, so I picked a new name (_sent) which nicely aligns with the request state flag.

It also made me realize that the tracepoint in do_read was premature in some error conditions.

Thanks,
Amir.

Changes from v1:
- Rename tracepoint s/_recv/_sent
- Fire in ioruing
- Fire consistently along with setting FR_SENT, which...
- Avoids firing when request is not sent sue to failure

[1] https://lore.kernel.org/fuse-devel/[email protected]/

 fs/fuse/dev.c        |  1 +
 fs/fuse/dev_uring.c  |  6 ++++--
 fs/fuse/fuse_trace.h | 22 ++++++++++++++++++++++
 3 files changed, 27 insertions(+), 2 deletions(-)
fs/fuse/dev.c +0 -0
index 5dda7080f4a90..2ad9aedc6237b 100644

fs/fuse/dev.c static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file, · line 1531

Quoted 7 lines
fs/fuse/dev.c +1 -0
@@ -1525,6 +1525,7 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
        list_move_tail(&req->list, &fpq->processing[hash]);
        __fuse_get_request(req);
        set_bit(FR_SENT, &req->flags);
+       trace_fuse_request_sent(req);
        spin_unlock(&fpq->lock);
        /* matches barrier in request_wait_answer() */
        smp_mb__after_atomic();

What information are you trying to ascertain with the tracing? I think in v1, the placement gave information on how long a request sits on fiq->pending before it gets selected for processing by the kernel (eg the pure queue wait time), whereas now it is bundled together with the time spent doing all the copying to the daemon's buffer. I think having the placement in v1 also gives a clearer estimate of just the copy latency, as on the daemon side you could compare that timestamp with the timestamp of when the read() returns. Is this placement here more useful for your use case than where you originally had it in v1?

Thanks,
Joanne

#2 lore raw
Quoted 44 lines · Joanne Koong
Quoted 42 lines · Amir Goldstein

This new tracepoint complements the existing fuse_request_send (enqueue) and fuse_request_end (completion) with a tracepoint at the transition of the request from the fiq->pending queue to the FR_SENT state.

The fuse_request_sent fires when a daemon thread reads the request. The fuse_request_sent does not fire if daemon fails to read the request. It also does not fire for forgets and NOTIFY_REPLY, which also do not trigger the _send and _end tracepoints.

This is needed for tools tracking the in-flight state of user initiated fuse requests.

---

Miklos,

On v1 patch review Bernd did not like the name _recv [1] and I did not like his _enqueue/_dequeue suggestion, so I picked a new name (_sent) which nicely aligns with the request state flag.

It also made me realize that the tracepoint in do_read was premature in some error conditions.

Thanks,
Amir.

Changes from v1:
- Rename tracepoint s/_recv/_sent
- Fire in ioruing
- Fire consistently along with setting FR_SENT, which...
- Avoids firing when request is not sent sue to failure

[1] https://lore.kernel.org/fuse-devel/[email protected]/

 fs/fuse/dev.c        |  1 +
 fs/fuse/dev_uring.c  |  6 ++++--
 fs/fuse/fuse_trace.h | 22 ++++++++++++++++++++++
 3 files changed, 27 insertions(+), 2 deletions(-)
Quoted 14 lines

fs/fuse/dev.c static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file, · line 1531

Quoted 12 lines
fs/fuse/dev.c +1 -0
index 5dda7080f4a90..2ad9aedc6237b 100644
@@ -1525,6 +1525,7 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
        list_move_tail(&req->list, &fpq->processing[hash]);
        __fuse_get_request(req);
        set_bit(FR_SENT, &req->flags);
+       trace_fuse_request_sent(req);
        spin_unlock(&fpq->lock);
        /* matches barrier in request_wait_answer() */
        smp_mb__after_atomic();

What information are you trying to ascertain with the tracing? I think

Here is a gist of the output of the tool fuseqtop [1]:

FUSE in-flight requests [sorted by total time, 3s interval] — Ctrl-C to stop
CONN OPCODE UNIQUE ST PID COMM
WAIT(ms) SERV(ms)
45 GETXATTR 14 D 3096727 getfattr

     1189.673 129593.636
45     GETXATTR         18                   D   3096730 getfattr
        0.002 129593.636
45     GETXATTR         20                   D   3096746 getfattr
      650.664 128186.420
45     GETXATTR         24                   D   3096762 getfattr
        0.064 128186.420
45     GETXATTR         28                   D   3097736 getfattr
     2255.352  46739.455
45     GETXATTR         30                   D   3097753 getfattr
     1463.358  46739.455
45     GETXATTR         34                   D   3097773 getfattr
      730.723  46739.455
45     GETXATTR         36                   D   3097790 getfattr
        0.016  46739.455
45     GETXATTR         40                   D   3097812 getfattr
      785.307  42250.883
45     GETXATTR         42                   D   3097835 getfattr
        0.014  42250.883
45     GETATTR          44                   Q   3097852 getfattr
    41411.019          -
45     GETATTR          46                   Q   3098339 df
     9951.074          -
45     GETATTR          48                   Q   3098368 df
     8556.918          -

[1] https://github.com/amir73il/bcc/commits/fuseq/

This is a depiction of a saturated fuse requests queue.
Without the trace_fuse_request_sent() tracepoints the tool can guess but not reliably ascertain the dequeue time.

Quoted 8 lines

in v1, the placement gave information on how long a request sits on fiq->pending before it gets selected for processing by the kernel (eg the pure queue wait time), whereas now it is bundled together with the time spent doing all the copying to the daemon's buffer. I think having the placement in v1 also gives a clearer estimate of just the copy latency, as on the daemon side you could compare that timestamp with the timestamp of when the read() returns. Is this placement here more useful for your use case than where you originally had it in v1?

I had not considered measuring the copy time at all.
My workloads are dealing with other orders of magnitude for serving time when serving non-passthrough files from the cloud.

So for my purpose the placing of the tracepoint _sent at this location is a good fit.

If others feel that a "start sending" (or whatever we call this) is also valuable then I think we can add it later if needed.

Thanks,
Amir.

maintainer Reviewed-by
#3 lore raw
Quoted 8 lines · Amir Goldstein
Quoted 6 lines · Joanne Koong
Quoted 4 lines · Amir Goldstein

This new tracepoint complements the existing fuse_request_send (enqueue) and fuse_request_end (completion) with a tracepoint at the transition of the request from the fiq->pending queue to the FR_SENT state.

nit: the io-uring path doesn't have a fiq->pending queue, so maybe better to just not mention fiq->pending here. perhaps the wording below for "when a daemon thread reads the request" could be made more generalized as well

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

The fuse_request_sent fires when a daemon thread reads the request. The fuse_request_sent does not fire if daemon fails to read the request. It also does not fire for forgets and NOTIFY_REPLY, which also do not trigger the _send and _end tracepoints.

btw, from what I see, the _send and _end tracepoints do get triggered by NOTIFY_REPLY

Quoted 95 lines
Quoted 33 lines
Quoted 33 lines

This is needed for tools tracking the in-flight state of user initiated fuse requests.

---

Miklos,

On v1 patch review Bernd did not like the name _recv [1] and I did not like his _enqueue/_dequeue suggestion, so I picked a new name (_sent) which nicely aligns with the request state flag.

It also made me realize that the tracepoint in do_read was premature in some error conditions.

Thanks,
Amir.

Changes from v1:
- Rename tracepoint s/_recv/_sent
- Fire in ioruing
- Fire consistently along with setting FR_SENT, which...
- Avoids firing when request is not sent sue to failure

[1] https://lore.kernel.org/fuse-devel/[email protected]/

 fs/fuse/dev.c        |  1 +
 fs/fuse/dev_uring.c  |  6 ++++--
 fs/fuse/fuse_trace.h | 22 ++++++++++++++++++++++
 3 files changed, 27 insertions(+), 2 deletions(-)
Quoted 14 lines

fs/fuse/dev.c static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file, · line 1531

Quoted 12 lines
fs/fuse/dev.c +1 -0
index 5dda7080f4a90..2ad9aedc6237b 100644
@@ -1525,6 +1525,7 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
        list_move_tail(&req->list, &fpq->processing[hash]);
        __fuse_get_request(req);
        set_bit(FR_SENT, &req->flags);
+       trace_fuse_request_sent(req);
        spin_unlock(&fpq->lock);
        /* matches barrier in request_wait_answer() */
        smp_mb__after_atomic();

What information are you trying to ascertain with the tracing? I think

Here is a gist of the output of the tool fuseqtop [1]:

FUSE in-flight requests [sorted by total time, 3s interval] — Ctrl-C to stop
CONN OPCODE UNIQUE ST PID COMM
WAIT(ms) SERV(ms)
45 GETXATTR 14 D 3096727 getfattr

     1189.673 129593.636
45     GETXATTR         18                   D   3096730 getfattr
        0.002 129593.636
45     GETXATTR         20                   D   3096746 getfattr
      650.664 128186.420
45     GETXATTR         24                   D   3096762 getfattr
        0.064 128186.420
45     GETXATTR         28                   D   3097736 getfattr
     2255.352  46739.455
45     GETXATTR         30                   D   3097753 getfattr
     1463.358  46739.455
45     GETXATTR         34                   D   3097773 getfattr
      730.723  46739.455
45     GETXATTR         36                   D   3097790 getfattr
        0.016  46739.455
45     GETXATTR         40                   D   3097812 getfattr
      785.307  42250.883
45     GETXATTR         42                   D   3097835 getfattr
        0.014  42250.883
45     GETATTR          44                   Q   3097852 getfattr
    41411.019          -
45     GETATTR          46                   Q   3098339 df
     9951.074          -
45     GETATTR          48                   Q   3098368 df
     8556.918          -

[1] https://github.com/amir73il/bcc/commits/fuseq/

This is a depiction of a saturated fuse requests queue.
Without the trace_fuse_request_sent() tracepoints the tool can guess but not reliably ascertain the dequeue time.

Quoted 8 lines

in v1, the placement gave information on how long a request sits on fiq->pending before it gets selected for processing by the kernel (eg the pure queue wait time), whereas now it is bundled together with the time spent doing all the copying to the daemon's buffer. I think having the placement in v1 also gives a clearer estimate of just the copy latency, as on the daemon side you could compare that timestamp with the timestamp of when the read() returns. Is this placement here more useful for your use case than where you originally had it in v1?

Quoted 6 lines

I had not considered measuring the copy time at all.
My workloads are dealing with other orders of magnitude for serving time when serving non-passthrough files from the cloud.

So for my purpose the placing of the tracepoint _sent at this location is a good fit.

Gotcha, that makes sense to me, thanks for the details.

Quoted 6 lines

If others feel that a "start sending" (or whatever we call this) is also valuable then I think we can add it later if needed.

Thanks,
Amir.

#4 lore raw
Quoted 7 lines · Joanne Koong
Quoted 5 lines · Amir Goldstein
Quoted 3 lines · Joanne Koong
Quoted 1 line · Amir Goldstein
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

This new tracepoint complements the existing fuse_request_send (enqueue) and fuse_request_end (completion) with a tracepoint at the transition of the request from the fiq->pending queue to the FR_SENT state.

nit: the io-uring path doesn't have a fiq->pending queue, so maybe better to just not mention fiq->pending here. perhaps the wording below for "when a daemon thread reads the request" could be made more generalized as well

Fair enough, how about:

This new tracepoint complements fuse_request_send (enqueue) and fuse_request_end (completion). It fires after the request has been successfully copied to the daemon's buffer, just before the daemon can start to process it.

Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

The fuse_request_sent fires when a daemon thread reads the request. The fuse_request_sent does not fire if daemon fails to read the request. It also does not fire for forgets and NOTIFY_REPLY, which also do not trigger the _send and _end tracepoints.

btw, from what I see, the _send and _end tracepoints do get triggered by NOTIFY_REPLY

Doh! I meant that forgets do not trigger the old tracepoints.

FUSE_NOTIFY_REPLY is awkward, because it triggers _end right where the "normal direction" requests trigger to _sent tracepoint would be and fwiw FUSE_NOTIFY_REPLY does not set the FR_SENT flag.
Having these two tracepoints (_sent and _end) with the same timestamp and pid do not add much value to tracing tools IMO.

So I could rephrase this:

fuse_request_sent does not fire if the copy of the request fails. It also does not fire for NOTIFY_REPLY, which fires the _end tracepoint at the end of copy.

...

Quoted 11 lines
Quoted 6 lines

I had not considered measuring the copy time at all.
My workloads are dealing with other orders of magnitude for serving time when serving non-passthrough files from the cloud.

So for my purpose the placing of the tracepoint _sent at this location is a good fit.

Gotcha, that makes sense to me, thanks for the details.

Here is the recap of amended commit message if you wish to reaffirm your RVB:

fuse: add fuse_request_sent tracepoint

This new tracepoint complements fuse_request_send (enqueue) and fuse_request_end (completion). It fires after the request has been successfully copied to the daemon's buffer, just before the daemon can start to process it.

fuse_request_sent does not fire if the copy of the request fails. It also does not fire for NOTIFY_REPLY, which fires the _end tracepoint at the end of copy.

This is needed for tools tracking the in-flight state of user initiated fuse requests.

Thanks for the review!
Amir.

maintainer Reviewed-by
#5 lore raw
Quoted 73 lines · Amir Goldstein
Quoted 7 lines · Joanne Koong
Quoted 5 lines · Amir Goldstein
Quoted 3 lines · Joanne Koong
Quoted 1 line · Amir Goldstein
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

This new tracepoint complements the existing fuse_request_send (enqueue) and fuse_request_end (completion) with a tracepoint at the transition of the request from the fiq->pending queue to the FR_SENT state.

nit: the io-uring path doesn't have a fiq->pending queue, so maybe better to just not mention fiq->pending here. perhaps the wording below for "when a daemon thread reads the request" could be made more generalized as well

Fair enough, how about:

This new tracepoint complements fuse_request_send (enqueue) and fuse_request_end (completion). It fires after the request has been successfully copied to the daemon's buffer, just before the daemon can start to process it.

Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

The fuse_request_sent fires when a daemon thread reads the request. The fuse_request_sent does not fire if daemon fails to read the request. It also does not fire for forgets and NOTIFY_REPLY, which also do not trigger the _send and _end tracepoints.

btw, from what I see, the _send and _end tracepoints do get triggered by NOTIFY_REPLY

Doh! I meant that forgets do not trigger the old tracepoints.

FUSE_NOTIFY_REPLY is awkward, because it triggers _end right where the "normal direction" requests trigger to _sent tracepoint would be and fwiw FUSE_NOTIFY_REPLY does not set the FR_SENT flag.
Having these two tracepoints (_sent and _end) with the same timestamp and pid do not add much value to tracing tools IMO.

So I could rephrase this:

fuse_request_sent does not fire if the copy of the request fails. It also does not fire for NOTIFY_REPLY, which fires the _end tracepoint at the end of copy.

...

Quoted 11 lines
Quoted 6 lines

I had not considered measuring the copy time at all.
My workloads are dealing with other orders of magnitude for serving time when serving non-passthrough files from the cloud.

So for my purpose the placing of the tracepoint _sent at this location is a good fit.

Gotcha, that makes sense to me, thanks for the details.

Here is the recap of amended commit message if you wish to reaffirm your RVB:

fuse: add fuse_request_sent tracepoint

This new tracepoint complements fuse_request_send (enqueue) and fuse_request_end (completion). It fires after the request has been successfully copied to the daemon's buffer, just before the daemon can start to process it.

Quoted 7 lines

fuse_request_sent does not fire if the copy of the request fails. It also does not fire for NOTIFY_REPLY, which fires the _end tracepoint at the end of copy.

This is needed for tools tracking the in-flight state of user initiated fuse requests.

This looks good to me.

Thanks,
Joanne

Quoted 3 lines

Thanks for the review!
Amir.

maintainer Applied
#6 lore raw
In reply to Amir Goldstein
Quoted 7 lines · Amir Goldstein

fuse: add fuse_request_sent tracepoint

This new tracepoint complements fuse_request_send (enqueue) and fuse_request_end (completion). It fires after the request has been successfully copied to the daemon's buffer, just before the daemon can start to process it.

Quoted 6 lines

fuse_request_sent does not fire if the copy of the request fails. It also does not fire for NOTIFY_REPLY, which fires the _end tracepoint at the end of copy.

This is needed for tools tracking the in-flight state of user initiated fuse requests.

Applied, thanks.

Miklos