Re: [PATCH] rw_semaphores, optimisations try #3

Linus Torvalds
2001-04-24T15:41:34Z

On Tue, 24 Apr 2001, David Howells wrote:
>
> Yes but the "struct rwsem_waiter" batch would have to be entirely deleted from
> the list before any of them are woken, otherwise the waking processes may
> destroy their "rwsem_waiter" blocks before they are dequeued (this destruction
> is not guarded by a spinlock).

Look again.

Yes, they may destroy the list, but nobody cares.

Why?

- nobody will look up the list because we do have the spinlock at this
point, so a destroyed list doesn't actually _matter_ to anybody

You were actually depending on this earlier, although maybe not on
purpose.

- list_remove_between() doesn't care about the integrity of the entries
it destroys. It only uses, and only changes, the entries that are still
on the list.

Subtlety is fine. It might warrant a comment, though.

Linus