Skip to contentSkip to conversation

fuse: add fuse_request_recv tracepoint

PATCH Superseded Amir Goldstein 3 participants 9 messages May 27 – May 31

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fuse: add fuse_request_recv tracepoint

This new tracepoint complements the existing fuse_request_send (enqueue) and fuse_request_end (completion) with a tracepoint at the transition from "pending" to "in-progress" at the moment a daemon thread dequeues a request from fiq->pending.

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

---

Miklos,

This patch is not technically a fix patch, but it complements the tracepoints that were added in 6.12 by commit 396b209e405a5 ("fuse: add simple request tracepoints"), so it is my intention to backport it up to 6.12.y for use on production kernels.

I came across the need for this tracepoint when working on fuse queue monitoring tools [1] for our production env.

The fuse_request_send tracepoint is broken on 6.12.y, so I also plan to post a backport patch for 0d375a1385ed8 ("fuse: capture the unique id of fuse commands being sent"). Not sure why it was not tagged as Fixes. The existence of fuse_request_recv

This patch is intentionally based on upstream fuse (v7.1-rc2) and not on for-next branch, with ease of backport in mind.

Specifically, commit 80cea98b648ba ("fuse: change req->fm to req->chan") on for-next needs to apply the same change to the new tracepoint as well.

Would you consider applying this patch at the bottom of for-next and make this adjustment to your refactoring commit?

Thanks,
Amir.

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

 fs/fuse/dev.c        |  1 +
 fs/fuse/fuse_trace.h | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)
fs/fuse/dev.c +1 -0
index 5dda7080f4a90..583155157d117 100644
@@ -1475,6 +1475,7 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
 	req = list_entry(fiq->pending.next, struct fuse_req, list);
 	clear_bit(FR_PENDING, &req->flags);
 	list_del_init(&req->list);
+	trace_fuse_request_recv(req);
 	spin_unlock(&fiq->lock);
 
 	args = req->args;
fs/fuse/fuse_trace.h +22 -0
index bbe9ddd8c7169..289a279b3c312 100644
@@ -101,6 +101,28 @@ TRACE_EVENT(fuse_request_send,
 		  __print_symbolic(__entry->opcode, OPCODES), __entry->len)
 );
 
+TRACE_EVENT(fuse_request_recv,
+	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
#1 lore raw
Quoted 18 lines · Amir Goldstein

This new tracepoint complements the existing fuse_request_send (enqueue) and fuse_request_end (completion) with a tracepoint at the transition from "pending" to "in-progress" at the moment a daemon thread dequeues a request from fiq->pending.

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

---

Miklos,

This patch is not technically a fix patch, but it complements the tracepoints that were added in 6.12 by commit 396b209e405a5 ("fuse: add simple request tracepoints"), so it is my intention to backport it up to 6.12.y for use on production kernels.

Quoted 7 lines

I came across the need for this tracepoint when working on fuse queue monitoring tools [1] for our production env.

The fuse_request_send tracepoint is broken on 6.12.y, so I also plan to post a backport patch for 0d375a1385ed8 ("fuse: capture the unique id of fuse commands being sent"). Not sure why it was not tagged as Fixes. The existence of fuse_request_recv

... in an LTS kernel will serve as a hint that the fuse_request_send tracepoint isn't broken...

Quoted 67 lines

This patch is intentionally based on upstream fuse (v7.1-rc2) and not on for-next branch, with ease of backport in mind.

Specifically, commit 80cea98b648ba ("fuse: change req->fm to req->chan") on for-next needs to apply the same change to the new tracepoint as well.

Would you consider applying this patch at the bottom of for-next and make this adjustment to your refactoring commit?

Thanks,
Amir.

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

 fs/fuse/dev.c        |  1 +
 fs/fuse/fuse_trace.h | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)
fs/fuse/dev.c +1 -0
index 5dda7080f4a90..583155157d117 100644
@@ -1475,6 +1475,7 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
        req = list_entry(fiq->pending.next, struct fuse_req, list);
        clear_bit(FR_PENDING, &req->flags);
        list_del_init(&req->list);
+       trace_fuse_request_recv(req);
        spin_unlock(&fiq->lock);
 
        args = req->args;
