I am tracking down a "scheduling while atomic" error in one of our drivers, and am wondering if ioctl's are an atomic context. Also if any one has anything to share on how to get into and out of atomic contexts, and common places they occur, it would be helpful.
An ioctl , which means "input-output control" is a kind of device-specific system call. There are only a few system calls in Linux (300-400), which are not enough to express all the unique functions devices may have. So a driver can define an ioctl which allows a userspace application to send it orders.
IOCTL is referred as Input and Output Control, which is used to talk with device drivers. IOCTL is a system call where system call is the programmatic way in which a computer program in user space requests a service from the kernel space of the operating system.
Adding more to confuse :" ioctl : However, ioctl is deprecated in the kernel, and you will find it hard to get any drivers with new uses of ioctl accepted upstream.
The ioctl() function manipulates the underlying device parameters of special files. In particular, many operating characteristics of character special files (e.g. terminals) may be controlled with ioctl() requests. The argument d must be an open file descriptor.
No, ioctls generally run in process context. If a driver grabs a spinlock during the ioctl processing then the driver will enter atomic context and will remain in atomic context until it releases the spinlock.
See: http://lwn.net/Articles/274695/ for a good discussion on atomic context in Linux
Have you turned on CONFIG_DEBUG_SPINLOCK_SLEEP
, that might give you more info, including a stack trace, of where the error is.
The other angle to look at is what sleeping functions are you calling. Examples are msleep()
, mutex_lock()
, copy_to_user()
etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With