staging/android: use multiple futex wait queues
PATCH 1/1 staging/android: use multiple futex wait queues
Use multiple per-offset wait queues instead of one big wait queue per region.
---
This patch is based on the simplify handle_vsoc_cond_wait patchset, currently under review: https://lkml.org/lkml/2019/2/7/870
--- drivers/staging/android/TODO | 4 --- drivers/staging/android/vsoc.c | 56 ++++++++++++++++++++++++++-------- 2 files changed, 44 insertions(+), 16 deletions(-)
drivers/staging/android/TODO +0 -4
@@ -12,10 +12,6 @@ ion/ - Better test framework (integration with VGEM was suggested) vsoc.c, uapi/vsoc_shm.h - - The current driver uses the same wait queue for all of the futexes in a - region. This will cause false wakeups in regions with a large number of - waiting threads. We should eventually use multiple queues and select the - queue based on the region. - Add debugfs support for examining the permissions of regions. - Remove VSOC_WAIT_FOR_INCOMING_INTERRUPT ioctl. This functionality has been superseded by the futex and is there for legacy reasons.
drivers/staging/android/vsoc.c +44 -12
110 lines not on this page · raw message
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerQuoted 4 lines · Hugo Lefeuvre
Use multiple per-offset wait queues instead of one big wait queue per region.
Signed-off-by Hugo Lefeuvre <[email protected]>
Have you tested this?
Noticed any performance speedups or slow downs?
thanks,
greg k-h
Quoted 8 lines
Quoted 4 lines
Use multiple per-offset wait queues instead of one big wait queue per region.
Signed-off-by Hugo Lefeuvre <[email protected]>Have you tested this?
Noticed any performance speedups or slow downs?
Not yet. I have started to set up a cuttlefish test environment but it might take some time until I am able to fully test these changes myself (having some trouble to find documentation)... I will post the results here when ready.
thanks!
regards,
Hugo
Signature · 3 lines
Hugo Lefeuvre (hle) | www.owl.eu.com RSA4096_ 360B 03B3 BF27 4F4D 7A3F D5E8 14AA 1EB8 A247 3DFD ed25519_ 37B2 6D38 0B25 B8A2 6B9F 3A65 A36F 5357 5F2D DC4C
drivers/staging/android/vsoc.c static int handle_vsoc_cond_wait(struct file *filp, struct vsoc_cond_wait *arg) · line 413
Quoted 5 lines · Hugo Lefeuvre
drivers/staging/android/vsoc.c +1
-0@@ -402,6 +410,7 @@ static int handle_vsoc_cond_wait(struct file *filp, struct vsoc_cond_wait *arg)struct vsoc_region_data *data = vsoc_dev.regions_data + region_number;int ret =0 ;struct vsoc_device_region *region_p =vsoc_region_from_filep (filp); +struct vsoc_futex_wait_queue_t *it, *wait_queue =NULL ;
^^^^^^^^^^^^^^^^^
drivers/staging/android/vsoc.c static int handle_vsoc_cond_wait(struct file *filp, struct vsoc_cond_wait *arg) · line 430
Quoted 11 lines
drivers/staging/android/vsoc.c +4
-0atomic_t *address =NULL ;ktime_t wake_time;@@ -415,10 +424,27 @@ static int handle_vsoc_cond_wait(struct file *filp, struct vsoc_cond_wait *arg) address =shm_off_to_virtual_addr (region_p->region_begin_offset + arg->offset); +/* Find wait queue corresponding to offset or create it */ +spin_lock (&data->futex_wait_queue_lock); +list_for_each_entry (it, &data->futex_wait_queue_list, list) { +if (wait_queue->offset == arg->offset) {
^^^^^^^^^^^^^^^^^^
You meant "it->offset".
drivers/staging/android/vsoc.c static int handle_vsoc_cond_wait(struct file *filp, struct vsoc_cond_wait *arg) · line 442
Quoted 12 lines
drivers/staging/android/vsoc.c +12
-0+ wait_queue = it; +break ; + } + } + +if (!wait_queue) { + wait_queue =kmalloc (sizeof (*wait_queue),GFP_KERNEL ); + wait_queue->offset = arg->offset; +init_waitqueue_head (&wait_queue->queue); +list_add (&wait_queue->list, &data->futex_wait_queue_list); + } +spin_unlock (&data->futex_wait_queue_lock);
regards,
dan carpenter
Quoted 4 lines
drivers/staging/android/vsoc.c static int handle_vsoc_cond_wait(struct file *filp, struct vsoc_cond_wait *arg) · line 430
Quoted 2 lines
drivers/staging/android/vsoc.c +2
-0+list_for_each_entry (it, &data->futex_wait_queue_list, list) { +if (wait_queue->offset == arg->offset) {^^^^^^^^^^^^^^^^^^You meant "
it->offset".
Right, this is not good. Fixed in v2.
Thanks for the feedback!
regards,
Hugo
Signature · 3 lines
Hugo Lefeuvre (hle) | www.owl.eu.com RSA4096_ 360B 03B3 BF27 4F4D 7A3F D5E8 14AA 1EB8 A247 3DFD ed25519_ 37B2 6D38 0B25 B8A2 6B9F 3A65 A36F 5357 5F2D DC4C
Hi,
Quoted 1 line
Have you tested this?
I have finally set up a cuttlefish test env and tested both my first patch set[0] and this patch (v2).
My first patch set works fine. I have nothing to say about it.
Quoted 1 line
Noticed any performance speedups or slow downs?
This patch doesn't work.
The boot process goes well. Overall, calls to vsoc_cond_wake are executed slightly faster. However the system freezes at some point.
The graphical interface generates many calls to vsoc_cond_wake and wait, so I suspect an issue with the locks. I will investigate this and come back with an updated patch.
regards,
Hugo
[0] https://lore.kernel.org/patchwork/patch/1039712/
Signature · 3 lines
Hugo Lefeuvre (hle) | www.owl.eu.com RSA4096_ 360B 03B3 BF27 4F4D 7A3F D5E8 14AA 1EB8 A247 3DFD ed25519_ 37B2 6D38 0B25 B8A2 6B9F 3A65 A36F 5357 5F2D DC4C