我正在寻找在linux上进行异步文件I/O的最有效方法.
POSIX glibc实现使用userland中的线程.
本机aio内核api仅适用于无缓冲操作,内核补丁用于添加对缓冲操作的支持,但这些补丁已超过3年,似乎没有人关心将它们集成到主线中.
我发现了许多允许异步I/O的其他想法,概念和补丁,尽管其中大多数都是在3年以上的文章中.在今天的内核中真正可用的是什么呢?我已经阅读过有关servlet,acalls,内核线程的内容以及我现在甚至都不记得的更多内容.
在今天的内核中进行缓冲异步文件输入/输出的最有效方法是什么?
在linux内核列表的实现中/include/linux/list.h,container_of宏的第一行(下面粘贴)背后的基本原理是什么?
const typeof( ((type *)0)->member ) *__mptr = (ptr);
Run Code Online (Sandbox Code Playgroud)
在我的示例代码中,我删除了这一行并将定义更改为
#define container_of(ptr, type, member) ({ \
(type *)( (char *)ptr - offsetof(type,member) );})
Run Code Online (Sandbox Code Playgroud)
我的代码仍显示预期的结果.那么第一行是多余的吗?或者它有一些我不知道的隐藏陷阱?
我在Faq/LinkedLists找到的代码
/**
* container_of - cast a member of a structure out to the containing structure
* @ptr: the pointer to the member.
* @type: the type of the container struct this is embedded in.
* @member: the name of the member within the struct.
*
*/
#define container_of(ptr, type, …Run Code Online (Sandbox Code Playgroud) 我是一个Android开发人员,我已经做了很长一段时间的ROM,我想开始内核开发,我知道它与linux内核本身有关,而且与android没有任何关系.
问题是我找不到任何在线资源来帮助我开始.所以我正在寻找的东西有点官方,比如android的开发者网站,java的java教程,python教程......等等
有什么事吗?从linux.org也许,但我在他们的网站上找不到任何东西.那些我应该充分理解的东西是什么?喜欢编程语言(我知道它在C中)或其他什么?
请记住,我只是想学习驱动程序配置和编译.
我正在构建linux内核,如果我的内核在git下,那么内核版本每次都是:
Image Name: Linux-2.6.39+
Run Code Online (Sandbox Code Playgroud)
如果我不使用git,那么一切都没问题,最后没有任何加分.
我知道这是由scripts/setlocalversion脚本完成的:
if test "$CONFIG_LOCALVERSION_AUTO" = "y"; then
# full scm version string
res="$res$(scm_version)"
else
# append a plus sign if the repository is not in a clean
# annotated or signed tagged state (as git describe only
# looks at signed or annotated tags - git tag -a/-s) and
# LOCALVERSION= is not specified
if test "${LOCALVERSION+set}" != "set"; then
scm=$(scm_version --short)
res="$res${scm:++}"
fi
fi
Run Code Online (Sandbox Code Playgroud)
那么,没有代码更改就可以说构建系统不需要在版本行的末尾添加"+"?
有许多方法可以在Linux内核中安排工作:定时器,tasklet,工作队列和内核线程.什么时候使用一个与另一个有什么指导方针?
有明显的因素:计时器函数和tasklet无法休眠,因此它们不能等待互斥锁,条件变量等.
在驱动程序中为我们选择哪种机制有哪些其他因素?
哪个是首选机制?
我希望尽快将支持DMA的PCIe硬件设备中的数据导入用户空间.
问:如何将"使用/和/通过DMA传输直接I/O连接到用户空间"
通过LDD3读取,似乎我需要执行一些不同类型的IO操作!?
dma_alloc_coherent给我一个可以传递给硬件设备的物理地址.但是在传输完成时需要设置get_user_pages并执行copy_to_user类型调用.这似乎是浪费,要求设备DMA进入内核内存(充当缓冲区),然后再将其传输到用户空间.LDD3 p453:/* Only now is it safe to access the buffer, copy to user, etc. */
我理想的是一些记忆:
我是否需要单页流映射,设置映射和用户空间缓冲区映射get_user_pages dma_map_page?
到目前为止,我的代码get_user_pages在用户空间的给定地址设置(我称之为直接I/O部分).然后,dma_map_page用一个页面get_user_pages.我将设备的返回值dma_map_page作为DMA物理传输地址.
我使用一些内核模块作为参考:drivers_scsi_st.c和drivers-net-sh_eth.c.我会看看infiniband代码,但无法找到哪一个是最基本的!
提前谢谢了.
在编译内核模块时,我得到了一个WARNING,其中包含一个添加编译选项CONFIG_DEBUG_SECTION_MISMATCH = y的注释.它给了我更详细的问题信息:
WARNING: \**\*path to module\***(.text+0x8d2): Section mismatch in reference from the function Pch_Spi_Enable_Bios_Wr() to the variable .devinit.data:ich9_pci_tbl.22939
The function Pch_Spi_Enable_Bios_Wr() references
the variable __devinitdata ich9_pci_tbl.22939.
This is often because Pch_Spi_Enable_Bios_Wr lacks a __devinitdata
annotation or the annotation of ich9_pci_tbl.22939 is wrong.
Run Code Online (Sandbox Code Playgroud)
我无法找到究竟核心部分不匹配的内容,更不用说如何修复它了.
Os:REDHAT LINUX Linux管理:2.6.18.8-1#
这是否可以直接从NIC读取MAC地址?我有下面的代码,但它只是从上面的层读取,但不是卡本身!
我试图弄清楚如何在我的linux机箱上找到以太网NIC的原始MAC地址.我知道如何找到用ifconfig当前的MAC地址,但如果该地址已更改,比如说使用
'ifconfig eth0 hw ether uu:vv:ww:yy:xx:zz',或者我设置"永久"使用它vi /etc/sysconfig/network-scripts/ifcfg-eth0.这个文件......我可以成功地UP它REBOOT也.我怎么找原件?必须有一种方法来找到它,因为它仍然永久地刻录到卡中,但我找不到一个工具来读取刻录的地址.它有什么用途或命令吗?我想为它编写C代码.但在上述情况下不知道如何做到这一点.
**下面的代码给出了我当前的 MAC但不是原始的MAC
#include <stdio.h> /* Standard I/O */
#include <stdlib.h> /* Standard Library */
#include <errno.h> /* Error number and related */
#define ENUMS
#include <sys/socket.h>
#include <net/route.h>
#include <net/if.h>
#include <features.h> /* for the glibc version number */
#if __GLIBC__ >= 2 && __GLIBC_MINOR >= 1
#include <netpacket/packet.h>
#include <net/ethernet.h> /* the L2 protocols */
#else
#include <asm/types.h>
#include <linux/if_packet.h> …Run Code Online (Sandbox Code Playgroud) 我正在尝试设置iptable规则,当我使用iptable时,我收到以下错误消息:
iptables v1.4.14: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
Run Code Online (Sandbox Code Playgroud)
我正在使用 :
cat /etc/debian_version
7.4
uname -a
Linux myserver 2.6.32-22-pve #1 SMP Mon Jul 15 08:36:46 CEST 2013 x86_64 GNU/Linux
uname -r
2.6.32-22-pve
Run Code Online (Sandbox Code Playgroud)
这是由服务提供商托管的虚拟服务器.
我该怎么做才能解决这个问题?
linux-kernel ×10
linux ×6
aio ×1
asynchronous ×1
c ×1
debian ×1
dma ×1
git ×1
io ×1
iptables ×1
kernel ×1
linked-list ×1
mac-address ×1
module ×1
pointers ×1
sockets ×1
struct ×1