fs/fuse/fuse_trace.h +22 -1
index bbe9ddd8c7169..289a279b3c312 100644
@@ -101,6 +101,28 @@ TRACE_EVENT(fuse_request_send,
                  __print_symbolic(__entry->opcode, OPCODES), __entry->len)
 );
 
+TRACE_EVENT(fuse_request_recv,
+       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),
 
--

2.54.0

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Amir Goldstein
Quoted 9 lines · Amir Goldstein

This new tracepoint complements the existing fuse_request_send (enqueue) and fuse_request_end (completion) with a tracepoint at the transition from "pending" to "in-progress" at the moment a daemon thread dequeues a request from fiq->pending.

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

Reviewed-by on v1 1/1
#3 lore raw
In reply to Amir Goldstein
Quoted 78 lines · Amir Goldstein

This new tracepoint complements the existing fuse_request_send (enqueue) and fuse_request_end (completion) with a tracepoint at the transition from "pending" to "in-progress" at the moment a daemon thread dequeues a request from fiq->pending.

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

---

Miklos,

This patch is not technically a fix patch, but it complements the tracepoints that were added in 6.12 by commit 396b209e405a5 ("fuse: add simple request tracepoints"), so it is my intention to backport it up to 6.12.y for use on production kernels.

I came across the need for this tracepoint when working on fuse queue monitoring tools [1] for our production env.

The fuse_request_send tracepoint is broken on 6.12.y, so I also plan to post a backport patch for 0d375a1385ed8 ("fuse: capture the unique id of fuse commands being sent"). Not sure why it was not tagged as Fixes. The existence of fuse_request_recv

This patch is intentionally based on upstream fuse (v7.1-rc2) and not on for-next branch, with ease of backport in mind.

Specifically, commit 80cea98b648ba ("fuse: change req->fm to req->chan") on for-next needs to apply the same change to the new tracepoint as well.

Would you consider applying this patch at the bottom of for-next and make this adjustment to your refactoring commit?

Thanks,
Amir.

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

 fs/fuse/dev.c        |  1 +
 fs/fuse/fuse_trace.h | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)
fs/fuse/dev.c +1 -0
index 5dda7080f4a90..583155157d117 100644
@@ -1475,6 +1475,7 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
 	req = list_entry(fiq->pending.next, struct fuse_req, list);
 	clear_bit(FR_PENDING, &req->flags);
 	list_del_init(&req->list);
+	trace_fuse_request_recv(req);
 	spin_unlock(&fiq->lock);
 
 	args = req->args;
fs/fuse/fuse_trace.h +15 -0
index bbe9ddd8c7169..289a279b3c312 100644
@@ -101,6 +101,28 @@ TRACE_EVENT(fuse_request_send,
 		  __print_symbolic(__entry->opcode, OPCODES), __entry->len)
 );
 
+TRACE_EVENT(fuse_request_recv,
+	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;

fs/fuse/fuse_trace.h TRACE_EVENT(fuse_request_send, · line 128

Quoted 10 lines
fs/fuse/fuse_trace.h +7 -0
+	),
+
+	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),
 

I find the name 'fuse_request_recv' a bit confusing. Why not 'fuse_request_read'?

#4 lore raw
Quoted 87 lines · Bernd Schubert
Quoted 83 lines · Amir Goldstein

This new tracepoint complements the existing fuse_request_send (enqueue) and fuse_request_end (completion) with a tracepoint at the transition from "pending" to "in-progress" at the moment a daemon thread dequeues a request from fiq->pending.

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

---

Miklos,

This patch is not technically a fix patch, but it complements the tracepoints that were added in 6.12 by commit 396b209e405a5 ("fuse: add simple request tracepoints"), so it is my intention to backport it up to 6.12.y for use on production kernels.

I came across the need for this tracepoint when working on fuse queue monitoring tools [1] for our production env.

The fuse_request_send tracepoint is broken on 6.12.y, so I also plan to post a backport patch for 0d375a1385ed8 ("fuse: capture the unique id of fuse commands being sent"). Not sure why it was not tagged as Fixes. The existence of fuse_request_recv

This patch is intentionally based on upstream fuse (v7.1-rc2) and not on for-next branch, with ease of backport in mind.

Specifically, commit 80cea98b648ba ("fuse: change req->fm to req->chan") on for-next needs to apply the same change to the new tracepoint as well.

Would you consider applying this patch at the bottom of for-next and make this adjustment to your refactoring commit?

