smp: convert the cpu maps lock into a rw lock
authorRoger Pau Monné <roger.pau@citrix.com>
Wed, 19 Feb 2020 15:09:03 +0000 (16:09 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 19 Feb 2020 15:09:03 +0000 (16:09 +0100)
commit5872c83b42c60801a2bfcd1800a56bbb8fc13400
tree6e71db31dd8956aa157fbf3c9048c9abad82a0ff
parent132cbe8f35632fb2fea0625ee8fdda53a19a1645
smp: convert the cpu maps lock into a rw lock

Most users of the cpu maps just care about the maps not changing while
the lock is being held, but don't actually modify the maps.

Convert the lock into a rw lock, and take the lock in read mode in
get_cpu_maps and in write mode in cpu_hotplug_begin. This will lower
the contention around the lock, since plug and unplug operations that
take the lock in write mode are not that common.

Note that the read lock can be taken recursively (as it's a shared
lock), and hence will keep the same behavior as the previously used
recursive lock. As for the write lock, it's only used by CPU
plug/unplug operations, and the lock is never taken recursively in
that case.

While there also change get_cpu_maps return type to bool.

Reported-by: Julien Grall <julien@xen.org>
Suggested-also-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Julien Grall <julien@xen.org>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/common/cpu.c
xen/include/xen/cpu.h