Re: [PATCH] fs/compat.c: rwsem instead of BKL around ioctl32_hash_table

Andi Kleen
2004-09-02T21:18:03Z

On Wed, Sep 01, 2004 at 08:40:15AM -0700, Roland Dreier wrote:
> Currently the BKL is used to synchronize access to ioctl32_hash_table
> in fs/compat.c. It seems that an rwsem would be more appropriate,
> since this would allow multiple lookups to occur in parallel (and also
> serve the general good of minimizing use of the BKL).
>
> I added lock_kernel()/unlock_kernel() around the call to t->handler
> when a compatibility handler is found in compat_sys_ioctl() to
> preserve the expectation that the BKL will be held during driver ioctl
> operations. It should be safe to do lock_kernel() while holding
> ioctl32_sem because of the magic BKL sleep semantics.
>
> I have booted this and run some basic 32-bit userspace on ppc64, and
> also compile tested this for x86_64 and sparc64.

It does not make much sense because the ioctl will take the BKL
anyways.

If you wanted to fix it properly better make it use RCU -
but it cannot work for the case of calling a compat handler.

-Andi