Thanks,
Amir.

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

 fs/fuse/dev.c        |  1 +
 fs/fuse/fuse_trace.h | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)
fs/fuse/dev.c +1 -0
index 5dda7080f4a90..583155157d117 100644
@@ -1475,6 +1475,7 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
      req = list_entry(fiq->pending.next, struct fuse_req, list);
      clear_bit(FR_PENDING, &req->flags);
      list_del_init(&req->list);
+     trace_fuse_request_recv(req);
      spin_unlock(&fiq->lock);
 
      args = req->args;
fs/fuse/fuse_trace.h +20 -0
index bbe9ddd8c7169..289a279b3c312 100644
@@ -101,6 +101,28 @@ TRACE_EVENT(fuse_request_send,
                __print_symbolic(__entry->opcode, OPCODES), __entry->len)
 );
 
+TRACE_EVENT(fuse_request_recv,
+     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))
Quoted 8 lines

fs/fuse/fuse_trace.h TRACE_EVENT(fuse_request_send, · line 128

Quoted 5 lines
fs/fuse/fuse_trace.h +2 -0
+);
+
 TRACE_EVENT(fuse_request_end,
      TP_PROTO(const struct fuse_req *req),
 

I find the name 'fuse_request_recv' a bit confusing. Why not 'fuse_request_read'?

Well, to balance fuse_request_send of course ;)

I'll note that _read() is not adequate for iouring, which bares the question, should we also add a tracepoint at iouring dispatch:

fs/fuse/dev_uring.c +0 -0
index 7b9822e8837bc..97cb990bf9de3 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_recv(req);
+       } else {
                fuse_uring_req_end(ent, req, err);

+ }

        return err;

}

Not sure which pid will be traced here? the libfuse queue worker thread pid? Is that meaningful to someone?

Another option for a tracepoint name, looking at the above would be trace_fuse_request_sent()

But I would not change the name until anyone insists.

Thanks,
Amir.

#5 lore raw
Quoted 124 lines · Amir Goldstein
Quoted 87 lines · Bernd Schubert
Quoted 83 lines · Amir Goldstein

This new tracepoint complements the existing fuse_request_send (enqueue) and fuse_request_end (completion) with a tracepoint at the transition from "pending" to "in-progress" at the moment a daemon thread dequeues a request from fiq->pending.

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

---

Miklos,

This patch is not technically a fix patch, but it complements the tracepoints that were added in 6.12 by commit 396b209e405a5 ("fuse: add simple request tracepoints"), so it is my intention to backport it up to 6.12.y for use on production kernels.

I came across the need for this tracepoint when working on fuse queue monitoring tools [1] for our production env.

The fuse_request_send tracepoint is broken on 6.12.y, so I also plan to post a backport patch for 0d375a1385ed8 ("fuse: capture the unique id of fuse commands being sent"). Not sure why it was not tagged as Fixes. The existence of fuse_request_recv

This patch is intentionally based on upstream fuse (v7.1-rc2) and not on for-next branch, with ease of backport in mind.

Specifically, commit 80cea98b648ba ("fuse: change req->fm to req->chan") on for-next needs to apply the same change to the new tracepoint as well.

Would you consider applying this patch at the bottom of for-next and make this adjustment to your refactoring commit?

Thanks,
Amir.

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

 fs/fuse/dev.c        |  1 +
 fs/fuse/fuse_trace.h | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)
fs/fuse/dev.c +1 -0
index 5dda7080f4a90..583155157d117 100644
@@ -1475,6 +1475,7 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
      req = list_entry(fiq->pending.next, struct fuse_req, list);
      clear_bit(FR_PENDING, &req->flags);
      list_del_init(&req->list);
+     trace_fuse_request_recv(req);
      spin_unlock(&fiq->lock);
 
      args = req->args;
fs/fuse/fuse_trace.h +20 -0
index bbe9ddd8c7169..289a279b3c312 100644
@@ -101,6 +101,28 @@ TRACE_EVENT(fuse_request_send,
                __print_symbolic(__entry->opcode, OPCODES), __entry->len)
 );
 
+TRACE_EVENT(fuse_request_recv,
+     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))
Quoted 8 lines

