]> git.apps.os.sepia.ceph.com Git - ceph-client.git/commit
proc/kcore: use percpu_rw_semaphore for kclist_lock
authorOmar Sandoval <osandov@fb.com>
Sat, 9 Nov 2024 01:28:41 +0000 (17:28 -0800)
committerChristian Brauner <brauner@kernel.org>
Mon, 2 Dec 2024 10:21:07 +0000 (11:21 +0100)
commit605291e2210130957e8a17a466f3f21c4fe0adef
tree94701902c98a99afd7bc297aae02c09dad438e1b
parent680e029fd62f7d9d8373788635f52c3de358d18d
proc/kcore: use percpu_rw_semaphore for kclist_lock

The list of memory ranges for /proc/kcore is protected by a
rw_semaphore. We lock it for reading on every read from /proc/kcore.
This is very heavy, especially since it is rarely locked for writing.
Since we want to strongly favor read lock performance, convert it to a
percpu_rw_semaphore. I also experimented with percpu_ref and SRCU, but
this change was the simplest and the fastest.

In my benchmark, this reduces the time per read by yet another 20
nanoseconds on top of the previous two changes, from 195 nanoseconds per
read to 175.

Link: https://github.com/osandov/drgn/issues/106
Signed-off-by: Omar Sandoval <osandov@fb.com>
Link: https://lore.kernel.org/r/83a3b235b4bcc3b8aef7c533e0657f4d7d5d35ae.1731115587.git.osandov@fb.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/proc/kcore.c