[RFC 0/2] rwsem: introduce upgrade_read interface

lizhe.67
2024-10-16T04:36:13Z

From: Li Zhe <lizhe.67@bytedance.com>

In the current kernel rwsem implementation, there is an interface to
downgrade write lock to read lock, but there is no interface to upgrade
a read lock to write lock. This means that in order to acquire write
lock while holding read lock, we have to release the read lock first and
then acquire the write lock, which will introduce some troubles in
concurrent programming. This patch set provides the 'upgrade_read' interface
to solve this problem. This interface can change a read lock to a write
lock.

Li Zhe (2):
rwsem: introduce upgrade_read interface
khugepaged: use upgrade_read() to optimize collapse_huge_page

include/linux/rwsem.h | 1 +
kernel/locking/rwsem.c | 87 ++++++++++++++++++++++++++++++++++++++++--
mm/khugepaged.c | 36 ++++++++---------
3 files changed, 104 insertions(+), 20 deletions(-)

--
2.20.1