Re: [PATCH 10/12] locking/rwsem: Merge owner into count on x86-64

From: Linus Torvalds
Date: Thu Mar 28 2019 - 16:44:21 EST


On Thu, Mar 28, 2019 at 11:12 AM Waiman Long <longman@xxxxxxxxxx> wrote:
>
> Reserving 2 bits for status flags,
> we will have 16 bits for the reader count. That can supports up to
> (64k-1) readers.

Explain why that's enough, please.

I could *easily* see more than 64k threads all on the same rwsem, all
at the same time.

Just do a really slow filesystem (think fuse), map a file with lots of
pages, and then fault in one page per thread. Boom. rwsem with more
than 64k concurrent readers.

So I think this approach is completely wrong, and/or needs a *lot* of
explanation why it works.

A small reader count works for the spinning rwlocks because we're
limited to the number of CPU's in the system. For a rwsem? No.

Linus