Skip to contentSkip to conversation

f_ops flag to speed up compatible ioctls in linux kernel

DISCUSSION Albert Cahalan 5 participants 5 messages Sep 1, 2004

lore
Share & tools
lore
#0 lore raw
Quoted 9 lines · Michael S. Tsirkin

Quoting Lee Revell [snip -- that was excessive]

Quoted 3 lines

By adding a new ioctl you are adding a new use of
the BKL. It has been suggested on dri-devel that
this should be fixed. Is this even possible?

I dont know - can the lock be released before the call to filp->f_op->ioctl ?

Quoted 7 lines

I assume the reason its there is for legacy code - existing ioctls may be assuming the BKL is taken, but maybe there could be another flag in f_ops to let sys_ioctl release the lock before doing the call ...

Like this - would that be safe?

Yes. It is proven to work.

#1 lore raw

Hello!
Quoting r. Albert Cahalan ([email protected]) "Re: f_ops flag to speed up compatible ioctls in linux kernel":

Quoted 16 lines
Quoted 15 lines · Michael S. Tsirkin

Quoting Lee Revell [snip -- that was excessive]

Quoted 3 lines

By adding a new ioctl you are adding a new use of
the BKL. It has been suggested on dri-devel that
this should be fixed. Is this even possible?

I dont know - can the lock be released before the call to filp->f_op->ioctl ?

I assume the reason its there is for legacy code - existing ioctls may be assuming the BKL is taken, but maybe there could be another flag in f_ops to let sys_ioctl release the lock before doing the call ...

Quoted 3 lines
Quoted 1 line

Like this - would that be safe?

Yes. It is proven to work.

Now that I look at the ioctl.c code, I see a several get_user/put_user inside the ioctl which are thus done while BKL is held.
But I thought get_user can block?

Why is this not a bug?

MST

#2 lore raw
Quoted 20 lines · Michael S. Tsirkin

Hello!
Quoting r. Albert Cahalan ([email protected]) "Re: f_ops flag to speed up compatible ioctls in linux kernel":

Quoted 18 lines
Quoted 16 lines · Michael S. Tsirkin

Quoting Lee Revell [snip -- that was excessive]

Quoted 3 lines

By adding a new ioctl you are adding a new use of
the BKL. It has been suggested on dri-devel that
this should be fixed. Is this even possible?

I dont know - can the lock be released before the call to filp->f_op->ioctl ?

I assume the reason its there is for legacy code - existing ioctls may be assuming the BKL is taken, but maybe there could be another flag in f_ops to let sys_ioctl release the lock before doing the call ...

Like this - would that be safe?

Quoted 8 lines
Quoted 1 line

Yes. It is proven to work.

Now that I look at the ioctl.c code, I see a several get_user/put_user inside the ioctl which are thus done while BKL is held.
But I thought get_user can block?

Why is this not a bug?

You can sleep while holding the BKL, it is automatically dropped and reacquired. The BKL has some magic properties, it does not work like a regular spinlock.

Lee

#3 lore raw
In reply to Michael S. Tsirkin

Michael> Now that I look at the ioctl.c code, I see a several Michael> get_user/put_user inside the ioctl which are thus done Michael> while BKL is held. But I thought get_user can block?

Michael> Why is this not a bug?

It's fine to sleep while holding the BKL (it will be dropped and then reacquired when the process wakes up).

- Roland

#4 lore raw
In reply to Michael S. Tsirkin
Quoted 5 lines · * Michael S. Tsirkin ([email protected]) wrote:

Now that I look at the ioctl.c code, I see a several get_user/put_user inside the ioctl which are thus done while BKL is held.
But I thought get_user can block?

Why is this not a bug?

Look at release_kernel_lock, esp. in kernel/sched.c. -chris