fs/fuse/fuse_trace.h TRACE_EVENT(fuse_request_send, · line 128

Quoted 5 lines
fs/fuse/fuse_trace.h +2 -0
+);
+
 TRACE_EVENT(fuse_request_end,
      TP_PROTO(const struct fuse_req *req),
 

I find the name 'fuse_request_recv' a bit confusing. Why not 'fuse_request_read'?

Well, to balance fuse_request_send of course ;)

I'll note that _read() is not adequate for iouring, which bares the question, should we also add a tracepoint at iouring dispatch:

fs/fuse/dev_uring.c +4 -2
index 7b9822e8837bc..97cb990bf9de3 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_recv(req);
+       } else {
                fuse_uring_req_end(ent, req, err);
+       }
 
        return err;

}

Quoted 8 lines

Not sure which pid will be traced here? the libfuse queue worker thread pid? Is that meaningful to someone?

Another option for a tracepoint name, looking at the above would be trace_fuse_request_sent()

But I would not change the name until anyone insists.

So the sad part is that I had done all of that

https://lore.kernel.org/all/[email protected]/

However, I had noticed that we take the fiq lock just to increase the request unique, changed it to an atomic and then Miklos asked to change it to a per CPU counter. That got complex with per-cpu, the updated series had bugs, new unpublished versions maybe did not have anymore, but I didn't have time to test and triple verify the complexity. Then Darrick also changed traces - I had even less time to fix conflicts - there were are. From todays point of view, I just should pushed back for the atomic change, we now still have the worse spin lock and incomplete traces.

Thanks,
Bernd

#6 lore raw
In reply to Amir Goldstein
Quoted 98 lines · Amir Goldstein
Quoted 87 lines · Bernd Schubert
Quoted 83 lines · Amir Goldstein

This new tracepoint complements the existing fuse_request_send (enqueue) and fuse_request_end (completion) with a tracepoint at the transition from "pending" to "in-progress" at the moment a daemon thread dequeues a request from fiq->pending.

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

---

Miklos,

This patch is not technically a fix patch, but it complements the tracepoints that were added in 6.12 by commit 396b209e405a5 ("fuse: add simple request tracepoints"), so it is my intention to backport it up to 6.12.y for use on production kernels.

I came across the need for this tracepoint when working on fuse queue monitoring tools [1] for our production env.

The fuse_request_send tracepoint is broken on 6.12.y, so I also plan to post a backport patch for 0d375a1385ed8 ("fuse: capture the unique id of fuse commands being sent"). Not sure why it was not tagged as Fixes. The existence of fuse_request_recv

This patch is intentionally based on upstream fuse (v7.1-rc2) and not on for-next branch, with ease of backport in mind.

Specifically, commit 80cea98b648ba ("fuse: change req->fm to req->chan") on for-next needs to apply the same change to the new tracepoint as well.

Would you consider applying this patch at the bottom of for-next and make this adjustment to your refactoring commit?

Thanks,
Amir.

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

 fs/fuse/dev.c        |  1 +
 fs/fuse/fuse_trace.h | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)
fs/fuse/dev.c +1 -0
index 5dda7080f4a90..583155157d117 100644
@@ -1475,6 +1475,7 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
      req = list_entry(fiq->pending.next, struct fuse_req, list);
      clear_bit(FR_PENDING, &req->flags);
      list_del_init(&req->list);
+     trace_fuse_request_recv(req);
      spin_unlock(&fiq->lock);
 
      args = req->args;
fs/fuse/fuse_trace.h +20 -0
index bbe9ddd8c7169..289a279b3c312 100644
@@ -101,6 +101,28 @@ TRACE_EVENT(fuse_request_send,
                __print_symbolic(__entry->opcode, OPCODES), __entry->len)
 );
 
+TRACE_EVENT(fuse_request_recv,
+     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))
Quoted 8 lines

fs/fuse/fuse_trace.h TRACE_EVENT(fuse_request_send, · line 128

Quoted 5 lines
fs/fuse/fuse_trace.h +2 -0
+);
+
 TRACE_EVENT(fuse_request_end,
      TP_PROTO(const struct fuse_req *req),
 

I find the name 'fuse_request_recv' a bit confusing. Why not 'fuse_request_read'?

Quoted 1 line

Well, to balance fuse_request_send of course ;)

Reading my own patch:

Rename trace_fuse_request_send to trace_fuse_request_enqueue Add trace_fuse_request_send
Add trace_fuse_request_bg_enqueue
Add trace_fuse_request_enqueue

