Re: [PATCH 3/3] locking/rwsem: Scan the wait_list for readers only once

From: Ingo Molnar
Date: Sat Aug 06 2016 - 17:44:42 EST



* Davidlohr Bueso <dave@xxxxxxxxxxxx> wrote:

> When wanting to wakeup readers, __rwsem_mark_wakeup() currently
> iterates the wait_list twice while looking to wakeup the first N
> queued reader-tasks. While this can be quite inefficient, it was
> there such that a awoken reader would be first and foremost
> acknowledged by the lock counter.
>
> Keeping the same logic, we can further benefit from the use of
> wake_qs and avoid entirely the first wait_list iteration that sets
> the counter as wake_up_process() isn't going to occur right away,
> and therefore we maintain the counter->list order of going about
> things.
>
> Other than saving cycles with O(n) "scanning", this change also
> nicely cleans up a good chunk of __rwsem_mark_wakeup(); both
> visually and less tedious to read.
>
> For example, the following improvements where seen on some will
> it scale microbenchmarks, on a 48-core Haswell:
>
> v4.7 v4.7-rwsem-v1
> Hmean signal1-processes-8 5792691.42 ( 0.00%) 5771971.04 ( -0.36%)
> Hmean signal1-processes-12 6081199.96 ( 0.00%) 6072174.38 ( -0.15%)
> Hmean signal1-processes-21 3071137.71 ( 0.00%) 3041336.72 ( -0.97%)
> Hmean signal1-processes-48 3712039.98 ( 0.00%) 3708113.59 ( -0.11%)
> Hmean signal1-processes-79 4464573.45 ( 0.00%) 4682798.66 ( 4.89%)
> Hmean signal1-processes-110 4486842.01 ( 0.00%) 4633781.71 ( 3.27%)
> Hmean signal1-processes-141 4611816.83 ( 0.00%) 4692725.38 ( 1.75%)
> Hmean signal1-processes-172 4638157.05 ( 0.00%) 4714387.86 ( 1.64%)
> Hmean signal1-processes-203 4465077.80 ( 0.00%) 4690348.07 ( 5.05%)
> Hmean signal1-processes-224 4410433.74 ( 0.00%) 4687534.43 ( 6.28%)

Please always make it clear in changelogs what the numbers mean, that higher
numbers are better, etc. - so that people don't have to re-read it 2-3 times to
figure out what it means.

Also, what are 'will it scale microbenchmarks'?

Thanks,

Ingo