Re: [PATCH 12/12] locking/rwsem: Make MSbit of count as guard bit to fail readlock

From: Linus Torvalds
Date: Thu Mar 28 2019 - 16:47:54 EST


On Thu, Mar 28, 2019 at 11:12 AM Waiman Long <longman@xxxxxxxxxx> wrote:
>
> With the merging of owner into count for x86-64, there is only 16 bits
> left for reader count. It is theoretically possible for an application to
> cause more than 64k readers to acquire a rwsem leading to count overflow.

Ahh, and here's the thing that makes 16 bits work for readers.

I think this at a minimum needs to be made very clear in the patch
that actually lowered the reader count bits, but preferably this just
needs to be done *before* that patch, so that you don't have a point
in history where rwlocks are simply not reliable.

Linus