with

fs/fuse/dev.c +0 -0

index 1ccf5a9c61ae2b11bc1d0b799c08e6da908a9782..8e1a95f80e5454d1351ecb90beacbb35779731bb 100644

fs/fuse/dev.c +0 -0
@@ -281,7 +281,9 @@ static void fuse_send_one(struct fuse_iqueue *fiq,

struct fuse_req *req)
req->in.h.len = sizeof(struct fuse_in_header) +
fuse_len_args(req->args->in_numargs,
(struct fuse_arg *) req->args->in_args);
- trace_fuse_request_send(req);
+
+ /* enqueue, as it is send to "fiq->ops queue" */
+ trace_fuse_request_enqueue(req);
fiq->ops->send_req(fiq, req);
}

@@ -580,6 +582,8 @@ static int fuse_request_queue_background(struct fuse_req *req)
}
__set_bit(FR_ISREPLY, &req->flags);

+ trace_fuse_request_bg_enqueue(req);
+

@@ -1314,6 +1318,7 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
clear_bit(FR_PENDING, &req->flags); list_del_init(&req->list); spin_unlock(&fiq->lock);
+ trace_fuse_request_send(req);

args = req->args;
reqsize = req->in.h.len;

IMHO, trace_fuse_request_enqueue / trace_fuse_request_bg_enqueue for adding to the queue and trace_fuse_request_send for reading/handling the request is less confusing.

Thanks,
Bernd

#7 lore raw
Quoted 102 lines · Bernd Schubert
Quoted 98 lines · Amir Goldstein
Quoted 95 lines · Bernd Schubert
Quoted 78 lines · Amir Goldstein

This new tracepoint complements the existing fuse_request_send (enqueue) and fuse_request_end (completion) with a tracepoint at the transition from "pending" to "in-progress" at the moment a daemon thread dequeues a request from fiq->pending.

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

---

Miklos,

This patch is not technically a fix patch, but it complements the tracepoints that were added in 6.12 by commit 396b209e405a5 ("fuse: add simple request tracepoints"), so it is my intention to backport it up to 6.12.y for use on production kernels.

I came across the need for this tracepoint when working on fuse queue monitoring tools [1] for our production env.

The fuse_request_send tracepoint is broken on 6.12.y, so I also plan to post a backport patch for 0d375a1385ed8 ("fuse: capture the unique id of fuse commands being sent"). Not sure why it was not tagged as Fixes. The existence of fuse_request_recv

This patch is intentionally based on upstream fuse (v7.1-rc2) and not on for-next branch, with ease of backport in mind.

Specifically, commit 80cea98b648ba ("fuse: change req->fm to req->chan") on for-next needs to apply the same change to the new tracepoint as well.

Would you consider applying this patch at the bottom of for-next and make this adjustment to your refactoring commit?

Thanks,
Amir.

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

 fs/fuse/dev.c        |  1 +
 fs/fuse/fuse_trace.h | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)
fs/fuse/dev.c +1 -0
index 5dda7080f4a90..583155157d117 100644
@@ -1475,6 +1475,7 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
      req = list_entry(fiq->pending.next, struct fuse_req, list);
      clear_bit(FR_PENDING, &req->flags);
      list_del_init(&req->list);
+     trace_fuse_request_recv(req);
      spin_unlock(&fiq->lock);
 
      args = req->args;
fs/fuse/fuse_trace.h +15 -0
index bbe9ddd8c7169..289a279b3c312 100644
@@ -101,6 +101,28 @@ TRACE_EVENT(fuse_request_send,
                __print_symbolic(__entry->opcode, OPCODES), __entry->len)
 );
 
+TRACE_EVENT(fuse_request_recv,
+     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;

fs/fuse/fuse_trace.h TRACE_EVENT(fuse_request_send, · line 128

Quoted 10 lines
fs/fuse/fuse_trace.h +7 -0
+     ),
+
+     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),
 

I find the name 'fuse_request_recv' a bit confusing. Why not 'fuse_request_read'?

Quoted 5 lines
Quoted 1 line

Well, to balance fuse_request_send of course ;)

Reading my own patch:

Rename trace_fuse_request_send to trace_fuse_request_enqueue

