fuse: Wake requests on the same cpu
Subsystems (3)
PATCH 1/1 fuse: Wake requests on the same cpu
For io-uring it makes sense to wake the waiting application (synchronous IO) on the same core.
With queue-per-pore
fio --directory=/tmp/dest --name=iops.\$jobnum --rw=randread --bs=4k \
--size=1G --numjobs=1 --iodepth=1 --time_based --runtime=30s
\ --group_reporting --ioengine=psync --direct=1no-io-uring
READ: bw=116MiB/s (122MB/s), 116MiB/s-116MiB/s
no-io-uring wake on the same core (not part of this patch)
READ: bw=115MiB/s (120MB/s), 115MiB/s-115MiB/s
unpatched
READ: bw=260MiB/s (273MB/s), 260MiB/s-260MiB/s
patched
READ: bw=345MiB/s (362MB/s), 345MiB/s-345MiB/s
Without io-uring and core bound fuse-server queues there is almost not difference. In fact, fio results are very fluctuating, in between 85MB/s and 205MB/s during the run.
With --numjobs=8
unpatched
READ: bw=2378MiB/s (2493MB/s), 2378MiB/s-2378MiB/s
patched
READ: bw=2402MiB/s (2518MB/s), 2402MiB/s-2402MiB/s
(differences within the confidence interval)
'-o io_uring_q_mask=0-3:8-11' (16 core / 32 SMT core system) and
unpatched
READ: bw=1286MiB/s (1348MB/s), 1286MiB/s-1286MiB/s
patched
READ: bw=1561MiB/s (1637MB/s), 1561MiB/s-1561MiB/s
I.e. no differences with many application threads and queue-per-core, but perf gain with overloaded queues - a bit surprising.
---
This was already part of the RFC series and was then removed on request to keep out optimizations from the main fuse-io-uring series.
Later I was hesitating to add it back, as I was working on reducing the required number of queues/rings and initially thought wake-on-current-cpu needs to be a conditional if queue-per-core or a reduced number of queues is used.
After testing with reduced number of queues, there is still a measurable benefit with reduced number of queues - no condition on that needed and the patch can be handled independently of queue size reduction.
--- fs/fuse/dev.c | 8 ++++++-- include/linux/wait.h | 6 +++--- kernel/sched/wait.c | 12 ++++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-)
fs/fuse/dev.c +6 -2
@@ -499,8 +499,12 @@ void fuse_request_end(struct fuse_req *req)flush_bg_queue (fc);spin_unlock (&fc->bg_lock); }else { -/* Wake up waiter sleeping in request_wait_answer() */ -wake_up (&req->waitq); +if (test_bit (FR_URING , &req->flags)) { +wake_up_on_current_cpu (&req->waitq); + }else { +/* Wake up waiter sleeping in request_wait_answer() */ +wake_up (&req->waitq); + } }if (test_bit (FR_ASYNC , &req->flags))
include/linux/wait.h +3 -3
@@ -219,6 +219,7 @@ void __wake_up_sync(struct wait_queue_head *wq_head, unsigned int mode);void __wake_up_pollfree (struct wait_queue_head *wq_head);#define wake_up (x) __wake_up(x, TASK_NORMAL, 1, NULL) +#define wake_up_on_current_cpu (x) __wake_up_on_current_cpu(x, TASK_NORMAL, NULL)#define wake_up_nr (x, nr) __wake_up(x, TASK_NORMAL, nr, NULL)#define wake_up_all (x) __wake_up(x, TASK_NORMAL, 0, NULL)#define wake_up_locked (x) __wake_up_locked((x), TASK_NORMAL, 1)
@@ -479,9 +480,8 @@ do { \__wait_event_cmd (wq_head, condition, cmd1, cmd2); \ } while (0) -#define __wait_event_interruptible (wq_head, condition) \ - ___wait_event(wq_head, condition, TASK_INTERRUPTIBLE, 0, 0, \ - schedule()) +#define __wait_event_interruptible (wq_head, condition) \ + ___wait_event(wq_head, condition, TASK_INTERRUPTIBLE, 0, 0, schedule())/** * wait_event_interruptible - sleep until a condition gets true
kernel/sched/wait.c +12 -0
@@ -147,10 +147,22 @@ int __wake_up(struct wait_queue_head *wq_head, unsigned int mode, }EXPORT_SYMBOL (__wake_up); +/** +* __wake_up - wake up threads blocked on a waitqueue, on the current cpu +* @wq_head: the waitqueue +* @mode: which threads +* @nr_exclusive: how many wake-one or wake-many threads to wake up +* @key: is directly passed to the wakeup function +* +* If this function wakes up a task, it executes a full memory barrier +* before accessing the task state. Returns the number of exclusive +* tasks that were awaken. +*/ void __wake_up_on_current_cpu (struct wait_queue_head *wq_head,unsigned int mode,void *key) {__wake_up_common_lock (wq_head, mode,1 ,WF_CURRENT_CPU , key); } +EXPORT_SYMBOL_GPL (__wake_up_on_current_cpu);/* * Same as __wake_up but called with the spinlock in wait_queue_head_t held.
---
base-commit: ec714e371f22f716a04e6ecb2a24988c92b26911
change-id: 20251013-wake-same-cpu-b7ddb0b0688e
Best regards,
Signature · 1 line
Bernd Schubert <[email protected]>
Quoted 2 lines · Bernd Schubert
+/**
+ *__wake_up- wake up threads blocked on a waitqueue, on the current cpu
That needs to be __wake_up_on_current_cpu
[..]
Quoted 5 lines
void
__wake_up_on_current_cpu(struct wait_queue_head *wq_head, unsigned int mode, void *key){
__wake_up_common_lock(wq_head, mode, 1, WF_CURRENT_CPU, key);
}
+EXPORT_SYMBOL_GPL(__wake_up_on_current_cpu);
Quoted 14 lines · Johannes Thumshirn
[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
Quoted 2 lines · Bernd Schubert
+/**
+ *__wake_up- wake up threads blocked on a waitqueue, on the current cpuThat needs to be
__wake_up_on_current_cpu
[..]Quoted 5 lines
void
__wake_up_on_current_cpu(struct wait_queue_head *wq_head, unsigned int mode, void *key){ __wake_up_common_lock(wq_head, mode, 1, WF_CURRENT_CPU, key);}
+EXPORT_SYMBOL_GPL(__wake_up_on_current_cpu);
Oops, thanks and spotting! v2 is coming.
Thanks,
Bernd