Skip to content

Commit 4fea593

Browse files
joannekoongMiklos Szeredi
authored andcommitted
fuse: optimize over-io-uring request expiration check
Currently, when checking whether a request has timed out, we check fpq processing, but fuse-over-io-uring has one fpq per core and 256 entries in the processing table. For systems where there are a large number of cores, this may be too much overhead. Instead of checking the fpq processing list, check ent_w_req_queue and ent_in_userspace. Signed-off-by: Joanne Koong <[email protected]> Reviewed-by: Bernd Schubert <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 03a3617 commit 4fea593

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

fs/fuse/dev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ bool fuse_request_expired(struct fuse_conn *fc, struct list_head *list)
4545
return time_is_before_jiffies(req->create_time + fc->timeout.req_timeout);
4646
}
4747

48-
bool fuse_fpq_processing_expired(struct fuse_conn *fc, struct list_head *processing)
48+
static bool fuse_fpq_processing_expired(struct fuse_conn *fc, struct list_head *processing)
4949
{
5050
int i;
5151

fs/fuse/dev_uring.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,21 @@ void fuse_uring_abort_end_requests(struct fuse_ring *ring)
140140
}
141141
}
142142

143+
static bool ent_list_request_expired(struct fuse_conn *fc, struct list_head *list)
144+
{
145+
struct fuse_ring_ent *ent;
146+
struct fuse_req *req;
147+
148+
ent = list_first_entry_or_null(list, struct fuse_ring_ent, list);
149+
if (!ent)
150+
return false;
151+
152+
req = ent->fuse_req;
153+
154+
return time_is_before_jiffies(req->create_time +
155+
fc->timeout.req_timeout);
156+
}
157+
143158
bool fuse_uring_request_expired(struct fuse_conn *fc)
144159
{
145160
struct fuse_ring *ring = fc->ring;
@@ -157,7 +172,8 @@ bool fuse_uring_request_expired(struct fuse_conn *fc)
157172
spin_lock(&queue->lock);
158173
if (fuse_request_expired(fc, &queue->fuse_req_queue) ||
159174
fuse_request_expired(fc, &queue->fuse_req_bg_queue) ||
160-
fuse_fpq_processing_expired(fc, queue->fpq.processing)) {
175+
ent_list_request_expired(fc, &queue->ent_w_req_queue) ||
176+
ent_list_request_expired(fc, &queue->ent_in_userspace)) {
161177
spin_unlock(&queue->lock);
162178
return true;
163179
}
@@ -494,7 +510,7 @@ static void fuse_uring_cancel(struct io_uring_cmd *cmd,
494510
spin_lock(&queue->lock);
495511
if (ent->state == FRRS_AVAILABLE) {
496512
ent->state = FRRS_USERSPACE;
497-
list_move(&ent->list, &queue->ent_in_userspace);
513+
list_move_tail(&ent->list, &queue->ent_in_userspace);
498514
need_cmd_done = true;
499515
ent->cmd = NULL;
500516
}
@@ -714,7 +730,7 @@ static int fuse_uring_send_next_to_ring(struct fuse_ring_ent *ent,
714730
cmd = ent->cmd;
715731
ent->cmd = NULL;
716732
ent->state = FRRS_USERSPACE;
717-
list_move(&ent->list, &queue->ent_in_userspace);
733+
list_move_tail(&ent->list, &queue->ent_in_userspace);
718734
spin_unlock(&queue->lock);
719735

720736
io_uring_cmd_done(cmd, 0, 0, issue_flags);
@@ -764,7 +780,7 @@ static void fuse_uring_add_req_to_ring_ent(struct fuse_ring_ent *ent,
764780
clear_bit(FR_PENDING, &req->flags);
765781
ent->fuse_req = req;
766782
ent->state = FRRS_FUSE_REQ;
767-
list_move(&ent->list, &queue->ent_w_req_queue);
783+
list_move_tail(&ent->list, &queue->ent_w_req_queue);
768784
fuse_uring_add_to_pq(ent, req);
769785
}
770786

@@ -1180,7 +1196,7 @@ static void fuse_uring_send(struct fuse_ring_ent *ent, struct io_uring_cmd *cmd,
11801196

11811197
spin_lock(&queue->lock);
11821198
ent->state = FRRS_USERSPACE;
1183-
list_move(&ent->list, &queue->ent_in_userspace);
1199+
list_move_tail(&ent->list, &queue->ent_in_userspace);
11841200
ent->cmd = NULL;
11851201
spin_unlock(&queue->lock);
11861202

fs/fuse/fuse_dev_i.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ void fuse_dev_queue_interrupt(struct fuse_iqueue *fiq, struct fuse_req *req);
6464
bool fuse_remove_pending_req(struct fuse_req *req, spinlock_t *lock);
6565

6666
bool fuse_request_expired(struct fuse_conn *fc, struct list_head *list);
67-
bool fuse_fpq_processing_expired(struct fuse_conn *fc, struct list_head *processing);
6867

6968
#endif
7069

0 commit comments

Comments
 (0)