IDGI. I don't see the value of this name change
Darick already fixed the _send() tracepoints in 6.18
and I see to reason to change them and break existing tracing scripts unless there is a really good reason to do so.

Quoted 13 lines

Add trace_fuse_request_send
Add trace_fuse_request_bg_enqueue
Add trace_fuse_request_enqueue

with

fs/fuse/dev.c +0 -0

index 1ccf5a9c61ae2b11bc1d0b799c08e6da908a9782..8e1a95f80e5454d1351ecb90beacbb35779731bb 100644

fs/fuse/dev.c static void fuse_send_one(struct fuse_iqueue *fiq, · line 287

Quoted 8 lines
fs/fuse/dev.c +3 -1
@@ -281,7 +281,9 @@ static void fuse_send_one(struct fuse_iqueue *fiq,
 struct fuse_req *req)
        req->in.h.len = sizeof(struct fuse_in_header) +
                fuse_len_args(req->args->in_numargs,
                              (struct fuse_arg *) req->args->in_args);
-       trace_fuse_request_send(req);
+
+       /* enqueue, as it is send to "fiq->ops queue" */
+       trace_fuse_request_enqueue(req);

Looks like this patch is based on old code?

fs/fuse/dev.c static int fuse_request_queue_background(struct · line 587

Quoted 10 lines
fs/fuse/dev.c +2 -0
        fiq->ops->send_req(fiq, req);
 }
@@ -580,6 +582,8 @@ static int fuse_request_queue_background(struct
 fuse_req *req)
        }
        __set_bit(FR_ISREPLY, &req->flags);
 
+       trace_fuse_request_bg_enqueue(req);
+

Is this path not handled in current upstream code?

Quoted 12 lines
fs/fuse/dev.c +1 -0
@@ -1314,6 +1318,7 @@ static ssize_t fuse_dev_do_read(struct fuse_dev
 *fud, struct file *file,
        clear_bit(FR_PENDING, &req->flags);
        list_del_init(&req->list);
        spin_unlock(&fiq->lock);
+       trace_fuse_request_send(req);
 
        args = req->args;
        reqsize = req->in.h.len;
Quoted 3 lines

IMHO, trace_fuse_request_enqueue / trace_fuse_request_bg_enqueue for adding to the queue and trace_fuse_request_send for reading/handling the request is less confusing.

Potato potato
enqueue->send / send->recv
There will be arguments for and against any names we pick I don't think that the name matters a lot here as long as the required information is provided to tracing tools

My question was, regarding fuse_uring_prepare_send(),
do we need a _recv()/_send()/_fetch()/_whatnot()
tracepoint in this code point and whether the pid reported in this tracepoint is useful. Is it the libfuse worker thread or something else?

Thanks,
Amir.

#8 lore raw
Quoted 130 lines · Amir Goldstein
Quoted 102 lines · Bernd Schubert
Quoted 98 lines · Amir Goldstein
Quoted 95 lines · Bernd Schubert
Quoted 78 lines · Amir Goldstein

This new tracepoint complements the existing fuse_request_send (enqueue) and fuse_request_end (completion) with a tracepoint at the transition from "pending" to "in-progress" at the moment a daemon thread dequeues a request from fiq->pending.

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

---

Miklos,

This patch is not technically a fix patch, but it complements the tracepoints that were added in 6.12 by commit 396b209e405a5 ("fuse: add simple request tracepoints"), so it is my intention to backport it up to 6.12.y for use on production kernels.

I came across the need for this tracepoint when working on fuse queue monitoring tools [1] for our production env.

The fuse_request_send tracepoint is broken on 6.12.y, so I also plan to post a backport patch for 0d375a1385ed8 ("fuse: capture the unique id of fuse commands being sent"). Not sure why it was not tagged as Fixes. The existence of fuse_request_recv

This patch is intentionally based on upstream fuse (v7.1-rc2) and not on for-next branch, with ease of backport in mind.

Specifically, commit 80cea98b648ba ("fuse: change req->fm to req->chan") on for-next needs to apply the same change to the new tracepoint as well.

Would you consider applying this patch at the bottom of for-next and make this adjustment to your refactoring commit?

Thanks,
Amir.

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

 fs/fuse/dev.c        |  1 +
 fs/fuse/fuse_trace.h | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)
