- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在我的驱动程序中添加了对 AIO 的支持(内核态中的 .aio_read 、 .aio_write 调用,用户态中的 libaio )并查看了各种来源,但我找不到如果在我的 aio_read、.aio_write 调用中我可以只存储一个指向的指针iovector 参数(假设此内存将保持不变,直到调用 aio_complete 之后),或者我需要对 iovector 数据结构进行深度复制。
static ssize_t aio_read( struct kiocb *iocb, const struct iovec *iovec, unsigned long nr_segs, loff_t pos );
static ssize_t aio_write( struct kiocb *iocb, const struct iovec *iovec, unsigned long nr_segs, loff_t pos );
以\drivers\usb\gadget\inode.c 的实现为例,他们似乎只是复制了 ep_aio_rwtail 函数中的指针,该函数具有:
priv->iv = iv;
但是当我尝试做类似的事情时,它经常发生在我处理它时 iovector 中的数据已经“损坏”。
例如,在我记录的 aio_read/write 调用中
iovector located at addr:0xbf1ebf04
segment 0: base: 0x76dbb468 len:512
但是当我在内核线程中进行真正的工作时(附加到用户空间 mm 之后),我记录了以下内容:
iovector located at addr:0xbf1ebf04
segment 0: base: 0x804e00c8 len:-1088503900
这是一个非常简单的测试用例,我只在我的用户应用程序中提交了 1 个异步命令。
为了让事情更有趣:我在 3.13 内核上大约有 80% 的时间出现损坏。
但我以前从未在 3.9 内核上看到它(但在我升级到 3.13 之前我只使用了一小段时间,现在恢复正常并尝试了十几次左右)。(使用 3.9 内核运行的示例有两次
iovector located at addr:0xbf9ee054
segment 0: base: 0x76e28468 len:512)
这是否敲响了警钟?
(当然,另一种可能性是我自己破坏了这些地址/长度,但奇怪的是我从来没有在 3.9 上遇到过这种情况)
编辑:在查看 linux aio 的 3.13 代码后回答我自己的问题(它在 3.9 中发生了显着变化),在 fs\aio.c 中你有:
static ssize_t aio_run_iocb(struct kiocb *req, unsigned opcode,
char __user *buf, bool compat)
{
...
结构 iovec inline_vec, *iovec = &inline_vec;
...
ret = rw_op(req, iovec, nr_segs, req->ki_pos);
...
}
所以这个iovec结构只是在栈上,一旦aio_read/write函数退出,它就会丢失。
并且小工具框架在\drivers\usb\gadget\inode.c 中包含一个错误(至少对于 3.13)...
最佳答案
NOTES It is a good idea to zero out the control block before use. The control block must not be changed while the read operation is in progress. The buffer area being read into must not be accessed during the operation or undefined results may occur. The memory areas involved must remain valid.
Simultaneous I/O operations specifying the same aiocb structure produce undefined results.
这表明驱动程序可以在操作期间依赖用户的数据结构。如果在操作过程中检测到这些结构已更改,则放弃操作并返回异步错误是明智的做法。
关于c - Linux内核异步AIO : do I need to copy over the struct iovec for later processing?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22228347/
如何将 jQuery 代码转换为 React JS? 我有一个带有文本“复制”的按钮。当我单击它时,应将其文本更改为“已复制”并复制到剪贴板。复制后,几秒钟后我希望文本返回到“复制”。我相信以下功能将
在任何情况下我都想使用 NumPy 的 np.copy() 而不是 Python 的 copy.copy() 方法?据我所知,两者都创建浅拷贝,但 NumPy 仅限于数组。 NumPy 是否有任何性能
%python -m timeit -s "import copy" "x = (1, 2, 3)" "copy.deepcopy(x)" 100000 loops, best of 3: 10.1
我想制作一个列表的副本(字面意思是一个单独的克隆,与原始列表没有任何共享)。我使用了 copy.copy() 并创建了 2 个单独的列表,但为什么每个副本的元素似乎仍然共享? 这很难解释,请查看以下输
我不明白使用通配符时 COPY 命令的行为。 我在 C:\Source 中有一个文本文件叫 mpt*.asm我想把它复制到 C:\Dest .这是批处理脚本所需要的,我不能确定 mpt*.asm 的确
相关但不等同于:Golang: How to copy Context object without deriving 是否可以推导出 context.WithTimeout来自 context.Ba
您可以实现 Copy 特性来为类型提供复制语义而不是 move 语义。仅当其所有组成元素(产品类型的每个因素,或总和类型的每个变体的每个因素)也都是复制时,才能执行此操作。 这还允许您制作相当大的类型
我有一段代码,我需要确定编码值的类型,但我不知道它是字符串、无符号整数还是字符串的矢量。我想做以下几件事:。然而,来自弯曲板条箱的值不能实现复制,它在调用Decode_Bencode_Object之后
我需要复制一些对象,我读到 copy.copy 模块可以在 Python 上执行此操作。问题是,这些对象有一些属性是长数组。 那么这个方法效率高吗?由于性能在我所做的这项工作中很重要。 有更好的方法吗
我尝试高效地制作 lua 表的副本。我编写了以下运行良好的函数 copyTable()(见下文)。但我想我可以使用函数的“按值传递”机制获得更高效的东西。我做了一些测试来探索这个机制: functio
使用 pry 插件:pry-clipboard 当我输入“copy-history”来复制我历史的最后一行时,它实际上是在复制“copy-history”并粘贴“copy-history”。 我是不是
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 11 个月前关闭。 Improve this
我不了解Kotlin中通过访问器处理字段和复制方法之间的区别。就像这样: 访问者示例: class Person(val name: String, var age: Int
如何从节点复制一些属性。例如。我只想从节点“Extn”复制“Srno”,“RollNo”,“right”。
我有以下两个 XSL 转换,我希望将它们链接到一个 XSL 文件中。 第一次转换: 第二个转换(使用第一个转换的输出作为输入): 我的目标是从 WSDL
我是 Vertica DB 的新手,之前使用过 Mysql。我想在 vertica 表中插入唯一记录,但 vertica 在插入时不支持唯一约束。我通过 COPY 查询在表中插入记录。所以我无法在插入
std::copy 与执行策略参数之间是否存在正式关系?无论是在实践中还是在标准中。 例如,会不会只是这样, namespace std{ template It copy(std::
我用 root 运行了以下命令来备份同一主机上的文件夹:cp -r master 主备 size of master : 76GB size of master-backup : 71GB 知道为什么
我遇到过一段代码,乍一看似乎毫无意义。但我意识到这可能会产生一些我不知道的未知含义,因为 Python 不是我最熟悉的语言。 import copy node = copy.copy(node) 阅读
我正在设计一个基类,我希望它为 copy.copy 定义基本行为。此行为包括在控制台中打印警告,然后复制实例,就好像它没有 __copy__ 一样。属性。 当定义一个空白时Foo类并复制它的一个实例,
我是一名优秀的程序员,十分优秀!