new way of ioctl --- unlocked_ioctl & compat_ioctl
来源:互联网 发布:linux route add 作用 编辑:程序博客网 时间:2024/05/16 04:48
http://lwn.net/Articles/119652/
The new way of ioctl()
ioctl() is one of the remaining parts of the kernel which runs under the Big Kernel Lock (BKL). In the past, the usage of the BKL has made it possible for long-running ioctl()methods to create long latencies for unrelated processes. Recent changes, which have made BKL-covered code preemptible, have mitigated that problem somewhat. Even so, the desire to eventually get rid of the BKL altogether suggests that ioctl() should move out from under its protection.
Simply removing the lock_kernel() call before calling ioctl() methods is not an option, however. Each one of those methods must first be audited to see what other locking may be necessary for it to run safely outside of the BKL. That is a huge job, one which would be hard to do in a single "flag day" operation. So a migration path must be provided. As of 2.6.11, that path will exist.
The patch (by Michael s. Tsirkin) adds a new member to the file_operations structure:
long (*unlocked_ioctl) (struct file *filp, unsigned int cmd, unsigned long arg);
If a driver or filesystem provides an unlocked_ioctl() method, it will be called in preference to the older ioctl().The differences are that the inode argument is not provided (it's available as filp->f_dentry->d_inode) and the BKL is not taken prior to the call. All new code should be written with its own locking, and should use unlocked_ioctl(). Old code should be converted as time allows. For code which must run on multiple kernels, there is a new HAVE_UNLOCKED_IOCTL macro which can be tested to see if the newer method is available or not.
Michael's patch adds one other operation:
long (*compat_ioctl) (struct file *filp, unsigned int cmd, unsigned long arg);
If this method exists, it will be called (without the BKL) whenever a 32-bit process calls ioctl() on a 64-bit system. It should then do whatever is required to convert the argument to native data types and carry out the request. If compat_ioctl() is not provided, the older conversion mechanism will be used, as before. The HAVE_COMPAT_IOCTL macro can be tested to see if this mechanism is available on any given kernel.
The compat_ioctl() method will probably filter down into a few subsystems. Andi Kleen has posted patches adding new compat_ioctl() methods to the block_device_operationsand scsi_host_template structures, for example, though those patches have not been merged as of this writing.
- new way of ioctl --- unlocked_ioctl & compat_ioctl
- ioctl/unlocked_ioctl/compat_ioctl
- The new way of ioctl()---ioctl新方法
- 关于ioctl,unlocked_ioctl和compat_ioctl执行的顺序
- 内核新的ioctl方式---- unlocked_ioctl和compat_ioctl
- 内核新的ioctl方式---- unlocked_ioctl和compat_ioctl
- 内核新的ioctl方式---- unlocked_ioctl和compat_ioctl
- 内核新的ioctl方式--unlocked_ioctl和compat_ioctl(解决error:unknown field 'ioctl' specified in initializer)
- unlocked_ioctl和compat_ioctl
- unlocked_ioctl和compat_ioctl
- unlocked_ioctl和compat_ioctl
- unlocked_ioctl和compat_ioctl
- The new way of ioctl()----转自LWN.net
- ioctl compat_ioctl unlock_ioctl
- ioctl compat_ioctl与unlock_ioctl
- ioctl 变成了 unlocked_ioctl
- ioctl与unlocked_ioctl区别
- ioctl 变成了 unlocked_ioctl
- hdu 5038(排序水题)
- 【算法导论】第五课 线性排序(基数排序 计数排序)
- Android逆向之动态调试总结
- 《Xcode基本用法》如何添加模拟器
- ActionBar的使用
- new way of ioctl --- unlocked_ioctl & compat_ioctl
- 2.9 属性组
- Palindrome Number
- Markdown 语法的简要规则
- 每天一个py小程序 001生成激活码
- Android toolBar详解
- Kali Linux网络配置
- 【算法导论】第六课 顺序统计,中值
- Java基础(异常)