fs/fuse/dev.c +1 -0
index 5dda7080f4a90..583155157d117 100644
@@ -1475,6 +1475,7 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
      req = list_entry(fiq->pending.next, struct fuse_req, list);
      clear_bit(FR_PENDING, &req->flags);
      list_del_init(&req->list);
+     trace_fuse_request_recv(req);
      spin_unlock(&fiq->lock);
 
      args = req->args;
fs/fuse/fuse_trace.h +15 -0
index bbe9ddd8c7169..289a279b3c312 100644
@@ -101,6 +101,28 @@ TRACE_EVENT(fuse_request_send,
                __print_symbolic(__entry->opcode, OPCODES), __entry->len)
 );
 
+TRACE_EVENT(fuse_request_recv,
+     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;

fs/fuse/fuse_trace.h TRACE_EVENT(fuse_request_send, · line 128

Quoted 10 lines
fs/fuse/fuse_trace.h +7 -0
+     ),
+
+     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),
 

I find the name 'fuse_request_recv' a bit confusing. Why not 'fuse_request_read'?

Quoted 5 lines
Quoted 1 line

Well, to balance fuse_request_send of course ;)

Reading my own patch:

Rename trace_fuse_request_send to trace_fuse_request_enqueue

IDGI. I don't see the value of this name change
Darick already fixed the _send() tracepoints in 6.18
and I see to reason to change them and break existing tracing scripts unless there is a really good reason to do so.

Quoted 15 lines

Add trace_fuse_request_send
Add trace_fuse_request_bg_enqueue
Add trace_fuse_request_enqueue

with

fs/fuse/dev.c +0 -0

index 1ccf5a9c61ae2b11bc1d0b799c08e6da908a9782..8e1a95f80e5454d1351ecb90beacbb35779731bb 100644

fs/fuse/dev.c +0 -0
@@ -281,7 +281,9 @@ static void fuse_send_one(struct fuse_iqueue *fiq,
 struct fuse_req *req)
        req->in.h.len = sizeof(struct fuse_in_header) +
Quoted 8 lines

fs/fuse/dev.c static void fuse_send_one(struct fuse_iqueue *fiq, · line 287

Quoted 6 lines
fs/fuse/dev.c +3 -1
                fuse_len_args(req->args->in_numargs,
                              (struct fuse_arg *) req->args->in_args);
-       trace_fuse_request_send(req);
+
+       /* enqueue, as it is send to "fiq->ops queue" */
+       trace_fuse_request_enqueue(req);

Looks like this patch is based on old code?

Sorry, I had posted part of the the old patch-

Quoted 36 lines

fs/fuse/dev.c static int fuse_request_queue_background(struct · line 587

Quoted 11 lines
fs/fuse/dev.c +2 -0
        fiq->ops->send_req(fiq, req);
 }
@@ -580,6 +582,8 @@ static int fuse_request_queue_background(struct
 fuse_req *req)
        }
        __set_bit(FR_ISREPLY, &req->flags);
 
+       trace_fuse_request_bg_enqueue(req);
+

Is this path not handled in current upstream code?

Quoted 12 lines
fs/fuse/dev.c +1 -0
@@ -1314,6 +1318,7 @@ static ssize_t fuse_dev_do_read(struct fuse_dev
 *fud, struct file *file,
        clear_bit(FR_PENDING, &req->flags);
        list_del_init(&req->list);
        spin_unlock(&fiq->lock);
+       trace_fuse_request_send(req);
 
        args = req->args;
        reqsize = req->in.h.len;
Quoted 3 lines

IMHO, trace_fuse_request_enqueue / trace_fuse_request_bg_enqueue for adding to the queue and trace_fuse_request_send for reading/handling the request is less confusing.

Potato potato
enqueue->send / send->recv
There will be arguments for and against any names we pick I don't think that the name matters a lot here as long as the required information is provided to tracing tools

Quoted 4 lines

My question was, regarding fuse_uring_prepare_send(),
do we need a _recv()/_send()/_fetch()/_whatnot()
tracepoint in this code point and whether the pid reported in this tracepoint is useful. Is it the libfuse worker thread or something else?

Yeah, that is the libfuse worker thread. I don't think the pid is useful, the tracepoint probably is, because it allows to determine how long requests have been queued.

I had created a script last year based on the old kernel patch

https://github.com/libfuse/libfuse/pull/1186

Thanks,
Bernd